Blame SOURCES/0415-network-dhcp-before-parsing-specified-dns-through-cm.patch

712866
From 5bc318633fdf2c5bfea88bf2cf03e5aac2e78a1d Mon Sep 17 00:00:00 2001
712866
From: Harald Hoyer <harald@redhat.com>
712866
Date: Wed, 29 Jun 2016 17:26:17 +0200
712866
Subject: [PATCH] network: dhcp before parsing specified dns through cmdline
712866
712866
I met a problem when passing kdump dns to dracut via "nameserver=x.x.x.x",
712866
the dns I provided didn't appear in the "/etc/resolv.conf".
712866
712866
After some debugging, found that when setup dhcp DNS, in setup_interface()
712866
and setup_interface6(), it has:
712866
    echo "search $search $domain" > /tmp/net.$netif.resolv.conf
712866
712866
So if "$search $domain" isn't NULL(this is ture in my kdump environment),
712866
the dns contents(that is, dns1, dns2, nameserver) in "ifup" before dhcp
712866
will be discarded.
712866
712866
This patch addresses it by handling dhcp first. In fact this is also the
712866
way the NetworkManager in 1st kernel works.
712866
712866
Signed-off-by: Xunlei Pang <xlpang@redhat.com>
712866
712866
cherry-pick of commit cf376023e6d0d4abd9816fa954bb917fc2557713
712866
---
712866
 modules.d/40network/ifup.sh | 31 +++++++++++++++----------------
712866
 1 file changed, 15 insertions(+), 16 deletions(-)
712866
712866
diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh
5c6c2a
index 37f51b9d..19b7bbdc 100755
712866
--- a/modules.d/40network/ifup.sh
712866
+++ b/modules.d/40network/ifup.sh
712866
@@ -350,16 +350,15 @@ fi
712866
 ip=$(getarg ip)
712866
 
712866
 if [ -z "$ip" ]; then
712866
-    for s in $(getargs nameserver); do
712866
-        [ -n "$s" ] || continue
712866
-        echo nameserver $s >> /tmp/net.$netif.resolv.conf
712866
-    done
712866
-
712866
     if [ "$netroot" = "dhcp6" ]; then
712866
         do_dhcp -6
712866
     else
712866
         do_dhcp -4
712866
     fi
712866
+    for s in $(getargs nameserver); do
712866
+        [ -n "$s" ] || continue
712866
+        echo nameserver $s >> /tmp/net.$netif.resolv.conf
712866
+    done
712866
 fi
712866
 
712866
 
712866
@@ -386,17 +385,6 @@ for p in $(getargs ip=); do
712866
     [ "$use_bridge" != 'true' ] && \
712866
     [ "$use_vlan" != 'true' ] && continue
712866
 
712866
-    # setup nameserver
712866
-    for s in "$dns1" "$dns2" $(getargs nameserver); do
712866
-        [ -n "$s" ] || continue
712866
-        echo nameserver $s >> /tmp/net.$netif.resolv.conf
712866
-    done
712866
-
712866
-    # Store config for later use
712866
-    for i in ip srv gw mask hostname macaddr dns1 dns2 mtu; do
712866
-        eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
712866
-    done > /tmp/net.$netif.override
712866
-
712866
     for autoopt in $(str_replace "$autoconf" "," " "); do
712866
         case $autoopt in
712866
             dhcp|on|any)
712866
@@ -412,6 +400,17 @@ for p in $(getargs ip=); do
712866
     done
712866
     ret=$?
712866
 
712866
+    # setup nameserver
712866
+    for s in "$dns1" "$dns2" $(getargs nameserver); do
712866
+        [ -n "$s" ] || continue
712866
+        echo nameserver $s >> /tmp/net.$netif.resolv.conf
712866
+    done
712866
+
712866
+    # Store config for later use
712866
+    for i in ip srv gw mask hostname macaddr dns1 dns2 mtu; do
712866
+        eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
712866
+    done > /tmp/net.$netif.override
712866
+
712866
     if [ $ret -eq 0 ]; then
712866
         > /tmp/net.${netif}.up
712866