always recreate devices by default if the config attribute list is not the default one
[project/netifd.git] / device.c
index f856f22..44541e2 100644 (file)
--- a/device.c
+++ b/device.c
@@ -336,6 +336,7 @@ enum dev_change_type
 device_reload_config(struct device *dev, struct blob_attr *attr)
 {
        struct blob_attr *tb[__DEV_ATTR_MAX], *tb1[__DEV_ATTR_MAX];
+       const struct config_param_list *params = dev->type->config_params;
 
        blobmsg_parse(dev_attrs, __DEV_ATTR_MAX, tb,
                blob_data(attr), blob_len(attr));
@@ -345,11 +346,14 @@ device_reload_config(struct device *dev, struct blob_attr *attr)
        else
                memset(tb1, 0, sizeof(tb1));
 
-       if (!config_diff(tb, tb1, &device_attr_list, NULL))
+       if (!config_diff(tb, tb1, dev->type->config_params, NULL))
                return DEV_CONFIG_NO_CHANGE;
 
        device_init_settings(dev, tb);
-       return DEV_CONFIG_APPLIED;
+       if (params == &device_attr_list)
+               return DEV_CONFIG_APPLIED;
+       else
+               return DEV_CONFIG_RECREATE;
 }
 
 static enum dev_change_type
@@ -435,7 +439,6 @@ device_create(const char *name, const struct device_type *type,
                                device_set_present(odev, false);
                                device_set_present(odev, true);
                        }
-                       free(config);
                        return odev;
                case DEV_CONFIG_NO_CHANGE:
                        D(DEVICE, "Device '%s': no configuration change\n", odev->ifname);