config: ra_management compatibility support
authorHans Dedecker <dedeckeh@gmail.com>
Mon, 9 Sep 2019 20:12:51 +0000 (22:12 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Thu, 12 Sep 2019 19:54:01 +0000 (21:54 +0200)
Keep supporting ra_management for backwards compatibility support;
ra_management will only be processed if neither ra_slaac and ra_flags
are set.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
src/config.c

index 53528a0137cb285a92d1a77a2d5d3579fa56b6df..a8458a5a053152ddb24cabed4fd9bc3c1ede07af 100644 (file)
@@ -59,6 +59,7 @@ enum {
        IFACE_ATTR_DHCPV6_PD,
        IFACE_ATTR_DHCPV6_NA,
        IFACE_ATTR_RA_DEFAULT,
        IFACE_ATTR_DHCPV6_PD,
        IFACE_ATTR_DHCPV6_NA,
        IFACE_ATTR_RA_DEFAULT,
+       IFACE_ATTR_RA_MANAGEMENT,
        IFACE_ATTR_RA_FLAGS,
        IFACE_ATTR_RA_SLAAC,
        IFACE_ATTR_RA_OFFLINK,
        IFACE_ATTR_RA_FLAGS,
        IFACE_ATTR_RA_SLAAC,
        IFACE_ATTR_RA_OFFLINK,
@@ -107,6 +108,7 @@ static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = {
        [IFACE_ATTR_PD_MANAGER] = { .name = "pd_manager", .type = BLOBMSG_TYPE_STRING },
        [IFACE_ATTR_PD_CER] = { .name = "pd_cer", .type = BLOBMSG_TYPE_STRING },
        [IFACE_ATTR_RA_DEFAULT] = { .name = "ra_default", .type = BLOBMSG_TYPE_INT32 },
        [IFACE_ATTR_PD_MANAGER] = { .name = "pd_manager", .type = BLOBMSG_TYPE_STRING },
        [IFACE_ATTR_PD_CER] = { .name = "pd_cer", .type = BLOBMSG_TYPE_STRING },
        [IFACE_ATTR_RA_DEFAULT] = { .name = "ra_default", .type = BLOBMSG_TYPE_INT32 },
+       [IFACE_ATTR_RA_MANAGEMENT] = { .name = "ra_management", .type = BLOBMSG_TYPE_INT32 },
        [IFACE_ATTR_RA_FLAGS] = { .name = "ra_flags", . type = BLOBMSG_TYPE_ARRAY },
        [IFACE_ATTR_RA_SLAAC] = { .name = "ra_slaac", .type = BLOBMSG_TYPE_BOOL },
        [IFACE_ATTR_RA_OFFLINK] = { .name = "ra_offlink", .type = BLOBMSG_TYPE_BOOL },
        [IFACE_ATTR_RA_FLAGS] = { .name = "ra_flags", . type = BLOBMSG_TYPE_ARRAY },
        [IFACE_ATTR_RA_SLAAC] = { .name = "ra_slaac", .type = BLOBMSG_TYPE_BOOL },
        [IFACE_ATTR_RA_OFFLINK] = { .name = "ra_offlink", .type = BLOBMSG_TYPE_BOOL },
@@ -734,6 +736,26 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
        if ((c = tb[IFACE_ATTR_RA_DEFAULT]))
                iface->default_router = blobmsg_get_u32(c);
 
        if ((c = tb[IFACE_ATTR_RA_DEFAULT]))
                iface->default_router = blobmsg_get_u32(c);
 
+       if (!tb[IFACE_ATTR_RA_FLAGS] && !tb[IFACE_ATTR_RA_SLAAC] &&
+           (c = tb[IFACE_ATTR_RA_MANAGEMENT])) {
+               switch (blobmsg_get_u32(c)) {
+               case 0:
+                       iface->ra_flags = ND_RA_FLAG_OTHER;
+                       iface->ra_slaac = true;
+                       break;
+               case 1:
+                       iface->ra_flags = ND_RA_FLAG_OTHER|ND_RA_FLAG_MANAGED;
+                       iface->ra_slaac = true;
+                       break;
+               case 2:
+                       iface->ra_flags = ND_RA_FLAG_OTHER|ND_RA_FLAG_MANAGED;
+                       iface->ra_slaac = false;
+                       break;
+               default:
+                       break;
+               }
+       }
+
        if ((c = tb[IFACE_ATTR_RA_FLAGS])) {
                iface->ra_flags = 0;
                if (parse_ra_flags(&iface->ra_flags, c) < 0)
        if ((c = tb[IFACE_ATTR_RA_FLAGS])) {
                iface->ra_flags = 0;
                if (parse_ra_flags(&iface->ra_flags, c) < 0)