[dhcp] RFC 3442 - improved dhclient-script

Jiří Popelka jpopelka at fedoraproject.org
Mon Oct 4 09:56:51 UTC 2010


commit 2560aa7e3c520ea5c2efbcee9cc8ef039a321447
Author: Jiri Popelka <jpopelka at redhat.com>
Date:   Mon Oct 4 11:51:33 2010 +0200

    RFC 3442 - improved dhclient-script

 dhclient-script |   39 +++++++++++++++++++++------------------
 dhcp.spec       |    6 +++++-
 2 files changed, 26 insertions(+), 19 deletions(-)
---
diff --git a/dhclient-script b/dhclient-script
index 1cd4ee0..3f22696 100755
--- a/dhclient-script
+++ b/dhclient-script
@@ -307,10 +307,6 @@ dhconfig() {
            [ -n "${new_static_routes}" ]; then
             if [ -n "${new_classless_static_routes}" ]; then
                 IFS=', |' static_routes=(${new_classless_static_routes})
-
-                # If the DHCP server returns both a Classless Static Routes option and
-                # a Router option, the DHCP client MUST ignore the Router option. (RFC3442)
-                new_routers=""
             else
                 IFS=', |' static_routes=(${new_static_routes})
             fi
@@ -319,19 +315,26 @@ dhconfig() {
             for((i=0; i<${#static_routes[@]}; i+=2)); do
                 target=${static_routes[$i]}
                 if [ -n "${new_classless_static_routes}" ]; then
-                    prefix=$(echo ${target} | cut -d "." -f 1)
-                    target=$(echo ${target} | cut -d "." -f 2-)
-                    IFS="." target_arr=(${target})
-                    unset IFS
-                    ((pads=4-${#target_arr[@]}))
-                    for j in $(seq $pads); do
-                        target=${target}".0"
-                    done
-
-                    # Client MUST zero any bits in the subnet number where the corresponding bit in the mask is zero.
-                    # In other words, the subnet number installed in the routing table is the logical AND of
-                    # the subnet number and subnet mask given in the Classless Static Routes option. (RFC3442)
-                    target="$(get_network_address ${target} ${prefix})"
+                    if [ ${target} = "0" ]; then
+                        # If the DHCP server returns both a Classless Static Routes option and
+                        # a Router option, the DHCP client MUST ignore the Router option. (RFC3442)
+                        new_routers=""
+                        prefix="0"
+                    else
+                        prefix=$(echo ${target} | cut -d "." -f 1)
+                        target=$(echo ${target} | cut -d "." -f 2-)
+                        IFS="." target_arr=(${target})
+                        unset IFS
+                        ((pads=4-${#target_arr[@]}))
+                        for j in $(seq $pads); do
+                            target=${target}".0"
+                        done
+
+                        # Client MUST zero any bits in the subnet number where the corresponding bit in the mask is zero.
+                        # In other words, the subnet number installed in the routing table is the logical AND of
+                        # the subnet number and subnet mask given in the Classless Static Routes option. (RFC3442)
+                        target="$(get_network_address ${target} ${prefix})"
+                    fi
                 else
                     prefix=$(class_bits ${target})
                 fi
@@ -353,7 +356,7 @@ dhconfig() {
                 fi
 
                 if is_router_reachable ${gateway}; then
-                    ip -4 route replace ${target}/${prefix} via ${gateway} dev ${interface} ${metric}
+                    ip -4 route replace ${target}/${prefix} proto static via ${gateway} dev ${interface} ${metric}
 
                     if [ $? -ne 0 ]; then
                         logmessage "failed to create static route: ${target}/${prefix} via ${gateway} dev ${interface} ${metric}"
diff --git a/dhcp.spec b/dhcp.spec
index 4a9d798..2447364 100644
--- a/dhcp.spec
+++ b/dhcp.spec
@@ -7,7 +7,7 @@
 Summary:  Dynamic host configuration protocol software
 Name:     dhcp
 Version:  4.2.0
-Release:  8%{?dist}
+Release:  9%{?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.
@@ -515,6 +515,10 @@ fi
 %attr(0644,root,root) %{_mandir}/man3/omapi.3.gz
 
 %changelog
+* Mon Oct 04 2010 Jiri Popelka <jpopelka at redhat.com> - 12:4.2.0-9
+- RFC 3442 - ignore Router option only if
+  Classless Static Routes option contains default router
+
 * Thu Sep 30 2010 Jiri Popelka <jpopelka at redhat.com> - 12:4.2.0-8
 - Explicitly clear the ARP cache and flush all addresses & routes
   instead of bringing the interface down (#574568)


More information about the scm-commits mailing list