- In dhclient-script:

- use ip command options '-4' or '-6' as shortcuts for '-f[amily] inet'
    resp. '-f[amily] inet6'
- do not use IP protocol family identifier with 'ip link'
This commit is contained in:
Jiří Popelka 2010-02-19 11:37:25 +00:00
parent 197cc48745
commit 5ec8ece1f2
2 changed files with 36 additions and 31 deletions

View File

@ -3,7 +3,7 @@
# dhclient-script: Network interface configuration script run by # dhclient-script: Network interface configuration script run by
# dhclient based on DHCP client communication # dhclient based on DHCP client communication
# #
# Copyright (C) 2008, 2009 Red Hat, Inc. # Copyright (C) 2008, 2009, 2010 Red Hat, Inc.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -202,7 +202,7 @@ is_router_reachable() {
if [ ! "${routersubnet}" = "${mysubnet}" ]; then if [ ! "${routersubnet}" = "${mysubnet}" ]; then
unreachable=1 unreachable=1
if arping -f -q -I ${interface} -w2 ${router}; then if arping -f -q -I ${interface} -w2 ${router}; then
ip route add ${router}/32 dev ${interface} ip -4 route add ${router}/32 dev ${interface}
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
unreachable=0 unreachable=0
else else
@ -226,7 +226,7 @@ add_default_gateway() {
fi fi
if is_router_reachable ${router} ; then if is_router_reachable ${router} ; then
ip route replace default via ${router} dev ${interface} ${metric} ip -4 route replace default via ${router} dev ${interface} ${metric}
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
logmessage "failed to create default route: ${router} dev ${interface} ${metric}" logmessage "failed to create default route: ${router} dev ${interface} ${metric}"
return 1 return 1
@ -242,14 +242,14 @@ dhconfig() {
if [ -n "${old_ip_address}" ] && [ -n "${alias_ip_address}" ] && if [ -n "${old_ip_address}" ] && [ -n "${alias_ip_address}" ] &&
[ ! "${alias_ip_address}" = "${old_ip_address}" ]; then [ ! "${alias_ip_address}" = "${old_ip_address}" ]; then
# possible new alias, remove old alias first # possible new alias, remove old alias first
ip -family inet addr del ${old_ip_address} dev ${interface}:0 ip -4 addr del ${old_ip_address} dev ${interface}:0
fi fi
if [ -n "${old_ip_address}" ] && if [ -n "${old_ip_address}" ] &&
[ ! "${old_ip_address}" = "${new_ip_address}" ]; then [ ! "${old_ip_address}" = "${new_ip_address}" ]; then
# IP address changed. Bringing down the interface will delete all # IP address changed. Bringing down the interface will delete all
# routes, and clear the ARP cache. # routes, and clear the ARP cache.
ip -family inet addr flush dev ${interface} >/dev/null 2>&1 ip -4 addr flush dev ${interface} >/dev/null 2>&1
fi fi
if [ "${reason}" = "BOUND" ] || [ "${reason}" = "REBOOT" ] || if [ "${reason}" = "BOUND" ] || [ "${reason}" = "REBOOT" ] ||
@ -259,8 +259,8 @@ dhconfig() {
[ ! "${old_broadcast_address}" = "${new_broadcast_address}" ] || [ ! "${old_broadcast_address}" = "${new_broadcast_address}" ] ||
[ ! "${old_routers}" = "${new_routers}" ] || [ ! "${old_routers}" = "${new_routers}" ] ||
[ ! "${old_interface_mtu}" = "${new_interface_mtu}" ]; then [ ! "${old_interface_mtu}" = "${new_interface_mtu}" ]; then
ip -family inet addr add ${new_ip_address}/${new_prefix} broadcast ${new_broadcast_address} dev ${interface} ip -4 addr add ${new_ip_address}/${new_prefix} broadcast ${new_broadcast_address} dev ${interface}
ip -family inet link set dev ${interface} up ip link set dev ${interface} up
if [ -n "${new_interface_mtu}" ]; then if [ -n "${new_interface_mtu}" ]; then
ip link set ${interface} mtu ${new_interface_mtu} ip link set ${interface} mtu ${new_interface_mtu}
@ -309,7 +309,7 @@ dhconfig() {
mysubnet=$(mask ${new_ip_address} ${new_subnet_mask}) mysubnet=$(mask ${new_ip_address} ${new_subnet_mask})
if [ "${routersubnet}" = "${mysubnet}" ]; then if [ "${routersubnet}" = "${mysubnet}" ]; then
ip route replace default via ${GATEWAY} dev ${interface} ip -4 route replace default via ${GATEWAY} dev ${interface}
fi fi
fi fi
fi fi
@ -339,7 +339,7 @@ dhconfig() {
fi fi
if is_router_reachable ${gateway}; then if is_router_reachable ${gateway}; then
ip route replace ${target}/$(class_bits ${target}) via ${gateway} dev ${interface} ${metric} ip -4 route replace ${target}/$(class_bits ${target}) via ${gateway} dev ${interface} ${metric}
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
logmessage "failed to create static route: ${target}/$(class_bits ${target}) via ${gateway} dev ${interface} ${metric}" logmessage "failed to create static route: ${target}/$(class_bits ${target}) via ${gateway} dev ${interface} ${metric}"
@ -353,9 +353,9 @@ dhconfig() {
if [ ! "${new_ip_address}" = "${alias_ip_address}" ] && if [ ! "${new_ip_address}" = "${alias_ip_address}" ] &&
[ -n "${alias_ip_address}" ]; then [ -n "${alias_ip_address}" ]; then
ip -family inet addr flush dev ${interface}:0 >/dev/null 2>&1 ip -4 addr flush dev ${interface}:0 >/dev/null 2>&1
ip -family inet addr add ${alias_ip_address}/${alias_prefix} dev ${interface}:0 ip -4 addr add ${alias_ip_address}/${alias_prefix} dev ${interface}:0
ip route replace ${alias_ip_address}/32 dev ${interface}:0 ip -4 route replace ${alias_ip_address}/32 dev ${interface}:0
fi fi
make_resolv_conf make_resolv_conf
@ -410,7 +410,7 @@ dh6config() {
exit_with_hooks 2 exit_with_hooks 2
fi fi
ip -f inet6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \ ip -6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \
dev ${interface} scope global dev ${interface} scope global
make_resolv_conf make_resolv_conf
;; ;;
@ -427,7 +427,7 @@ dh6config() {
exit_with_hooks 2 exit_with_hooks 2
fi fi
ip -f inet6 addr change ${new_ip6_address}/${new_ip6_prefixlen} \ ip -6 addr change ${new_ip6_address}/${new_ip6_prefixlen} \
dev ${interface} scope global preferred_lft 0 dev ${interface} scope global preferred_lft 0
;; ;;
esac esac
@ -497,7 +497,7 @@ need_config ${CONFIG}
source_config >/dev/null 2>&1 source_config >/dev/null 2>&1
new_prefix="$(get_prefix ${new_ip_address} ${new_subnet_mask})" new_prefix="$(get_prefix ${new_ip_address} ${new_subnet_mask})"
old_prefix="$(get_prefix ${old_ip_address} ${new_subnet_mask})" old_prefix="$(get_prefix ${old_ip_address} ${old_subnet_mask})"
alias_prefix="$(get_prefix ${alias_ip_address} ${alias_subnet_mask})" alias_prefix="$(get_prefix ${alias_ip_address} ${alias_subnet_mask})"
case "${reason}" in case "${reason}" in
@ -509,14 +509,14 @@ case "${reason}" in
PREINIT) PREINIT)
if [ -n "${alias_ip_address}" ]; then if [ -n "${alias_ip_address}" ]; then
# Bring down alias interface, its routes will disappear too. # Bring down alias interface, its routes will disappear too.
ip -family inet link set ${interface}:0 down ip link set ${interface}:0 down
fi fi
if [ "${keep_old_ip}" = "yes" ]; then if [ "${keep_old_ip}" = "yes" ]; then
ip -family inet link set ${interface} up ip link set ${interface} up
else else
ip -family inet addr flush dev ${interface} >/dev/null 2>&1 ip -4 addr flush dev ${interface} >/dev/null 2>&1
ip -family inet link set ${interface} up ip link set ${interface} up
fi fi
if [ -n "${DHCLIENT_DELAY}" ] && [ ${DHCLIENT_DELAY} -gt 0 ]; then if [ -n "${DHCLIENT_DELAY}" ] && [ ${DHCLIENT_DELAY} -gt 0 ]; then
@ -531,7 +531,7 @@ case "${reason}" in
ip link set ${interface} up ip link set ${interface} up
# remove any stale addresses from aborted clients # remove any stale addresses from aborted clients
ip -f inet6 addr flush dev ${interface} scope global permanent ip -6 addr flush dev ${interface} scope global permanent
exit_with_hooks 0 exit_with_hooks 0
;; ;;
@ -560,7 +560,7 @@ case "${reason}" in
exit_with_hooks 2 exit_with_hooks 2
fi fi
ip -f inet6 addr del ${old_ip6_address}/${old_ip6_prefixlen} \ ip -6 addr del ${old_ip6_address}/${old_ip6_prefixlen} \
dev ${interface} dev ${interface}
# execute any additional client side configuration scripts we have # execute any additional client side configuration scripts we have
@ -627,18 +627,18 @@ case "${reason}" in
if [ -n "${alias_ip_address}" ]; then if [ -n "${alias_ip_address}" ]; then
# Turn off alias interface # Turn off alias interface
ip -family inet link set ${interface}:0 down ip link set ${interface}:0 down
fi fi
if [ -n "${old_ip_address}" ]; then if [ -n "${old_ip_address}" ]; then
# Shut down interface, which will delete routes and clear arp cache. # Shut down interface, which will delete routes and clear arp cache.
ip -family inet addr flush dev ${interface} >/dev/null 2>&1 ip -4 addr flush dev ${interface} >/dev/null 2>&1
ip -family inet link set ${interface} down ip link set ${interface} down
fi fi
if [ -n "${alias_ip_address}" ]; then if [ -n "${alias_ip_address}" ]; then
ip -family inet addr add ${alias_ip_address}/${alias_prefix} dev ${interface}:0 ip -4 addr add ${alias_ip_address}/${alias_prefix} dev ${interface}:0
ip -family inet route replace ${alias_ip_address}/32 ${interface}:0 ip -4 route replace ${alias_ip_address}/32 ${interface}:0
fi fi
exit_with_hooks 0 exit_with_hooks 0
@ -647,10 +647,10 @@ case "${reason}" in
TIMEOUT) TIMEOUT)
if [ -n "${new_routers}" ]; then if [ -n "${new_routers}" ]; then
if [ -n "${alias_ip_address}" ]; then if [ -n "${alias_ip_address}" ]; then
ip -family inet addr flush dev ${interface}:0 >/dev/null 2>&1 ip -4 addr flush dev ${interface}:0 >/dev/null 2>&1
fi fi
ip -family inet addr add ${new_ip_address}/${new_prefix} broadcast ${new_broadcast_address} dev ${interface} ip -4 addr add ${new_ip_address}/${new_prefix} broadcast ${new_broadcast_address} dev ${interface}
set ${new_routers} set ${new_routers}
if ping -q -c 1 -w 10 -I ${interface} ${1}; then if ping -q -c 1 -w 10 -I ${interface} ${1}; then
@ -658,8 +658,8 @@ case "${reason}" in
exit_with_hooks 0 exit_with_hooks 0
fi fi
ip -family inet addr flush dev ${interface} >/dev/null 2>&1 ip -4 addr flush dev ${interface} >/dev/null 2>&1
ip -family inet link set ${interface} down ip link set ${interface} down
exit_with_hooks 1 exit_with_hooks 1
else else
exit_with_hooks 1 exit_with_hooks 1

View File

@ -13,7 +13,7 @@
Summary: Dynamic host configuration protocol software Summary: Dynamic host configuration protocol software
Name: dhcp Name: dhcp
Version: %{basever} Version: %{basever}
Release: 8%{?dist} Release: 9%{?dist}
# NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to # NEVER CHANGE THE EPOCH on this package. The previous maintainer (prior to
# dcantrell maintaining the package) made incorrect use of the epoch and # dcantrell maintaining the package) made incorrect use of the epoch and
# that's why it is at 12 now. It should have never been used, but it was. # that's why it is at 12 now. It should have never been used, but it was.
@ -500,6 +500,11 @@ fi
%attr(0644,root,root) %{_mandir}/man3/omapi.3.gz %attr(0644,root,root) %{_mandir}/man3/omapi.3.gz
%changelog %changelog
* Fri Feb 19 2010 Jiri Popelka <jpopelka@redhat.com> - 12:4.1.1-9
- In dhclient-script:
- use ip command options '-4' or '-6' as shortcuts for '-f[amily] inet' resp. '-f[amily] inet6'
- do not use IP protocol family identifier with 'ip link'
* Thu Feb 18 2010 Jiri Popelka <jpopelka@redhat.com> - 12:4.1.1-8 * Thu Feb 18 2010 Jiri Popelka <jpopelka@redhat.com> - 12:4.1.1-8
- Fix installation of pm-utils script (#479639, c#16) - Fix installation of pm-utils script (#479639, c#16)