Blame SOURCES/0223-do-ip-route-replace-default-instead-of-add.patch

18971c
From aa5313ca0e17bb08dd0629c3f9385672408caceb Mon Sep 17 00:00:00 2001
18971c
From: Will Woods <wwoods@redhat.com>
18971c
Date: Thu, 28 Aug 2014 13:44:47 -0400
18971c
Subject: [PATCH] do 'ip route replace default' instead of 'add'
18971c
18971c
When you define the gateway for an interface, dracut sets it up with:
18971c
18971c
  ip route add default via $gw dev $netif
18971c
18971c
If a default route is already set (e.g. if you have multiple NICs), this
18971c
will fail with the message "RTNETLINK answers: File exists".
18971c
18971c
So, if your first NIC isn't usable as a default route
18971c
18971c
Using "ip route replace default" instead allows ifup/dhclient-script to
18971c
correctly change the default route to the new interface.
18971c
---
18971c
 modules.d/40network/dhclient-script.sh | 2 +-
18971c
 modules.d/40network/ifup.sh            | 2 +-
18971c
 2 files changed, 2 insertions(+), 2 deletions(-)
18971c
18971c
diff --git a/modules.d/40network/dhclient-script.sh b/modules.d/40network/dhclient-script.sh
18971c
index ba05250d..885303a2 100755
18971c
--- a/modules.d/40network/dhclient-script.sh
18971c
+++ b/modules.d/40network/dhclient-script.sh
18971c
@@ -45,7 +45,7 @@ setup_interface() {
18971c
         valid_lft ${lease_time} preferred_lft ${lease_time} \
18971c
         dev $netif
18971c
 
18971c
-    [ -n "$gw" ] && echo ip route add default via $gw dev $netif > /tmp/net.$netif.gw
18971c
+    [ -n "$gw" ] && echo ip route replace default via $gw dev $netif > /tmp/net.$netif.gw
18971c
 
18971c
     [ -n "${search}${domain}" ] && echo "search $search $domain" > /tmp/net.$netif.resolv.conf
18971c
     if  [ -n "$namesrv" ] ; then
18971c
diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh
18971c
index 43e84a2c..67b1d9f8 100755
18971c
--- a/modules.d/40network/ifup.sh
18971c
+++ b/modules.d/40network/ifup.sh
18971c
@@ -145,7 +145,7 @@ do_static() {
18971c
         ip addr add $ip/$mask ${srv:+peer $srv} brd + dev $netif
18971c
     fi
18971c
 
18971c
-    [ -n "$gw" ] && echo ip route add default via $gw dev $netif > /tmp/net.$netif.gw
18971c
+    [ -n "$gw" ] && echo ip route replace default via $gw dev $netif > /tmp/net.$netif.gw
18971c
     [ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
18971c
 
18971c
     return 0