Add support for onlink-flags for IPv4 routes
authorSteven Barth <steven@midlink.org>
Tue, 10 Jun 2014 15:59:16 +0000 (17:59 +0200)
committerSteven Barth <steven@midlink.org>
Tue, 10 Jun 2014 15:59:16 +0000 (17:59 +0200)
Signed-off-by: Steven Barth <steven@midlink.org>
interface-ip.c
interface-ip.h
system-linux.c

index 33b5d43..bd6f164 100644 (file)
@@ -38,6 +38,7 @@ enum {
        ROUTE_VALID,
        ROUTE_TABLE,
        ROUTE_SOURCE,
+       ROUTE_ONLINK,
        __ROUTE_MAX
 };
 
@@ -51,6 +52,7 @@ 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 },
 };
 
 const struct uci_blob_param_list route_attr_list = {
@@ -347,6 +349,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;
index de8343d..93d55ee 100644 (file)
@@ -42,6 +42,9 @@ enum device_addr_flags {
 
        /* route resides in default source-route table */
        DEVROUTE_SRCTABLE       = (1 << 8),
+
+       /* route is on-link */
+       DEVROUTE_ONLINK         = (1 << 9),
 };
 
 union if_addr {
index 06226ef..7447422 100644 (file)
@@ -1221,6 +1221,7 @@ static int system_rt(struct device *dev, struct device_route *route, int cmd)
                .rtm_protocol = (route->flags & DEVADDR_KERNEL) ? RTPROT_KERNEL : RTPROT_STATIC,
                .rtm_scope = scope,
                .rtm_type = (cmd == RTM_DELROUTE) ? 0: RTN_UNICAST,
+               .rtm_flags = (route->flags & DEVROUTE_ONLINK) ? RTNH_F_ONLINK : 0,
        };
        struct nl_msg *msg;