X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=interface.c;h=257eaca5a705310e916b4941c43258c15d1b77ed;hb=677f9754526a7923417fb70f9a8a38adaeb251a6;hp=a8f7b8f01267f9e519d9d52fe978b067879cd126;hpb=76a6865acbed4df30d57bf57f62522c681081152;p=project%2Fnetifd.git diff --git a/interface.c b/interface.c index a8f7b8f..257eaca 100644 --- a/interface.c +++ b/interface.c @@ -100,6 +100,8 @@ interface_flush_state(struct interface *iface) static void mark_interface_down(struct interface *iface) { + if (iface->state == IFS_UP) + interface_event(iface, IFEV_DOWN); interface_flush_state(iface); iface->state = IFS_DOWN; } @@ -113,8 +115,9 @@ __interface_set_down(struct interface *iface, bool force) iface->state == IFS_TEARDOWN) return; + if (iface->state == IFS_UP) + interface_event(iface, IFEV_DOWN); iface->state = IFS_TEARDOWN; - interface_event(iface, IFEV_DOWN); interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, force); if (force) interface_flush_state(iface); @@ -184,6 +187,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); } @@ -272,8 +277,9 @@ interface_proto_cb(struct interface_proto_state *state, enum interface_proto_eve return; netifd_log_message(L_NOTICE, "Interface '%s' has lost the connection\n", iface->name); + if (iface->state == IFS_UP) + interface_event(iface, IFEV_DOWN); iface->state = IFS_SETUP; - interface_event(iface, IFEV_DOWN); break; } } @@ -517,8 +523,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); } }