diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2018-03-28 00:00:03 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-03-28 00:02:52 +0200 |
commit | 123fdda0a4a838e61c6a7d15c69d3b438136aee0 (patch) | |
tree | 8d050c4aa0586e2381f6f51adffb44913715416b | |
parent | 46ba2468a3de85076ce92ce8e8cc7a086bac69f0 (diff) | |
download | busybox-w32-123fdda0a4a838e61c6a7d15c69d3b438136aee0.tar.gz busybox-w32-123fdda0a4a838e61c6a7d15c69d3b438136aee0.tar.bz2 busybox-w32-123fdda0a4a838e61c6a7d15c69d3b438136aee0.zip |
ifupdown: do not fail if interface disappears during ifdown
Interface may not exist because it got deleted by an ifdown hook script
earlier. This may happen when a virtual interface, such as VLAN, has multiple
iface blocks defined.
function old new delta
static_down6 14 40 +26
static_down 54 70 +16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 42/0) Total: 42 bytes
Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/ifupdown.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 534c9f0c7..5481134e5 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -138,6 +138,7 @@ | |||
138 | //usage: "\n -v Print out what would happen before doing it" | 138 | //usage: "\n -v Print out what would happen before doing it" |
139 | //usage: "\n -f Force deconfiguration" | 139 | //usage: "\n -f Force deconfiguration" |
140 | 140 | ||
141 | #include <net/if.h> | ||
141 | #include "libbb.h" | 142 | #include "libbb.h" |
142 | #include "common_bufsiz.h" | 143 | #include "common_bufsiz.h" |
143 | /* After libbb.h, since it needs sys/types.h on some systems */ | 144 | /* After libbb.h, since it needs sys/types.h on some systems */ |
@@ -503,6 +504,8 @@ static int FAST_FUNC static_up6(struct interface_defn_t *ifd, execfn *exec) | |||
503 | 504 | ||
504 | static int FAST_FUNC static_down6(struct interface_defn_t *ifd, execfn *exec) | 505 | static int FAST_FUNC static_down6(struct interface_defn_t *ifd, execfn *exec) |
505 | { | 506 | { |
507 | if (!if_nametoindex(ifd->iface)) | ||
508 | return 1; /* already gone */ | ||
506 | # if ENABLE_FEATURE_IFUPDOWN_IP | 509 | # if ENABLE_FEATURE_IFUPDOWN_IP |
507 | return execute("ip link set %iface% down", ifd, exec); | 510 | return execute("ip link set %iface% down", ifd, exec); |
508 | # else | 511 | # else |
@@ -598,6 +601,9 @@ static int FAST_FUNC static_up(struct interface_defn_t *ifd, execfn *exec) | |||
598 | static int FAST_FUNC static_down(struct interface_defn_t *ifd, execfn *exec) | 601 | static int FAST_FUNC static_down(struct interface_defn_t *ifd, execfn *exec) |
599 | { | 602 | { |
600 | int result; | 603 | int result; |
604 | |||
605 | if (!if_nametoindex(ifd->iface)) | ||
606 | return 2; /* already gone */ | ||
601 | # if ENABLE_FEATURE_IFUPDOWN_IP | 607 | # if ENABLE_FEATURE_IFUPDOWN_IP |
602 | /* Optional "label LBL" is necessary if interface is an alias (eth0:0), | 608 | /* Optional "label LBL" is necessary if interface is an alias (eth0:0), |
603 | * otherwise "ip addr flush dev eth0:0" flushes all addresses on eth0. | 609 | * otherwise "ip addr flush dev eth0:0" flushes all addresses on eth0. |