summaryrefslogtreecommitdiff
path: root/vlan.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-07-05 14:18:04 +0200
committerFelix Fietkau <nbd@openwrt.org>2012-07-05 15:10:43 +0200
commit6094417533d97662f693d134ab04595a292de30c (patch)
treefffff9ec567c011095f9d5239481baff78b985a3 /vlan.c
parent0be9a1d0c1db1164a296a70157c01d1e5165d6cc (diff)
downloadnetifd-6094417533d97662f693d134ab04595a292de30c.tar.gz
fix ifname for alias+vlan chains
Diffstat (limited to 'vlan.c')
-rw-r--r--vlan.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/vlan.c b/vlan.c
index d1fb70b..ee0652f 100644
--- a/vlan.c
+++ b/vlan.c
@@ -61,6 +61,12 @@ static int vlan_set_device_state(struct device *dev, bool up)
return ret;
}
+static void vlan_dev_set_name(struct vlan_device *vldev, struct device *dev)
+{
+ vldev->dev.hidden = dev->hidden;
+ snprintf(vldev->dev.ifname, IFNAMSIZ, "%s.%d", dev->ifname, vldev->id);
+}
+
static void vlan_dev_cb(struct device_user *dep, enum device_event ev)
{
struct vlan_device *vldev;
@@ -73,6 +79,10 @@ static void vlan_dev_cb(struct device_user *dep, enum device_event ev)
case DEV_EVENT_REMOVE:
device_set_present(&vldev->dev, false);
break;
+ case DEV_EVENT_UPDATE_IFNAME:
+ vlan_dev_set_name(vldev, dep->dev);
+ device_broadcast_event(&vldev->dev, ev);
+ break;
default:
break;
}
@@ -104,7 +114,6 @@ static struct device *get_vlan_device(struct device *dev, int id, bool create)
return NULL;
vldev = calloc(1, sizeof(*vldev));
- snprintf(vldev->dev.ifname, IFNAMSIZ, "%s.%d", dev->ifname, id);
device_init_virtual(&vldev->dev, &vlan_type, NULL);
vldev->dev.default_config = true;
@@ -113,6 +122,7 @@ static struct device *get_vlan_device(struct device *dev, int id, bool create)
vldev->dev.set_state = vlan_set_device_state;
vldev->id = id;
+ vlan_dev_set_name(vldev, dev);
vldev->dep.cb = vlan_dev_cb;
device_add_user(&vldev->dep, dev);