Re: Make pccard.ether working if there is already a dhclient running

From: Martin Blapp <mb_at_imp.ch>
Date: Sat, 9 Aug 2003 14:50:49 +0200 (CEST)
I have now fixed the remaining issues.
Comments are welcome.

Martin

------------------------------------------------------

Simplify the pccard dhcp handling a lot. There are now
many configurations which have a NIC on board, and
pccard slots. If a dhclient is running on the internal
nic, the user was forced to kill a running dhclient
manually.

If a pccard is included at startup time, /etc/rc.d/dhclient
start does include it into the startup list for dhcp devices.
That means you can you then dhcp on the internal and the
pccard device.

If the card is plugged in later, a running dhclient (working
for the internal interface only) is killed, and restarted,
but with the interface name of the new pccard.

Here is my example config which works really fine now:

ifconfig_sis0="DHCP"
pccard_ifconfig=DHCP
removable_interfaces="an0 wi0"

--- etc/pccard_ether	Thu Jun 26 04:44:08 2003
+++ etc/pccard_ether	Sat Aug  9 14:31:58 2003
_at__at_ -12,11 +12,32 _at__at_
 		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
+		eval _active_list=\"`/bin/ps -xwwww | \
+			/usr/bin/grep dhclient | \
+			/usr/bin/grep -v grep | \
+			/usr/bin/sed -e 's|^.*dhclient||'`\"
+
+		_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`
 }

 start_dhcp() {
_at__at_ -35,7 +56,7 _at__at_
 			pidfile="/var/run/dhclient.${interface}.pid"
 			dhclient_flags="${dhclient_flags} -pf ${pidfile}"
 		fi
-		${dhclient_program} ${dhclient_flags} ${interface}
+		${dhclient_program} ${dhclient_flags} $_dhcplist ${interface}
 	else
 		echo "${dhclient_program}: DHCP client software not available"
 	fi
--- etc/network.subr	Sat Aug  9 11:48:47 2003
+++ etc/network.subr	Sat Aug  9 14:10:59 2003
_at__at_ -299,6 +299,24 _at__at_
 		esac
 	done

+	case ${pccard_ifconfig} in
+	[Dd][Hh][Cc][Pp])
+		for _if in ${removable_interfaces} ; 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
+		;;
+	*)
+		;;
+	esac
+
 	case "$type" in
 	nodhcp)
 		echo $_nodhcplist
Received on Sat Aug 09 2003 - 03:50:56 UTC

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