[pkg-dhcp-devel] Bug#645502: Resync dhclient-script with FreeBSD version
Robert Millan
rmh at debian.org
Sun Oct 16 11:49:39 UTC 2011
Package: isc-dhcp-client
Version: 4.2.2-1
Severity: important
Tags: patch
This patch resyncs instances of ifconfig and route commands in dhclient-script
with the FreeBSD version provided by upstream.
It fixes severe problems derived from CLI incompatibility, which make dhclient
behave erratically in some situations (e.g. when removing routes).
-- System Information:
Debian Release: 6.0.2
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: kfreebsd-amd64 (x86_64)
Kernel: kFreeBSD 8.1-1-amd64
Locale: LANG=ca_AD.UTF-8, LC_CTYPE=ca_AD.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages isc-dhcp-client depends on:
ii debianutils 3.4 Miscellaneous utilities specific t
ii isc-dhcp-common 4.1.1-P1-15+squeeze3 common files used by all the isc-d
ii libc0.1 2.11.2-10 Embedded GNU C Library: Shared lib
isc-dhcp-client recommends no packages.
Versions of packages isc-dhcp-client suggests:
pn avahi-autoipd <none> (no description available)
pn resolvconf <none> (no description available)
-- no debconf information
-------------- next part --------------
=== modified file 'debian/dhclient-script.kfreebsd'
--- debian/dhclient-script.kfreebsd 2011-10-15 09:16:20 +0000
+++ debian/dhclient-script.kfreebsd 2011-10-16 10:49:37 +0000
@@ -2,6 +2,8 @@
# dhclient-script for GNU/kFreeBSD. Aurelien Jarno, May, 2005.
# Based on Linux and FreeBSD scripts.
+export PATH=/lib/freebsd:$PATH
+
# update /etc/resolv.conf based on received values
make_resolv_conf() {
local new_resolv_conf
@@ -153,27 +155,33 @@ case "$reason" in
[ "$old_ip_address" != "$new_ip_address" ]; then
ifconfig $interface inet -alias $old_ip_address $medium
route delete $old_ip_address 127.1 >/dev/null 2>&1
- # IP address changed. Bringing down the interface will delete all other
- # route, and clear the ARP cache.
- ifconfig $interface inet 0 down
- fi
-
- # point to point
- if [ "$new_subnet_mask" = "255.255.255.255" ]; then
- for router in $new_routers; do
- route add $router $new_ip_address
+ for router in $old_routers; do
+ route delete default $router >/dev/null 2>&1
done
+ if [ -n "$old_static_routes" ]; then
+ set -- $old_static_routes
+ while [ $# -gt 1 ]; do
+ route delete $1 $2
+ shift; shift
+ done
+ fi
+ arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' |sh
fi
if [ -z "$old_ip_address" ] ||
[ "$old_ip_address" != "$new_ip_address" ] ||
[ "$reason" = "BOUND" ] || [ "$reason" = "REBOOT" ]; then
- ifconfig $interface inet $new_ip_address ${new_subnet_mask:+netmask $new_subnet_mask} \
- ${new_broadcast_address:+broadcast $new_broadcast_address} $medium $mtu_arg
- route add $new_ip_address 127.1 ${IF_METRIC:+metric $IF_METRIC} >/dev/null 2>&1
-
+ ifconfig $interface inet $new_ip_address $new_netmask_arg \
+ $new_broadcast_arg $mtu_arg $metric_arg $medium
+ route add $new_ip_address 127.1 >/dev/null 2>&1
for router in $new_routers; do
- route add default $router >/dev/null 2>&1
+ # If the subnet is captive, eg the netmask is /32 but the default
+ # gateway is (obviously) outside of this, then we need to produce a
+ # host route to reach the gateway.
+ if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
+ route add -host $router -interface $interface
+ fi
+ route add default $router >/dev/null 2>&1
done
if [ -n "$new_static_routes" ]; then
@@ -183,6 +191,24 @@ case "$reason" in
shift; shift
done
fi
+ else
+ # we haven't changed the address, have we changed other options
+ # that we wish to update?
+ if [ x$new_routers != x ] && [ x$new_routers != x$old_routers ] ; then
+ # if we've changed routers delete the old and add the new.
+ for router in $old_routers; do
+ route delete default $router >/dev/null 2>&1
+ done
+ for router in $new_routers; do
+ # If the subnet is captive, eg the netmask is /32 but the default
+ # gateway is (obviously) outside of this, then we need to produce a
+ # host route to reach the gateway.
+ if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
+ route add -host $router -interface $interface
+ fi
+ route add default $router >/dev/null 2>&1
+ done
+ fi
fi
if [ -n "$alias_ip_address" ] &&
@@ -206,13 +232,22 @@ case "$reason" in
if [ -n "$old_ip_address" ]; then
ifconfig $interface inet -alias $old_ip_address $medium
route delete $old_ip_address 127.1 >/dev/null 2>&1
- # Shut down interface, which will delete all other routes and clear arp cache.
- ifconfig $interface inet 0 down
+ for router in $old_routers; do
+ route delete default $router >/dev/null 2>&1
+ done
+ if [ -n "$old_static_routes" ]; then
+ set -- $old_static_routes
+ while [ $# -gt 1 ]; do
+ route delete $1 $2
+ shift; shift
+ done
+ fi
+ arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' \
+ |sh >/dev/null 2>&1
fi
if [ -n "$alias_ip_address" ]; then
- ifconfig $interface inet alias $alias_ip_address \
- ${alias_subnet_mask:+netmask $alias_subnet_mask}
+ ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
route add $alias_ip_address 127.0.0.1
fi
@@ -224,23 +259,25 @@ case "$reason" in
route delete $alias_ip_address 127.0.0.1 > /dev/null 2>&1
fi
- ifconfig $interface inet $new_ip_address ${new_subnet_mask:+netmask $new_subnet_mask} \
- ${new_broadcast_address:+broadcast $new_broadcast_address} $medium $mtu_arg
+ ifconfig $interface inet $new_ip_address $new_netmask_arg \
+ $new_broadcast_arg $mtu_arg $metric_arg $medium
+ sleep 1
- set -- $new_routers
- first_router="$1"
- if [ -z "$first_router" ] || ping -q -c 1 $first_router; then
- if [ -n "$alias_ip_address" ] &&
- [ "$new_ip_address" != "$alias_ip_address" ]; then
- ifconfig $interface inet alias $alias_ip_address \
- ${alias_subnet_mask:+netmask $alias_subnet_mask}
- route add $alias_ip_address 127.0.0.1
+ if [ -n "$new_routers" ]; then
+ set -- $new_routers
+ if ping -q -c 1 $1; then
+ if [ x$new_ip_address != x$alias_ip_address ] && \
+ [ x$alias_ip_address != x ]; then
+ ifconfig $interface inet alias $alias_ip_address $alias_subnet_arg
+ route add $alias_ip_address 127.0.0.1
fi
route add $new_ip_address 127.1 >/dev/null 2>&1
-
for router in $new_routers; do
- route add default $router ${IF_METRIC:+metric $IF_METRIC}
+ if [ "x$new_subnet_mask" = "x255.255.255.255" ] ; then
+ route add -host $router -interface $interface
+ fi
+ route add default $router >/dev/null 2>&1
done
set -- $new_static_routes
while [ $# -gt 1 ]; do
@@ -249,10 +286,23 @@ case "$reason" in
done
make_resolv_conf
- else
- # Changed from 'ifconfig $interface inet 0 down' - see Debian bug #144666
- ifconfig $interface inet 0
+ else
exit_with_hooks 2 "$@"
+ fi
+ else
+ ifconfig $interface inet -alias $new_ip_address $medium
+ for router in $old_routers; do
+ route delete default $router >/dev/null 2>&1
+ done
+ if [ -n "$old_static_routes" ]; then
+ set -- $old_static_routes
+ while [ $# -gt 1 ]; do
+ route delete $1 $2
+ shift; shift
+ done
+ fi
+ arp -n -a | sed -n -e 's/^.*(\(.*\)) at .*$/arp -d \1/p' \
+ |sh >/dev/null 2>&1
fi
;;
More information about the pkg-dhcp-devel
mailing list