PERFORCE change 66276 for review

Sam Leffler sam at FreeBSD.org
Thu Dec 2 13:22:39 PST 2004


http://perforce.freebsd.org/chv.cgi?CH=66276

Change 66276 by sam at sam_ebb on 2004/12/02 21:21:44

	make things more like old script:
	o use logger for diagnostics
	o delete old_routers instead of assuming a single default route
	o check if default route is ours when clearing old_routers
	o selectively remove arp entries instead of flushing everything

Affected files ...

.. //depot/projects/wifi/sbin/dhclient/dhclient-script#2 edit

Differences ...

==== //depot/projects/wifi/sbin/dhclient/dhclient-script#2 (text+ko) ====

@@ -18,6 +18,16 @@
 #
 #
 
+NETSTAT=/usr/bin/netstat
+GREP=/usr/bin/grep
+AWK=/usr/bin/awk
+
+if [ -x /usr/bin/logger ]; then
+	LOGGER="/usr/bin/logger -s -p user.notice -t dhclient"
+else
+	LOGGER=echo
+fi
+
 #
 # Helper functions that implement common actions.
 #
@@ -56,9 +66,11 @@
 }
 
 delete_old_routes() {
-	# Delete existing default route. We only allow one, so no need to
-	# process $old_routers list.
-	route delete default >/dev/null 2>&1
+	for router in $old_routers; do
+		if [ $if_defaultroute = x -o $if_defaultroute = $interface ]; then
+			route delete default $route >/dev/null 2>&1
+		fi
+	done
 
 	if [ -n "$old_static_routes" ]; then
 		set $old_static_routes
@@ -68,7 +80,8 @@
 		done
 	fi
 
-	arp -dan
+	arp -an | sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' | \
+		sh >/dev/null 2>&1
 }
 
 add_new_routes() {
@@ -142,11 +155,17 @@
 #
 
 if [ -n "$new_network_number" ]; then
-	echo "New Network Number: $new_network_number"
+	$LOGGER "New Network Number: $new_network_number"
 fi
 
 if [ -n "$new_broadcast_address" ]; then
-	echo "New Broadcast Address: $new_broadcast_address"
+	$LOGGER "New Broadcast Address: $new_broadcast_address"
+fi
+
+if [ -x $NETSTAT ]; then
+	if_defaulroute=`$NETSTAT -rn | $GREP "^default" | $AWK '{print $6}'`
+else
+	if_defaultroute="x"
 fi
 
 case $reason in


More information about the p4-projects mailing list