diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2013-04-04 14:41:38 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2013-04-04 14:44:16 +0200 |
commit | 09ae3bfa2ad7a3a9630fdf290b872a2d7673843f (patch) | |
tree | b7d2a9324a84b8118a858ca7bd809f57abda043c /interface-ip.c | |
parent | 48ffedb4a2b6701eec99e32e91b8a66a0a4be950 (diff) |
Implement support for route / route6 table attribute
Diffstat (limited to 'interface-ip.c')
-rw-r--r-- | interface-ip.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/interface-ip.c b/interface-ip.c index ed95b2e..190c158 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -34,6 +34,7 @@ enum { ROUTE_METRIC, ROUTE_MTU, ROUTE_VALID, + ROUTE_TABLE, __ROUTE_MAX }; @@ -44,6 +45,7 @@ static const struct blobmsg_policy route_attr[__ROUTE_MAX] = { [ROUTE_GATEWAY] = { .name = "gateway", .type = BLOBMSG_TYPE_STRING }, [ROUTE_METRIC] = { .name = "metric", .type = BLOBMSG_TYPE_INT32 }, [ROUTE_MTU] = { .name = "mtu", .type = BLOBMSG_TYPE_INT32 }, + [ROUTE_TABLE] = { .name = "table", .type = BLOBMSG_TYPE_STRING }, [ROUTE_VALID] = { .name = "valid", .type = BLOBMSG_TYPE_INT32 }, }; @@ -124,6 +126,9 @@ __find_ip_route_target(struct interface_ip_settings *ip, union if_addr *a, if (!match_if_addr(&route->addr, a, route->mask)) continue; + if (route->flags & DEVROUTE_TABLE) + continue; + if (!*res || route->mask < (*res)->mask) *res = route; } @@ -251,6 +256,16 @@ interface_ip_add_route(struct interface *iface, struct blob_attr *attr, bool v6) route->flags |= DEVROUTE_MTU; } + if ((cur = tb[ROUTE_TABLE]) != NULL) { + if (!system_resolve_rt_table(blobmsg_data(cur), &route->table)) { + DPRINTF("Failed to resolve routing table: %s\n", (char *) blobmsg_data(cur)); + goto error; + } + + if (route->table) + route->flags |= DEVROUTE_TABLE; + } + if ((cur = tb[ROUTE_VALID]) != NULL) route->valid_until = system_get_rtime() + blobmsg_get_u32(cur); |