X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=interface-ip.c;h=587826a996cd708d094b00fc658fcaf3a4919dbc;hp=bd6f16483a245086cc2170dee7769181e2c79795;hb=81b14db5ca47ae44efc5ccb982f16597873ab4ba;hpb=8f0c8e8e91945a3e5c3fa7111b2a3494b731b32c diff --git a/interface-ip.c b/interface-ip.c index bd6f164..587826a 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -39,6 +39,7 @@ enum { ROUTE_TABLE, ROUTE_SOURCE, ROUTE_ONLINK, + ROUTE_TYPE, __ROUTE_MAX }; @@ -53,6 +54,7 @@ static const struct blobmsg_policy route_attr[__ROUTE_MAX] = { [ROUTE_VALID] = { .name = "valid", .type = BLOBMSG_TYPE_INT32 }, [ROUTE_SOURCE] = { .name = "source", .type = BLOBMSG_TYPE_STRING }, [ROUTE_ONLINK] = { .name = "onlink", .type = BLOBMSG_TYPE_BOOL }, + [ROUTE_TYPE] = { .name = "type", .type = BLOBMSG_TYPE_STRING } }; const struct uci_blob_param_list route_attr_list = { @@ -363,6 +365,10 @@ interface_ip_add_route(struct interface *iface, struct blob_attr *attr, bool v6) goto error; } + /* only set the table flag if not using the main (default) table */ + if (system_is_default_rt_table(route->table)) + route->table = 0; + if (route->table) route->flags |= DEVROUTE_TABLE; } @@ -374,6 +380,14 @@ interface_ip_add_route(struct interface *iface, struct blob_attr *attr, bool v6) route->valid_until = valid_until; } + if ((cur = tb[ROUTE_TYPE]) != NULL) { + if (!system_resolve_rt_type(blobmsg_data(cur), &route->type)) { + DPRINTF("Failed to resolve routing type: %s\n", (char *) blobmsg_data(cur)); + goto error; + } + route->flags |= DEVROUTE_TYPE; + } + vlist_add(&ip->route, &route->node, route); return; @@ -586,7 +600,8 @@ interface_update_proto_route(struct vlist_tree *tree, if (node_old && node_new) keep = !memcmp(&route_old->nexthop, &route_new->nexthop, sizeof(route_old->nexthop)) && - (route_old->mtu == route_new->mtu) && !route_old->failed; + (route_old->mtu == route_new->mtu) && (route_old->type == route_new->type) && + !route_old->failed; if (node_old) { if (!(route_old->flags & DEVADDR_EXTERNAL) && route_old->enabled && !keep) @@ -1223,7 +1238,6 @@ interface_ip_init(struct interface *iface) __interface_ip_init(&iface->proto_ip, iface); __interface_ip_init(&iface->config_ip, iface); vlist_init(&iface->host_routes, route_cmp, interface_update_host_route); - } static void