1 --- busybox-1.20.1/networking/ifupdown.c
2 +++ busybox-1.20.1-ifupdown/networking/ifupdown.c
3 @@ -140,8 +140,6 @@ static const char keywords_up_down[] ALI
12 @@ -895,6 +893,11 @@ static struct interfaces_file_t *read_in
13 if (rest_of_line[0] == '\0')
14 bb_error_msg_and_die("option with empty value \"%s\"", buf);
16 + if (strcmp(first_word, "post-up") == 0)
17 + first_word += 5; /* "up" */
18 + else if (strcmp(first_word, "pre-down") == 0)
19 + first_word += 4; /* "down" */
21 /* If not one of "up", "down",... words... */
22 if (index_in_strings(keywords_up_down, first_word) < 0) {
24 @@ -963,7 +966,7 @@ static char *setlocalenv(const char *for
28 -static void set_environ(struct interface_defn_t *iface, const char *mode)
29 +static void set_environ(struct interface_defn_t *iface, const char *mode, const char *opt)
33 @@ -976,7 +979,7 @@ static void set_environ(struct interface
36 /* note: last element will stay NULL: */
37 - G.my_environ = xzalloc(sizeof(char *) * (iface->n_options + 6));
38 + G.my_environ = xzalloc(sizeof(char *) * (iface->n_options + 7));
41 for (i = 0; i < iface->n_options; i++) {
42 @@ -990,6 +993,7 @@ static void set_environ(struct interface
43 *pp++ = setlocalenv("%s=%s", "ADDRFAM", iface->address_family->name);
44 *pp++ = setlocalenv("%s=%s", "METHOD", iface->method->name);
45 *pp++ = setlocalenv("%s=%s", "MODE", mode);
46 + *pp++ = setlocalenv("%s=%s", "PHASE", opt);
48 *pp++ = setlocalenv("%s=%s", "PATH", G.startup_PATH);
50 @@ -1044,21 +1048,21 @@ static int check(char *str)
51 static int iface_up(struct interface_defn_t *iface)
53 if (!iface->method->up(iface, check)) return -1;
54 - set_environ(iface, "start");
55 + set_environ(iface, "start", "pre-up");
56 if (!execute_all(iface, "pre-up")) return 0;
57 if (!iface->method->up(iface, doit)) return 0;
58 + set_environ(iface, "start", "post-up");
59 if (!execute_all(iface, "up")) return 0;
60 - if (!execute_all(iface, "post-up")) return 0;
64 static int iface_down(struct interface_defn_t *iface)
66 if (!iface->method->down(iface,check)) return -1;
67 - set_environ(iface, "stop");
68 - if (!execute_all(iface, "pre-down")) return 0;
69 + set_environ(iface, "stop", "pre-down");
70 if (!execute_all(iface, "down")) return 0;
71 if (!iface->method->down(iface, doit)) return 0;
72 + set_environ(iface, "stop", "post-down");
73 if (!execute_all(iface, "post-down")) return 0;