Package: wicd-daemon
Version: 1.7.2.3-1
Followup-For: Bug #557156

I can confirm that this bug is still present and it completely breaks my
network setup when resuming from suspend. In my case, I have a 
desktop system that uses 'eth1' as its wired interface:

- this interface is configured through /etc/network/interfaces (since Woody, or 
even
  earlier)

- I have not configured wicd at all, it was just pulled in as a dependency 
because 
  GNOME's NetworkManager depends on it

- there is no way to disable the suspend script (I have filed a separate bug on 
this)

When resuming from suspend the following happens:

- /usr/lib/pm-utils/sleep.d/55wicd is run
- the script calls /usr/share/wicd/daemon/autoconnect.py
- this script calls dhclient
- the interface is auto reconfigured to use a dynamic (instead of static IP 
address)

Please see the attached file generated using 'script' (wicd-test-resume.log)
that shows the behaviour. The /var/log/wicd/wicd.log file (attached is an 
extract) 
shows that seems to be the behaviour when resuming from suspend.

I'm attaching also my current  /etc/wicd/wired-settings.conf configuration file 
for review.

As I cannot disable the /usr/lib/pm-utils/sleep.d/55wicd script I've introduced 
another
script in /etc/pm/sleep.d/00_restart_network that stops dhclient and
reconfigures the interface. Writting this script was a little bit tricky as
there is a race condition in how the power management scripts are run (as wicd
dettachs to a background process). It seems to work well in my system and
prevents this bug. I'm attaching it also here for the benefit of those affected
by this bug.

Please feel free to ask for additional information.

By the way: this bug is pretty serious, in my opinion it makes this package
unsuitable for release. 

Regards

Javier



-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 3.2.0-2-686-pae (SMP w/2 CPU cores)
Locale: LANG=es_ES.UTF-8, LC_CTYPE=es_ES.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages wicd-daemon depends on:
ii  adduser                         3.113+nmu1
ii  dbus                            1.5.12-1
ii  debconf                         1.5.42
ii  ethtool                         1:3.1-1
ii  iproute                         20120319-1
ii  iputils-ping                    3:20101006-1+b1
ii  isc-dhcp-client [dhcp3-client]  4.2.2.dfsg.1-4
ii  lsb-base                        4.1+Debian2
ii  net-tools                       1.60-24.1
ii  psmisc                          22.16-1
ii  python                          2.7.2-10
ii  python-dbus                     0.84.0-3
ii  python-gobject                  3.2.0-3
ii  python-wicd                     1.7.2.3-1
ii  wireless-tools                  30~pre9-8
ii  wpasupplicant                   0.7.3-6

Versions of packages wicd-daemon recommends:
ii  wicd-gtk [wicd-client]  1.7.2.3-1

Versions of packages wicd-daemon suggests:
ii  pm-utils  1.4.1-9

Versions of packages wicd depends on:
ii  wicd-gtk [wicd-client]  1.7.2.3-1

Versions of packages wicd-gtk depends on:
ii  python         2.7.2-10
ii  python-glade2  2.24.0-3
ii  python-gtk2    2.24.0-3

Versions of packages wicd-gtk recommends:
ii  gksu           2.0.2-6
ii  python-notify  0.1.1-3

Versions of packages python-wicd depends on:
ii  python     2.7.2-10
ii  python2.6  2.6.7-4
ii  python2.7  2.7.3~rc2-2.1

-- debconf information:
* wicd/users: jfs
[wired-default]
ip = None
broadcast = None
netmask = None
gateway = None
search_domain = None
dns_domain = None
dns1 = None
dns2 = None
dns3 = None
beforescript = None
afterscript = None
predisconnectscript = None
postdisconnectscript = None
encryption_enabled = None
default = True
dhcphostname = silicio
lastused = True

Script iniciado (lun 21 may 2012 18:19:36 CEST
)
fetchmail: background fetchmail at 12848 awakened.
jfs@silicio:log$ 
jfs@silicio:log$ ps -ef |grep dhcl
jfs@silicio:log$ ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:c0:df:03:c5:e9  
          inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::2c0:dfff:fe03:c5e9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7336517 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16048323 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:963483172 (918.8 MiB)  TX bytes:2499792887 (2.3 GiB)
          Interrupt:20 Base address:0xd000 

jfs@silicio:log$ cat /etc/network/interfaces  |grep eth1
auto eth1
iface eth1 inet static
#mapping eth1
# iface eth1:1 inet dhcp
jfs@silicio:log$ sudo -s
silicio:/var/log# /usr/share/wicd/daemon/autoconnect.py
silicio:/var/log# ps -ef |grep dhc
root     19460  2769  0 18:21 ?        00:00:00 /sbin/dhclient -v -r eth1
root     19462 18898  0 18:21 pts/0    00:00:00 grep dhc
root     19463 19460  0 18:21 ?        00:00:00 /bin/bash /sbin/dhclient-script
silicio:/var/log# ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:c0:df:03:c5:e9  
          inet addr:192.168.1.34  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::2c0:dfff:fe03:c5e9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7336668 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16048587 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:963498342 (918.8 MiB)  TX bytes:2499828021 (2.3 GiB)
          Interrupt:20 Base address:0xd000 

