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

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