aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
Diffstat (limited to 'networking')
-rw-r--r--networking/ifupdown.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index dfda20670..9b3498696 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -140,8 +140,6 @@ static const char keywords_up_down[] ALIGN1 =
140 "up\0" 140 "up\0"
141 "down\0" 141 "down\0"
142 "pre-up\0" 142 "pre-up\0"
143 "pre-down\0"
144 "post-up\0"
145 "post-down\0" 143 "post-down\0"
146; 144;
147 145
@@ -895,6 +893,11 @@ static struct interfaces_file_t *read_interfaces(const char *filename)
895 if (rest_of_line[0] == '\0') 893 if (rest_of_line[0] == '\0')
896 bb_error_msg_and_die("option with empty value \"%s\"", buf); 894 bb_error_msg_and_die("option with empty value \"%s\"", buf);
897 895
896 if (strcmp(first_word, "post-up") == 0)
897 first_word += 5; /* "up" */
898 else if (strcmp(first_word, "pre-down") == 0)
899 first_word += 4; /* "down" */
900
898 /* If not one of "up", "down",... words... */ 901 /* If not one of "up", "down",... words... */
899 if (index_in_strings(keywords_up_down, first_word) < 0) { 902 if (index_in_strings(keywords_up_down, first_word) < 0) {
900 int i; 903 int i;
@@ -963,7 +966,7 @@ static char *setlocalenv(const char *format, const char *name, const char *value
963 return result; 966 return result;
964} 967}
965 968
966static void set_environ(struct interface_defn_t *iface, const char *mode) 969static void set_environ(struct interface_defn_t *iface, const char *mode, const char *opt)
967{ 970{
968 int i; 971 int i;
969 char **pp; 972 char **pp;
@@ -976,7 +979,7 @@ static void set_environ(struct interface_defn_t *iface, const char *mode)
976 } 979 }
977 980
978 /* note: last element will stay NULL: */ 981 /* note: last element will stay NULL: */
979 G.my_environ = xzalloc(sizeof(char *) * (iface->n_options + 6)); 982 G.my_environ = xzalloc(sizeof(char *) * (iface->n_options + 7));
980 pp = G.my_environ; 983 pp = G.my_environ;
981 984
982 for (i = 0; i < iface->n_options; i++) { 985 for (i = 0; i < iface->n_options; i++) {
@@ -990,6 +993,7 @@ static void set_environ(struct interface_defn_t *iface, const char *mode)
990 *pp++ = setlocalenv("%s=%s", "ADDRFAM", iface->address_family->name); 993 *pp++ = setlocalenv("%s=%s", "ADDRFAM", iface->address_family->name);
991 *pp++ = setlocalenv("%s=%s", "METHOD", iface->method->name); 994 *pp++ = setlocalenv("%s=%s", "METHOD", iface->method->name);
992 *pp++ = setlocalenv("%s=%s", "MODE", mode); 995 *pp++ = setlocalenv("%s=%s", "MODE", mode);
996 *pp++ = setlocalenv("%s=%s", "PHASE", opt);
993 if (G.startup_PATH) 997 if (G.startup_PATH)
994 *pp++ = setlocalenv("%s=%s", "PATH", G.startup_PATH); 998 *pp++ = setlocalenv("%s=%s", "PATH", G.startup_PATH);
995} 999}
@@ -1044,21 +1048,21 @@ static int check(char *str)
1044static int iface_up(struct interface_defn_t *iface) 1048static int iface_up(struct interface_defn_t *iface)
1045{ 1049{
1046 if (!iface->method->up(iface, check)) return -1; 1050 if (!iface->method->up(iface, check)) return -1;
1047 set_environ(iface, "start"); 1051 set_environ(iface, "start", "pre-up");
1048 if (!execute_all(iface, "pre-up")) return 0; 1052 if (!execute_all(iface, "pre-up")) return 0;
1049 if (!iface->method->up(iface, doit)) return 0; 1053 if (!iface->method->up(iface, doit)) return 0;
1054 set_environ(iface, "start", "post-up");
1050 if (!execute_all(iface, "up")) return 0; 1055 if (!execute_all(iface, "up")) return 0;
1051 if (!execute_all(iface, "post-up")) return 0;
1052 return 1; 1056 return 1;
1053} 1057}
1054 1058
1055static int iface_down(struct interface_defn_t *iface) 1059static int iface_down(struct interface_defn_t *iface)
1056{ 1060{
1057 if (!iface->method->down(iface,check)) return -1; 1061 if (!iface->method->down(iface,check)) return -1;
1058 set_environ(iface, "stop"); 1062 set_environ(iface, "stop", "pre-down");
1059 if (!execute_all(iface, "pre-down")) return 0;
1060 if (!execute_all(iface, "down")) return 0; 1063 if (!execute_all(iface, "down")) return 0;
1061 if (!iface->method->down(iface, doit)) return 0; 1064 if (!iface->method->down(iface, doit)) return 0;
1065 set_environ(iface, "stop", "post-down");
1062 if (!execute_all(iface, "post-down")) return 0; 1066 if (!execute_all(iface, "post-down")) return 0;
1063 return 1; 1067 return 1;
1064} 1068}