diff options
author | Felix Fietkau <nbd@openwrt.org> | 2015-04-18 23:26:51 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2015-04-18 23:26:51 +0200 |
commit | ab369490f931712c21913902f8cb9a81fc2767a4 (patch) | |
tree | dc0f746ea0f199e90a9de0b071a82a5872525823 /interface.c | |
parent | 944f30d3f96577464545dd35691f96b06fbcc6ab (diff) |
interface: detect and handle changes in device config
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'interface.c')
-rw-r--r-- | interface.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/interface.c b/interface.c index 8239eac..f72d967 100644 --- a/interface.c +++ b/interface.c @@ -1041,6 +1041,35 @@ interface_replace_dns(struct interface_ip_settings *new, struct interface_ip_set vlist_simple_replace(&new->dns_search, &old->dns_search); } +static bool +interface_device_config_changed(struct interface *if_old, struct interface *if_new) +{ + struct blob_attr *ntb[__DEV_ATTR_MAX]; + struct blob_attr *otb[__DEV_ATTR_MAX]; + struct device *dev = if_old->main_dev.dev; + unsigned long diff; + + BUILD_BUG_ON(sizeof(diff) < __DEV_ATTR_MAX / 8); + + if (!dev) + return false; + + if (if_old->device_config != if_new->device_config) + return true; + + if (!if_new->device_config) + return false; + + blobmsg_parse(device_attr_list.params, __DEV_ATTR_MAX, otb, + blob_data(if_old->config), blob_len(if_old->config)); + + blobmsg_parse(device_attr_list.params, __DEV_ATTR_MAX, ntb, + blob_data(if_new->config), blob_len(if_new->config)); + + uci_blob_diff(ntb, otb, &device_attr_list, &diff); + return diff; +} + static void interface_change_config(struct interface *if_old, struct interface *if_new) { @@ -1058,6 +1087,9 @@ interface_change_config(struct interface *if_old, struct interface *if_new) reload = true; } + if (!reload && interface_device_config_changed(if_old, if_new)) + reload = true; + if (FIELD_CHANGED_STR(ifname) || if_old->proto_handler != if_new->proto_handler) reload = true; |