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: <BROADCAST,MULTICAST,UP,LOWER_UP> 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 <hbathini@linux.vnet.ibm.com>
Acked-by: Dave Young <dyoung@redhat.com>
This commit is contained in:
Hari Bathini 2016-11-04 00:16:14 +05:30 committed by Dave Young
parent 892bea7aae
commit 78e985e51c

View File

@ -161,7 +161,11 @@ kdump_get_perm_addr() {
kdump_setup_ifname() { kdump_setup_ifname() {
local _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" _ifname="kdump-$1"
else else
_ifname="$1" _ifname="$1"