[PATCH] ifupdown: correct ifstate update on ifup -a
Richard Genoud
richard.genoud at gmail.com
Wed Jun 18 13:44:28 UTC 2014
When ifup -a is called and there's an error on one interface, ifstate
isn't updated, even if some interfaces went up successfully.
This patch allows ifstate to be updated with the successfull mounted
interfaces.
Steps to reproduce :
/etc/network/interfaces :
iface eth0 inet static
address 192.168.2.240
netmask 255.255.255.0
auto eth0 lo
iface lo inet loopback
(order of "auto eth0 lo" is important, doesn't happens with
"auto lo eth0")
at startup:
$ cat /var/run/ifstate
eth0=eth0
lo=lo
$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:04:A3:91:C4:E3
inet addr:192.168.2.240 Bcast:0.0.0.0 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:26 Base address:0xc000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
$ ifdown -a -v
run-parts /etc/network/if-down.d
ip addr flush dev eth0
ip link set eth0 down
run-parts /etc/network/if-post-down.d
run-parts /etc/network/if-down.d
ip addr flush dev lo
ip link set lo down
run-parts /etc/network/if-post-down.d
$ cat /var/run/ifstate
$ ifconfig
$ # add an address to make ifupdown fail on eth0
$ # we could also add a non-exitant interface in network/interfaces
$ ip addr add 192.168.2.240/24 dev eth0 label eth0
$ ifconfig
$ ifup -a -v
run-parts /etc/network/if-pre-up.d
ip addr add 192.168.2.240/24 dev eth0 label eth0
RTNETLINK answers: File exists
ip link set eth0 up
run-parts /etc/network/if-pre-up.d
ip addr add 127.0.0.1/8 dev lo
ip link set lo up
run-parts /etc/network/if-up.d
$ cat /var/run/ifstate
$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:04:A3:91:C4:E3
inet addr:192.168.2.240 Bcast:0.0.0.0 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Interrupt:26 Base address:0xc000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
lo has been brought by ifupdown and still /var/run/ifstate is empty.
With this patch, /var/run/ifstate would have been :
lo=lo
Signed-off-by: Richard Genoud <richard.genoud at gmail.com>
---
networking/ifupdown.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index c35d97a1aae5..c4a9e8bf3a00 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -1239,6 +1239,7 @@ int ifupdown_main(int argc UNUSED_PARAM, char **argv)
char *pch;
bool okay = 0;
int cmds_ret;
+ any_failures = 0;
iface = xstrdup(target_list->data);
target_list = target_list->link;
--
1.8.5.5
More information about the busybox
mailing list