In Bug 78, shortkey points out:
[oweals/busybox.git] / networking / ifupdown.c
index 95d78ea469445735f1bb29fe36935776598cf40d..1842be58bcac02c1a7233601796472dda49ec0ef 100644 (file)
@@ -551,21 +551,15 @@ static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
        return(0);
 }
 
-static int bootp_down(struct interface_defn_t *ifd, execfn *exec)
-{
-#ifdef CONFIG_FEATURE_IFUPDOWN_IP
-       return(execute("ip link set %iface% down", ifd, exec));
-#else
-       return(execute("ifconfig %iface% down", ifd, exec));
-#endif
-}
-
 static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
 {
        int result = 0;
        if (execable("/sbin/udhcpc")) {
-               execute("kill -USR2 `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
-               execute("kill -9 `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
+               /* SIGUSR2 forces udhcpc to release the current lease and go inactive,
+                * and SIGTERM causes udhcpc to exit.  Signals are queued and processed
+                * sequentially so we don't need to sleep */
+               result = execute("kill -USR2 `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
+               result += execute("kill -TERM `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
        } else if (execable("/sbin/pump")) {
                result = execute("pump -i %iface% -k", ifd, exec);
        } else if (execable("/sbin/dhclient")) {
@@ -573,8 +567,7 @@ static int dhcp_down(struct interface_defn_t *ifd, execfn *exec)
        } else if (execable("/sbin/dhcpcd")) {
                result = execute("dhcpcd -k %iface%", ifd, exec);
        }
-       static_down(ifd, exec);
-       return (result || bootp_down(ifd, exec));
+       return (result || static_down(ifd, exec));
 }
 
 static int bootp_up(struct interface_defn_t *ifd, execfn *exec)
@@ -611,7 +604,7 @@ static struct method_t methods[] =
        { "wvdial", wvdial_up, wvdial_down, },
        { "ppp", ppp_up, ppp_down, },
        { "static", static_up, static_down, },
-       { "bootp", bootp_up, bootp_down, },
+       { "bootp", bootp_up, static_down, },
        { "dhcp", dhcp_up, dhcp_down, },
        { "loopback", loopback_up, loopback_down, },
 };
@@ -706,7 +699,7 @@ static const llist_t *find_list_string(const llist_t *list, const char *string)
        return(NULL);
 }
 
-static struct interfaces_file_t *read_interfaces(char *filename)
+static struct interfaces_file_t *read_interfaces(const char *filename)
 {
 #ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING
        struct mapping_defn_t *currmap = NULL;
@@ -1199,7 +1192,7 @@ extern int ifupdown_main(int argc, char **argv)
        FILE *state_fp = NULL;
        llist_t *state_list = NULL;
        llist_t *target_list = NULL;
-       char *interfaces = "/etc/network/interfaces";
+       const char *interfaces = "/etc/network/interfaces";
        const char *statefile = "/var/run/ifstate";
 
 #ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING
@@ -1226,7 +1219,7 @@ extern int ifupdown_main(int argc, char **argv)
                {
                        switch (i) {
                                case 'i':       /* interfaces */
-                                       interfaces = bb_xstrdup(optarg);
+                                       interfaces = optarg;
                                        break;
                                case 'v':       /* verbose */
                                        verbose = 1;