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

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