ifup/down broken!!!

David Henderson dhenderson at digital-pipe.com
Mon Sep 26 15:03:49 UTC 2016


Good morning all!  Thanks for the help Denys, replies are inline...


On 9/24/16, Denys Vlasenko <vda.linux at googlemail.com> wrote:
> ..On Sat, Sep 24, 2016 at 7:41 PM, David Henderson
> <dhenderson at digital-pipe.com> wrote:
>> Good afternoon all!  This is to let those that are attempting to work
>> with the busybox applets 'ifup' and 'ifdown' that their current status
>> is broken in certain conditions and to let them know the unfortunate
>> work around you must go through to make it work.
>>
>> Testing has shown that there are two conditions that must be meet in
>> order for an 'ifup -a' call during boot to process correctly:
>>
>> 1) you must have a pre-existing /etc/network/interfaces file
>
>> 2) each adapter must have static network config information (e.g. no
>> dhcp)
>
>> If those two conditions are true, then everything works as designed.
>> Any alterations causes the applets to choke from an apparent issue
>> writing to the /var/run/ifstate file.
>
>
> Trying to reproduce.
>
> My /etc/network/interfaces is two lines:
> iface lo inet loopback
> iface eth0 inet dhcp
>
> I have these empty directories:
> /etc/network/if-down.d
> /etc/network/if-post-down.d
> /etc/network/if-pre-up.d
> /etc/network/if-up.d
> /var/run
>
>
> Booting a qemu machine:
>
> ./run-qemu /boot/vmlinuz-4.8.0-rc5+
> [    0.000000] Linux version 4.8.0-rc5+ (root at localhost) (gcc version
> 6.1.1 20160810 (Red Hat 6.1.1-5) (GCC) ) #7 SMP Sat Sep 17 23:24:30
> CEST 2016
> [    0.000000] Command line: panic=1 console=ttyS0
> [    0.000000] x86/fpu: Legacy x87 FPU detected.
> [    0.000000] x86/fpu: Using 'eager' FPU context switches.
> [    0.000000] e820: BIOS-provided physical RAM map:
> [    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff]
> usable
> ...
> ...
> [    1.761051] tsc: Refined TSC clocksource calibration: 2712.012 MHz
> [    1.761931] clocksource: tsc: mask: 0xffffffffffffffff max_cycles:
> 0x271791bffc3, max_idle_ns: 440795320414 ns
> [    1.893550] input: ImExPS/2 BYD TouchPad as
> /devices/platform/i8042/serio1/input/input3
> [    2.771797] clocksource: Switched to clocksource tsc
> Your current kernel is:
> Linux (none) 4.8.0-rc5+ #7 SMP Sat Sep 17 23:24:30 CEST 2016 x86_64
> GNU/Linux
> I see following modules in current directory:
> e1000.ko
> e1000e.ko
>
>       (need to load e1000 module for eth0 to exist:)
>
> / # insmod e1000.ko
> [   45.919343] e1000: Intel(R) PRO/1000 Network Driver - version
> 7.3.21-k8-NAPI
> [   45.919590] e1000: Copyright (c) 1999-2006 Intel Corporation.
> [   46.412214] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 11
> [   46.706789] e1000 0000:00:03.0 eth0: (PCI:33MHz:32-bit)
> 52:54:00:12:34:56
> [   46.707506] e1000 0000:00:03.0 eth0: Intel(R) PRO/1000 Network
> Connection
> [   46.714497] insmod (127) used greatest stack depth: 12872 bytes left
>
>       (ok, let's try it!!!)
>
> / # ifup eth0
> [   50.696362] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
> [   50.697526] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow
> Control: RX
> [   50.700412] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
> udhcpc: started, v1.26.0.git
> udhcpc: sending discover
> udhcpc: sending select for 10.0.2.15
> udhcpc: lease of 10.0.2.15 obtained, lease time 86400
>
> / # ip a
> 1: lo: <LOOPBACK> mtu 65536 qdisc noop qlen 1
>     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
> 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen
> 1000
>     link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
>     inet6 fec0::5054:ff:fe12:3456/64 scope site tentative dynamic
>        valid_lft 86400sec preferred_lft 14400sec
>     inet6 fe80::5054:ff:fe12:3456/64 scope link
>        valid_lft forever preferred_lft forever
>
> / # cat /var/run/ifstate
> eth0=eth0
>
> / # ifup lo
>
> / # ip a
> 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1
>     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
>     inet 127.0.0.1/8 scope host lo
>        valid_lft forever preferred_lft forever
>     inet6 ::1/128 scope host
>        valid_lft forever preferred_lft forever
> 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen
> 1000
>     link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
>     inet6 fec0::5054:ff:fe12:3456/64 scope site dynamic
>        valid_lft 86400sec preferred_lft 14400sec
>     inet6 fe80::5054:ff:fe12:3456/64 scope link
>        valid_lft forever preferred_lft forever
>
> / # cat /var/run/ifstate
> eth0=eth0
> lo=lo
>
>
> So. Works for me.

Performed a fresh boot of the machine, there is currently an active
wlan0, but no contents in /var/run/ifstate.  I ifdown'ed the wlan0 so
that there were no working ethernet devices:

# ifconfig
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:2547 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2547 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:2016302 (1.9 MB)  TX bytes:2016302 (1.9 MB)

# ip route
127.0.0.1 dev lo

# ls -al /var/run/ifstate
-rw-rw-r--  1 root  staff  0 Sep 26 13:00 /var/run/ifstate

# strace -oLOG -tt -f -s99 ifup eth0
udhcpc (v1.24.1) started
Sending discover...
Sending discover...
Sending select for 192.168.0.171...
Lease of 192.168.0.171 obtained, lease time 86400
deleting routers
route: SIOCDELRT: No such process
adding dns 8.8.8.8
adding dns 8.8.4.4
run-parts: /etc/network/if-up.d/000_dns-nameservers: exit status 1

(now it just sits there)

I have to kill udhcpc in order to return control.  Checking the
script, I couldn't see where it failed so I began commenting out until
it didn't exit 1 any longer.  The script is as follows:

#!/bin/sh
#
# DEBUG
echo 'resolv.conf' > /tmp/debug.ifup
env >> /tmp/debug.ifup

# everything below this point was added recently
CONFIG=''

# this segment was what was causing an exit 1
[ -e '/etc/network/interfaces' ] && ( echo "$IFACE" | grep -q ':' ) && {
        [ "$IF_DNS_DOMAIN" ] && CONFIG="${CONFIG}domain ${IF_DNS_DOMAIN}\n"
        [ "$IF_DNS_SEARCH" ] && CONFIG="${CONFIG}search ${IF_DNS_SEARCH}\n"
        [ "$IF_DNS_SORTLIST" ] && CONFIG="${CONFIG}sortlist
${IF_DNS_SORTLIST}\n"
        for NS in $IF_DNS_NAMESERVER $IF_DNS_NAMESERVERS; do
                CONFIG="${CONFIG}nameserver $NS\n"
        done
}
[ "$CONFIG" != '' ] && echo -e "$CONFIG" > /etc/resolv.conf


The "[ -e '/etc/network/interfaces' ] && ..." section was the part
that appears to be causing the 'exit 1' status - most likely from the
'grep -q ':'' call.  Does this indicate an issue with /bin/sh as the
normal exit value of the script should be 0?  It appears that the
'grep' call is returning a false response that is being retained and
causing the 'exit 1' status of the script even though the script
continues to process until the end (which should be an exit 0 now
right?).  To resolve the problem, I simply put an 'exit 0' at the end
of the script.  Doing so now allows the /var/run/ifstate file to be
written to successfully.


>> The only solution I can see is
>> that the burden of manually maintaining the /var/run/ifstate file is
>> on the user/interface.
>
>
> In my attempt at reproducing it, /var/run/ifstate was successfully created.
>
> Please provide the LOG file from the following command:
>
> strace -oLOG -tt -f -s99 ifup eth0
>
> (You were already asked to provide this information)

Sorry about that, it probably was an issue with the machine not having
that binary installed and no network connection to get it at the time
as to why that didn't get run.  However, it appears to have shown
where the issue was - thanks to whomever stated to do that!

Thanks,
Dave


More information about the busybox mailing list