netifd: Fix lost interface device config for devices having default config
authorHans Dedecker <dedeckeh@gmail.com>
Fri, 10 Oct 2014 13:35:08 +0000 (13:35 +0000)
committerSteven Barth <steven@midlink.org>
Sun, 12 Oct 2014 12:25:37 +0000 (14:25 +0200)
As the PPP main device (either a simple or old style vlan device) is freed when PPP interfaces are reloaded; interface device specific config (eg mtu/macaddr/...) is lost as the interface config is not re-applied on the newly created device.
Patch fixes the issue by re-applying the interface device config after the main device is claimed and is having default config.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
interface.c

index 35f20b0..4543250 100644 (file)
@@ -501,6 +501,8 @@ interface_claim_device(struct interface *iface)
        } else if (iface->ifname &&
                !(iface->proto_handler->flags & PROTO_FLAG_NODEV)) {
                dev = device_get(iface->ifname, true);
+               if (dev && dev->default_config && iface->device_config)
+                       device_set_config(dev, dev->type, iface->config);
        } else {
                dev = iface->ext_dev.dev;
        }
@@ -881,8 +883,8 @@ interface_handle_link(struct interface *iface, const char *name, bool add, bool
 
        if (add) {
                device_set_present(dev, true);
-               if (iface->device_config)
-                       device_set_config(dev, &simple_device_type, iface->config);
+               if (iface->device_config && dev->default_config)
+                       device_set_config(dev, dev->type, iface->config);
 
                system_if_apply_settings(dev, &dev->settings, dev->settings.flags);
                ret = interface_add_link(iface, dev, link_ext);