dhclient-script: s/addr add/addr replace/

It might happen that the address is already there,
in which case we want to update life-times.
BZ#1187856#c15

ip addr add =     NLM_F_CREATE|NLM_F_EXCL
ip addr replace = NLM_F_CREATE|NLM_F_REPLACE
ip addr change =  NLM_F_REPLACE

from linux/netlink.h
NLM_F_REPLACE   0x100   /* Override existing            */
NLM_F_EXCL      0x200   /* Do not touch, if it exists   */
NLM_F_CREATE    0x400   /* Create, if it does not exist */
This commit is contained in:
Jiri Popelka 2015-02-13 19:49:39 +01:00
parent 3fbee316e3
commit e79843f283
2 changed files with 9 additions and 6 deletions

View File

@ -347,7 +347,7 @@ 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 -4 addr add ${new_ip_address}/${new_prefix} broadcast ${new_broadcast_address} dev ${interface} \ ip -4 addr replace ${new_ip_address}/${new_prefix} broadcast ${new_broadcast_address} dev ${interface} \
valid_lft ${new_dhcp_lease_time} preferred_lft ${new_dhcp_lease_time} >/dev/null 2>&1 valid_lft ${new_dhcp_lease_time} preferred_lft ${new_dhcp_lease_time} >/dev/null 2>&1
ip link set dev ${interface} up ip link set dev ${interface} up
@ -485,7 +485,7 @@ dhconfig() {
[ -n "${alias_ip_address}" ]; then [ -n "${alias_ip_address}" ]; then
# Reset the alias address (fix: this should really only do this on changes) # Reset the alias address (fix: this should really only do this on changes)
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
ip -4 addr add ${alias_ip_address}/${alias_prefix} broadcast ${alias_broadcast_address} dev ${interface} label ${interface}:0 ip -4 addr replace ${alias_ip_address}/${alias_prefix} broadcast ${alias_broadcast_address} dev ${interface} label ${interface}:0
ip -4 route replace ${alias_ip_address}/32 dev ${interface} ip -4 route replace ${alias_ip_address}/32 dev ${interface}
fi fi
@ -541,7 +541,7 @@ dhconfig() {
# the addresses in any IAs it receives in the Reply message before # the addresses in any IAs it receives in the Reply message before
# using that address for traffic. # using that address for traffic.
add_ipv6_addr_with_DAD() { add_ipv6_addr_with_DAD() {
ip -6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \ ip -6 addr replace ${new_ip6_address}/${new_ip6_prefixlen} \
dev ${interface} scope global valid_lft ${new_max_life} \ dev ${interface} scope global valid_lft ${new_max_life} \
preferred_lft ${new_preferred_life} preferred_lft ${new_preferred_life}
@ -780,7 +780,7 @@ case "${reason}" in
remove_old_addr 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 replace ${alias_ip_address}/${alias_prefix} broadcast ${alias_broadcast_address} dev ${interface} label ${interface}:0
ip -4 route replace ${alias_ip_address}/32 dev ${interface} ip -4 route replace ${alias_ip_address}/32 dev ${interface}
fi fi
@ -793,7 +793,7 @@ 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
ip -4 addr add ${new_ip_address}/${new_prefix} \ ip -4 addr replace ${new_ip_address}/${new_prefix} \
broadcast ${new_broadcast_address} dev ${interface} \ broadcast ${new_broadcast_address} dev ${interface} \
valid_lft ${new_dhcp_lease_time} preferred_lft ${new_dhcp_lease_time} valid_lft ${new_dhcp_lease_time} preferred_lft ${new_dhcp_lease_time}
set ${new_routers} set ${new_routers}

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.2 Version: 4.3.2
Release: 0.1%{prever}%{?dist} Release: 0.2%{prever}%{?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.
@ -657,6 +657,9 @@ done
%doc doc/html/ %doc doc/html/
%changelog %changelog
* Fri Feb 13 2015 Jiri Popelka <jpopelka@redhat.com> - 12:4.3.2-0.2b1
- dhclient-script: s/addr add/addr replace/
* Sun Feb 08 2015 Jiri Popelka <jpopelka@redhat.com> - 12:4.3.2-0.1b1 * Sun Feb 08 2015 Jiri Popelka <jpopelka@redhat.com> - 12:4.3.2-0.1b1
- 4.3.2b1 - 4.3.2b1