]> git.ozlabs.org Git - petitboot/blobdiff - discover/network.c
discover: Support DHCP "pathprefix" configuration option
[petitboot] / discover / network.c
index d39f7a7c0ef57af83ae39b26e4bcb10acf4b26dd..2857076902cd4b23554b4bb405f74a923a2e0190 100644 (file)
@@ -69,7 +69,7 @@ static const struct interface_config *find_config_by_hwaddr(
                uint8_t *hwaddr)
 {
        const struct config *config;
-       int i;
+       unsigned int i;
 
        config = config_get();
        if (!config)
@@ -204,7 +204,7 @@ static int interface_down(struct interface *interface)
 static void udhcpc_process_exit(struct process *process)
 {
        struct interface *interface = process->data;
-       pb_log("udhcp client [pid %d] for interface %s exited, rc %d\n",
+       pb_debug("udhcp client [pid %d] for interface %s exited, rc %d\n",
                        process->pid, interface->name, process->exit_status);
        interface->udhcpc_process = NULL;
        process_release(process);
@@ -219,6 +219,8 @@ static void configure_interface_dhcp(struct interface *interface)
                pb_system_apps.udhcpc,
                "-R",
                "-n",
+               "-O", "pxeconffile",
+               "-O", "pxepathprefix",
                "-p", pidfile,
                "-i", interface->name,
                NULL,
@@ -369,6 +371,7 @@ static int network_handle_nlmsg(struct network *network, struct nlmsghdr *nlmsg)
        info = NLMSG_DATA(nlmsg);
 
        have_ifaddr = have_ifname = false;
+       mtu = 1;
 
        attrlen = nlmsg->nlmsg_len - sizeof(*info);
 
@@ -414,14 +417,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);
@@ -483,7 +487,8 @@ retry:
 static void network_init_dns(struct network *network)
 {
        const struct config *config;
-       int i, rc, len;
+       unsigned int i;
+       int rc, len;
        bool modified;
        char *buf;
 
@@ -544,8 +549,8 @@ struct network *network_init(struct device_handler *handler,
        network = talloc(handler, struct network);
        list_init(&network->interfaces);
        network->handler = handler;
-       network->manual_config = false;
        network->dry_run = dry_run;
+       network->manual_config = config_get()->network.n_interfaces != 0;
 
        network_init_dns(network);
 
@@ -578,8 +583,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);