From 78e985e51cf18db4d273b5c590369c9213d11a39 Mon Sep 17 00:00:00 2001 From: Hari Bathini Date: Fri, 4 Nov 2016 00:16:14 +0530 Subject: [PATCH] kdump/fadump: fix network interface name when switching from fadump to kdump When a remote dump target is specified, kdump dracut module prefixes 'kdump-' to network interface name (ifname) as kernel assigned names are not persistent. In fadump mode, kdump dracut module is added to the default initrd, which adds the 'kdump-' prefix to the ifname of the prodcution kernel itself. If fadump mode is disabled after this, kdump dracut module picks the ifname that is already prefixed with 'kdump-' in the production kernel and adds another 'kdump-' to it, making the ifname something like kdump-kdump-eth0 for kdump kernel. Eventually, kdump kernel fails with below traces: dracut-initqueue[246]: RTNETLINK answers: Network is unreachable dracut-initqueue[246]: arping: Device kdump-kdump-eth0 not available. The ip command shows the below: kdump:/# ip addr show kdump-kdump-eth0 2: kdump-kdump-eth: mtu 1500 \ qdisc pfifo_fast state UNKNOWN qlen 1000 link/ether 22:82:87:7b:98:02 brd ff:ff:ff:ff:ff:ff inet6 2002:903:15f:550:2082:87ff:fe7b:9802/64 scope global \ mngtmpaddr dynamic valid_lft 2591890sec preferred_lft 604690sec inet6 fe80::2082:87ff:fe7b:9802/64 scope link valid_lft forever preferred_lft forever kdump:/# The trailing 0 from kdump-kdump-eth0 is missing in the ifname, probably truncated owing to ifname length limit, while setting. This patch fixes this by avoiding addition of the prefix 'kdump-' when such prefix is already present in the ifname. Signed-off-by: Hari Bathini Acked-by: Dave Young --- dracut-module-setup.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 68e0ff8..0baffaa 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -161,7 +161,11 @@ kdump_get_perm_addr() { kdump_setup_ifname() { local _ifname - if [[ $1 =~ eth* ]]; then + # If ifname already has 'kdump-' prefix, we must be switching from + # fadump to kdump. Skip prefixing 'kdump-' in this case as adding + # another prefix may truncate the ifname. Since an ifname with + # 'kdump-' is already persistent, this should be fine. + if [[ $1 =~ eth* ]] && [[ ! $1 =~ ^kdump-* ]]; then _ifname="kdump-$1" else _ifname="$1"