summaryrefslogtreecommitdiffhomepage
path: root/vlan.c
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2016-06-06 14:58:31 +0200
committerFelix Fietkau <nbd@nbd.name>2016-06-06 15:42:00 +0200
commit29521f9a232f039318fd8525c410b3127836626f (patch)
tree10b3ea2876ecbf09de1c839ff9e1baa9935ee676 /vlan.c
parentfef10041f3a495d79f03f99bdf416a68a0ee91aa (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.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/vlan.c b/vlan.c
index ac434ce..7f8697b 100644
--- a/vlan.c
+++ b/vlan.c
@@ -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;