summaryrefslogtreecommitdiffhomepage
path: root/interface.c
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2014-01-17 00:39:40 +0100
committerSteven Barth <steven@midlink.org>2014-01-17 00:39:40 +0100
commit1418ef786f275b8458462ee3494573524ca0042c (patch)
treeb8f54642f54ad2b6d0bbda84290281bf53a0d677 /interface.c
parent7d79d0a8aa5a5b4c1ed987af119356438d98fe7b (diff)
Add indicator-flags to ubus and hotplug update-events
Diffstat (limited to 'interface.c')
-rw-r--r--interface.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/interface.c b/interface.c
index 9c208a2..0032e57 100644
--- a/interface.c
+++ b/interface.c
@@ -151,15 +151,23 @@ interface_add_data(struct interface *iface, const struct blob_attr *data)
if (!blobmsg_check_attr(data, true))
return UBUS_STATUS_INVALID_ARGUMENT;
- n = calloc(1, sizeof(*n) + blob_pad_len(data));
- memcpy(n->data, data, blob_pad_len(data));
- n->node.key = blobmsg_name(n->data);
+ const char *name = blobmsg_name(data);
+ unsigned len = blob_pad_len(data);
+
+ o = avl_find_element(&iface->data, name, o, node);
+ if (o) {
+ if (blob_pad_len(o->data) == len && !memcmp(o->data, data, len))
+ return 0;
- o = avl_find_element(&iface->data, n->node.key, o, node);
- if (o)
interface_data_del(iface, o);
+ }
+ n = calloc(1, sizeof(*n) + len);
+ memcpy(n->data, data, len);
+ n->node.key = blobmsg_name(n->data);
avl_insert(&iface->data, &n->node);
+
+ iface->updated |= IUF_DATA;
return 0;
}
@@ -846,6 +854,7 @@ set_config_state(struct interface *iface, enum interface_config_state s)
void
interface_update_start(struct interface *iface)
{
+ iface->updated = 0;
interface_ip_update_start(&iface->proto_ip);
}