[PATCH RFC] module-setup.sh: install usb serial driver for ttyUSB0
by Dave Young
In case one want to use usb serial console, we need to pack the usb serial
driver into kdump initramfs so that one can see the console output on the usb
console.
I only handled ttyUSB0, this is like a hard code, but it should be enough for
most cases. Also only install the driver for the ttyUSB0 device.
Tested with adding "console=ttyUSB0" in 2nd kernel commandline.
Tested latest F22 kernel, there's CONFIG_USB_SERIAL_CONSOLE=y, kdump work ok.
Signed-off-by: Dave Young <dyoung(a)redhat.com>
---
dracut-module-setup.sh | 8 ++++++++
1 file changed, 8 insertions(+)
--- kexec-tools.orig/dracut-module-setup.sh
+++ kexec-tools/dracut-module-setup.sh
@@ -626,4 +626,12 @@ installkernel() {
[ "$wdt" = "iTCO_wdt" ] && instmods lpc_ich
instmods $wdt
fi
+
+ if [ -c /dev/ttyUSB0 ]; then
+ _majmin=$(get_maj_min /dev/ttyUSB0)
+
+ _driver=$(readlink /sys/dev/char/$_majmin/device/driver)
+ _driver=$(basename $_driver)
+ instmods $_driver
+ fi
}
7 years
[PATCH v4 1/2] kdump-lib: Add get_ifcfg_filename() to get the proper ifcfg file
by Xunlei Pang
Previously, we assumed the ifcfg file of a network "interface" is
"/etc/sysconfig/network-scripts/ifcfg-<interface>", but actually
it is not the case.
For example, for network interface "enp0s25", we are able to
generate like "/etc/sysconfig/network-scripts/ifcfg-enp0s25-test"
for it via network-manager.
The "suffix" in "ifcfg-<suffix>" is actually a "configuration"
name not "interface" name, though normally we use the "interface"
name as its "configuration" name. You can refer to "man ifup"
for some detail.
So, this patch adds some assistant helpers to acquire the right
ifcfg file for an interface. Borrow some logic from script below:
"/etc/sysconfig/network-scripts/network-functions"
Signed-off-by: Xunlei Pang <xlpang(a)redhat.com>
---
kdump-lib.sh | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 102 insertions(+)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 4d34206..90913c5 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -230,3 +230,105 @@ is_hostname()
fi
echo $1 | grep -q "[a-zA-Z]"
}
+
+get_hwaddr()
+{
+ if [ -f "/sys/class/net/${1}/address" ]; then
+ awk '{ print toupper($0) }' < /sys/class/net/${1}/address
+ elif [ -d "/sys/class/net/${1}" ]; then
+ ip -o link show ${1} 2>/dev/null | \
+ awk '{ print toupper(gensub(/.*link\/[^ ]* ([[:alnum:]:]*).*/,
+ "\\1", 1)); }'
+ fi
+}
+
+get_ifcfg_by_device()
+{
+ grep -E -i -l "^[[:space:]]*DEVICE=\"*${1}\"*[[:space:]]*$" \
+ /etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1
+}
+
+get_ifcfg_by_hwaddr()
+{
+ grep -E -i -l "^[[:space:]]*HWADDR=\"*${1}\"*[[:space:]]*$" \
+ /etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1
+}
+
+get_ifcfg_by_uuid()
+{
+ grep -E -i -l "^[[:space:]]*UUID=\"*${1}\"*[[:space:]]*$" \
+ /etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1
+}
+
+get_ifcfg_by_name()
+{
+ grep -E -i -l "^[[:space:]]*NAME=\"*${1}\"*[[:space:]]*$" \
+ /etc/sysconfig/network-scripts/ifcfg-* 2>/dev/null | head -1
+}
+
+is_nm_running()
+{
+ [ "$(LANG=C nmcli -t --fields running general status 2>/dev/null)" = "running" ]
+}
+
+is_nm_handling()
+{
+ LANG=C nmcli -t --fields device,state dev status 2>/dev/null \
+ | grep -q "^\(${1}:connected\)\|\(${1}:connecting.*\)$"
+}
+
+# $1: netdev name
+get_ifcfg_nmcli()
+{
+ local nm_uuid nm_name
+ local ifcfg_file
+
+ # Get the active nmcli config name of $1
+ if is_nm_running && is_nm_handling "${1}" ; then
+ # The configuration "uuid" and "name" generated by nm is wrote to
+ # the ifcfg file as "UUID=<nm_uuid>" and "NAME=<nm_name>".
+ nm_uuid=$(LANG=C nmcli -t --fields uuid,device c show --active 2>/dev/null \
+ | grep "${1}" | head -1 | cut -d':' -f1)
+ nm_name=$(LANG=C nmcli -t --fields name,device c show --active 2>/dev/null \
+ | grep "${1}" | head -1 | cut -d':' -f1)
+ ifcfg_file=$(get_ifcfg_by_uuid "${nm_uuid}")
+ [ -z "${ifcfg_file}" ] && ifcfg_file=$(get_ifcfg_by_name "${nm_name}")
+ fi
+
+ echo -n "${ifcfg_file}"
+}
+
+# $1: netdev name
+get_ifcfg_legacy()
+{
+ local ifcfg_file
+
+ ifcfg_file="/etc/sysconfig/network-scripts/ifcfg-${1}"
+ [ -f "${ifcfg_file}" ] && echo -n "${ifcfg_file}" && return
+
+ ifcfg_file=$(get_ifcfg_by_name "${1}")
+ [ -f "${ifcfg_file}" ] && echo -n "${ifcfg_file}" && return
+
+ local hwaddr=$(get_hwaddr "${1}")
+ if [ -n "$hwaddr" ]; then
+ ifcfg_file=$(get_ifcfg_by_hwaddr "${hwaddr}")
+ [ -f "${ifcfg_file}" ] && echo -n "${ifcfg_file}" && return
+ fi
+
+ ifcfg_file=$(get_ifcfg_by_device "${1}")
+
+ echo -n "${ifcfg_file}"
+}
+
+# $1: netdev name
+# Return the ifcfg file whole name(including the path) of $1 if any.
+get_ifcfg_filename() {
+ local ifcfg_file
+
+ ifcfg_file=$(get_ifcfg_nmcli "${1}")
+ if [ -z "${ifcfg_file}" ]; then
+ ifcfg_file=$(get_ifcfg_legacy "${1}")
+ fi
+
+ echo -n "${ifcfg_file}"
+}
--
1.8.3.1
7 years
[PATCH] kdumpctrl: kdump feasibility should fail if no crash memory
by Pratyush Anand
Currently initramfs is rebuilt even when crash kernel memory is not
available and then latter on kdump service is failed.
Its better to fail during feasibility itself when crash memory is not
reserved.
Signed-off-by: Pratyush Anand <panand(a)redhat.com>
---
kdumpctl | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index c7abaafdda27..38f29d2a305d 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -545,13 +545,6 @@ need_64bit_headers()
# as the currently running kernel.
load_kdump()
{
- MEM_RESERVED=$(cat /sys/kernel/kexec_crash_size)
- if [ $MEM_RESERVED -eq 0 ]
- then
- echo "No memory reserved for crash kernel." >&2
- return 1
- fi
-
ARCH=`uname -m`
if [ "$ARCH" == "i686" -o "$ARCH" == "i386" ]
then
@@ -876,8 +869,26 @@ check_fence_kdump_config()
return 0
}
+is_crash_mem_reserved()
+{
+ MEM_RESERVED=$(cat /sys/kernel/kexec_crash_size)
+ if [ $MEM_RESERVED -eq 0 ]
+ then
+ echo "No memory reserved for crash kernel." >&2
+ return 0
+ fi
+
+ return 1
+}
+
+
check_dump_feasibility()
{
+ is_crash_mem_reserved
+ if [ $? -eq 0 ];then
+ return 1
+ fi
+
if [ $DEFAULT_DUMP_MODE == "fadump" ]; then
return 0
fi
--
2.5.5
7 years
[PATCH] .gitignore: Update to make it more generic
by Pratyush Anand
We do not have *.tar.xz, *.tar.gz as part of repositiry, so ignore them
all.
Also ignore *.swp, and *.rpm because many of such temporary files are
created during development and such files would not be the part of
repository.
Signed-off-by: Pratyush Anand <panand(a)redhat.com>
---
.gitignore | 23 ++++-------------------
1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/.gitignore b/.gitignore
index c13b1aed05ce..3c087dafc049 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,19 +1,4 @@
-/eppic_030413.tar.gz
-/makedumpfile-1.5.7.tar.gz
-/kexec-tools-2.0.8.tar.xz
-/kdump-anaconda-addon-005-2-g86366ae.tar.gz
-/kdump-anaconda-addon-005-5-gbf53665.tar.gz
-/kdump-anaconda-addon-005-8-ge6ea581.tar.gz
-/kdump-anaconda-addon-005-9-g6115ca7.tar.gz
-/kexec-tools-2.0.9.tar.xz
-/makedumpfile-1.5.8.tar.gz
-/eppic_050615.tar.gz
-/kexec-tools-2.0.10.tar.xz
-/kdump-anaconda-addon-005-10-gd16915f.tar.gz
-/kdump-anaconda-addon-005-11-g59f9b73.tar.gz
-/kdump-anaconda-addon-005-12-g60fa4c1.tar.gz
-/kdump-anaconda-addon-005-14-g563e904.tar.gz
-/kdump-anaconda-addon-005-16-g586cc82.tar.gz
-/kexec-tools-2.0.11.tar.xz
-/makedumpfile-1.5.9.tar.gz
-/kexec-tools-2.0.12.tar.xz
+*.gz
+*.xz
+*.swp
+*.rpm
--
2.5.5
7 years
[PATCH 0/5] kdumpctl: force rebuild when dump target is modified
by Pratyush Anand
Kexec-tools should be able to recognize if a dump target is reformatted, or
dump path mounts another device.
Changes since v4:
- patch 4/5 is a new change
- patch 4/4 of V3 is now 4/5. There has been many modifications in this
patch. It includes feedback from Baoquan and Xunlei. Have also done some
modification to recognize changes related to minix and NFS filesystem as
well. Infact, whole structure of function is_fs_uuid_changed() has been
modified. Now it has been renamed as is_dump_fs_modified() to suit it
better. Although I have tested it rigorously, but still a careful review
of is_dump_fs_modified() will be helpful.
Changes since v3:
- "$ret" unquoted
- No message for "$system_modified" != "0"
- image_time is now global
- is_dump_target_modified has been renamed as is_fs_uuid_changed
Changes since v2:
-- now is_system_modified returns 2 in case of invalid modification, 1 in
case of valid modification and 0 in case of no modification.
-- file modification check has been moved to is_system_modified now
-- variables have been put under "" in if condition check
Changes since v1:
-- Local variable is defined in shell function now
-- raw target does not take persistent names "by-uuid" now
-- dracut arguments grep is more robust
-- When no UUID then warn and return
Pratyush Anand (5):
mkdumprd: do not lookup in by-uuid dirs for raw device's persistent
name
kdumpctl: force rebuild in case of dynamic system modification
kdumpctl: Move file modification check logic in is_system_modified()
mkdumprd: move to_dev_name() to kdump-lib.sh
kdumpctl: force rebuild in case of file system is modified
kdump-lib.sh | 14 +++++
kdumpctl | 173 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
mkdumprd | 28 ++++------
3 files changed, 171 insertions(+), 44 deletions(-)
--
2.5.5
7 years, 1 month
[PATCH] kdumpctl: rebuild when dump path is mounted to different device
by Pratyush Anand
If a disk is mounted on /var/crash, and is changed from /dev/diskA to
/dev/diskB then rebuild. If /var/crash and / have been mounted on same disk
but now a different disk is mounted at /var/crash then also rebuild.
Signed-off-by: Pratyush Anand <panand(a)redhat.com>
---
This patch would apply on top of series "kdumpctl: force rebuild when dump
target is modified".
Some testing after this patch:
[root@localhost panand]# kdumpctl restart
kexec: unloaded kdump kernel
Stopping kdump: [OK]
Detected change(s) in the following file(s):
/etc/kdump.conf
Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img
kexec: loaded kdump kernel
Starting kdump: [OK]
[root@localhost panand]# egrep -v '^#' /etc/kdump.conf
path /var/crash
[root@localhost panand]# kdumpctl restart
kexec: unloaded kdump kernel
Stopping kdump: [OK]
kexec: loaded kdump kernel
Starting kdump: [OK]
[root@localhost panand]# mount /dev/sdc1 /var/crash/
[root@localhost panand]# kdumpctl restart
kexec: unloaded kdump kernel
Stopping kdump: [OK]
Detected change in File System UUID
Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img
kexec: loaded kdump kernel
Starting kdump: [OK]
[root@localhost panand]# kdumpctl restart
kexec: unloaded kdump kernel
Stopping kdump: [OK]
kexec: loaded kdump kernel
Starting kdump: [OK]
[root@localhost panand]# umount /var/crash
[root@localhost panand]# kdumpctl restart
kexec: unloaded kdump kernel
Stopping kdump: [OK]
Detected change in File System UUID
Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img
kexec: loaded kdump kernel
Starting kdump: [OK]
[root@localhost panand]# kdumpctl restart
kexec: unloaded kdump kernel
Stopping kdump: [OK]
kexec: loaded kdump kernel
Starting kdump: [OK]
[root@localhost panand]# mount /dev/sdc1 /var/crash/
[root@localhost panand]# kdumpctl restart
kexec: unloaded kdump kernel
Stopping kdump: [OK]
Detected change in File System UUID
Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img
kexec: loaded kdump kernel
Starting kdump: [OK]
[root@localhost panand]# umount /var/crash
[root@localhost panand]# mount /dev/sdb1 /var/crash/
[root@localhost panand]# kdumpctl restart
kexec: unloaded kdump kernel
Stopping kdump: [OK]
Detected change in File System UUID
Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img
kexec: loaded kdump kernel
Starting kdump: [OK]
core_collector makedumpfile -l --message-level 1 -d 31
[root@localhost panand]# umount /var/crash
Change kdump.conf to dump in ext4 target
[root@localhost panand]# egrep -v '^#' /etc/kdump.conf
ext4 /dev/sdb1
path /var/crash
core_collector makedumpfile -l --message-level 1 -d 31
[root@localhost panand]# mount /dev/sdb1 /mnt/;mkdir /mnt/var;mkdir /mnt/var/crash
[root@localhost panand]# kdumpctl restart
kexec: unloaded kdump kernel
Stopping kdump: [OK]
Detected change(s) in the following file(s):
/etc/kdump.conf
Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img
kexec: loaded kdump kernel
Starting kdump: [OK]
[root@localhost panand]# umount /dev/sdb1;mount /dev/sdb1 /mnt/
[root@localhost panand]# kdumpctl restart
kexec: unloaded kdump kernel
Stopping kdump: [OK]
kexec: loaded kdump kernel
Starting kdump: [OK]
[root@localhost panand]# umount /dev/sdb1;mkfs.ext4 /dev/sdb1;mount /dev/sdb1 /mnt/;mkdir /mnt/var;mkdir /mnt/var/crash
mke2fs 1.42.13 (17-May-2015)
/dev/sdb1 contains a ext4 file system
last mounted on Thu Apr 21 10:56:33 2016
Proceed anyway? (y,n) y
Discarding device blocks: done
Creating filesystem with 5242624 4k blocks and 1310720 inodes
Filesystem UUID: 29c6c988-3137-418c-a3a7-4cc9490d69e9
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[root@localhost panand]# kdumpctl restart
kexec: unloaded kdump kernel
Stopping kdump: [OK]
Detected change in File System UUID
Rebuilding /boot/initramfs-4.5.0-302.fc24.x86_64+debugkdump.img
kexec: loaded kdump kernel
Starting kdump: [OK]
kdumpctl | 33 ++++++++++++++++++++++++++-------
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 30832424562a..2ce00899a1e4 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -359,25 +359,44 @@ is_files_modified()
return 0
}
+# if a device different than root device is mounted at $path then echo
+# the name of mounted device
+path_mount_device()
+{
+ local _path _mnt
+
+ _path=$(get_save_path)
+ #check if _path's mount point is root ("/")
+ _mnt=$(df $_path 2>/dev/null | tail -1 | awk '{ print $NF }')
+ if [[ "$_mnt" != "/" ]]; then
+ echo $(df $_path 2>/dev/null | tail -1 | awk '{ print $1 }')
+ fi
+}
+
is_fs_uuid_changed()
{
local _target _dracut_args _uuid
_target=$(egrep "^ext[234]|^xfs|^btrfs" /etc/kdump.conf)
- #if dump target does not exist then do not rebuild
- [[ -n "$_target" ]] || return 0
-
_dracut_args=$(lsinitrd $TARGET_INITRD | grep "^Arguments:" | head -1)
if [[ -z "$_dracut_args" ]];then
echo "Warning: No dracut arguments found in initrd"
return 0
fi
- #if --mount or --device is not by UUID, then also do not rebuild
- echo $_dracut_args | grep "by-uuid" &> /dev/null
- [[ $? -eq 0 ]] || return 0
- _target=$(echo $_target | cut -d ' ' -f 2)
+ # if dump target does not exist, and dump path's mount point is same
+ # as that of root then do not rebuild
+ if [[ -n "$_target" ]]; then
+ _target=$(echo $_target | cut -d ' ' -f 2)
+ else
+ _target=$(path_mount_device)
+ fi
+ if [[ -z "$_target" ]]; then
+ echo $_dracut_args | grep "by-uuid" &> /dev/null
+ [[ $? -eq 0 ]] || return 0
+ fi
+
_uuid=$(blkid $_target | awk -F"UUID=" '{print $2}' | cut -d '"' -f 2)
if [[ -z "$_uuid" ]];then
echo "Warning: UUID is not present"
--
2.5.0
7 years, 1 month
Re: [PATCH 0/5] kdumpctl: force rebuild when dump target is modified
by Pratyush Anand
Oops..forgot to add subject-prefix as V5. Kindly treat this series as "PATCH V5"
On Fri, Apr 29, 2016 at 12:20 PM, Pratyush Anand <panand(a)redhat.com> wrote:
> Kexec-tools should be able to recognize if a dump target is reformatted, or
> dump path mounts another device.
>
> Changes since v4:
> - patch 4/5 is a new change
> - patch 4/4 of V3 is now 4/5. There has been many modifications in this
> patch. It includes feedback from Baoquan and Xunlei. Have also done some
> modification to recognize changes related to minix and NFS filesystem as
> well. Infact, whole structure of function is_fs_uuid_changed() has been
> modified. Now it has been renamed as is_dump_fs_modified() to suit it
> better. Although I have tested it rigorously, but still a careful review
> of is_dump_fs_modified() will be helpful.
>
> Changes since v3:
> - "$ret" unquoted
> - No message for "$system_modified" != "0"
> - image_time is now global
> - is_dump_target_modified has been renamed as is_fs_uuid_changed
>
> Changes since v2:
> -- now is_system_modified returns 2 in case of invalid modification, 1 in
> case of valid modification and 0 in case of no modification.
> -- file modification check has been moved to is_system_modified now
> -- variables have been put under "" in if condition check
>
> Changes since v1:
> -- Local variable is defined in shell function now
> -- raw target does not take persistent names "by-uuid" now
> -- dracut arguments grep is more robust
> -- When no UUID then warn and return
>
> Pratyush Anand (5):
> mkdumprd: do not lookup in by-uuid dirs for raw device's persistent
> name
> kdumpctl: force rebuild in case of dynamic system modification
> kdumpctl: Move file modification check logic in is_system_modified()
> mkdumprd: move to_dev_name() to kdump-lib.sh
> kdumpctl: force rebuild in case of file system is modified
>
> kdump-lib.sh | 14 +++++
> kdumpctl | 173 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
> mkdumprd | 28 ++++------
> 3 files changed, 171 insertions(+), 44 deletions(-)
>
> --
> 2.5.5
>
7 years, 1 month
[PATCH V4 0/4] kdumpctl: force rebuild when dump target is modified
by Pratyush Anand
When dump target is re-formatted then its UUID changes. These patches add
support to recognize such changes and then force initramfs rebuild, if
dracut argument has an UUID based root location.
Changes since v3:
- "$ret" unquoted
- No message for "$system_modified" != "0"
- image_time is now global
- is_dump_target_modified has been renamed as is_fs_uuid_changed
Changes since v2:
-- now is_system_modified returns 2 in case of invalid modification, 1 in
case of valid modification and 0 in case of no modification.
-- file modification check has been moved to is_system_modified now
-- variables have been put under "" in if condition check
Changes since v1:
-- Local variable is defined in shell function now
-- raw target does not take persistent names "by-uuid" now
-- dracut arguments grep is more robust
-- When no UUID then warn and return
Pratyush Anand (4):
mkdumprd: do not lookup in by-uuid dirs for raw device's persistent
name
kdumpctl: force rebuild in case of dynamic system modification
kdumpctl: Move file modification check logic in is_system_modified()
kdumpctl: force rebuild in case of file system UUID changes
kdumpctl | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------
mkdumprd | 14 +++++--
2 files changed, 111 insertions(+), 30 deletions(-)
--
2.5.0
7 years, 1 month
Re: [PATCH] module-setup: Fix improper dns setup in kdump_setup_dns()
by Xunlei Pang
On 2016/04/26 at 17:07, Thomas Haller wrote:
> On Mon, 2016-04-25 at 17:47 +0800, Hangbin Liu wrote:
>> cc Daniel and network manager development team. They are experts on
>> NM.
>>
>> On Mon, Apr 25, 2016 at 04:45:23PM +0800, Baoquan He wrote:
>>>
>>> Using NetworkManager or not using it can bring us so different
>>> behaviours and different /etc/resolv.conf. Could you give
>>> suggestion how
>>> we can make decision to choose a reasonable one since kdump
>>> probablly
>>> need to cope with both of them?
>
> Hi,
>
>
> Yes, NetworkManager's an initscript's interpretation differs in some
> aspects.
>
>
> To quote `man nm-settings-ifcfg-rh`:
>
>
> Semantic change of variables
>
> NetworkManager had to slightly change the semantic for a few
> variables.
>
> · PEERDNS - initscripts interpret PEERDNS=no to mean "never touch
> resolv.conf". NetworkManager interprets it to say "never add
> automatic (DHCP, PPP, VPN, etc.) nameservers to resolv.conf".
>
>
> The behavior you described matches the documentation.
Thanks!
Then dracut follows NetworkManager at this point. But dracut does dhcp after
handling nameservers in "nameserver=" and "ip=" specified by users, I guess
NetworkManager does dhcp first, then appends DNS1&DNS2 in the ifcfg files.
I happened to spot a dracut DNS bug caused by the above-mentioned order,
I will try to post a patch to see if can fix it to follow NetworkManager.
Regards,
Xunlei
>
>
> Thomas
7 years, 1 month
Re: [PATCH] module-setup: Fix improper dns setup in kdump_setup_dns()
by Baoquan He
Thanks, Leo.
Hi Daniel and NetworkManager team,
We are kdump team dev, now have question about DNS handling from
NetworkManager and those scripts in /etc/sysconfig/network-scripts.
Could you please help to have a look when it's convenient to you?
Thanks
Baoquan
On 04/25/16 at 05:47pm, Hangbin Liu wrote:
> cc Daniel and network manager development team. They are experts on NM.
>
> On Mon, Apr 25, 2016 at 04:45:23PM +0800, Baoquan He wrote:
> > Hi network experts,
> >
> > We got confusion on network DNS handling when we try to fix a kdump
> > bug. For better representation let's assume a network interface enp0s25
> > with static DNS setting in ifcfg-enp0s25 as "DNS1=8.8.8.8", and dhclient
> > privides 2 DNS server ip:
> >
> > 10.72.17.5
> > 10.68.5.26
> >
> >
> > Now the confusion is:
> >
> > 1) In 1st kernel if NetworkManager take control of the network setup and
> > PEERDNS=yes, the behaviour of DNS handling is that it adds dhclient's DNS
> > firstly then add static DNS from ifcfg-enp0s25. The result of
> > /etc/resolv.conf will be as follows:
> > nameserver 10.72.17.5
> > nameserver 10.68.5.26
> > nameserver 8.8.8.8
> >
> > - But if we set PEERDNS=no, the result of /etc/resolv.conf is:
> > nameserver 8.8.8.8
> > Apprently "PEERDNS=no" doesn't allow dhclient to add its DNS into
> > /etc/resolv.conf.
> >
> > 2) However in 1st kernel if NetworkManager is disabled, means scripts
> > under /etc/sysconfig/network-scripts/ take control of network setup and
> > PEERDNS=yes, its behaviour is much different with NetworkManager. It
> > will firstly add dhclient's DNS, then replace the first entry, namely
> > "10.72.17.5" with the found static DNS from ifcfg-enp0s25. The result of
> > /etc/resolv.conf will be like:
> > nameserver 8.8.8.8
> > nameserver 10.68.5.26
> >
> > - If PEERDNS=no set in ifcfg-enp0s25
> > /etc/resolv.conf won't be changed at all.
> >
> > Using NetworkManager or not using it can bring us so different
> > behaviours and different /etc/resolv.conf. Could you give suggestion how
> > we can make decision to choose a reasonable one since kdump probablly
> > need to cope with both of them?
> >
> > In fact above cases are not problems we have since dracut have another
> > different rules then above, and we need handle it. But now we need to
> > clarify how DNS handling acts in 1st kernel. Your suggestions and ideas
> > are very precisous to us.
> >
> > Thanks
> > Baoquan
> >
> > On 04/25/16 at 03:29pm, Xunlei Pang wrote:
> > > ============= 3. Conclusion =============
> > > Dracut, network-manager, and "network-scripts" all have different hehavior
> > > in handling DNS.
> > >
> > > As a dhcp example:
> > > Suppose enp0s25, the dhcped DNSes are stable: 10.72.17.5 and 10.68.5.26
> > >
> > > In ifcfg-enp0s25:
> > > DNS1: 8.8.8.8
> > >
> > > 1) For 1st kernel's network-manager, the final nameservers in /etc/resolv.conf
> > > -) If PEERDNS=yes(default is yes if PEERDNS doesn't exist) in ifcfg-enp0s25
> > > nameserver 10.72.17.5
> > > nameserver 10.68.5.26
> > > nameserver 8.8.8.8
> > > -) If PEERDNS=no in ifcfg-enp0s25
> > > nameserver 10.72.17.5
> > > nameserver 10.68.5.26
> > > nameserver 8.8.8.8
> > >
> > > 2) For 1st kernel's scripts under /etc/sysconfig/network-scripts/ without network-manager
> > > -) If PEERDNS=yes in ifcfg-enp0s25
> > > nameserver 8.8.8.8
> > > nameserver 10.68.5.26
> > > -) If PEERDNS=no in ifcfg-enp0s25
> > > Not touch /etc/resolv.conf
> > > (i.e. /etc/resolv.conf is left unchanged as that before calling "ifup <config>")
> > >
> > > 3) For dracut in latest fedora kexec-tools(1st kernel using network-manager)
> > > "${initdir}/etc/cmdline.d/42dns.conf" will contain:
> > > nameserver=8.8.8.8
> > > nameserver=10.72.17.5
> > > nameserver=10.68.5.26
> > > nameserver=8.8.8.8
> > >
> > > -) If "rd.peerdns=1"(default is "1" if "rd.peerdns" doesn't exist) is passed which is the default case
> > > nameserver 8.8.8.8
> > > nameserver 10.72.17.5
> > > nameserver 10.68.5.26
> > > nameserver 8.8.8.8
> > > nameserver 10.72.17.5 // the last two are drauct' dhcp generated items
> > > nameserver 10.68.5.26
> > > -) If "rd.peerdns=0" is passed
> > > nameserver 8.8.8.8
> > > nameserver 10.72.17.5
> > > nameserver 10.68.5.26
> > > nameserver 8.8.8.8
> > >
> > >
> > > Regards,
> > > Xunlei
> > >
> > > >> Regards,
> > > >> Xunlei
> > > >>
> > > >>> Regards,
> > > >>> Xunlei
> > > >>>
> > > >>>> Thanks
> > > >>>> Minfei
> > > >>>>
> > > >>>>> There are two issues by doing this:
> > > >>>>> 1) The dns sequence is different from that in 1st system.
> > > >>>>> 2) There are some duplicated items.
> > > >>>>> NOTE: kdump_setup_dns() meant to avoid the duplication,
> > > >>>>> but the original shell command is actually disfunctional:
> > > >>>>> "[ ! $(cat $_dnsfile | grep -q $_dns) ]" (always true)
> > > >>>>>
> > > >>>>> Fix the issues by firstly parsing "/etc/resolv.conf", then
> > > >>>>> parsing ifcfg file, finally delete the duplicated items.
> > > >>>>>
> > > >>>>> Signed-off-by: Xunlei Pang <xlpang(a)redhat.com>
> > > >>>>> ---
> > > >>>>> dracut-module-setup.sh | 27 ++++++++++++++++-----------
> > > >>>>> 1 file changed, 16 insertions(+), 11 deletions(-)
> > > >>>>>
> > > >>>>> diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
> > > >>>>> index 350864e..b7763f7 100755
> > > >>>>> --- a/dracut-module-setup.sh
> > > >>>>> +++ b/dracut-module-setup.sh
> > > >>>>> @@ -68,14 +68,6 @@ kdump_setup_dns() {
> > > >>>>> local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf
> > > >>>>> local ifcfg_file
> > > >>>>>
> > > >>>>> - ifcfg_file=$(get_ifcfg_filename $1)
> > > >>>>> - if [ -f "${ifcfg_file}" ]; then
> > > >>>>> - . ${ifcfg_file}
> > > >>>>> - fi
> > > >>>>> -
> > > >>>>> - [ -n "$DNS1" ] && echo "nameserver=$DNS1" > "$_dnsfile"
> > > >>>>> - [ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile"
> > > >>>>> -
> > > >>>>> while read content;
> > > >>>>> do
> > > >>>>> _nameserver=$(echo $content | grep ^nameserver)
> > > >>>>> @@ -84,10 +76,23 @@ kdump_setup_dns() {
> > > >>>>> _dns=$(echo $_nameserver | cut -d' ' -f2)
> > > >>>>> [ -z "$_dns" ] && continue
> > > >>>>>
> > > >>>>> - if [ ! -f $_dnsfile ] || [ ! $(cat $_dnsfile | grep -q $_dns) ]; then
> > > >>>>> - echo "nameserver=$_dns" >> "$_dnsfile"
> > > >>>>> - fi
> > > >>>>> + echo "nameserver=$_dns" >> "$_dnsfile"
> > > >>>>> done < "/etc/resolv.conf"
> > > >>>>> +
> > > >>>>> + unset DNS1 DNS2
> > > >>>>> + ifcfg_file=$(get_ifcfg_filename $1)
> > > >>>>> + if [ -f "${ifcfg_file}" ]; then
> > > >>>>> + . ${ifcfg_file}
> > > >>>>> + fi
> > > >>>>> +
> > > >>>>> + [ -n "$DNS1" ] && echo "nameserver=$DNS1" >> "$_dnsfile"
> > > >>>>> + [ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile"
> > > >>>>> +
> > > >>>>> + # Delete duplicated lines
> > > >>>>> + if [ -f "$_dnsfile" ]; then
> > > >>>>> + awk '!a[$0]++' $_dnsfile > $_dnsfile.tmp
> > > >>>>> + mv -f $_dnsfile.tmp $_dnsfile
> > > >>>>> + fi
> > > >>>>> }
> > > >>>>>
> > > >>>>> #$1: netdev name
> > > >>>>> --
> > > >>>>> 1.8.3.1
> > > >>>>> _______________________________________________
> > > >>>>> kexec mailing list
> > > >>>>> kexec(a)lists.fedoraproject.org
> > > >>>>> http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
> > > >>> _______________________________________________
> > > >>> kexec mailing list
> > > >>> kexec(a)lists.fedoraproject.org
> > > >>> http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
> > > >> _______________________________________________
> > > >> kexec mailing list
> > > >> kexec(a)lists.fedoraproject.org
> > > >> http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org
> > >
>
> --
>
> Thanks & Best Regards
> Hangbin Liu <haliu(a)redhat.com>
> Leo on #kernel-qe, #kernel, #eng-china
7 years, 1 month