From ba4408a365b95ebc1df2719eff3b2b3415331118 Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Fri, 27 Apr 2012 02:06:28 +0200 Subject: [PATCH] busybox: fix segfault in mount, use individual patches from upstream --- .../0001-ifupdown-backport-from-master.patch | 205 ------------------ ...pdown-support-post-up-pre-down-hooks.patch | 60 +++++ .../0002-ifupdown-code-shrink.patch | 122 +++++++++++ ...interface-from-state_list-if-iface_u.patch | 31 +++ ...support-metric-for-static-default-gw.patch | 64 ++++++ ...wn-improve-compatibility-with-Debian.patch | 97 +++++++++ ...x_version_code-don-t-fail-on-3.0-foo.patch | 43 ++++ .../busybox/busybox_1.19.4.bbappend | 9 +- 8 files changed, 424 insertions(+), 207 deletions(-) delete mode 100644 meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0001-ifupdown-backport-from-master.patch create mode 100644 meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0001-ifupdown-support-post-up-pre-down-hooks.patch create mode 100644 meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0002-ifupdown-code-shrink.patch create mode 100644 meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0003-ifupdown-remove-interface-from-state_list-if-iface_u.patch create mode 100644 meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0004-ifupdown-support-metric-for-static-default-gw.patch create mode 100644 meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0005-ifupdown-improve-compatibility-with-Debian.patch create mode 100644 meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0006-get_linux_version_code-don-t-fail-on-3.0-foo.patch diff --git a/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0001-ifupdown-backport-from-master.patch b/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0001-ifupdown-backport-from-master.patch deleted file mode 100644 index 99db79cc..00000000 --- a/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0001-ifupdown-backport-from-master.patch +++ /dev/null @@ -1,205 +0,0 @@ -From 56871fb364862abc3812394f66a462b680fe6e84 Mon Sep 17 00:00:00 2001 -From: Andreas Oberritter -Date: Thu, 12 Apr 2012 03:13:27 +0200 -Subject: [PATCH] ifupdown: backport from master - -Signed-off-by: Andreas Oberritter ---- - networking/ifupdown.c | 66 +++++++++++++++++++++++------------------------- - 1 files changed, 32 insertions(+), 34 deletions(-) - -diff --git a/networking/ifupdown.c b/networking/ifupdown.c -index 3820330..abfdf64 100644 ---- a/networking/ifupdown.c -+++ b/networking/ifupdown.c -@@ -87,7 +87,6 @@ struct mapping_defn_t { - - char *script; - -- int max_mappings; - int n_mappings; - char **mapping; - }; -@@ -102,7 +101,6 @@ struct interface_defn_t { - const struct method_t *method; - - char *iface; -- int max_options; - int n_options; - struct variable_t *option; - }; -@@ -138,6 +136,14 @@ struct globals { - #define INIT_G() do { } while (0) - - -+static const char keywords_up_down[] ALIGN1 = -+ "up\0" -+ "down\0" -+ "pre-up\0" -+ "post-down\0" -+; -+ -+ - #if ENABLE_FEATURE_IFUPDOWN_IPV4 || ENABLE_FEATURE_IFUPDOWN_IPV6 - - static void addstr(char **bufp, const char *str, size_t str_length) -@@ -395,11 +401,11 @@ static int FAST_FUNC static_up6(struct interface_defn_t *ifd, execfn *exec) - result = execute("ip addr add %address%/%netmask% dev %iface%[[ label %label%]]", ifd, exec); - result += execute("ip link set[[ mtu %mtu%]][[ addr %hwaddress%]] %iface% up", ifd, exec); - /* Was: "[[ ip ....%gateway% ]]". Removed extra spaces w/o checking */ -- result += execute("[[ip route add ::/0 via %gateway%]]", ifd, exec); -+ result += execute("[[ip route add ::/0 via %gateway%]][[ prio %metric%]]", ifd, exec); - # else - result = execute("ifconfig %iface%[[ media %media%]][[ hw %hwaddress%]][[ mtu %mtu%]] up", ifd, exec); - result += execute("ifconfig %iface% add %address%/%netmask%", ifd, exec); -- result += execute("[[route -A inet6 add ::/0 gw %gateway%]]", ifd, exec); -+ result += execute("[[route -A inet6 add ::/0 gw %gateway%[[ metric %metric%]]]]", ifd, exec); - # endif - return ((result == 3) ? 3 : 0); - } -@@ -482,7 +488,7 @@ static int FAST_FUNC static_up(struct interface_defn_t *ifd, execfn *exec) - result = execute("ip addr add %address%/%bnmask%[[ broadcast %broadcast%]] " - "dev %iface%[[ peer %pointopoint%]][[ label %label%]]", ifd, exec); - result += execute("ip link set[[ mtu %mtu%]][[ addr %hwaddress%]] %iface% up", ifd, exec); -- result += execute("[[ip route add default via %gateway% dev %iface%]]", ifd, exec); -+ result += execute("[[ip route add default via %gateway% dev %iface%[[ prio %metric%]]]]", ifd, exec); - return ((result == 3) ? 3 : 0); - # else - /* ifconfig said to set iface up before it processes hw %hwaddress%, -@@ -492,7 +498,7 @@ static int FAST_FUNC static_up(struct interface_defn_t *ifd, execfn *exec) - result += execute("ifconfig %iface% %address% netmask %netmask%" - "[[ broadcast %broadcast%]][[ pointopoint %pointopoint%]] ", - ifd, exec); -- result += execute("[[route add default gw %gateway% %iface%]]", ifd, exec); -+ result += execute("[[route add default gw %gateway%[[ metric %metric%]] %iface%]]", ifd, exec); - return ((result == 3) ? 3 : 0); - # endif - } -@@ -803,7 +809,6 @@ static struct interfaces_file_t *read_interfaces(const char *filename) - currmap->match = xrealloc_vector(currmap->match, 4, currmap->n_matches); - currmap->match[currmap->n_matches++] = xstrdup(first_word); - } -- /*currmap->max_mappings = 0; - done by xzalloc */ - /*currmap->n_mappings = 0;*/ - /*currmap->mapping = NULL;*/ - /*currmap->script = NULL;*/ -@@ -888,23 +893,21 @@ static struct interfaces_file_t *read_interfaces(const char *filename) - if (rest_of_line[0] == '\0') - bb_error_msg_and_die("option with empty value \"%s\"", buf); - -- if (strcmp(first_word, "up") != 0 -- && strcmp(first_word, "down") != 0 -- && strcmp(first_word, "pre-up") != 0 -- && strcmp(first_word, "post-down") != 0 -- ) { -+ if (strcmp(first_word, "post-up") == 0) -+ strcpy(first_word, "up"); -+ else if (strcmp(first_word, "pre-down") == 0) -+ strcpy(first_word, "down"); -+ -+ /* If not one of "up", "down",... words... */ -+ if (index_in_strings(keywords_up_down, first_word) < 0) { - int i; - for (i = 0; i < currif->n_options; i++) { - if (strcmp(currif->option[i].name, first_word) == 0) - bb_error_msg_and_die("duplicate option \"%s\"", buf); - } - } -- if (currif->n_options >= currif->max_options) { -- currif->max_options += 10; -- currif->option = xrealloc(currif->option, -- sizeof(*currif->option) * currif->max_options); -- } - debug_noise("\t%s=%s\n", first_word, rest_of_line); -+ currif->option = xrealloc_vector(currif->option, 4, currif->n_options); - currif->option[currif->n_options].name = xstrdup(first_word); - currif->option[currif->n_options].value = xstrdup(rest_of_line); - currif->n_options++; -@@ -916,11 +919,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename) - bb_error_msg_and_die("duplicate script in mapping \"%s\"", buf); - currmap->script = xstrdup(next_word(&rest_of_line)); - } else if (strcmp(first_word, "map") == 0) { -- if (currmap->n_mappings >= currmap->max_mappings) { -- currmap->max_mappings = currmap->max_mappings * 2 + 1; -- currmap->mapping = xrealloc(currmap->mapping, -- sizeof(char *) * currmap->max_mappings); -- } -+ currmap->mapping = xrealloc_vector(currmap->mapping, 2, currmap->n_mappings); - currmap->mapping[currmap->n_mappings] = xstrdup(next_word(&rest_of_line)); - currmap->n_mappings++; - } else { -@@ -967,7 +966,7 @@ static char *setlocalenv(const char *format, const char *name, const char *value - return result; - } - --static void set_environ(struct interface_defn_t *iface, const char *mode) -+static void set_environ(struct interface_defn_t *iface, const char *mode, const char *opt) - { - int i; - char **pp; -@@ -980,15 +979,11 @@ static void set_environ(struct interface_defn_t *iface, const char *mode) - } - - /* note: last element will stay NULL: */ -- G.my_environ = xzalloc(sizeof(char *) * (iface->n_options + 6)); -+ G.my_environ = xzalloc(sizeof(char *) * (iface->n_options + 7)); - pp = G.my_environ; - - for (i = 0; i < iface->n_options; i++) { -- if (strcmp(iface->option[i].name, "up") == 0 -- || strcmp(iface->option[i].name, "down") == 0 -- || strcmp(iface->option[i].name, "pre-up") == 0 -- || strcmp(iface->option[i].name, "post-down") == 0 -- ) { -+ if (index_in_strings(keywords_up_down, iface->option[i].name) >= 0) { - continue; - } - *pp++ = setlocalenv("IF_%s=%s", iface->option[i].name, iface->option[i].value); -@@ -998,6 +993,7 @@ static void set_environ(struct interface_defn_t *iface, const char *mode) - *pp++ = setlocalenv("%s=%s", "ADDRFAM", iface->address_family->name); - *pp++ = setlocalenv("%s=%s", "METHOD", iface->method->name); - *pp++ = setlocalenv("%s=%s", "MODE", mode); -+ *pp++ = setlocalenv("%s=%s", "PHASE", opt); - if (G.startup_PATH) - *pp++ = setlocalenv("%s=%s", "PATH", G.startup_PATH); - } -@@ -1052,9 +1048,10 @@ static int check(char *str) - static int iface_up(struct interface_defn_t *iface) - { - if (!iface->method->up(iface, check)) return -1; -- set_environ(iface, "start"); -+ set_environ(iface, "start", "pre-up"); - if (!execute_all(iface, "pre-up")) return 0; - if (!iface->method->up(iface, doit)) return 0; -+ set_environ(iface, "start", "post-up"); - if (!execute_all(iface, "up")) return 0; - return 1; - } -@@ -1062,9 +1059,10 @@ static int iface_up(struct interface_defn_t *iface) - static int iface_down(struct interface_defn_t *iface) - { - if (!iface->method->down(iface,check)) return -1; -- set_environ(iface, "stop"); -+ set_environ(iface, "stop", "pre-down"); - if (!execute_all(iface, "down")) return 0; - if (!iface->method->down(iface, doit)) return 0; -+ set_environ(iface, "stop", "post-down"); - if (!execute_all(iface, "post-down")) return 0; - return 1; - } -@@ -1317,9 +1315,9 @@ int ifupdown_main(int argc UNUSED_PARAM, char **argv) - llist_t *state_list = read_iface_state(); - llist_t *iface_state = find_iface_state(state_list, iface); - -- if (cmds == iface_up) { -- char * const newiface = xasprintf("%s=%s", iface, liface); -- if (iface_state == NULL) { -+ if (cmds == iface_up && !any_failures) { -+ char *newiface = xasprintf("%s=%s", iface, liface); -+ if (!iface_state) { - llist_add_to_end(&state_list, newiface); - } else { - free(iface_state->data); --- -1.7.5.4 - diff --git a/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0001-ifupdown-support-post-up-pre-down-hooks.patch b/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0001-ifupdown-support-post-up-pre-down-hooks.patch new file mode 100644 index 00000000..f62fe058 --- /dev/null +++ b/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0001-ifupdown-support-post-up-pre-down-hooks.patch @@ -0,0 +1,60 @@ +From b58a1a06ca695aed6a4f6e5039e2de0e5a3df111 Mon Sep 17 00:00:00 2001 +From: Peter Korsgaard +Date: Wed, 19 Oct 2011 02:35:54 +0200 +Subject: [PATCH 1/6] ifupdown: support post-up / pre-down hooks + +function old new delta +set_environ 330 371 +41 +ifupdown_main 2156 2194 +38 +iface_up 97 113 +16 +iface_down 97 113 +16 +------------------------------------------------------------------------------ +(add/remove: 0/0 grow/shrink: 4/0 up/down: 111/0) Total: 111 bytes + +Signed-off-by: Peter Korsgaard +Signed-off-by: Denys Vlasenko +--- + networking/ifupdown.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/networking/ifupdown.c b/networking/ifupdown.c +index 3820330..abc6b58 100644 +--- a/networking/ifupdown.c ++++ b/networking/ifupdown.c +@@ -891,6 +891,8 @@ static struct interfaces_file_t *read_interfaces(const char *filename) + if (strcmp(first_word, "up") != 0 + && strcmp(first_word, "down") != 0 + && strcmp(first_word, "pre-up") != 0 ++ && strcmp(first_word, "pre-down") != 0 ++ && strcmp(first_word, "post-up") != 0 + && strcmp(first_word, "post-down") != 0 + ) { + int i; +@@ -987,6 +989,8 @@ static void set_environ(struct interface_defn_t *iface, const char *mode) + if (strcmp(iface->option[i].name, "up") == 0 + || strcmp(iface->option[i].name, "down") == 0 + || strcmp(iface->option[i].name, "pre-up") == 0 ++ || strcmp(iface->option[i].name, "pre-down") == 0 ++ || strcmp(iface->option[i].name, "post-up") == 0 + || strcmp(iface->option[i].name, "post-down") == 0 + ) { + continue; +@@ -1056,6 +1060,7 @@ static int iface_up(struct interface_defn_t *iface) + if (!execute_all(iface, "pre-up")) return 0; + if (!iface->method->up(iface, doit)) return 0; + if (!execute_all(iface, "up")) return 0; ++ if (!execute_all(iface, "post-up")) return 0; + return 1; + } + +@@ -1063,6 +1068,7 @@ static int iface_down(struct interface_defn_t *iface) + { + if (!iface->method->down(iface,check)) return -1; + set_environ(iface, "stop"); ++ if (!execute_all(iface, "pre-down")) return 0; + if (!execute_all(iface, "down")) return 0; + if (!iface->method->down(iface, doit)) return 0; + if (!execute_all(iface, "post-down")) return 0; +-- +1.7.9.5 + diff --git a/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0002-ifupdown-code-shrink.patch b/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0002-ifupdown-code-shrink.patch new file mode 100644 index 00000000..d0ca6557 --- /dev/null +++ b/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0002-ifupdown-code-shrink.patch @@ -0,0 +1,122 @@ +From e5221a142e8ee4509734c17584f898a1f4ac86cc Mon Sep 17 00:00:00 2001 +From: Denys Vlasenko +Date: Wed, 19 Oct 2011 02:37:08 +0200 +Subject: [PATCH 2/6] ifupdown: code shrink + +function old new delta +keywords_up_down - 43 +43 +set_environ 371 259 -112 +ifupdown_main 2194 2073 -121 +------------------------------------------------------------------------------ +(add/remove: 1/0 grow/shrink: 0/2 up/down: 43/-233) Total: -190 bytes + +Signed-off-by: Denys Vlasenko +--- + networking/ifupdown.c | 42 +++++++++++++++--------------------------- + 1 file changed, 15 insertions(+), 27 deletions(-) + +diff --git a/networking/ifupdown.c b/networking/ifupdown.c +index abc6b58..5946323 100644 +--- a/networking/ifupdown.c ++++ b/networking/ifupdown.c +@@ -87,7 +87,6 @@ struct mapping_defn_t { + + char *script; + +- int max_mappings; + int n_mappings; + char **mapping; + }; +@@ -102,7 +101,6 @@ struct interface_defn_t { + const struct method_t *method; + + char *iface; +- int max_options; + int n_options; + struct variable_t *option; + }; +@@ -138,6 +136,16 @@ struct globals { + #define INIT_G() do { } while (0) + + ++static const char keywords_up_down[] ALIGN1 = ++ "up\0" ++ "down\0" ++ "pre-up\0" ++ "pre-down\0" ++ "post-up\0" ++ "post-down\0" ++; ++ ++ + #if ENABLE_FEATURE_IFUPDOWN_IPV4 || ENABLE_FEATURE_IFUPDOWN_IPV6 + + static void addstr(char **bufp, const char *str, size_t str_length) +@@ -803,7 +811,6 @@ static struct interfaces_file_t *read_interfaces(const char *filename) + currmap->match = xrealloc_vector(currmap->match, 4, currmap->n_matches); + currmap->match[currmap->n_matches++] = xstrdup(first_word); + } +- /*currmap->max_mappings = 0; - done by xzalloc */ + /*currmap->n_mappings = 0;*/ + /*currmap->mapping = NULL;*/ + /*currmap->script = NULL;*/ +@@ -888,25 +895,16 @@ static struct interfaces_file_t *read_interfaces(const char *filename) + if (rest_of_line[0] == '\0') + bb_error_msg_and_die("option with empty value \"%s\"", buf); + +- if (strcmp(first_word, "up") != 0 +- && strcmp(first_word, "down") != 0 +- && strcmp(first_word, "pre-up") != 0 +- && strcmp(first_word, "pre-down") != 0 +- && strcmp(first_word, "post-up") != 0 +- && strcmp(first_word, "post-down") != 0 +- ) { ++ /* If not one of "up", "down",... words... */ ++ if (index_in_strings(keywords_up_down, first_word) < 0) { + int i; + for (i = 0; i < currif->n_options; i++) { + if (strcmp(currif->option[i].name, first_word) == 0) + bb_error_msg_and_die("duplicate option \"%s\"", buf); + } + } +- if (currif->n_options >= currif->max_options) { +- currif->max_options += 10; +- currif->option = xrealloc(currif->option, +- sizeof(*currif->option) * currif->max_options); +- } + debug_noise("\t%s=%s\n", first_word, rest_of_line); ++ currif->option = xrealloc_vector(currif->option, 4, currif->n_options); + currif->option[currif->n_options].name = xstrdup(first_word); + currif->option[currif->n_options].value = xstrdup(rest_of_line); + currif->n_options++; +@@ -918,11 +916,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename) + bb_error_msg_and_die("duplicate script in mapping \"%s\"", buf); + currmap->script = xstrdup(next_word(&rest_of_line)); + } else if (strcmp(first_word, "map") == 0) { +- if (currmap->n_mappings >= currmap->max_mappings) { +- currmap->max_mappings = currmap->max_mappings * 2 + 1; +- currmap->mapping = xrealloc(currmap->mapping, +- sizeof(char *) * currmap->max_mappings); +- } ++ currmap->mapping = xrealloc_vector(currmap->mapping, 2, currmap->n_mappings); + currmap->mapping[currmap->n_mappings] = xstrdup(next_word(&rest_of_line)); + currmap->n_mappings++; + } else { +@@ -986,13 +980,7 @@ static void set_environ(struct interface_defn_t *iface, const char *mode) + pp = G.my_environ; + + for (i = 0; i < iface->n_options; i++) { +- if (strcmp(iface->option[i].name, "up") == 0 +- || strcmp(iface->option[i].name, "down") == 0 +- || strcmp(iface->option[i].name, "pre-up") == 0 +- || strcmp(iface->option[i].name, "pre-down") == 0 +- || strcmp(iface->option[i].name, "post-up") == 0 +- || strcmp(iface->option[i].name, "post-down") == 0 +- ) { ++ if (index_in_strings(keywords_up_down, iface->option[i].name) >= 0) { + continue; + } + *pp++ = setlocalenv("IF_%s=%s", iface->option[i].name, iface->option[i].value); +-- +1.7.9.5 + diff --git a/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0003-ifupdown-remove-interface-from-state_list-if-iface_u.patch b/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0003-ifupdown-remove-interface-from-state_list-if-iface_u.patch new file mode 100644 index 00000000..e53d78a1 --- /dev/null +++ b/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0003-ifupdown-remove-interface-from-state_list-if-iface_u.patch @@ -0,0 +1,31 @@ +From a7b406ba64b7a4d9c9610726cb72568fc9848f5d Mon Sep 17 00:00:00 2001 +From: Lauri Hintsala +Date: Wed, 14 Dec 2011 16:49:58 +0200 +Subject: [PATCH 3/6] ifupdown: remove interface from state_list if iface_up + fails + +Fix the issue where interface is set to the configured state even if +configuration has failed. Add error check to state setting logic. + +Signed-off-by: Lauri Hintsala +Signed-off-by: Denys Vlasenko +--- + networking/ifupdown.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/networking/ifupdown.c b/networking/ifupdown.c +index 5946323..9c2cad2 100644 +--- a/networking/ifupdown.c ++++ b/networking/ifupdown.c +@@ -1311,7 +1311,7 @@ int ifupdown_main(int argc UNUSED_PARAM, char **argv) + llist_t *state_list = read_iface_state(); + llist_t *iface_state = find_iface_state(state_list, iface); + +- if (cmds == iface_up) { ++ if (cmds == iface_up && !any_failures) { + char * const newiface = xasprintf("%s=%s", iface, liface); + if (iface_state == NULL) { + llist_add_to_end(&state_list, newiface); +-- +1.7.9.5 + diff --git a/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0004-ifupdown-support-metric-for-static-default-gw.patch b/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0004-ifupdown-support-metric-for-static-default-gw.patch new file mode 100644 index 00000000..3e77a1c8 --- /dev/null +++ b/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0004-ifupdown-support-metric-for-static-default-gw.patch @@ -0,0 +1,64 @@ +From fecb0cbff5ca703f8fc00a8e0e93f1f2e3ae942b Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Fri, 17 Feb 2012 19:36:26 +0000 +Subject: [PATCH 4/6] ifupdown: support metric for static default gw + +This is useful when you have multiple ISPs with failover. It allows +setting the priority of the static gateway and makes it possible +to specify multiple static gateways. + +The ubuntu ifupdown supports it. + +function old new delta +.rodata 116725 116797 +72 +------------------------------------------------------------------------------ +(add/remove: 0/0 grow/shrink: 1/0 up/down: 72/0) Total: 72 bytes + text data bss dec hex filename + 953343 7313 8984 969640 ecba8 busybox_old + 953415 7313 8984 969712 ecbf0 busybox_unstripped + +Signed-off-by: Natanael Copa +Signed-off-by: Denys Vlasenko +--- + networking/ifupdown.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/networking/ifupdown.c b/networking/ifupdown.c +index 9c2cad2..9f49619 100644 +--- a/networking/ifupdown.c ++++ b/networking/ifupdown.c +@@ -403,11 +403,11 @@ static int FAST_FUNC static_up6(struct interface_defn_t *ifd, execfn *exec) + result = execute("ip addr add %address%/%netmask% dev %iface%[[ label %label%]]", ifd, exec); + result += execute("ip link set[[ mtu %mtu%]][[ addr %hwaddress%]] %iface% up", ifd, exec); + /* Was: "[[ ip ....%gateway% ]]". Removed extra spaces w/o checking */ +- result += execute("[[ip route add ::/0 via %gateway%]]", ifd, exec); ++ result += execute("[[ip route add ::/0 via %gateway%]][[ prio %metric%]]", ifd, exec); + # else + result = execute("ifconfig %iface%[[ media %media%]][[ hw %hwaddress%]][[ mtu %mtu%]] up", ifd, exec); + result += execute("ifconfig %iface% add %address%/%netmask%", ifd, exec); +- result += execute("[[route -A inet6 add ::/0 gw %gateway%]]", ifd, exec); ++ result += execute("[[route -A inet6 add ::/0 gw %gateway%[[ metric %metric%]]]]", ifd, exec); + # endif + return ((result == 3) ? 3 : 0); + } +@@ -490,7 +490,7 @@ static int FAST_FUNC static_up(struct interface_defn_t *ifd, execfn *exec) + result = execute("ip addr add %address%/%bnmask%[[ broadcast %broadcast%]] " + "dev %iface%[[ peer %pointopoint%]][[ label %label%]]", ifd, exec); + result += execute("ip link set[[ mtu %mtu%]][[ addr %hwaddress%]] %iface% up", ifd, exec); +- result += execute("[[ip route add default via %gateway% dev %iface%]]", ifd, exec); ++ result += execute("[[ip route add default via %gateway% dev %iface%[[ prio %metric%]]]]", ifd, exec); + return ((result == 3) ? 3 : 0); + # else + /* ifconfig said to set iface up before it processes hw %hwaddress%, +@@ -500,7 +500,7 @@ static int FAST_FUNC static_up(struct interface_defn_t *ifd, execfn *exec) + result += execute("ifconfig %iface% %address% netmask %netmask%" + "[[ broadcast %broadcast%]][[ pointopoint %pointopoint%]] ", + ifd, exec); +- result += execute("[[route add default gw %gateway% %iface%]]", ifd, exec); ++ result += execute("[[route add default gw %gateway%[[ metric %metric%]] %iface%]]", ifd, exec); + return ((result == 3) ? 3 : 0); + # endif + } +-- +1.7.9.5 + diff --git a/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0005-ifupdown-improve-compatibility-with-Debian.patch b/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0005-ifupdown-improve-compatibility-with-Debian.patch new file mode 100644 index 00000000..84e1947e --- /dev/null +++ b/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0005-ifupdown-improve-compatibility-with-Debian.patch @@ -0,0 +1,97 @@ +From 7ec30bf273cbdf5f0ae335684939a883182e493e Mon Sep 17 00:00:00 2001 +From: Andreas Oberritter +Date: Mon, 23 Apr 2012 22:08:39 +0200 +Subject: [PATCH 5/6] ifupdown: improve compatibility with Debian + +Set environment variable 'PHASE'. +Treat post-up and pre-down as aliases for up and down. +Uses the same logic as ifupdown.nw from ifupdown-0.6.16. +Makes it possible to execute Debian's ifupdown script for +wpa-supplicant. + +Signed-off-by: Andreas Oberritter +Signed-off-by: Denys Vlasenko +--- + networking/ifupdown.c | 20 ++++++++++++-------- + 1 file changed, 12 insertions(+), 8 deletions(-) + +diff --git a/networking/ifupdown.c b/networking/ifupdown.c +index 9f49619..5c3dcec 100644 +--- a/networking/ifupdown.c ++++ b/networking/ifupdown.c +@@ -140,8 +140,6 @@ static const char keywords_up_down[] ALIGN1 = + "up\0" + "down\0" + "pre-up\0" +- "pre-down\0" +- "post-up\0" + "post-down\0" + ; + +@@ -895,6 +893,11 @@ static struct interfaces_file_t *read_interfaces(const char *filename) + if (rest_of_line[0] == '\0') + bb_error_msg_and_die("option with empty value \"%s\"", buf); + ++ if (strcmp(first_word, "post-up") == 0) ++ first_word += 5; /* "up" */ ++ else if (strcmp(first_word, "pre-down") == 0) ++ first_word += 4; /* "down" */ ++ + /* If not one of "up", "down",... words... */ + if (index_in_strings(keywords_up_down, first_word) < 0) { + int i; +@@ -963,7 +966,7 @@ static char *setlocalenv(const char *format, const char *name, const char *value + return result; + } + +-static void set_environ(struct interface_defn_t *iface, const char *mode) ++static void set_environ(struct interface_defn_t *iface, const char *mode, const char *opt) + { + int i; + char **pp; +@@ -976,7 +979,7 @@ static void set_environ(struct interface_defn_t *iface, const char *mode) + } + + /* note: last element will stay NULL: */ +- G.my_environ = xzalloc(sizeof(char *) * (iface->n_options + 6)); ++ G.my_environ = xzalloc(sizeof(char *) * (iface->n_options + 7)); + pp = G.my_environ; + + for (i = 0; i < iface->n_options; i++) { +@@ -990,6 +993,7 @@ static void set_environ(struct interface_defn_t *iface, const char *mode) + *pp++ = setlocalenv("%s=%s", "ADDRFAM", iface->address_family->name); + *pp++ = setlocalenv("%s=%s", "METHOD", iface->method->name); + *pp++ = setlocalenv("%s=%s", "MODE", mode); ++ *pp++ = setlocalenv("%s=%s", "PHASE", opt); + if (G.startup_PATH) + *pp++ = setlocalenv("%s=%s", "PATH", G.startup_PATH); + } +@@ -1044,21 +1048,21 @@ static int check(char *str) + static int iface_up(struct interface_defn_t *iface) + { + if (!iface->method->up(iface, check)) return -1; +- set_environ(iface, "start"); ++ set_environ(iface, "start", "pre-up"); + if (!execute_all(iface, "pre-up")) return 0; + if (!iface->method->up(iface, doit)) return 0; ++ set_environ(iface, "start", "post-up"); + if (!execute_all(iface, "up")) return 0; +- if (!execute_all(iface, "post-up")) return 0; + return 1; + } + + static int iface_down(struct interface_defn_t *iface) + { + if (!iface->method->down(iface,check)) return -1; +- set_environ(iface, "stop"); +- if (!execute_all(iface, "pre-down")) return 0; ++ set_environ(iface, "stop", "pre-down"); + if (!execute_all(iface, "down")) return 0; + if (!iface->method->down(iface, doit)) return 0; ++ set_environ(iface, "stop", "post-down"); + if (!execute_all(iface, "post-down")) return 0; + return 1; + } +-- +1.7.9.5 + diff --git a/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0006-get_linux_version_code-don-t-fail-on-3.0-foo.patch b/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0006-get_linux_version_code-don-t-fail-on-3.0-foo.patch new file mode 100644 index 00000000..41c31b8e --- /dev/null +++ b/meta-opendreambox/recipes-core/busybox/busybox-1.19.4/0006-get_linux_version_code-don-t-fail-on-3.0-foo.patch @@ -0,0 +1,43 @@ +From c011ab2fb52c2ee03aa9544b0d242683ee4362e1 Mon Sep 17 00:00:00 2001 +From: Andreas Oberritter +Date: Fri, 27 Apr 2012 01:40:25 +0200 +Subject: [PATCH 6/6] get_linux_version_code: don't fail on 3.0-foo + +Fixes segmentation fault in mount (nfs): + + #0 __GI_____strtol_l_internal (nptr=0x0, endptr=0x0, base=10, group=, loc=0x77f6f3c8) at strtol_l.c:298 + #1 __GI_strtol (nptr=, endptr=, base=) at strtol.c:110 + #2 get_linux_version_code () at libbb/kernel_version.c:34 + #3 find_kernel_nfs_mount_version () at util-linux/mount.c:979 + +Signed-off-by: Andreas Oberritter +--- + libbb/kernel_version.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/libbb/kernel_version.c b/libbb/kernel_version.c +index a168a1e..12f1146 100644 +--- a/libbb/kernel_version.c ++++ b/libbb/kernel_version.c +@@ -20,7 +20,7 @@ + int FAST_FUNC get_linux_version_code(void) + { + struct utsname name; +- char *s; ++ char *s, *t; + int i, r; + + if (uname(&name) == -1) { +@@ -31,7 +31,8 @@ int FAST_FUNC get_linux_version_code(void) + s = name.release; + r = 0; + for (i = 0; i < 3; i++) { +- r = r * 256 + atoi(strtok(s, ".")); ++ t = strtok(s, "."); ++ r = r * 256 + (t ? atoi(t) : 0); + s = NULL; + } + return r; +-- +1.7.9.5 + diff --git a/meta-opendreambox/recipes-core/busybox/busybox_1.19.4.bbappend b/meta-opendreambox/recipes-core/busybox/busybox_1.19.4.bbappend index 1ef18120..58200404 100644 --- a/meta-opendreambox/recipes-core/busybox/busybox_1.19.4.bbappend +++ b/meta-opendreambox/recipes-core/busybox/busybox_1.19.4.bbappend @@ -1,7 +1,12 @@ -PR .= "-dream6" +PR .= "-dream7" SRC_URI += "file://telnetd.xinetd.in \ - file://0001-ifupdown-backport-from-master.patch" + file://0001-ifupdown-support-post-up-pre-down-hooks.patch \ + file://0002-ifupdown-code-shrink.patch \ + file://0003-ifupdown-remove-interface-from-state_list-if-iface_u.patch \ + file://0004-ifupdown-support-metric-for-static-default-gw.patch \ + file://0005-ifupdown-improve-compatibility-with-Debian.patch \ + file://0006-get_linux_version_code-don-t-fail-on-3.0-foo.patch" inherit xinetd -- 2.20.1