diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2016-06-06 14:58:31 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2016-06-06 15:42:00 +0200 |
commit | 29521f9a232f039318fd8525c410b3127836626f (patch) | |
tree | 10b3ea2876ecbf09de1c839ff9e1baa9935ee676 /vlan.c | |
parent | fef10041f3a495d79f03f99bdf416a68a0ee91aa (diff) |
device: Fix device find failure in avl list due to device name change
As device name is used as key in avl list a device name change will break the avl find logic.
Function device_set_ifname offers api to set the device name and re-inserts the avl node in the list
when the avl key value is changed.
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'vlan.c')
-rw-r--r-- | vlan.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -63,8 +63,11 @@ static int vlan_set_device_state(struct device *dev, bool up) static void vlan_dev_set_name(struct vlan_device *vldev, struct device *dev) { + char name[IFNAMSIZ]; + vldev->dev.hidden = dev->hidden; - snprintf(vldev->dev.ifname, IFNAMSIZ, "%s.%d", dev->ifname, vldev->id); + snprintf(name, IFNAMSIZ, "%s.%d", dev->ifname, vldev->id); + device_set_ifname(&vldev->dev, name); } static void vlan_dev_cb(struct device_user *dep, enum device_event ev) @@ -81,7 +84,6 @@ static void vlan_dev_cb(struct device_user *dep, enum device_event ev) break; case DEV_EVENT_UPDATE_IFNAME: vlan_dev_set_name(vldev, dep->dev); - device_broadcast_event(&vldev->dev, ev); break; case DEV_EVENT_TOPO_CHANGE: /* Propagate topo changes */ @@ -124,9 +126,10 @@ static struct device *get_vlan_device(struct device *dev, int id, bool create) return NULL; vldev->id = id; - vlan_dev_set_name(vldev, dev); - device_init(&vldev->dev, &vlan_type, vldev->dev.ifname); + device_init(&vldev->dev, &vlan_type, NULL); + + vlan_dev_set_name(vldev, dev); vldev->dev.default_config = true; vldev->set_state = vldev->dev.set_state; |