preserve interface main hotplug device on reload
[project/netifd.git] / device.c
index d47bcdf..8f0e823 100644 (file)
--- a/device.c
+++ b/device.c
@@ -214,7 +214,7 @@ device_init_settings(struct device *dev, struct blob_attr **tb)
        }
 
        if ((cur = tb[DEV_ATTR_MACADDR])) {
-               ea = ether_aton(blob_data(cur));
+               ea = ether_aton(blobmsg_data(cur));
                if (ea) {
                        memcpy(s->macaddr, ea, 6);
                        s->flags |= DEV_OPT_MACADDR;
@@ -465,6 +465,9 @@ device_set_disabled(struct device *dev, bool value)
 
 void device_add_user(struct device_user *dep, struct device *dev)
 {
+       if (dep->dev)
+               device_remove_user(dep);
+
        dep->dev = dev;
        list_add_tail(&dep->list, &dev->users);
        if (dep->cb && dev->present) {