[pkg-dhcp-commits] [SCM] ISC DHCP packaging for Debian branch, master, updated. debian/4.1.1-P1-16.1-14-g02638d8
Andrew Pollock
apollock at debian.org
Thu May 19 05:53:14 UTC 2011
The following commit has been merged in the master branch:
commit 1062dcadce55e29aeea6b0f8cef6c8b63ba0d527
Author: Peter Marschall <peter at adpm.de>
Date: Sat Jan 8 21:48:56 2011 +0100
dhclient-script.linux: convert to iproute2
Convert the IPv4 part from ifconfig & route to iproute2's ip
and comment what is done.
Signed-off-by: Peter Marschall <peter at adpm.de>
diff --git a/debian/dhclient-script.linux b/debian/dhclient-script.linux
index 3ab16bf..624a17e 100644
--- a/debian/dhclient-script.linux
+++ b/debian/dhclient-script.linux
@@ -139,18 +139,18 @@ if [ -n "$old_broadcast_address" ]; then
old_broadcast_arg="broadcast $old_broadcast_address"
fi
if [ -n "$new_subnet_mask" ]; then
- new_subnet_arg="netmask $new_subnet_mask"
+ new_mask="/$new_subnet_mask"
fi
if [ -n "$alias_subnet_mask" ]; then
- alias_subnet_arg="netmask $alias_subnet_mask"
+ alias_mask="/$alias_subnet_mask"
fi
# The 576 MTU is only used for X.25 and dialup connections
# where the admin wants low latency. Such a low MTU can cause
# problems with UDP traffic, among other things. As such,
# disallow MTUs from 576 and below by default, so that broken
# MTUs are ignored, but higher stuff is allowed (1492, 1500, etc).
-if [ -n "$new_interface_mtu" ] && [ $new_interface_mtu -gt 576 ]; then
- mtu_arg="mtu $new_interface_mtu"
+if [ -z "$new_interface_mtu" ] || [ "$new_interface_mtu" -lt 576 ]; then
+ new_interface_mtu=''
fi
if [ -n "$IF_METRIC" ]; then
metric_arg="metric $IF_METRIC" # interfaces(5), "metric" option
@@ -175,107 +175,131 @@ case "$reason" in
# The DHCP client is requesting that an interface be
# configured as required in order to send packets prior to
# receiving an actual address. - dhclient-script(8)
+
+ # ensure interface is up
+ ip link set dev ${interface} up
+
if [ -n "$alias_ip_address" ]; then
- # Bring down alias interface. Its routes will disappear too.
- ifconfig $interface:0- inet 0
+ # flush alias IP from interface
+ ip -4 addr flush dev ${interface} label ${interface}:0
fi
- ifconfig $interface inet 0 up
-
;;
BOUND|RENEW|REBIND|REBOOT)
if [ -n "$old_host_name" ] && [ -n "$new_host_name" ] &&
[ "$old_host_name" != "$new_host_name" ]; then
+ # hostname changed => set it
hostname "$new_host_name"
fi
if [ -n "$old_ip_address" ] && [ -n "$alias_ip_address" ] &&
[ "$alias_ip_address" != "$old_ip_address" ]; then
- # Possible new alias. Remove old alias.
- ifconfig $interface:0- inet 0
+ # alias IP may have changed => flush it
+ ip -4 addr flush dev ${interface} label ${interface}:0
fi
if [ -n "$old_ip_address" ] &&
[ "$old_ip_address" != "$new_ip_address" ]; then
- # IP address changed. Bringing down the interface will delete all routes,
- # and clear the ARP cache.
- ifconfig $interface inet 0
+ # leased IP has changed => flush it
+ ip -4 addr flush dev ${interface} label ${interface}
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_arg \
- $new_broadcast_arg $mtu_arg
+ # new IP has been leased or leased IP changed => set it
+ ip -4 addr add ${new_ip_address}${new_mask} ${new_broadcast_arg} \
+ dev ${interface} label ${interface}
- # point to point
- if [ "$new_subnet_mask" = "255.255.255.255" ]; then
- for router in $new_routers; do
- route add -host $router dev $interface
- done
+ if [ -n "$new_interface_mtu" ]; then
+ # set MTU
+ ip link set dev ${interface} mtu ${new_interface_mtu}
fi
for router in $new_routers; do
- route add default dev $interface gw $router $metric_arg
+ if [ "$new_subnet_mask" = "255.255.255.255" ]; then
+ # point-to-point connection => set explicit route
+ ip -4 route add ${router} dev $interface >/dev/null 2>&1
+ fi
+
+ # set default route
+ ip -4 route add default via ${router} dev ${interface} \
+ ${metric_arg} >/dev/null 2>&1
done
fi
if [ -n "$alias_ip_address" ] &&
[ "$new_ip_address" != "$alias_ip_address" ]; then
- ifconfig $interface:0- inet 0
- ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
- route add -host $alias_ip_address $interface:0
+ # separate alias IP given, which may have changed
+ # => flush it, set it & add host route to it
+ ip -4 addr flush dev ${interface} label ${interface}:0
+ ip -4 addr add ${alias_ip_address}${alias_mask} \
+ dev ${interface} label ${interface}:0
+ ip -4 route add ${alias_ip_address} dev ${interface} >/dev/null 2>&1
fi
+ # update /etc/resolv.conf
make_resolv_conf
;;
EXPIRE|FAIL|RELEASE|STOP)
if [ -n "$alias_ip_address" ]; then
- # Turn off alias interface.
- ifconfig $interface:0- inet 0
+ # flush alias IP
+ ip -4 addr flush dev ${interface} label ${interface}:0
fi
if [ -n "$old_ip_address" ]; then
- # Shut down interface, which will delete routes and clear arp cache.
- ifconfig $interface inet 0
+ # flush leased IP
+ ip -4 addr flush dev ${interface} label ${interface}
fi
if [ -n "$alias_ip_address" ]; then
- ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
- route add -host $alias_ip_address $interface:0
+ # alias IP given => set it & add host route to it
+ ip -4 addr add ${alias_ip_address}${alias_network_arg} \
+ dev ${interface} label ${interface}:0
+ ip -4 route add ${alias_ip_address} dev ${interface} >/dev/null 2>&1
fi
;;
TIMEOUT)
if [ -n "$alias_ip_address" ]; then
- ifconfig $interface:0- inet 0
+ # flush alias IP
+ ip -4 addr flush dev ${interface} label ${interface}:0
fi
- ifconfig $interface inet $new_ip_address $new_subnet_arg \
- $new_broadcast_arg $mtu_arg
+ # set IP from recorded lease
+ ip -4 addr add ${new_ip_address}${new_mask} ${new_broadcast_arg} \
+ dev ${interface} label ${interface}
- set -- $new_routers
- first_router="$1"
+ if [ -n "$new_interface_mtu" ]; then
+ # set MTU
+ ip link set dev ${interface} mtu ${new_interface_mtu}
+ fi
- if [ -z "$first_router" ] || ping -q -c 1 $first_router; then
+ # if there is no router recorded in the lease or the 1st router answers pings
+ if [ -z "$new_routers" ] || ping -q -c 1 "${new_routers%% *}"; then
if [ -n "$alias_ip_address" ] &&
[ "$new_ip_address" != "$alias_ip_address" ]; then
- ifconfig $interface:0 inet $alias_ip_address $alias_subnet_arg
- route add -host $alias_ip_address dev $interface:0
+ # separate alias IP given => set up the alias IP & add host route to it
+ ip -4 addr add ${alias_ip_address}${alias_mask} \
+ dev ${interface} label ${interface}:0
+ ip -4 route add ${alias_ip_address} dev ${interface} >/dev/null 2>&1
fi
+ # set default route
for router in $new_routers; do
- route add default dev $interface gw $router $metric_arg
+ ip -4 route add default via ${router} dev ${interface} \
+ ${metric_arg} >/dev/null 2>&1
done
+ # update /etc/resolv.conf
make_resolv_conf
else
- # Changed from 'ifconfig $interface inet 0 down' - see Debian bug #144666
- ifconfig $interface inet 0
+ # flush all IPs from interface
+ ip -4 addr flush dev ${interface}
exit_with_hooks 2 "$@"
fi
--
ISC DHCP packaging for Debian
More information about the pkg-dhcp-commits
mailing list