diff options
author | Felix Fietkau <nbd@nbd.name> | 2020-11-20 18:58:10 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2020-11-20 19:01:17 +0100 |
commit | 4544f026bb0996adb6d95224031f0ba35cb8c046 (patch) | |
tree | 0ed33ee832d2ef7037b0bf15ea884c688b2db3c7 /config.c | |
parent | 5e18d5b9ccb189efb914733e7b74073f5c75e0df (diff) | |
download | netifd-4544f026bb0996adb6d95224031f0ba35cb8c046.tar.gz |
bridge-vlan: add support for defining aliases for vlan ids
When defining a bridge-vlan like this:
config bridge-vlan
option device 'switch0'
option vlan '1'
option ports 'lan1 lan2 lan3 lan4'
option alias 'lan'
You can use switch0.lan instead of switch0.1 to refer to the VLAN.
This ensures that the VLAN ID can be kept in a single place in the config
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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); } |