silicio:/var/log# exit
jfs@silicio:log$ exit

Script terminado (lun 21 may 2012 18:21:53 CEST
)
2012/05/21 18:21:31 :: Setting false IP...
2012/05/21 18:21:31 :: Stopping wpa_supplicant
2012/05/21 18:21:31 :: Flushing the routing table...
2012/05/21 18:21:31 :: Putting interface up...
2012/05/21 18:21:33 :: Running DHCP with hostname silicio
2012/05/21 18:21:33 :: attempting to set hostname with dhclient
2012/05/21 18:21:33 :: using dhcpcd or another supported client may work better
2012/05/21 18:21:33 :: Internet Systems Consortium DHCP Client 4.2.2
2012/05/21 18:21:33 :: Copyright 2004-2011 Internet Systems Consortium.
2012/05/21 18:21:33 :: All rights reserved.
2012/05/21 18:21:33 :: For info, please visit https://www.isc.org/software/dhcp/
2012/05/21 18:21:33 :: 
2012/05/21 18:21:33 :: Listening on LPF/eth1/00:c0:df:03:c5:e9
2012/05/21 18:21:33 :: Sending on   LPF/eth1/00:c0:df:03:c5:e9
2012/05/21 18:21:33 :: Sending on   Socket/fallback
2012/05/21 18:21:33 :: DHCPDISCOVER on eth1 to 255.255.255.255 port 67 interval 
7
2012/05/21 18:21:33 :: DHCPREQUEST on eth1 to 255.255.255.255 port 67
2012/05/21 18:21:33 :: DHCPOFFER from 192.168.1.1
2012/05/21 18:21:33 :: DHCPACK from 192.168.1.1
2012/05/21 18:21:33 :: Reloading /etc/samba/smb.conf: smbd only.
2012/05/21 18:21:33 :: bound to 192.168.1.34 -- renewal in 32472 seconds.
2012/05/21 18:21:33 :: DHCP connection successful
2012/05/21 18:21:37 :: Connecting thread exiting.
2012/05/21 18:21:42 :: Sending connection attempt result success
#!/bin/sh 

# Action script ensure that the network is properly restarted
# after resuming from suspension/hibernate
#
# Copyright: Copyright (c) 2012  Javier Fernandez-Sanguino <j...@debian.org>
# License:   GPL-2
#

PATH=/sbin:/usr/sbin:/bin:/usr/bin

# The interface you want to force reconfiguration with
IFACE=eth1

# Abort if the interface does not exist

if [ ! -e /proc/sys/net/ipv4/conf/$IFACE  ] ; then
	echo "ERROR: The script $0 was unable to find the interface $IFACE. Please review"
	exit 2
fi

interface_available() {
	if [ -z "`ifconfig $IFACE 2>/dev/null | grep ^$IFACE`" ] ; then
		return 1
	fi
	return 0
}

wait_for_interface() {
# Wait for the interface to be available, we wait for 10 seconds maximum
	count=0
	while ! interface_available && [ $count -lt 10 ] ; do
		count=$(($count+1))
		[ $count -eq 1 ] && echo -n "waiting for interface:"
		echo -n " $count "
		sleep 1
	done
	[ $count -gt 0 ] && echo
}

dhclient_available() {
	if [ -e /var/run/dhclient.pid ] ; then
		PID=`cat /var/run/dhclient.pid`
# Check if dhclient is associated with our interface and stop it it is 
		ps -f -p $PID
		if [ -n "`ps -f -p $PID | grep $IFACE`" ] ; then
			return 0
		fi
	fi
	return 1
}


wait_for_dhclient() {
# Wait for dhclient to start, we wait for 10 seconds maximum
	count=0
	while ! dhclient_available && [ $count -lt 10 ] ; do
		count=$(($count+1))
		[ $count -eq 1 ] && echo -n "waiting for dhclient:"
		echo -n " $count "
		sleep 1
	done
	[ $count -gt 0 ] && echo

}

kill_dhclient() {
		# Kill dhclient if we see it (wicd starts it even if we don't want it too)
		if [ -e /var/run/dhclient.pid ] ; then
			PID=`cat /var/run/dhclient.pid`
		# Check if dhclient is associated with our interface and stop it it is 
			if [ -n "`ps -ef |grep $PID | grep $IFACE`" ] ; then
				start-stop-daemon --stop --pidfile /var/run/dhclient.pid --oknodo --exec /sbin/dhclient
				sleep 1 # Wait a little bit for dhclient to die
			fi
		fi
}


case "${1}" in
        hibernate)
                ;;
        resume|thaw)

		wait_for_interface
		if ! interface_available ; then
			echo "ERROR: The interface $IFACE is not available. $0 will ABORT."
			exit 1
		fi

		# We have to wait for dhclient to start because of a race condition on
		# how the scripts are executed after pm-suspend (wicd backgrounds). This
		# ensures we wait for it to start and then we stop it (in my slow home system
		# it will wait for 3 seconds)
		wait_for_dhclient
		kill_dhclient		

		# Reconfigure the interface using the settings in /etc/network/interfaces
		ifdown --force $IFACE
		ifup --force $IFACE
                ;;
        *) exit $NA
                ;;
esac

Reply via email to