summaryrefslogtreecommitdiffhomepage
path: root/config.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2013-04-04 14:41:39 +0200
committerJo-Philipp Wich <jow@openwrt.org>2013-04-04 15:06:02 +0200
commita47c3353cdf46b730f43198052c8f807e2bd313f (patch)
treed823e8d658d662e90e02531aeab997629e02e7d1 /config.c
parent09ae3bfa2ad7a3a9630fdf290b872a2d7673843f (diff)
Add support for ip rules
Diffstat (limited to 'config.c')
-rw-r--r--config.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/config.c b/config.c
index 3b44bce..f3e5f9d 100644
--- a/config.c
+++ b/config.c
@@ -20,6 +20,7 @@
#include "netifd.h"
#include "interface.h"
#include "interface-ip.h"
+#include "iprule.h"
#include "proto.h"
#include "config.h"
@@ -246,6 +247,18 @@ config_parse_route(struct uci_section *s, bool v6)
}
static void
+config_parse_rule(struct uci_section *s, bool v6)
+{
+ void *rule;
+
+ blob_buf_init(&b, 0);
+ rule = blobmsg_open_array(&b, "rule");
+ uci_to_blob(&b, s, &rule_attr_list);
+ blobmsg_close_array(&b, rule);
+ iprule_add(blob_data(b.head), v6);
+}
+
+static void
config_init_devices(void)
{
struct uci_element *e;
@@ -436,6 +449,25 @@ config_init_routes(void)
}
static void
+config_init_rules(void)
+{
+ struct uci_element *e;
+
+ iprule_update_start();
+
+ uci_foreach_element(&uci_network->sections, e) {
+ struct uci_section *s = uci_to_section(e);
+
+ if (!strcmp(s->type, "rule"))
+ config_parse_rule(s, false);
+ else if (!strcmp(s->type, "rule6"))
+ config_parse_rule(s, true);
+ }
+
+ iprule_update_complete();
+}
+
+static void
config_init_globals(void)
{
struct uci_section *globals = uci_lookup_section(
@@ -465,6 +497,7 @@ config_init_all(void)
config_init_devices();
config_init_interfaces();
config_init_routes();
+ config_init_rules();
config_init_globals();
config_init = false;