aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2018-03-28 00:00:03 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2018-03-28 00:02:52 +0200
commit123fdda0a4a838e61c6a7d15c69d3b438136aee0 (patch)
tree8d050c4aa0586e2381f6f51adffb44913715416b
parent46ba2468a3de85076ce92ce8e8cc7a086bac69f0 (diff)
downloadbusybox-123fdda0a4a838e61c6a7d15c69d3b438136aee0.tar.gz
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.c6
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 @@
//usage: "\n -v Print out what would happen before doing it"
//usage: "\n -f Force deconfiguration"
+#include <net/if.h>
#include "libbb.h"
#include "common_bufsiz.h"
/* 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)
static int FAST_FUNC static_down6(struct interface_defn_t *ifd, execfn *exec)
{
+ if (!if_nametoindex(ifd->iface))
+ return 1; /* already gone */
# if ENABLE_FEATURE_IFUPDOWN_IP
return execute("ip link set %iface% down", ifd, exec);
# else
@@ -598,6 +601,9 @@ static int FAST_FUNC static_up(struct interface_defn_t *ifd, execfn *exec)
static int FAST_FUNC static_down(struct interface_defn_t *ifd, execfn *exec)
{
int result;
+
+ if (!if_nametoindex(ifd->iface))
+ return 2; /* already gone */
# if ENABLE_FEATURE_IFUPDOWN_IP
/* Optional "label LBL" is necessary if interface is an alias (eth0:0),
* otherwise "ip addr flush dev eth0:0" flushes all addresses on eth0.