[dhcp] dhclient-script: address alias fixes (#741786)

Jiří Popelka jpopelka at fedoraproject.org
Thu Sep 29 12:31:36 UTC 2011


commit 5c5bbc0b1aab91b1a9d3b0e6da7c691f6c1a2e02
Author: Jiri Popelka <jpopelka at redhat.com>
Date:   Thu Sep 29 14:18:16 2011 +0200

    dhclient-script: address alias fixes (#741786)

 dhclient-script |   23 ++++++++++++-----------
 dhcp.spec       |    5 ++++-
 2 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/dhclient-script b/dhclient-script
index 6eb3d74..7762524 100644
--- a/dhclient-script
+++ b/dhclient-script
@@ -333,7 +333,7 @@ dhconfig() {
     if [ -n "${old_ip_address}" ] && [ -n "${alias_ip_address}" ] &&
        [ ! "${alias_ip_address}" = "${old_ip_address}" ]; then
         # possible new alias, remove old alias first
-        ip -4 addr del ${old_ip_address} dev ${interface}:0
+        ip -4 addr del ${old_ip_address} dev ${interface} label ${interface}:0
     fi
 
     if [ -n "${old_ip_address}" ] &&
@@ -479,9 +479,10 @@ dhconfig() {
 
     if [ ! "${new_ip_address}" = "${alias_ip_address}" ] &&
        [ -n "${alias_ip_address}" ]; then
-        ip -4 addr flush dev ${interface}:0 >/dev/null 2>&1
-        ip -4 addr add ${alias_ip_address}/${alias_prefix} dev ${interface}:0
-        ip -4 route replace ${alias_ip_address}/32 dev ${interface}:0
+        # 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 add ${alias_ip_address}/${alias_prefix} broadcast ${alias_broadcast_address} dev ${interface} label ${interface}:0
+        ip -4 route replace ${alias_ip_address}/32 dev ${interface}
     fi
 
     make_resolv_conf
@@ -648,8 +649,8 @@ case "${reason}" in
 
     PREINIT)
         if [ -n "${alias_ip_address}" ]; then
-            # Bring down alias interface, its routes will disappear too.
-            ip link set ${interface}:0 down
+            # Flush alias, its routes will disappear too.
+            ip -4 addr flush dev ${interface} label ${interface}:0 >/dev/null 2>&1
         fi
 
         if [ "${keep_old_ip}" = "yes" ]; then
@@ -724,8 +725,8 @@ case "${reason}" in
         fi
 
         if [ -n "${alias_ip_address}" ]; then
-            # Turn off alias interface
-            ip link set ${interface}:0 down
+            # Flush alias
+            ip -4 addr flush dev ${interface} label ${interface}:0 >/dev/null 2>&1
         fi
 
         if [ -n "${old_ip_address}" ]; then
@@ -734,8 +735,8 @@ case "${reason}" in
         fi
 
         if [ -n "${alias_ip_address}" ]; then
-            ip -4 addr add ${alias_ip_address}/${alias_prefix} dev ${interface}:0
-            ip -4 route replace ${alias_ip_address}/32 ${interface}:0
+            ip -4 addr add ${alias_ip_address}/${alias_prefix} broadcast ${alias_broadcast_address} dev ${interface} label ${interface}:0
+            ip -4 route replace ${alias_ip_address}/32 dev ${interface}
         fi
 
         exit_with_hooks 0
@@ -744,7 +745,7 @@ case "${reason}" in
     TIMEOUT)
         if [ -n "${new_routers}" ]; then
             if [ -n "${alias_ip_address}" ]; then
-                ip -4 addr flush dev ${interface}:0 >/dev/null 2>&1
+                ip -4 addr flush dev ${interface} label ${interface}:0 >/dev/null 2>&1
             fi
 
             ip -4 addr add ${new_ip_address}/${new_prefix} broadcast ${new_broadcast_address} dev ${interface}
diff --git a/dhcp.spec b/dhcp.spec
index 09e764f..e9b810b 100644
--- a/dhcp.spec
+++ b/dhcp.spec
@@ -19,7 +19,7 @@
 Summary:  Dynamic host configuration protocol software
 Name:     dhcp
 Version:  4.2.2
-Release:  9%{?dist}
+Release:  10%{?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.
@@ -657,6 +657,9 @@ fi
 %{_initddir}/dhcrelay
 
 %changelog
+* Thu Sep 29 2011 Jiri Popelka <jpopelka at redhat.com> - 12:4.2.2-10
+- dhclient-script: address alias handling fixes from Scott Shambarger (#741786)
+
 * Thu Sep 22 2011 Jiri Popelka <jpopelka at redhat.com> - 12:4.2.2-9
 - dhclient-script: do not backup&restore /etc/resolv.conf and /etc/localtime.
 


More information about the scm-commits mailing list