summaryrefslogtreecommitdiff
path: root/device.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2020-11-20 18:58:10 +0100
committerFelix Fietkau <nbd@nbd.name>2020-11-20 19:01:17 +0100
commit4544f026bb0996adb6d95224031f0ba35cb8c046 (patch)
tree0ed33ee832d2ef7037b0bf15ea884c688b2db3c7 /device.c
parent5e18d5b9ccb189efb914733e7b74073f5c75e0df (diff)
downloadnetifd-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 'device.c')
-rw-r--r--device.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/device.c b/device.c
index e484c09..3e2b5e9 100644
--- a/device.c
+++ b/device.c
@@ -109,6 +109,11 @@ void device_unlock(void)
device_free_unused(NULL);
}
+static int device_vlan_len(struct kvlist *kv, const void *data)
+{
+ return sizeof(unsigned int);
+}
+
void device_vlan_update(bool done)
{
struct device *dev;
@@ -117,10 +122,15 @@ void device_vlan_update(bool done)
if (!dev->vlans.update)
continue;
- if (!done)
+ if (!done) {
+ if (dev->vlan_aliases.get_len)
+ kvlist_free(&dev->vlan_aliases);
+ else
+ kvlist_init(&dev->vlan_aliases, device_vlan_len);
vlist_update(&dev->vlans);
- else
+ } else {
vlist_flush(&dev->vlans);
+ }
}
}