system: fix treatment of RT_TABLE_MAIN
[project/netifd.git] / interface-ip.c
index a82d8e7..715e498 100644 (file)
@@ -38,6 +38,8 @@ enum {
        ROUTE_VALID,
        ROUTE_TABLE,
        ROUTE_SOURCE,
+       ROUTE_ONLINK,
+       ROUTE_TYPE,
        __ROUTE_MAX
 };
 
@@ -51,6 +53,8 @@ static const struct blobmsg_policy route_attr[__ROUTE_MAX] = {
        [ROUTE_TABLE] = { .name = "table", .type = BLOBMSG_TYPE_STRING },
        [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 = {
@@ -347,6 +351,9 @@ interface_ip_add_route(struct interface *iface, struct blob_attr *attr, bool v6)
                route->sourcemask = (mask) ? atoi(mask) : ((af == AF_INET6) ? 128 : 32);
        }
 
+       if ((cur = tb[ROUTE_ONLINK]) != NULL && blobmsg_get_bool(cur))
+               route->flags |= DEVROUTE_ONLINK;
+
        if (is_proto_route) {
                route->table = (v6) ? iface->ip6table : iface->ip4table;
                route->flags |= DEVROUTE_SRCTABLE;
@@ -369,6 +376,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;
 
@@ -581,6 +596,7 @@ 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->type == route_new->type) &&
                        !route_old->failed;
 
        if (node_old) {
@@ -1218,7 +1234,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