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 ---
* No changes from v3.
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"
When fadump mode is enabled, the default initrd is rebuilt with kdump dracut module. As the default initrd is altered, the original default initrd is backed up. But we are not restoring it when fadump mode is disabled. This patch tries to restore the backed up default initrd on disabling fadump mode.
Signed-off-by: Hari Bathini hbathini@linux.vnet.ibm.com ---
Changes from v3: * Added checksum verification while restoring initrd. * Moved backup/restore logic under mode switch check. * Moved mode switch check up to not miss restore while switching back to kdump (in case of a missing kdump initrd).
kdumpctl | 105 +++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 83 insertions(+), 22 deletions(-)
diff --git a/kdumpctl b/kdumpctl index d0bbb55..6153f96 100755 --- a/kdumpctl +++ b/kdumpctl @@ -8,7 +8,10 @@ KDUMP_CONFIG_FILE="/etc/kdump.conf" MKDUMPRD="/sbin/mkdumprd -f" SAVE_PATH=/var/crash SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" +INITRD_CHECKSUM_LOCATION="/root/.fadump_initrd_checksum" DUMP_TARGET="" +DEFAULT_INITRD="" +DEFAULT_INITRD_BAK="" TARGET_INITRD="" FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered" @@ -154,9 +157,6 @@ rebuild_fadump_initrd() { local target_initrd_tmp
- # backup fadump initrd for reference before replacing it - backup_initrd - # this file tells the initrd is fadump enabled touch /tmp/fadump.initramfs target_initrd_tmp="$TARGET_INITRD.tmp" @@ -220,15 +220,39 @@ check_executable() done }
-backup_initrd() +backup_default_initrd() { - local target_initrd_bak + if [ ! -e $DEFAULT_INITRD_BAK ]; then + echo "Backing up $DEFAULT_INITRD before rebuild." + # save checksum to verify before restoring + sha1sum $DEFAULT_INITRD > $INITRD_CHECKSUM_LOCATION + cp $DEFAULT_INITRD $DEFAULT_INITRD_BAK + if [ $? -ne 0 ]; then + echo "WARNING: failed to backup $DEFAULT_INITRD." + rm -f $DEFAULT_INITRD_BAK + fi + fi +}
- # Check if backup initrd is already present. - target_initrd_bak="$TARGET_INITRD.bak" - if [ ! -e $target_initrd_bak ];then - echo "Backing up $TARGET_INITRD" - cp $TARGET_INITRD $target_initrd_bak +restore_default_initrd() +{ + # If a backup initrd exists, we must be switching back from + # fadump to kdump. Restore the original default initrd. + if [ -f $DEFAULT_INITRD_BAK ] && [ -f $INITRD_CHECKSUM_LOCATION ]; then + # verify checksum before restoring + backup_checksum=`sha1sum $DEFAULT_INITRD_BAK | awk '{ print $1 }'` + default_checksum=`cat $INITRD_CHECKSUM_LOCATION | awk '{ print $1 }'` + if [ "$default_checksum" != "$backup_checksum" ]; then + echo "WARNING: checksum mismatch! Can't restore original initrd.." + else + rm -f $INITRD_CHECKSUM_LOCATION + mv $DEFAULT_INITRD_BAK $DEFAULT_INITRD + if [[ $? -eq 0 ]]; then + echo -n "Restoring original initrd as fadump mode " + echo "is disabled." + sync + fi + fi fi }
@@ -320,10 +344,12 @@ check_boot_dir() fi }
-setup_target_initrd() +setup_initrd() { + DEFAULT_INITRD="${KDUMP_BOOTDIR}/initramfs-`uname -r`.img" + DEFAULT_INITRD_BAK="${KDUMP_BOOTDIR}/.initramfs-`uname -r`.img.default" if [ $DEFAULT_DUMP_MODE == "fadump" ]; then - TARGET_INITRD="${KDUMP_BOOTDIR}/initramfs-${kdump_kver}.img" + TARGET_INITRD="$DEFAULT_INITRD" if [ ! -s "$TARGET_INITRD" ]; then echo "Error: No initrd found to rebuild!" return 1 @@ -504,7 +530,6 @@ check_rebuild() local extra_modules local _force_rebuild force_rebuild="0" local ret system_modified="0" - local initramfs_has_fadump
check_boot_dir
@@ -515,7 +540,7 @@ check_rebuild() fi
kdump_kernel="${KDUMP_BOOTDIR}/${KDUMP_IMG}-${kdump_kver}${KDUMP_IMG_EXT}" - setup_target_initrd + setup_initrd if [ $? -ne 0 ]; then return 1 fi @@ -547,15 +572,11 @@ check_rebuild() system_modified="1" fi
- #check if target initrd has fadump support - if [ "$DEFAULT_DUMP_MODE" = "fadump" ] && [ -f "$TARGET_INITRD" ]; then - initramfs_has_fadump=`lsinitrd -m $TARGET_INITRD | grep ^kdumpbase$ | wc -l` - fi - - if [ $image_time -eq 0 ]; then + if is_mode_switched; then + echo -n "Dump mode changed from last boot."; echo + handle_mode_switch + elif [ $image_time -eq 0 ]; then echo -n "No kdump initial ramdisk found."; echo - elif [ $DEFAULT_DUMP_MODE == "fadump" ] && [ "$initramfs_has_fadump" -eq "0" ]; then - echo "$TARGET_INITRD has no fadump support" elif [ "$force_rebuild" != "0" ]; then echo -n "Force rebuild $TARGET_INITRD"; echo elif [ "$system_modified" != "0" ]; then @@ -714,6 +735,46 @@ propagate_ssh_key() fi }
+is_mode_switched() +{ + local _mod_included + + if [ ! -f $DEFAULT_INITRD ]; then + return 1 + fi + + # find if default initrd has kdumpbase module included. + _mod_included=`lsinitrd -m $DEFAULT_INITRD | grep ^kdumpbase$ | wc -l` + + if [ "$DEFAULT_DUMP_MODE" != "fadump" ]; then + # If kdumpbase module is included in default initrd, + # we must have just switched from fadump mode. + if [ "$_mod_included" -eq "1" ]; then + return 0 + fi + elif [ "$_mod_included" -eq "0" ]; then + # If kdumpbase module is missing in default initrd, + # we must have just switched from kdump mode. + return 0 + fi + + return 1 +} + +handle_mode_switch() +{ + if [ "$DEFAULT_DUMP_MODE" == "fadump" ]; then + # backup initrd for reference before replacing it + # with fadump aware initrd + backup_default_initrd + else + # check if a backup of default initrd exists. If yes, + # it signifies a switch from fadump mode. So, restore + # the backed up default initrd. + restore_default_initrd + fi +} + is_fadump_capable() { # Check if firmware-assisted dump is enabled
Hi Hari,
Thanks for the update, except one nitpick see the inline comment otherwise it looks good to me.
On 11/04/16 at 12:16am, Hari Bathini wrote:
When fadump mode is enabled, the default initrd is rebuilt with kdump dracut module. As the default initrd is altered, the original default initrd is backed up. But we are not restoring it when fadump mode is disabled. This patch tries to restore the backed up default initrd on disabling fadump mode.
Signed-off-by: Hari Bathini hbathini@linux.vnet.ibm.com
Changes from v3:
- Added checksum verification while restoring initrd.
- Moved backup/restore logic under mode switch check.
- Moved mode switch check up to not miss restore while switching back to kdump (in case of a missing kdump initrd).
kdumpctl | 105 +++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 83 insertions(+), 22 deletions(-)
diff --git a/kdumpctl b/kdumpctl index d0bbb55..6153f96 100755 --- a/kdumpctl +++ b/kdumpctl @@ -8,7 +8,10 @@ KDUMP_CONFIG_FILE="/etc/kdump.conf" MKDUMPRD="/sbin/mkdumprd -f" SAVE_PATH=/var/crash SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" +INITRD_CHECKSUM_LOCATION="/root/.fadump_initrd_checksum"
Can we use /boot/ instead of /root/ for the checksum?
DUMP_TARGET="" +DEFAULT_INITRD="" +DEFAULT_INITRD_BAK="" TARGET_INITRD="" FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" FADUMP_REGISTER_SYS_NODE="/sys/kernel/fadump_registered" @@ -154,9 +157,6 @@ rebuild_fadump_initrd() { local target_initrd_tmp
- # backup fadump initrd for reference before replacing it
- backup_initrd
- # this file tells the initrd is fadump enabled touch /tmp/fadump.initramfs target_initrd_tmp="$TARGET_INITRD.tmp"
@@ -220,15 +220,39 @@ check_executable() done }
-backup_initrd() +backup_default_initrd() {
- local target_initrd_bak
- if [ ! -e $DEFAULT_INITRD_BAK ]; then
echo "Backing up $DEFAULT_INITRD before rebuild."
# save checksum to verify before restoring
sha1sum $DEFAULT_INITRD > $INITRD_CHECKSUM_LOCATION
cp $DEFAULT_INITRD $DEFAULT_INITRD_BAK
if [ $? -ne 0 ]; then
echo "WARNING: failed to backup $DEFAULT_INITRD."
rm -f $DEFAULT_INITRD_BAK
fi
- fi
+}
- # Check if backup initrd is already present.
- target_initrd_bak="$TARGET_INITRD.bak"
- if [ ! -e $target_initrd_bak ];then
echo "Backing up $TARGET_INITRD"
cp $TARGET_INITRD $target_initrd_bak
+restore_default_initrd() +{
- # If a backup initrd exists, we must be switching back from
- # fadump to kdump. Restore the original default initrd.
- if [ -f $DEFAULT_INITRD_BAK ] && [ -f $INITRD_CHECKSUM_LOCATION ]; then
# verify checksum before restoring
backup_checksum=`sha1sum $DEFAULT_INITRD_BAK | awk '{ print $1 }'`
default_checksum=`cat $INITRD_CHECKSUM_LOCATION | awk '{ print $1 }'`
if [ "$default_checksum" != "$backup_checksum" ]; then
echo "WARNING: checksum mismatch! Can't restore original initrd.."
else
rm -f $INITRD_CHECKSUM_LOCATION
mv $DEFAULT_INITRD_BAK $DEFAULT_INITRD
if [[ $? -eq 0 ]]; then
echo -n "Restoring original initrd as fadump mode "
echo "is disabled."
sync
fi
fifi
}
@@ -320,10 +344,12 @@ check_boot_dir() fi }
-setup_target_initrd() +setup_initrd() {
- DEFAULT_INITRD="${KDUMP_BOOTDIR}/initramfs-`uname -r`.img"
- DEFAULT_INITRD_BAK="${KDUMP_BOOTDIR}/.initramfs-`uname -r`.img.default" if [ $DEFAULT_DUMP_MODE == "fadump" ]; then
TARGET_INITRD="${KDUMP_BOOTDIR}/initramfs-${kdump_kver}.img"
if [ ! -s "$TARGET_INITRD" ]; then echo "Error: No initrd found to rebuild!" return 1TARGET_INITRD="$DEFAULT_INITRD"
@@ -504,7 +530,6 @@ check_rebuild() local extra_modules local _force_rebuild force_rebuild="0" local ret system_modified="0"
local initramfs_has_fadump
check_boot_dir
@@ -515,7 +540,7 @@ check_rebuild() fi
kdump_kernel="${KDUMP_BOOTDIR}/${KDUMP_IMG}-${kdump_kver}${KDUMP_IMG_EXT}"
- setup_target_initrd
- setup_initrd if [ $? -ne 0 ]; then return 1 fi
@@ -547,15 +572,11 @@ check_rebuild() system_modified="1" fi
- #check if target initrd has fadump support
- if [ "$DEFAULT_DUMP_MODE" = "fadump" ] && [ -f "$TARGET_INITRD" ]; then
initramfs_has_fadump=`lsinitrd -m $TARGET_INITRD | grep ^kdumpbase$ | wc -l`
- fi
- if [ $image_time -eq 0 ]; then
- if is_mode_switched; then
echo -n "Dump mode changed from last boot."; echo
handle_mode_switch
- elif [ $image_time -eq 0 ]; then echo -n "No kdump initial ramdisk found."; echo
- elif [ $DEFAULT_DUMP_MODE == "fadump" ] && [ "$initramfs_has_fadump" -eq "0" ]; then
elif [ "$force_rebuild" != "0" ]; then echo -n "Force rebuild $TARGET_INITRD"; echo elif [ "$system_modified" != "0" ]; thenecho "$TARGET_INITRD has no fadump support"
@@ -714,6 +735,46 @@ propagate_ssh_key() fi }
+is_mode_switched() +{
- local _mod_included
- if [ ! -f $DEFAULT_INITRD ]; then
return 1
- fi
- # find if default initrd has kdumpbase module included.
- _mod_included=`lsinitrd -m $DEFAULT_INITRD | grep ^kdumpbase$ | wc -l`
- if [ "$DEFAULT_DUMP_MODE" != "fadump" ]; then
# If kdumpbase module is included in default initrd,
# we must have just switched from fadump mode.
if [ "$_mod_included" -eq "1" ]; then
return 0
fi
- elif [ "$_mod_included" -eq "0" ]; then
# If kdumpbase module is missing in default initrd,
# we must have just switched from kdump mode.
return 0
- fi
- return 1
+}
+handle_mode_switch() +{
- if [ "$DEFAULT_DUMP_MODE" == "fadump" ]; then
# backup initrd for reference before replacing it
# with fadump aware initrd
backup_default_initrd
- else
# check if a backup of default initrd exists. If yes,
# it signifies a switch from fadump mode. So, restore
# the backed up default initrd.
restore_default_initrd
- fi
+}
is_fadump_capable() { # Check if firmware-assisted dump is enabled
Thanks Dave
Hi Dave,
Thanks for the review..
On Friday 04 November 2016 11:35 AM, Dave Young wrote:
Hi Hari,
Thanks for the update, except one nitpick see the inline comment otherwise it looks good to me.
On 11/04/16 at 12:16am, Hari Bathini wrote:
When fadump mode is enabled, the default initrd is rebuilt with kdump dracut module. As the default initrd is altered, the original default initrd is backed up. But we are not restoring it when fadump mode is disabled. This patch tries to restore the backed up default initrd on disabling fadump mode.
Signed-off-by: Hari Bathini hbathini@linux.vnet.ibm.com
Changes from v3:
Added checksum verification while restoring initrd.
Moved backup/restore logic under mode switch check.
Moved mode switch check up to not miss restore while switching back to kdump (in case of a missing kdump initrd).
kdumpctl | 105 +++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 83 insertions(+), 22 deletions(-)
diff --git a/kdumpctl b/kdumpctl index d0bbb55..6153f96 100755 --- a/kdumpctl +++ b/kdumpctl @@ -8,7 +8,10 @@ KDUMP_CONFIG_FILE="/etc/kdump.conf" MKDUMPRD="/sbin/mkdumprd -f" SAVE_PATH=/var/crash SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" +INITRD_CHECKSUM_LOCATION="/root/.fadump_initrd_checksum"
Can we use /boot/ instead of /root/ for the checksum?
Yeah. I am ok with that too. You want me to re-spin with that change?
- Hari
On 11/08/16 at 02:42pm, Hari Bathini wrote:
Hi Dave,
Thanks for the review..
On Friday 04 November 2016 11:35 AM, Dave Young wrote:
Hi Hari,
Thanks for the update, except one nitpick see the inline comment otherwise it looks good to me.
On 11/04/16 at 12:16am, Hari Bathini wrote:
When fadump mode is enabled, the default initrd is rebuilt with kdump dracut module. As the default initrd is altered, the original default initrd is backed up. But we are not restoring it when fadump mode is disabled. This patch tries to restore the backed up default initrd on disabling fadump mode.
Signed-off-by: Hari Bathini hbathini@linux.vnet.ibm.com
Changes from v3:
Added checksum verification while restoring initrd.
Moved backup/restore logic under mode switch check.
Moved mode switch check up to not miss restore while switching back to kdump (in case of a missing kdump initrd).
kdumpctl | 105 +++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 83 insertions(+), 22 deletions(-)
diff --git a/kdumpctl b/kdumpctl index d0bbb55..6153f96 100755 --- a/kdumpctl +++ b/kdumpctl @@ -8,7 +8,10 @@ KDUMP_CONFIG_FILE="/etc/kdump.conf" MKDUMPRD="/sbin/mkdumprd -f" SAVE_PATH=/var/crash SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" +INITRD_CHECKSUM_LOCATION="/root/.fadump_initrd_checksum"
Can we use /boot/ instead of /root/ for the checksum?
Yeah. I am ok with that too. You want me to re-spin with that change?
No need, will wait about one week, if no other comments I will merge it in Fedora.
Thanks Dave
On 11/08/16 at 05:20pm, Dave Young wrote:
On 11/08/16 at 02:42pm, Hari Bathini wrote:
Hi Dave,
Thanks for the review..
On Friday 04 November 2016 11:35 AM, Dave Young wrote:
Hi Hari,
Thanks for the update, except one nitpick see the inline comment otherwise it looks good to me.
On 11/04/16 at 12:16am, Hari Bathini wrote:
When fadump mode is enabled, the default initrd is rebuilt with kdump dracut module. As the default initrd is altered, the original default initrd is backed up. But we are not restoring it when fadump mode is disabled. This patch tries to restore the backed up default initrd on disabling fadump mode.
Signed-off-by: Hari Bathini hbathini@linux.vnet.ibm.com
Changes from v3:
Added checksum verification while restoring initrd.
Moved backup/restore logic under mode switch check.
Moved mode switch check up to not miss restore while switching back to kdump (in case of a missing kdump initrd).
kdumpctl | 105 +++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 83 insertions(+), 22 deletions(-)
diff --git a/kdumpctl b/kdumpctl index d0bbb55..6153f96 100755 --- a/kdumpctl +++ b/kdumpctl @@ -8,7 +8,10 @@ KDUMP_CONFIG_FILE="/etc/kdump.conf" MKDUMPRD="/sbin/mkdumprd -f" SAVE_PATH=/var/crash SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" +INITRD_CHECKSUM_LOCATION="/root/.fadump_initrd_checksum"
Can we use /boot/ instead of /root/ for the checksum?
Yeah. I am ok with that too. You want me to re-spin with that change?
No need, will wait about one week, if no other comments I will merge it in Fedora.
Hari, applied the patches in Fedora rawhide, please feel free to do a test with below build:
http://koji.fedoraproject.org/koji/buildinfo?buildID=817006
Thanks Dave _______________________________________________ kexec mailing list -- kexec@lists.fedoraproject.org To unsubscribe send an email to kexec-leave@lists.fedoraproject.org
On Friday 11 November 2016 12:10 PM, Dave Young wrote:
On 11/08/16 at 05:20pm, Dave Young wrote:
On 11/08/16 at 02:42pm, Hari Bathini wrote:
Hi Dave,
Thanks for the review..
On Friday 04 November 2016 11:35 AM, Dave Young wrote:
Hi Hari,
Thanks for the update, except one nitpick see the inline comment otherwise it looks good to me.
On 11/04/16 at 12:16am, Hari Bathini wrote:
When fadump mode is enabled, the default initrd is rebuilt with kdump dracut module. As the default initrd is altered, the original default initrd is backed up. But we are not restoring it when fadump mode is disabled. This patch tries to restore the backed up default initrd on disabling fadump mode.
Signed-off-by: Hari Bathini hbathini@linux.vnet.ibm.com
Changes from v3:
Added checksum verification while restoring initrd.
Moved backup/restore logic under mode switch check.
Moved mode switch check up to not miss restore while switching back to kdump (in case of a missing kdump initrd).
kdumpctl | 105 +++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 83 insertions(+), 22 deletions(-)
diff --git a/kdumpctl b/kdumpctl index d0bbb55..6153f96 100755 --- a/kdumpctl +++ b/kdumpctl @@ -8,7 +8,10 @@ KDUMP_CONFIG_FILE="/etc/kdump.conf" MKDUMPRD="/sbin/mkdumprd -f" SAVE_PATH=/var/crash SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" +INITRD_CHECKSUM_LOCATION="/root/.fadump_initrd_checksum"
Can we use /boot/ instead of /root/ for the checksum?
Yeah. I am ok with that too. You want me to re-spin with that change?
No need, will wait about one week, if no other comments I will merge it in Fedora.
Hari, applied the patches in Fedora rawhide, please feel free to do a test with below build:
Hi Dave,
Thanks for picking the patches.. Tested successfully with kexec-tools-2.0.13-8.fc26.ppc64le.rpm
- Hari