* [PATCH 1/2] network: dhcp before parsing specified dns through cmdline
@ 2016-04-26 10:05 Xunlei Pang
[not found] ` <1461665111-7385-1-git-send-email-xlpang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Xunlei Pang @ 2016-04-26 10:05 UTC (permalink / raw)
To: Harald Hoyer, initramfs-u79uwXL29TY76Z2rM5mHXA,
kdump-team-H+wXaHxf7aLQT0dZR+AlfA
Cc: Xunlei Pang
I met a problem when passing kdump dns to dracut via "nameserver=x.x.x.x",
the dns I provided didn't appear in the "/etc/resolv.conf".
After some debugging, found that when setup dhcp DNS, in setup_interface()
and setup_interface6(), it has:
echo "search $search $domain" > /tmp/net.$netif.resolv.conf
So if "$search $domain" isn't NULL(this is ture in my kdump environment),
the dns contents(that is, dns1, dns2, nameserver) in "ifup" before dhcp
will be discarded.
This patch addresses it by handling dhcp first. In fact this is also the
way the NetworkManager in 1st kernel works.
Signed-off-by: Xunlei Pang <xlpang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
modules.d/40network/ifup.sh | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh
index 7c179bd..702b8dc 100755
--- a/modules.d/40network/ifup.sh
+++ b/modules.d/40network/ifup.sh
@@ -321,16 +321,16 @@ fi
ip=$(getarg ip)
if [ -z "$NO_AUTO_DHCP" ] && [ -z "$ip" ]; then
- for s in $(getargs nameserver); do
- [ -n "$s" ] || continue
- echo nameserver $s >> /tmp/net.$netif.resolv.conf
- done
-
if [ "$netroot" = "dhcp6" ]; then
do_dhcp -6
else
do_dhcp -4
fi
+
+ for s in $(getargs nameserver); do
+ [ -n "$s" ] || continue
+ echo nameserver $s >> /tmp/net.$netif.resolv.conf
+ done
fi
@@ -355,17 +355,6 @@ for p in $(getargs ip=); do
# If this option isn't directed at our interface, skip it
[ -n "$dev" ] && [ "$dev" != "$netif" ] && continue
- # setup nameserver
- for s in "$dns1" "$dns2" $(getargs nameserver); do
- [ -n "$s" ] || continue
- echo nameserver $s >> /tmp/net.$netif.resolv.conf
- done
-
- # Store config for later use
- for i in ip srv gw mask hostname macaddr mtu dns1 dns2; do
- eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
- done > /tmp/net.$netif.override
-
for autoopt in $(str_replace "$autoconf" "," " "); do
case $autoopt in
dhcp|on|any)
@@ -381,6 +370,17 @@ for p in $(getargs ip=); do
done
ret=$?
+ # setup nameserver
+ for s in "$dns1" "$dns2" $(getargs nameserver); do
+ [ -n "$s" ] || continue
+ echo nameserver $s >> /tmp/net.$netif.resolv.conf
+ done
+
+ # Store config for later use
+ for i in ip srv gw mask hostname macaddr mtu dns1 dns2; do
+ eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
+ done > /tmp/net.$netif.override
+
if [ $ret -eq 0 ]; then
> /tmp/net.${netif}.up
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread[parent not found: <1461665111-7385-1-git-send-email-xlpang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* [PATCH 2/2] network/net-lib.sh: delete duplicated DNS items from "/etc/resolv.conf" [not found] ` <1461665111-7385-1-git-send-email-xlpang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2016-04-26 10:05 ` Xunlei Pang [not found] ` <1461665111-7385-2-git-send-email-xlpang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2016-06-07 9:15 ` [PATCH 1/2] network: dhcp before parsing specified dns through cmdline Harald Hoyer 1 sibling, 1 reply; 5+ messages in thread From: Xunlei Pang @ 2016-04-26 10:05 UTC (permalink / raw) To: Harald Hoyer, initramfs-u79uwXL29TY76Z2rM5mHXA, kdump-team-H+wXaHxf7aLQT0dZR+AlfA Cc: Xunlei Pang Users can pass the DNS information throught "nameserver=" cmdline, there maybe duplicated inputs. "/etc/resolv.conf" have some restrictions on the number of DNS items effective, so make sure that this file contains no duplicated items. We achieve this by simply making the file have no duplicated lines. Signed-off-by: Xunlei Pang <xlpang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> --- modules.d/40network/module-setup.sh | 2 +- modules.d/40network/net-lib.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh index 4bf93cc..53b4b60 100755 --- a/modules.d/40network/module-setup.sh +++ b/modules.d/40network/module-setup.sh @@ -23,7 +23,7 @@ installkernel() { # called by dracut install() { local _arch _i _dir - inst_multiple ip arping dhclient sed + inst_multiple ip arping dhclient sed awk inst_multiple -o ping ping6 inst_multiple -o brctl inst_multiple -o teamd teamdctl teamnl diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh index 31f1a56..005ad1b 100755 --- a/modules.d/40network/net-lib.sh +++ b/modules.d/40network/net-lib.sh @@ -120,7 +120,7 @@ setup_net() { [ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts # set up resolv.conf [ -e /tmp/net.$netif.resolv.conf ] && \ - cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf + awk '!array[$0]++' /tmp/net.$netif.resolv.conf > /etc/resolv.conf [ -e /tmp/net.$netif.gw ] && . /tmp/net.$netif.gw # add static route -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
[parent not found: <1461665111-7385-2-git-send-email-xlpang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH 2/2] network/net-lib.sh: delete duplicated DNS items from "/etc/resolv.conf" [not found] ` <1461665111-7385-2-git-send-email-xlpang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> @ 2016-04-26 11:03 ` Dracut GitHub Import Bot 2016-06-07 9:16 ` Harald Hoyer 1 sibling, 0 replies; 5+ messages in thread From: Dracut GitHub Import Bot @ 2016-04-26 11:03 UTC (permalink / raw) To: initramfs-u79uwXL29TY76Z2rM5mHXA Patchset imported to github. Pull request: <https://github.com/haraldh/dracut/compare/master...dracut-mailing-devs:1461665111-7385-2-git-send-email-xlpang%40redhat.com> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] network/net-lib.sh: delete duplicated DNS items from "/etc/resolv.conf" [not found] ` <1461665111-7385-2-git-send-email-xlpang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2016-04-26 11:03 ` Dracut GitHub Import Bot @ 2016-06-07 9:16 ` Harald Hoyer 1 sibling, 0 replies; 5+ messages in thread From: Harald Hoyer @ 2016-06-07 9:16 UTC (permalink / raw) To: Xunlei Pang, initramfs-u79uwXL29TY76Z2rM5mHXA, kdump-team-H+wXaHxf7aLQT0dZR+AlfA Am 26.04.2016 um 12:05 schrieb Xunlei Pang: > Users can pass the DNS information throught "nameserver=" cmdline, > there maybe duplicated inputs. > > "/etc/resolv.conf" have some restrictions on the number of DNS items > effective, so make sure that this file contains no duplicated items. > > We achieve this by simply making the file have no duplicated lines. > > Signed-off-by: Xunlei Pang <xlpang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > --- > modules.d/40network/module-setup.sh | 2 +- > modules.d/40network/net-lib.sh | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh > index 4bf93cc..53b4b60 100755 > --- a/modules.d/40network/module-setup.sh > +++ b/modules.d/40network/module-setup.sh > @@ -23,7 +23,7 @@ installkernel() { > # called by dracut > install() { > local _arch _i _dir > - inst_multiple ip arping dhclient sed > + inst_multiple ip arping dhclient sed awk > inst_multiple -o ping ping6 > inst_multiple -o brctl > inst_multiple -o teamd teamdctl teamnl > diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh > index 31f1a56..005ad1b 100755 > --- a/modules.d/40network/net-lib.sh > +++ b/modules.d/40network/net-lib.sh > @@ -120,7 +120,7 @@ setup_net() { > [ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts > # set up resolv.conf > [ -e /tmp/net.$netif.resolv.conf ] && \ > - cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf > + awk '!array[$0]++' /tmp/net.$netif.resolv.conf > /etc/resolv.conf > [ -e /tmp/net.$netif.gw ] && . /tmp/net.$netif.gw > > # add static route > Thanks! Pushed, although replaced awk with a shell function ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] network: dhcp before parsing specified dns through cmdline [not found] ` <1461665111-7385-1-git-send-email-xlpang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> 2016-04-26 10:05 ` [PATCH 2/2] network/net-lib.sh: delete duplicated DNS items from "/etc/resolv.conf" Xunlei Pang @ 2016-06-07 9:15 ` Harald Hoyer 1 sibling, 0 replies; 5+ messages in thread From: Harald Hoyer @ 2016-06-07 9:15 UTC (permalink / raw) To: Xunlei Pang, initramfs-u79uwXL29TY76Z2rM5mHXA, kdump-team-H+wXaHxf7aLQT0dZR+AlfA Am 26.04.2016 um 12:05 schrieb Xunlei Pang: > I met a problem when passing kdump dns to dracut via "nameserver=x.x.x.x", > the dns I provided didn't appear in the "/etc/resolv.conf". > > After some debugging, found that when setup dhcp DNS, in setup_interface() > and setup_interface6(), it has: > echo "search $search $domain" > /tmp/net.$netif.resolv.conf > > So if "$search $domain" isn't NULL(this is ture in my kdump environment), > the dns contents(that is, dns1, dns2, nameserver) in "ifup" before dhcp > will be discarded. > > This patch addresses it by handling dhcp first. In fact this is also the > way the NetworkManager in 1st kernel works. > > Signed-off-by: Xunlei Pang <xlpang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> > --- > modules.d/40network/ifup.sh | 32 ++++++++++++++++---------------- > 1 file changed, 16 insertions(+), 16 deletions(-) > > diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh > index 7c179bd..702b8dc 100755 > --- a/modules.d/40network/ifup.sh > +++ b/modules.d/40network/ifup.sh > @@ -321,16 +321,16 @@ fi > ip=$(getarg ip) > > if [ -z "$NO_AUTO_DHCP" ] && [ -z "$ip" ]; then > - for s in $(getargs nameserver); do > - [ -n "$s" ] || continue > - echo nameserver $s >> /tmp/net.$netif.resolv.conf > - done > - > if [ "$netroot" = "dhcp6" ]; then > do_dhcp -6 > else > do_dhcp -4 > fi > + > + for s in $(getargs nameserver); do > + [ -n "$s" ] || continue > + echo nameserver $s >> /tmp/net.$netif.resolv.conf > + done > fi > > > @@ -355,17 +355,6 @@ for p in $(getargs ip=); do > # If this option isn't directed at our interface, skip it > [ -n "$dev" ] && [ "$dev" != "$netif" ] && continue > > - # setup nameserver > - for s in "$dns1" "$dns2" $(getargs nameserver); do > - [ -n "$s" ] || continue > - echo nameserver $s >> /tmp/net.$netif.resolv.conf > - done > - > - # Store config for later use > - for i in ip srv gw mask hostname macaddr mtu dns1 dns2; do > - eval '[ "$'$i'" ] && echo '$i'="$'$i'"' > - done > /tmp/net.$netif.override > - > for autoopt in $(str_replace "$autoconf" "," " "); do > case $autoopt in > dhcp|on|any) > @@ -381,6 +370,17 @@ for p in $(getargs ip=); do > done > ret=$? > > + # setup nameserver > + for s in "$dns1" "$dns2" $(getargs nameserver); do > + [ -n "$s" ] || continue > + echo nameserver $s >> /tmp/net.$netif.resolv.conf > + done > + > + # Store config for later use > + for i in ip srv gw mask hostname macaddr mtu dns1 dns2; do > + eval '[ "$'$i'" ] && echo '$i'="$'$i'"' > + done > /tmp/net.$netif.override > + > if [ $ret -eq 0 ]; then > > /tmp/net.${netif}.up > > Thanks! Pushed ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-06-07 9:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-26 10:05 [PATCH 1/2] network: dhcp before parsing specified dns through cmdline Xunlei Pang
[not found] ` <1461665111-7385-1-git-send-email-xlpang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-04-26 10:05 ` [PATCH 2/2] network/net-lib.sh: delete duplicated DNS items from "/etc/resolv.conf" Xunlei Pang
[not found] ` <1461665111-7385-2-git-send-email-xlpang-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2016-04-26 11:03 ` Dracut GitHub Import Bot
2016-06-07 9:16 ` Harald Hoyer
2016-06-07 9:15 ` [PATCH 1/2] network: dhcp before parsing specified dns through cmdline Harald Hoyer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox