[git commit] ifupdown: when flushing addresses with "ip", add label %label%

Denys Vlasenko vda.linux at googlemail.com
Tue Sep 20 15:31:11 UTC 2016


commit: https://git.busybox.net/busybox/commit/?id=92d98f0612c147171a0e9e03dd7fdfde890ee9e5
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

User report:

or our board we setup eth0:0 on a 10.10.10.x/29 netwrok.

The problem is ip addr flush dev eth0:0 removes all ip addresses from
eth0.  You can see this if you run
ip -stat -stat addr flush dev eth0:0

2: eth0    inet 172.27.105.10/22 brd 172.27.107.255 scope global eth0
       valid_lft forever preferred_lft forever
2: eth0    inet 10.10.10.9/29 scope global eth0:0
       valid_lft forever preferred_lft forever
2: eth0    inet6 fe80::a2f6:fdff:fe18:2b13/64 scope link
       valid_lft forever preferred_lft forever

*** Round 1, deleting 3 addresses ***
*** Flush is complete after 1 round ***

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 networking/ifupdown.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 25b04c9..5c24451 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -492,7 +492,7 @@ static int FAST_FUNC static_up(struct interface_defn_t *ifd, execfn *exec)
 	result = execute("ifconfig %iface%[[ hw %hwaddress%]][[ media %media%]][[ mtu %mtu%]] up",
 				ifd, exec);
 	result += execute("ifconfig %iface% %address% netmask %netmask%"
-				"[[ broadcast %broadcast%]][[ pointopoint %pointopoint%]] ",
+				"[[ broadcast %broadcast%]][[ pointopoint %pointopoint%]]",
 				ifd, exec);
 	result += execute("[[route add default gw %gateway%[[ metric %metric%]] %iface%]]", ifd, exec);
 	return ((result == 3) ? 3 : 0);
@@ -503,7 +503,10 @@ static int FAST_FUNC static_down(struct interface_defn_t *ifd, execfn *exec)
 {
 	int result;
 # if ENABLE_FEATURE_IFUPDOWN_IP
-	result = execute("ip addr flush dev %iface%", ifd, exec);
+	/* Optional "label LBL" is necessary if interface is an alias (eth0:0),
+	 * otherwise "ip addr flush dev eth0:0" flushes all addresses on eth0.
+	 */
+	result = execute("ip addr flush dev %iface%[[ label %label%]]", ifd, exec);
 	result += execute("ip link set %iface% down", ifd, exec);
 # else
 	/* result = execute("[[route del default gw %gateway% %iface%]]", ifd, exec); */


More information about the busybox-cvs mailing list