dhclient-script: don't flush all addresses, just the used one

This commit is contained in:
Jiri Popelka 2014-02-19 18:02:20 +01:00
parent 7caf8ab713
commit d80cfcbfe3
2 changed files with 24 additions and 9 deletions

View File

@ -320,12 +320,22 @@ execute_client_side_configuration_scripts() {
flush_dev() { flush_dev() {
# Instead of bringing the interface down (#574568) # Instead of bringing the interface down (#574568)
# explicitly clear the ARP cache and flush all addresses & routes. # explicitly clear ARP cache and flush all addresses & routes.
ip -4 addr flush dev ${1} >/dev/null 2>&1 ip -4 addr flush dev ${1} >/dev/null 2>&1
ip -4 route flush dev ${1} >/dev/null 2>&1 ip -4 route flush dev ${1} >/dev/null 2>&1
ip -4 neigh flush dev ${1} >/dev/null 2>&1 ip -4 neigh flush dev ${1} >/dev/null 2>&1
} }
remove_old_addr() {
if [ -n "${old_ip_address}" ]; then
if [ -n "${old_prefix}" ]; then
ip -4 addr del ${old_ip_address}/${old_prefix} dev ${interface} >/dev/null 2>&1
else
ip -4 addr del ${old_ip_address} dev ${interface} >/dev/null 2>&1
fi
fi
}
dhconfig() { 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
@ -695,8 +705,9 @@ case "${reason}" in
# ensure interface is up # ensure interface is up
ip link set dev ${interface} up ip link set dev ${interface} up
# remove any stale addresses from aborted clients # aborted client cleans after itself since 4.2.6
ip -6 addr flush dev ${interface} scope global permanent # so the following is not needed anymore
#ip -6 addr flush dev ${interface} scope global permanent
exit_with_hooks 0 exit_with_hooks 0
;; ;;
@ -752,10 +763,10 @@ case "${reason}" in
ip -4 addr flush dev ${interface} label ${interface}:0 >/dev/null 2>&1 ip -4 addr flush dev ${interface} label ${interface}:0 >/dev/null 2>&1
fi fi
if [ -n "${old_ip_address}" ]; then # upstream script sets interface down here,
# Delete addresses/routes/arp cache. # we only remove old ip address
flush_dev ${interface} #flush_dev ${interface}
fi remove_old_addr
if [ -n "${alias_ip_address}" ]; then if [ -n "${alias_ip_address}" ]; then
ip -4 addr add ${alias_ip_address}/${alias_prefix} broadcast ${alias_broadcast_address} dev ${interface} label ${interface}:0 ip -4 addr add ${alias_ip_address}/${alias_prefix} broadcast ${alias_broadcast_address} dev ${interface} label ${interface}:0
@ -781,7 +792,8 @@ case "${reason}" in
exit_with_hooks 0 exit_with_hooks 0
fi fi
flush_dev ${interface} #flush_dev ${interface}
remove_old_addr
exit_with_hooks 1 exit_with_hooks 1
else else
exit_with_hooks 1 exit_with_hooks 1

View File

@ -18,7 +18,7 @@
Summary: Dynamic host configuration protocol software Summary: Dynamic host configuration protocol software
Name: dhcp Name: dhcp
Version: 4.3.0 Version: 4.3.0
Release: 4%{?dist} Release: 5%{?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.
@ -603,6 +603,9 @@ done
%changelog %changelog
* Wed Feb 19 2014 Jiri Popelka <jpopelka@redhat.com> - 12:4.3.0-5
- dhclient-script: don't flush all addresses, just the used one
* Tue Feb 18 2014 Jiri Popelka <jpopelka@redhat.com> - 12:4.3.0-4 * Tue Feb 18 2014 Jiri Popelka <jpopelka@redhat.com> - 12:4.3.0-4
- IPoIB: add GUID/DUID to dhcpd logs (#1064416) - IPoIB: add GUID/DUID to dhcpd logs (#1064416)