]> git.ozlabs.org Git - petitboot/blobdiff - discover/network.c
discover: Bring down configured interfaces on discover server exit.
[petitboot] / discover / network.c
index bc7e186a1921e8531bb2fd37ed026f5e47e5977e..8cc01833d5875990358ea0bc897eea0bf5ab6fe0 100644 (file)
@@ -416,14 +416,15 @@ static int network_handle_nlmsg(struct network *network, struct nlmsghdr *nlmsg)
                memcpy(interface->hwaddr, ifaddr, sizeof(interface->hwaddr));
                strncpy(interface->name, ifname, sizeof(interface->name) - 1);
                add_interface(network, interface);
-
-               /* tell the sysinfo code about this interface */
-               if (strcmp(interface->name, "lo"))
-                       system_info_register_interface(
-                                       sizeof(interface->hwaddr),
-                                       interface->hwaddr, interface->name);
        }
 
+       /* notify the sysinfo code about changes to this interface */
+       if (strcmp(interface->name, "lo"))
+               system_info_register_interface(
+                               sizeof(interface->hwaddr),
+                               interface->hwaddr, interface->name,
+                               info->ifi_flags & IFF_LOWER_UP);
+
        configure_interface(network, interface,
                        info->ifi_flags & IFF_UP,
                        info->ifi_flags & IFF_LOWER_UP);
@@ -581,8 +582,13 @@ int network_shutdown(struct network *network)
        if (network->waiter)
                waiter_remove(network->waiter);
 
-       list_for_each_entry(&network->interfaces, interface, list)
+       list_for_each_entry(&network->interfaces, interface, list) {
+               if (interface->state == IFSTATE_IGNORED)
+                       continue;
+               if (!strcmp(interface->name, "lo"))
+                       continue;
                interface_down(interface);
+       }
 
        close(network->netlink_sd);
        talloc_free(network);