Re: Problem with dhclient & wi0 on resume.

From: Martin Blapp <mb_at_imp.ch>
Date: Tue, 12 Aug 2003 14:50:22 +0200 (CEST)
Hi,

Can you please try the attached patch ? There was one mayor
typo ...

- for _if in _active_list ; do
+ for _if in ${_active_list} ; do

I also found two other bugs. And there is still one
if we get 2 pccards at the same time configured with dhcp.
But I think this setting is used very rarly.

Martin

--- etc/pccard_ether	Tue Aug 12 14:14:13 2003
+++ etc/pccard_ether	Tue Aug 12 14:43:31 2003
_at__at_ -8,48 +8,55 _at__at_
 #

 stop_dhcp() {
+	# If dhclient is already running, record
+	# it's interfaces.
+	if [ -x /usr/bin/grep ]; then
+		eval _active_list=\"`/bin/ps -axwww | \
+			/usr/bin/grep dhclient | \
+			/usr/bin/grep -v grep | \
+			/usr/bin/sed -e 's|^.*dhclient||' | \
+			/usr/bin/awk '{for (i=1;i<=NF;i++) \
+				{ if ($i~/[a-zA-Z].[0-9]$/) \
+				{ printf(" %s",$i) } }}'` \
+			\"
+	fi
+
+	_aprefix=
+	for _if in ${_active_list} ; do
+		_test_if=`ifconfig ${_if} 2>&1`
+		case "$_test_if" in
+		"ifconfig: interface $_if does not exist")
+			;;
+		${interface})
+			# Don't record the same device twice.
+			;;
+		*)
+			_dhcplist="${_dhcplist}${_aprefix}${_if}"
+			[ -z "$_aprefix" ] && _aprefix=' '
+			;;
+		esac
+	done
 	if [ -s /var/run/dhclient.${interface}.pid ]; then
 		pidfile="/var/run/dhclient.${interface}.pid"
 	elif [ -s /var/run/dhcpc.${interface}.pid ]; then
 		pidfile="/var/run/dhcpc.${interface}.pid"
 	elif [ -s /var/run/dhclient.pid ]; then
-		# If dhclient is already running, record
-		# it's interfaces.
-		if [ -x /usr/bin/grep ]; then
-			eval _active_list=\"`/bin/ps -axwww | \
-				/usr/bin/grep dhclient | \
-				/usr/bin/grep -v grep | \
-				/usr/bin/sed -e 's|^.*dhclient||' | \
-				/usr/bin/awk '{for (i=1;i<=NF;i++) \
-					{ if ($i~/[a-zA-Z].[0-9]$/) \
-					{ printf(" %s",$i) } }}'` \
-				\"
-		fi
-
-		_aprefix=
-		for _if in _active_list ; do
-			_test_if=`ifconfig ${_if} 2>&1`
-			case "$_test_if" in
-			"ifconfig: interface $_if does not exist")
-				;;
-			*)
-				_dhcplist="${_dhcplist}${_aprefix}${_if}"
-				[ -z "$_aprefix" ] && _aprefix=' '
-				;;
-			esac
-		done
-
 		pidfile="/var/run/dhclient.pid"
 	else
 		return
 	fi
 	kill `cat ${pidfile}`
 	rm -f ${pidfile}
-	sh `/etc/rc.d/dhclient start`
+	case ${startstop} in
+	[Ss][Tt][Oo][Pp])
+		sh `/etc/rc.d/dhclient start`
+		;;
+	*)
+		;;
+	esac
 }

 start_dhcp() {
-	stop_dhcp
 	case ${pccard_ether_delay} in
 	[Nn][Oo])
 		;;
_at__at_ -57,6 +64,7 _at__at_
 		sleep ${pccard_ether_delay}
 		;;
         esac
+	stop_dhcp
 	[ -n "$dhcp_program" ] && dhclient_program="$dhcp_program"
 	[ -n "$dhcp_flags" ] && dhclient_flags="$dhcp_flags"
 	if [ -x "${dhclient_program}" ]; then
Received on Tue Aug 12 2003 - 03:50:27 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:18 UTC