[dhcp] dhclient-script: use 'ip addr replace' for both BOUND & RENEW

Jiří Popelka jpopelka at fedoraproject.org
Tue Feb 17 15:25:40 UTC 2015


commit 986801e117ab39dc5cc87982847e383c0ff0c5fb
Author: Jiri Popelka <jpopelka at redhat.com>
Date:   Tue Feb 17 16:22:24 2015 +0100

    dhclient-script: use 'ip addr replace' for both BOUND & RENEW
    
    amends e79843f28

 dhclient-script |   21 +++++++++------------
 dhcp.spec       |    5 ++++-
 2 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/dhclient-script b/dhclient-script
index 99d2dbb..17f5757 100644
--- a/dhclient-script
+++ b/dhclient-script
@@ -340,6 +340,13 @@ dhconfig() {
         flush_dev ${interface}
     fi
 
+    # make sure the interface is up
+    ip link set dev ${interface} up
+
+    # replace = add if it doesn't exist or override (update lifetimes) if it's there
+    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
+
     if [ "${reason}" = "BOUND" ] || [ "${reason}" = "REBOOT" ] ||
        [ ! "${old_ip_address}" = "${new_ip_address}" ] ||
        [ ! "${old_subnet_mask}" = "${new_subnet_mask}" ] ||
@@ -347,9 +354,6 @@ dhconfig() {
        [ ! "${old_broadcast_address}" = "${new_broadcast_address}" ] ||
        [ ! "${old_routers}" = "${new_routers}" ] ||
        [ ! "${old_interface_mtu}" = "${new_interface_mtu}" ]; then
-        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
-        ip link set dev ${interface} up
 
         # The 576 MTU is only used for X.25 and dialup connections
         # where the admin wants low latency.  Such a low MTU can cause
@@ -475,10 +479,6 @@ dhconfig() {
                 fi
             fi
         fi
-
-    else # RENEW||REBIND - only update address lifetimes
-        ip -4 addr change ${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
     fi
 
     if [ ! "${new_ip_address}" = "${alias_ip_address}" ] &&
@@ -600,12 +600,9 @@ dh6config() {
                [[ -n "${new_ip6_prefixlen}" ]]; then
                if [[  ! "${new_ip6_address}" = "${old_ip6_address}" ]]; then
                    [[ -n "${old_ip6_address}" ]] && ip -6 addr del ${old_ip6_address} dev ${interface}
-                   add_ipv6_addr_with_DAD
-               else # only update address lifetimes
-                   ip -6 addr change ${new_ip6_address}/${new_ip6_prefixlen} \
-                      dev ${interface} scope global valid_lft ${new_max_life} \
-                                                preferred_lft ${new_preferred_life}
                fi
+               # call it even if new_ip6_address = old_ip6_address to update lifetimes
+               add_ipv6_addr_with_DAD
             fi
 
             if [ ! "${new_dhcp6_name_servers}" = "${old_dhcp6_name_servers}" ] ||
diff --git a/dhcp.spec b/dhcp.spec
index 8779790..6b4933c 100644
--- a/dhcp.spec
+++ b/dhcp.spec
@@ -18,7 +18,7 @@
 Summary:  Dynamic host configuration protocol software
 Name:     dhcp
 Version:  4.3.2
-Release:  0.3%{prever}%{?dist}
+Release:  0.4%{prever}%{?dist}
 # NEVER CHANGE THE EPOCH on this package.  The previous maintainer (prior to
 # 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.
@@ -675,6 +675,9 @@ done
 %doc doc/html/
 
 %changelog
+* Tue Feb 17 2015 Jiri Popelka <jpopelka at redhat.com> - 12:4.3.2-0.4b1
+- dhclient-script: use 'ip addr replace' for both BOUND & RENEW
+
 * Tue Feb 17 2015 Jiri Popelka <jpopelka at redhat.com> - 12:4.3.2-0.3b1
 - doc/dhclient/dhclient-enter-hooks for dhclient-script debugging
 


More information about the scm-commits mailing list