Only update resolv.conf if changed (avoid logspam)
[project/netifd.git] / device.c
index bc5bc46..9ef444e 100644 (file)
--- a/device.c
+++ b/device.c
@@ -183,14 +183,27 @@ static void __init dev_init(void)
 
 static void __device_broadcast_event(struct list_head *head, enum device_event ev)
 {
-       struct device_user *dep, *tmp;
+       struct device_user *dep;
+       static uint8_t idx[__DEV_EVENT_MAX];
+       bool found;
 
-       list_for_each_entry_safe(dep, tmp, head, list) {
-               if (!dep->cb)
-                       continue;
+       idx[ev]++;
+       do {
+               found = false;
 
-               dep->cb(dep, ev);
-       }
+               list_for_each_entry(dep, head, list) {
+                       if (!dep->cb)
+                               continue;
+
+                       if (dep->ev_idx[ev] == idx[ev])
+                               continue;
+
+                       dep->cb(dep, ev);
+                       dep->ev_idx[ev] = idx[ev];
+                       found = true;
+                       break;
+               }
+       } while (found);
 }
 
 void device_broadcast_event(struct device *dev, enum device_event ev)
@@ -584,6 +597,10 @@ device_create(const char *name, const struct device_type *type,
        if (odev) {
                odev->current_config = true;
                change = device_set_config(odev, type, config);
+               if (odev->external) {
+                       system_if_apply_settings(odev, &odev->settings);
+                       change = DEV_CONFIG_APPLIED;
+               }
                switch (change) {
                case DEV_CONFIG_RESTART:
                case DEV_CONFIG_APPLIED:
@@ -658,7 +675,7 @@ device_dump_status(struct blob_buf *b, struct device *dev)
                if (st.flags & DEV_OPT_MTU)
                        blobmsg_add_u32(b, "mtu", st.mtu);
                if (st.flags & DEV_OPT_MACADDR)
-                       blobmsg_add_string(b, "macaddr", ether_ntoa((struct ether_addr *) st.macaddr));
+                       blobmsg_add_string(b, "macaddr", format_macaddr(st.macaddr));
                if (st.flags & DEV_OPT_TXQUEUELEN)
                        blobmsg_add_u32(b, "txqueuelen", st.txqueuelen);
        }