Add time.h include
[project/netifd.git] / interface.c
index d0eec4a..787d7d9 100644 (file)
@@ -184,6 +184,8 @@ interface_claim_device(struct interface *iface)
                if (dev)
                        device_add_user(&iface->main_dev, dev);
        }
+       if (iface->proto_handler->flags & PROTO_FLAG_INIT_AVAILABLE)
+               interface_set_available(iface, true);
 }
 
 
@@ -475,8 +477,9 @@ interface_change_config(struct interface *if_old, struct interface *if_new)
        if_old->ifname = if_new->ifname;
        if_old->proto_handler = if_new->proto_handler;
 
-       if (strcmp(old_ifname, if_new->ifname) != 0 ||
-               proto != if_new->proto_handler) {
+       if ((!!old_ifname != !!if_new->ifname) ||
+           (old_ifname && strcmp(old_ifname, if_new->ifname) != 0) ||
+           proto != if_new->proto_handler) {
                D(INTERFACE, "Reload interface '%s' because of ifname/proto change\n",
                  if_old->name);
                goto reload;
@@ -516,8 +519,8 @@ interface_update(struct vlist_tree *tree, struct vlist_node *node_new,
                set_config_state(if_old, IFC_REMOVE);
        } else if (node_new) {
                D(INTERFACE, "Create interface '%s'\n", if_new->name);
-               interface_claim_device(if_new);
                proto_init_interface(if_new, if_new->config);
+               interface_claim_device(if_new);
                netifd_ubus_add_interface(if_new);
        }
 }