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

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