You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

90 lines
3.2 KiB

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