From 4544f026bb0996adb6d95224031f0ba35cb8c046 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 20 Nov 2020 18:58:10 +0100 Subject: 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 --- config.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'config.c') diff --git a/config.c b/config.c index 563dedc..d91830c 100644 --- 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); } -- cgit v1.2.1