Package: ifupdown Version: 0.7 Severity: important Tags: patch
Hello,
Take the following /etc/network/interfaces:
$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
On a Debian Squeeze system doing:
$ service networking restart
fails to bring-up the interface eth0.
After digging into the init script I found a problem on the logic:
ifup_hotplug () {
if [ -d /sys/class/net ]
then
ifaces=$(for iface in $(ifquery --list --allow=hotplug)
do
if [ -e "/sys/class/net/$iface" -a "$(cat
/sys/class/net/$iface/operstate)" = up ]
then
echo "$iface"
fi
done)
if [ -n "$ifaces" ]
then
ifup $ifaces || true
fi
fi
}
Is wrong, because it is checking if the interface is already up before doing
the ifup.
And the interface will be of course down, because we have just did an ifdown
previously.
... So we won't bring the interface up when restarting the network, which is a
serious problem IMHO.
Instead of checking the interface status, is better idea to check if the
interface is already
configured or not.
Just simply: if the interface is not already configured then do the ifup.
The attached patch solves this issue and allows to correctly restart the
networking even for
interfaces configured with allow-hotplug
--- networking 2012-08-20 19:25:57.289873424 +0200
+++ networking.new 2012-08-20 19:24:21.333876444 +0200
@@ -80,7 +80,7 @@
then
ifaces=$(for iface in $(ifquery --list --allow=hotplug)
do
- if [ -e "/sys/class/net/$iface" -a "$(cat /sys/class/net/$iface/operstate)" = up ]
+ if [ -e "/sys/class/net/$iface" -a ! $(grep -q "$iface" /run/network/ifstate) ]
then
echo "$iface"
fi
signature.asc
Description: OpenPGP digital signature

