Blame SOURCES/0370-network-dhclient-script.sh-add-classless-static-rout.patch

712866
From a48ea27debb926a30810c9f1a42f096494c727e2 Mon Sep 17 00:00:00 2001
712866
From: Harald Hoyer <harald@redhat.com>
712866
Date: Mon, 29 Feb 2016 14:52:16 +0100
712866
Subject: [PATCH] network/dhclient-script.sh: add classless-static-routes
712866
 support
712866
712866
https://bugzilla.redhat.com/show_bug.cgi?id=1260955
712866
---
712866
 modules.d/40network/dhclient-script.sh | 48 ++++++++++++++++++++++++++++++++++
712866
 modules.d/40network/dhclient.conf      |  5 +++-
712866
 2 files changed, 52 insertions(+), 1 deletion(-)
712866
712866
diff --git a/modules.d/40network/dhclient-script.sh b/modules.d/40network/dhclient-script.sh
5c6c2a
index 6d4b9dd1..95538585 100755
712866
--- a/modules.d/40network/dhclient-script.sh
712866
+++ b/modules.d/40network/dhclient-script.sh
712866
@@ -95,6 +95,51 @@ setup_interface6() {
712866
     [ -n "$hostname" ] && echo "echo ${hostname%.$domain}${domain:+.$domain} > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
712866
 }
712866
 
712866
+function parse_option_121() {
712866
+    while [ $# -ne 0 ]; do
712866
+        mask="$1"
712866
+        shift
712866
+
712866
+        # Is the destination a multicast group?
712866
+        if [ $1 -ge 224 -a $1 -lt 240 ]; then
712866
+            multicast=1
712866
+        else
712866
+            multicast=0
712866
+        fi
712866
+
712866
+        # Parse the arguments into a CIDR net/mask string
712866
+        if [ $mask -gt 24 ]; then
712866
+            destination="$1.$2.$3.$4/$mask"
712866
+            shift; shift; shift; shift
712866
+        elif [ $mask -gt 16 ]; then
712866
+            destination="$1.$2.$3.0/$mask"
712866
+            shift; shift; shift
712866
+        elif [ $mask -gt 8 ]; then
712866
+            destination="$1.$2.0.0/$mask"
712866
+            shift; shift
712866
+        else
712866
+            destination="$1.0.0.0/$mask"
712866
+            shift
712866
+        fi
712866
+
712866
+        # Read the gateway
712866
+        gateway="$1.$2.$3.$4"
712866
+        shift; shift; shift; shift
712866
+
712866
+        # Multicast routing on Linux
712866
+        #  - If you set a next-hop address for a multicast group, this breaks with Cisco switches
712866
+        #  - If you simply leave it link-local and attach it to an interface, it works fine.
712866
+        if [ $multicast -eq 1 ]; then
712866
+            temp_result="$destination dev $interface"
712866
+        else
712866
+            temp_result="$destination via $gateway dev $interface"
712866
+        fi
712866
+
712866
+        echo "/sbin/ip route add $temp_result"
712866
+    done
712866
+}
712866
+
712866
+
712866
 case $reason in
712866
     PREINIT)
712866
         echo "dhcp: PREINIT $netif up"
712866
@@ -129,6 +174,9 @@ case $reason in
712866
         {
712866
             echo '. /lib/net-lib.sh'
712866
             echo "setup_net $netif"
712866
+            if [ -n "$new_classless_static_routes" ]; then
712866
+                modify_routes add "$(parse_option_121 $new_classless_static_routes)"
712866
+            fi
712866
             echo "source_hook initqueue/online $netif"
712866
             [ -e /tmp/net.$netif.manualup ] || echo "/sbin/netroot $netif"
712866
             echo "rm -f -- $hookdir/initqueue/setup_net_$netif.sh"
712866
diff --git a/modules.d/40network/dhclient.conf b/modules.d/40network/dhclient.conf
5c6c2a
index dbf58821..7b067632 100644
712866
--- a/modules.d/40network/dhclient.conf
712866
+++ b/modules.d/40network/dhclient.conf
712866
@@ -1,3 +1,6 @@
712866
+
712866
+option classless-routes code 121 = array of unsigned integer 8;
712866
+
712866
 request subnet-mask, broadcast-address, time-offset, routers,
712866
         domain-name, domain-name-servers, domain-search, host-name,
712866
-        root-path, interface-mtu;
712866
+        root-path, interface-mtu classless-routes;