netifd: propagate error code on netifd_reload()
[project/netifd.git] / interface-event.c
index 3cdfbdb..4976c2c 100644 (file)
@@ -30,7 +30,14 @@ static void task_complete(struct uloop_process *proc, int ret);
 static struct uloop_process task = {
        .cb = task_complete,
 };
-static const char * const eventnames[] = {"ifdown", "ifup", "ifupdate", "free", "reload"};
+static const char * const eventnames[] = {
+       [IFEV_DOWN] = "ifdown",
+       [IFEV_UP] = "ifup",
+       [IFEV_UPDATE] = "ifupdate",
+       [IFEV_FREE] = "free",
+       [IFEV_RELOAD] = "reload",
+       [IFEV_LINK_UP] = "iflink",
+};
 
 static void
 run_cmd(const char *ifname, const char *device, enum interface_event event,
@@ -117,6 +124,10 @@ interface_queue_event(struct interface *iface, enum interface_event ev)
 
        netifd_ubus_interface_notify(iface, ev != IFEV_DOWN);
 
+       /* no hotplug.d calls for link up */
+       if (ev == IFEV_LINK_UP)
+               return;
+
        if (current == iface) {
                /* an event for iface is being processed */
                if (!list_empty(&iface->hotplug_list)) {
@@ -178,15 +189,17 @@ static void interface_event_cb(struct interface_user *dep, struct interface *ifa
                               enum interface_event ev)
 {
        switch (ev) {
+               case IFEV_LINK_UP:
                case IFEV_UP:
                case IFEV_UPDATE:
                case IFEV_DOWN:
                        interface_queue_event(iface, ev);
                        break;
                case IFEV_FREE:
-               case IFEV_RELOAD:
                        interface_dequeue_event(iface);
                        break;
+               default:
+                       break;
        }
 }