Package: ifupdown
Version: 0.8.10
Severity: normal
Tags: patch

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

There appears to be a bit of a chicken-n-egg problem with "wpa-roam"
type interfaces, and any other type of interface which need ifup
before a carrier can be detected:
"/etc/init.d/networking start" will only call ifup on hotplug class
interfaces with a carrier.

A "wpa-roam" type interface will not be able to detect a carrier
until wpa_supplicaant has been started, which is supposed to happen
in the pre-up phase.  But there won't be any pre-up phase unless
ifup is called... catch 22.

This is the relevant part if my /etc/network/interfaces:

 # use wpa_action to control this interface
 allow-hotplug wlan0
 iface wlan0 inet manual
     wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

 # 'default' is used by wpa_cli as the fallback mapping target
 iface default inet dhcp


Note that the udev hotplug script /lib/udev/ifupdown-hotplug works
fine - unconditionally calling ifup on any new hotplug interface. So
"hotplugging" wlan0 after the system is up will bring up the interface
and start wpa_supplicant.

The problem lies in the hotplug fallback code in /etc/init.d/networking,
which AFAIU is supposed to catch interfaces hotplugged/detected *before*
the system was fully operational.  It makes ifup_hotplug depend on carrier
by testing for
   [ "$(cat /sys/class/net/$link/operstate)" = up ]

This code has been like that "forever", and I cannot explain why it
suddenly has become a problem.  I assume this might be related to udevadm
"settle" support, or some other unrelated boot process change.  The main
point is that this code now has become a problem by preventing wlan
interfaces from automatically coming up on boot.

The simple attached patch fixes the problem for me.  But I must admit
that I do not understand the intentions of the original code.  It seems
completely illogical to avoid ifup unless the link is up, but I assume
there is a reason this was found necessary.  In any case, I don't think
that reason can be valid anymore since the /lib/udev/ifupdown-hotplug
behaves differently.

(yes, I know I should probably give up and use networkd or whatever, but
FWIW the simple patch here does allow my to continue using my existin 
ifupdown+wpa_supplicant config)


Bjørn

- -- System Information:
Debian Release: 8.3
  APT prefers stable
  APT policy: (700, 'stable'), (600, 'unstable'), (500, 'stable-updates')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.5.0-rc4+ (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages ifupdown depends on:
ii  adduser              3.113+nmu3
ii  init-system-helpers  1.28
ii  iproute2             4.3.0-1git
ii  libc6                2.21-7
ii  lsb-base             4.1+Debian13+nmu1

Versions of packages ifupdown recommends:
ii  isc-dhcp-client [dhcp-client]  4.3.1-6+deb8u2

Versions of packages ifupdown suggests:
ii  ppp     2.4.6-3.1
pn  rdnssd  <none>

- -- Configuration Files:
/etc/default/networking changed:
VERBOSE=yes

/etc/init.d/networking changed:
PATH="/sbin:/bin"
RUN_DIR="/run/network"
IFSTATE="$RUN_DIR/ifstate"
STATEDIR="$RUN_DIR/state"
[ -x /sbin/ifup ] || exit 0
[ -x /sbin/ifdown ] || exit 0
. /lib/lsb/init-functions
CONFIGURE_INTERFACES=yes
EXCLUDE_INTERFACES=
VERBOSE=no
[ -f /etc/default/networking ] && . /etc/default/networking
verbose=""
[ "$VERBOSE" = yes ] && verbose=-v
process_exclusions() {
    set -- $EXCLUDE_INTERFACES
    exclusions=""
    for d
    do
        exclusions="-X $d $exclusions"
    done
    echo $exclusions
}
process_options() {
    [ -e /etc/network/options ] || return 0
    log_warning_msg "/etc/network/options still exists and it will be IGNORED! 
Please use /etc/sysctl.conf instead."
}
check_ifstate() {
    if [ ! -d "$RUN_DIR" ] ; then
        if ! mkdir -p "$RUN_DIR" ; then
            log_failure_msg "can't create $RUN_DIR"
            exit 1
        fi
        if ! chown root:netdev "$RUN_DIR" ; then
            log_warning_msg "can't chown $RUN_DIR"
        fi
    fi
    if [ ! -r "$IFSTATE" ] ; then
        if ! :> "$IFSTATE" ; then
            log_failure_msg "can't initialise $IFSTATE"
            exit 1
        fi
    fi
}
check_network_file_systems() {
    [ -e /proc/mounts ] || return 0
    if [ -e /etc/iscsi/iscsi.initramfs ]; then
        log_warning_msg "not deconfiguring network interfaces: iSCSI root is 
mounted."
        exit 0
    fi
    while read DEV MTPT FSTYPE REST; do
        case $DEV in
        /dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*|curlftpfs*)
            log_warning_msg "not deconfiguring network interfaces: network 
devices still mounted."
            exit 0
            ;;
        esac
        case $FSTYPE in
        
nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|pvfs|pvfs2|fuse.httpfs|fuse.curlftpfs)
            log_warning_msg "not deconfiguring network interfaces: network file 
