On 1/14/21 11:42 AM, Lianbo Jiang wrote:
Currently, kdump will fail to save vmcore when using the scp and
ipv6.
The reason is that the scp requires IPv6 addresses to be enclosed in
square brackets, but ssh doesn’t require this.
Let's enclose the ipv6 address in square brackets for scp dump.
Signed-off-by: Lianbo Jiang <lijiang(a)redhat.com>
---
dracut-kdump.sh | 32 +++++++++++++++++++++++++++++---
kdump-lib-initramfs.sh | 1 +
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index 370d217cea52..3367bc5f7c63 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -111,6 +111,7 @@ dump_ssh()
local _dir="$KDUMP_PATH/$HOST_IP-$DATEDIR"
local _host=$2
local _vmcore="vmcore"
+ local _ipv6_addr="" _username=""
dinfo "saving to $_host:$_dir"
@@ -122,8 +123,17 @@ dump_ssh()
dinfo "saving vmcore"
+ if is_ipv6_address "$_host"; then
+ _username=${_host%@*}
+ _ipv6_addr="[${_host#*@}]"
+ fi
+
if [ "${CORE_COLLECTOR%%[[:blank:]]*}" = "scp" ]; then
- scp -q $_opt /proc/vmcore "$_host:$_dir/vmcore-incomplete"
+ if [ -n "$_username" ] && [ -n "$_ipv6_addr" ];
then
+ scp -q $_opt /proc/vmcore
"$_username@$_ipv6_addr:$_dir/vmcore-incomplete"
+ else
+ scp -q $_opt /proc/vmcore "$_host:$_dir/vmcore-incomplete"
+ fi
_exitcode=$?
else
$CORE_COLLECTOR /proc/vmcore | ssh $_opt $_host "dd bs=512
of=$_dir/vmcore-incomplete"
@@ -143,8 +153,13 @@ dump_ssh()
derror "saving vmcore failed, _exitcode:$_exitcode"
fi
+ dinfo "saving the $KDUMP_LOG_FILE to $_host:$_dir/"
save_log
- scp -q $_opt $KDUMP_LOG_FILE "$_host:$_dir/"
+ if [ -n "$_username" ] && [ -n "$_ipv6_addr" ]; then
+ scp -q $_opt $KDUMP_LOG_FILE "$_username@$_ipv6_addr:$_dir/"
+ else
+ scp -q $_opt $KDUMP_LOG_FILE "$_host:$_dir/"
+ fi
_ret=$?
if [ $_ret -ne 0 ]; then
derror "saving log file failed, _exitcode:$_ret"
@@ -161,6 +176,7 @@ save_opalcore_ssh() {
local _path=$1
local _opts="$2"
local _location=$3
+ local _user_name="" _ipv6addr=""
ddebug "_path=$_path _opts=$_opts _location=$_location"
@@ -173,8 +189,18 @@ save_opalcore_ssh() {
fi
fi
+ if is_ipv6_address "$_host"; then
+ _user_name=${_location%@*}
+ _ipv6addr="[${_location#*@}]"
+ fi
+
dinfo "saving opalcore:$OPALCORE to $_location:$_path"
- scp $_opts $OPALCORE $_location:$_path/opalcore-incomplete
+
+ if [ -n "$_user_name" ] && [ -n "$_ipv6addr" ]; then
+ scp $_opts $OPALCORE $_user_name@$_ipv6addr:$_path/opalcore-incomplete
+ else
+ scp $_opts $OPALCORE $_location:$_path/opalcore-incomplete
+ fi
if [ $? -ne 0 ]; then
derror "saving opalcore failed"
return 1
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index e766f95c7d6a..4eba3db75673 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -168,6 +168,7 @@ dump_fs()
derror "saving vmcore failed, _exitcode:$_exitcode"
fi
+ dinfo "saving the $KDUMP_LOG_FILE to $_dump_path/"
save_log
mv $KDUMP_LOG_FILE $_dump_path/
if [ $_exitcode -ne 0 ]; then
Acked-by: Pingfan Liu <piliu(a)redhat.com>