aboutsummaryrefslogtreecommitdiffstats
path: root/main/busybox/0017-ifupdown-do-not-fail-if-interface-disappears-during-.patch
blob: bdf24b78384ce7d82052e894f589504b1885b9b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From 444a2f6be54186ae9ade1f2c3d4356cd62a720c5 Mon Sep 17 00:00:00 2001
From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
Date: Fri, 23 Mar 2018 14:56:52 +0200
Subject: [PATCH] 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.

Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
---
 networking/ifupdown.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 534c9f0c7..35d13c5e1 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -141,6 +141,7 @@
 #include "libbb.h"
 #include "common_bufsiz.h"
 /* After libbb.h, since it needs sys/types.h on some systems */
+#include <net/if.h>
 #include <sys/utsname.h>
 #include <fnmatch.h>
 
@@ -503,6 +504,7 @@ 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;
 # if ENABLE_FEATURE_IFUPDOWN_IP
 	return execute("ip link set %iface% down", ifd, exec);
 # else
@@ -598,6 +600,7 @@ 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;
 # 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.
-- 
2.14.3