diff options
author | Felix Fietkau <nbd@nbd.name> | 2021-06-04 09:05:31 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2021-06-04 09:05:33 +0200 |
commit | 50381d0a2998f6c0fc4823f0c2aa4206063d549e (patch) | |
tree | e22f15cc925923c12a741a41e4fa289270c3a547 /vlandev.c | |
parent | 7f199050f395d5295a3f665bcd2eb8cc755d08aa (diff) | |
download | netifd-50381d0a2998f6c0fc4823f0c2aa4206063d549e.tar.gz |
bridge: allow adding/removing VLANs to configured member ports via hotplug
This is useful for a dynamic VLAN setup, where extra tags need to be created
on the trunking port on demand
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'vlandev.c')
-rw-r--r-- | vlandev.c | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -61,7 +61,7 @@ struct vlandev_device { }; static int -vlandev_hotplug_add(struct device *dev, struct device *member, struct blob_attr *vlan) +__vlandev_hotplug_op(struct device *dev, struct device *member, struct blob_attr *vlan, bool add) { struct vlandev_device *mvdev = container_of(dev, struct vlandev_device, dev); void *a; @@ -75,19 +75,22 @@ vlandev_hotplug_add(struct device *dev, struct device *member, struct blob_attr blobmsg_printf(&b, NULL, "%d", mvdev->config.vid); blobmsg_close_array(&b, a); - return dev->hotplug_ops->add(dev, member, blobmsg_data(b.head)); + if (add) + return dev->hotplug_ops->add(dev, member, blobmsg_data(b.head)); + else + return dev->hotplug_ops->del(dev, member, blobmsg_data(b.head)); } static int -vlandev_hotplug_del(struct device *dev, struct device *member) +vlandev_hotplug_add(struct device *dev, struct device *member, struct blob_attr *vlan) { - struct vlandev_device *mvdev = container_of(dev, struct vlandev_device, dev); - - dev = mvdev->parent.dev; - if (!dev || !dev->hotplug_ops) - return UBUS_STATUS_NOT_SUPPORTED; + return __vlandev_hotplug_op(dev, member, vlan, true); +} - return dev->hotplug_ops->del(dev, member); +static int +vlandev_hotplug_del(struct device *dev, struct device *member, struct blob_attr *vlan) +{ + return __vlandev_hotplug_op(dev, member, vlan, false); } static int |