Blame SOURCES/0281-Add-support-for-ethernet-point-to-point-connections-.patch

18971c
From 28be8992c3c1facfd80dfcc6afad951f33098783 Mon Sep 17 00:00:00 2001
18971c
From: Gerd von Egidy <gerd.von.egidy@intra2net.com>
18971c
Date: Thu, 5 Mar 2015 12:07:57 +0100
18971c
Subject: [PATCH] Add support for ethernet point-to-point connections
18971c
 configured via DHCP
18971c
18971c
When current dracut receives an ip with netmask of 255.255.255.255 via DHCP,
18971c
setting the also supplied default gateway fails (because it is obviously not
18971c
within the netmask).
18971c
18971c
The setup with a netmask of /32 is quite common in colocation datacenters
18971c
where you don't want the machines of two different customers to directly talk
18971c
to each other. At least two of the biggest colocation providers in Germany
18971c
(1&1 and Strato) do it that way. NetworkManager supports this kind of setup
18971c
and the dhclient-scripts of several distributions too.
18971c
18971c
In this patch I have implemented a simple approach very similar to what is
18971c
found in Debian. The dhclient-script from Fedora uses a more sophisticated
18971c
approach, but that relies on the ipcalc utility which would introduce a
18971c
dependency on Fedora-initscripts for dracut.
18971c
18971c
Signed-off-by: Gerd von Egidy <gerd.von.egidy@intra2net.com>
18971c
(cherry picked from commit 99ccbc30dff9fa51dd3187dc10f8f632e5e54e4b)
18971c
---
18971c
 modules.d/40network/dhclient-script.sh | 8 +++++++-
18971c
 1 file changed, 7 insertions(+), 1 deletion(-)
18971c
18971c
diff --git a/modules.d/40network/dhclient-script.sh b/modules.d/40network/dhclient-script.sh
18971c
index 7972af99..12e2869f 100755
18971c
--- a/modules.d/40network/dhclient-script.sh
18971c
+++ b/modules.d/40network/dhclient-script.sh
18971c
@@ -49,7 +49,13 @@ setup_interface() {
18971c
         ${lease_time:+valid_lft $lease_time} \
18971c
         ${preferred_lft:+preferred_lft ${preferred_lft}}
18971c
 
18971c
-    [ -n "$gw" ] && echo ip route replace default via $gw dev $netif > /tmp/net.$netif.gw
18971c
+    if [ -n "$gw" ] ; then
18971c
+        if [ "$mask" == "255.255.255.255" ] ; then
18971c
+            # point-to-point connection => set explicit route to gateway
18971c
+            echo ip route add $gw dev $netif > /tmp/net.$netif.gw
18971c
+        fi
18971c
+        echo ip route replace default via $gw dev $netif >> /tmp/net.$netif.gw
18971c
+    fi
18971c
 
18971c
     [ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net.$netif.resolv.conf
18971c
     if  [ -n "$namesrv" ] ; then