summaryrefslogtreecommitdiffhomepage
path: root/interface.c
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2013-05-17 16:24:37 +0200
committerSteven Barth <steven@midlink.org>2013-05-17 16:24:37 +0200
commit2f31bff38d4dc2f36006ded6b8a7d039cb569eaa (patch)
tree0712ef82fedf0c105d9c587637f7c4ae1920a0b7 /interface.c
parentbc4a4bb127622c76085ecec7fd20448aad7bafaf (diff)
Add option to define target routing table for protocol routes.
This unifies source-routing for both IPv6 and IPv4 (default off). Based on a patch by Kristian Evensen
Diffstat (limited to 'interface.c')
-rw-r--r--interface.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/interface.c b/interface.c
index a2c3f44..42e5a82 100644
--- a/interface.c
+++ b/interface.c
@@ -26,6 +26,7 @@
struct vlist_tree interfaces;
static LIST_HEAD(iface_all_users);
+static unsigned int interface_serial = 0;
enum {
IFACE_ATTR_IFNAME,
@@ -39,6 +40,8 @@ enum {
IFACE_ATTR_INTERFACE,
IFACE_ATTR_IP6ASSIGN,
IFACE_ATTR_IP6HINT,
+ IFACE_ATTR_IP4TABLE,
+ IFACE_ATTR_IP6TABLE,
IFACE_ATTR_MAX
};
@@ -54,6 +57,8 @@ static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = {
[IFACE_ATTR_INTERFACE] = { .name = "interface", .type = BLOBMSG_TYPE_STRING },
[IFACE_ATTR_IP6ASSIGN] = { .name = "ip6assign", .type = BLOBMSG_TYPE_INT32 },
[IFACE_ATTR_IP6HINT] = { .name = "ip6hint", .type = BLOBMSG_TYPE_STRING },
+ [IFACE_ATTR_IP4TABLE] = { .name = "ip4table", .type = BLOBMSG_TYPE_STRING },
+ [IFACE_ATTR_IP6TABLE] = { .name = "ip6table", .type = BLOBMSG_TYPE_STRING },
};
static const union config_param_info iface_attr_info[IFACE_ATTR_MAX] = {
@@ -497,6 +502,18 @@ interface_init(struct interface *iface, const char *name,
iface->config_ip.assignment_hint = strtol(blobmsg_get_string(cur), NULL, 16) &
~((1 << (64 - iface->config_ip.assignment_length)) - 1);
+ if ((cur = tb[IFACE_ATTR_IP4TABLE])) {
+ if (!system_resolve_rt_table(blobmsg_data(cur), &iface->ip4table))
+ DPRINTF("Failed to resolve routing table: %s\n", (char *) blobmsg_data(cur));
+ }
+
+ // Set a default exteranl routing table for IPv6 to do source-based-filtering
+ iface->ip6table = 1000 + ++interface_serial;
+ if ((cur = tb[IFACE_ATTR_IP6TABLE])) {
+ if (!system_resolve_rt_table(blobmsg_data(cur), &iface->ip6table))
+ DPRINTF("Failed to resolve routing table: %s\n", (char *) blobmsg_data(cur));
+ }
+
iface->config_autostart = iface->autostart;
}