Bug 6212

Summary: ifupdown: correct ifstate update on ifup -a
Product: Busybox Reporter: richard.genoud
Component: NetworkingAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:
Attachments: patch correcting ifup -a behaviour

Description richard.genoud 2013-04-24 12:16:40 UTC
Created attachment 4844 [details]
patch correcting ifup -a behaviour

When ifup -a is called and there's an error on one interface, ifstate isn't updated, even if some interfaces went up successfully.
Patch attached.
Version : 1.21.0

    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.
    /var/run/ifstate should have been :
    lo=lo
    and with "auto lo eth0", it is lo=lo
Comment 1 Denys Vlasenko 2015-03-22 16:10:05 UTC
Fixed in git, patch by Frank Bergmann <frank.frajasalo@googlemail.com>

Thanks!