systems still mounted."
            exit 0
            ;;
        esac
    done < /proc/mounts
}
check_network_swap() {
    [ -e /proc/swaps ] || return 0
    while read DEV MTPT FSTYPE REST; do
        case $DEV in
        /dev/nbd*|/dev/nd[a-z]*|/dev/etherd/e*)
            log_warning_msg "not deconfiguring network interfaces: network swap 
still mounted."
            exit 0
            ;;
        esac
    done < /proc/swaps
}
ifup_hotplug () {
    if [ -d /sys/class/net ]
    then
            ifaces=$(for iface in $(ifquery --list --allow=hotplug)
                            do
                                    link=${iface##:*}
                                    link=${link##.*}
                                    if [ -e "/sys/class/net/$link" ]
                                    then
                                        echo "$iface"
                                    fi
                            done)
            if [ -n "$ifaces" ]
            then
                ifup $ifaces "$@" || true
            fi
    fi
}
case "$1" in
start)
        if init_is_upstart; then
                exit 1
        fi
        process_options
        check_ifstate
        if [ "$CONFIGURE_INTERFACES" = no ]
        then
            log_action_msg "Not configuring network interfaces, see 
/etc/default/networking"
            exit 0
        fi
        set -f
        exclusions=$(process_exclusions)
        log_action_begin_msg "Configuring network interfaces"
        if [ -x /sbin/udevadm ]; then
                if [ -n "$(ifquery --list --exclude=lo)" ] || [ -n "$(ifquery 
--list --allow=hotplug)" ]; then
                        udevadm settle || true
                fi
        fi
        if ifup -a $exclusions $verbose && ifup_hotplug $exclusions $verbose
        then
            log_action_end_msg $?
        else
            log_action_end_msg $?
        fi
        ;;
stop)
        if init_is_upstart; then
                exit 0
        fi
        check_network_file_systems
        check_network_swap
        log_action_begin_msg "Deconfiguring network interfaces"
        if ifdown -a --exclude=lo $verbose; then
            log_action_end_msg $?
        else
            log_action_end_msg $?
        fi
        ;;
reload)
        if init_is_upstart; then
                exit 1
        fi
        process_options
        log_action_begin_msg "Reloading network interfaces configuration"
        state=$(ifquery --state)
        ifdown -a --exclude=lo $verbose || true
        if ifup --exclude=lo $state $verbose ; then
            log_action_end_msg $?
        else
            log_action_end_msg $?
        fi
        ;;
force-reload|restart)
        if init_is_upstart; then
                exit 1
        fi
        process_options
        log_warning_msg "Running $0 $1 is deprecated because it may not 
re-enable some interfaces"
        log_action_begin_msg "Reconfiguring network interfaces"
        ifdown -a --exclude=lo $verbose || true
        set -f
        exclusions=$(process_exclusions)
        if ifup -a --exclude=lo $exclusions $verbose && ifup_hotplug 
$exclusions $verbose
        then
            log_action_end_msg $?
        else
            log_action_end_msg $?
        fi
        ;;
*)
        echo "Usage: /etc/init.d/networking 
{start|stop|reload|restart|force-reload}"
        exit 1
        ;;
esac
exit 0


- -- no debconf information

-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAlbBuHMACgkQ10rqkowbIskXPgCeNrqnFEGhMNEwWGPLh3NGFWa7
jFQAnRHFTXnvO9ZekQOxb188vmkGiZaK
=mxBr
-----END PGP SIGNATURE-----
--- /etc/init.d/networking.OLD	2015-07-19 23:45:52.000000000 +0200
+++ /etc/init.d/networking	2016-02-15 12:00:54.600641776 +0100
@@ -107,12 +107,7 @@
 				    link=${link##.*}
 				    if [ -e "/sys/class/net/$link" ]
 				    then
-					# link detection does not work unless we up the link
-					ip link set "$iface" up || true
-					if [ "$(cat /sys/class/net/$link/operstate)" = up ]
-					then
-					    echo "$iface"
-					fi
+					echo "$iface"
 				    fi
 			    done)
 	    if [ -n "$ifaces" ]

Reply via email to