bridge-vlan: add support for defining aliases for vlan ids
[project/netifd.git] / config.c
index 563dedc4a8b722d3ca4aa2ca967b3d50dbca8629..d91830c8a931917239a3502a4f256674cfad2627 100644 (file)
--- a/config.c
+++ b/config.c
@@ -279,15 +279,18 @@ config_parse_vlan(struct device *dev, struct uci_section *s)
                BRVLAN_ATTR_VID,
                BRVLAN_ATTR_LOCAL,
                BRVLAN_ATTR_PORTS,
+               BRVLAN_ATTR_ALIAS,
                __BRVLAN_ATTR_MAX,
        };
        static const struct blobmsg_policy vlan_attrs[__BRVLAN_ATTR_MAX] = {
                [BRVLAN_ATTR_VID] = { "vlan", BLOBMSG_TYPE_INT32 },
                [BRVLAN_ATTR_LOCAL] = { "local", BLOBMSG_TYPE_BOOL },
                [BRVLAN_ATTR_PORTS] = { "ports", BLOBMSG_TYPE_ARRAY },
+               [BRVLAN_ATTR_ALIAS] = { "alias", BLOBMSG_TYPE_ARRAY },
        };
        static const struct uci_blob_param_info vlan_attr_info[__BRVLAN_ATTR_MAX] = {
                [BRVLAN_ATTR_PORTS] = { .type = BLOBMSG_TYPE_STRING },
+               [BRVLAN_ATTR_ALIAS] = { .type = BLOBMSG_TYPE_STRING },
        };
        static const struct uci_blob_param_list vlan_attr_list = {
                .n_params = __BRVLAN_ATTR_MAX,
@@ -363,6 +366,9 @@ config_parse_vlan(struct device *dev, struct uci_section *s)
                port++;
        }
 
+       blobmsg_for_each_attr(cur, tb[BRVLAN_ATTR_ALIAS], rem)
+               kvlist_set(&dev->vlan_aliases, blobmsg_get_string(cur), &vid);
+
        vlist_add(&dev->vlans, &vlan->node, &vlan->vid);
 }