nterface-ip: remove superfluous iface check in interface_ip_set_enabled()
[project/netifd.git] / vlan.c
diff --git a/vlan.c b/vlan.c
index 3d0a4cf..067f624 100644 (file)
--- 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)
 {
 
 static void vlan_dev_set_name(struct vlan_device *vldev, struct device *dev)
 {
+       char name[IFNAMSIZ];
+
        vldev->dev.hidden = dev->hidden;
        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)
 }
 
 static void vlan_dev_cb(struct device_user *dep, enum device_event ev)
@@ -79,14 +82,8 @@ static void vlan_dev_cb(struct device_user *dep, enum device_event ev)
        case DEV_EVENT_REMOVE:
                device_set_present(&vldev->dev, new_state);
                break;
        case DEV_EVENT_REMOVE:
                device_set_present(&vldev->dev, new_state);
                break;
-       case DEV_EVENT_LINK_UP:
-               new_state = true;
-       case DEV_EVENT_LINK_DOWN:
-               device_set_link(&vldev->dev, new_state);
-               break;
        case DEV_EVENT_UPDATE_IFNAME:
                vlan_dev_set_name(vldev, dep->dev);
        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 */
                break;
        case DEV_EVENT_TOPO_CHANGE:
                /* Propagate topo changes */
@@ -99,10 +96,9 @@ static void vlan_dev_cb(struct device_user *dep, enum device_event ev)
 
 static struct device *get_vlan_device(struct device *dev, int id, bool create)
 {
 
 static struct device *get_vlan_device(struct device *dev, int id, bool create)
 {
-       static const struct device_type vlan_type = {
+       static struct device_type vlan_type = {
                .name = "VLAN",
                .config_params = &device_attr_list,
                .name = "VLAN",
                .config_params = &device_attr_list,
-               .keep_link_status = true,
                .free = free_vlan_if,
        };
        struct vlan_device *vldev;
                .free = free_vlan_if,
        };
        struct vlan_device *vldev;
@@ -126,11 +122,14 @@ static struct device *get_vlan_device(struct device *dev, int id, bool create)
        D(DEVICE, "Create vlan device '%s.%d'\n", dev->ifname, id);
 
        vldev = calloc(1, sizeof(*vldev));
        D(DEVICE, "Create vlan device '%s.%d'\n", dev->ifname, id);
 
        vldev = calloc(1, sizeof(*vldev));
+       if (!vldev)
+               return NULL;
 
        vldev->id = id;
 
        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;
        vldev->dev.default_config = true;
 
        vldev->set_state = vldev->dev.set_state;