When dumping to ssh via local ipv6 address, the ssh parameter in kdump.conf is supposed to have the form like
ssh user@fe80::cc1:8bff:fe90:b95f%eth0
where "%eth0" is an existing network interface supporting ipv6.
The get_remote_host function in kdump-lib.sh currently doesn't remove the network interface in the link local ipv6 addresses, causing the ip command in kdump_install_net function to fail, leading to a "Bad kdump location" message.
Meanwhile, current logic in kdump_install_net and kdump_setup_iscsi_device will find the network interface to use by "ip route" command, which might be different from what user specified in kdump.conf in link local ipv6 cases.
This commit 1) adds a helper function is_ipv6_link_local to find out whether a host is a link local ipv6 address. 2) changes logic in kdump_install_net and kdump_setup_iscsi_device to get rid of ifname for link local ipv6 before ip command, and use network interface specified in link local ipv6 cases.
Signed-off-by: Ziyue Yang ziyang@redhat.com --- dracut-module-setup.sh | 33 ++++++++++++++++++++++++--------- kdump-lib.sh | 5 +++++ 2 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ae13337..70fd572 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -341,12 +341,19 @@ kdump_install_net() { _server=`echo $_serv_tmp | cut -d' ' -f1` fi
- _route=`/sbin/ip -o route get to $_server 2>&1` - [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1 - - #the field in the ip output changes if we go to another subnet + if is_ipv6_link_local $_server; then + # use network interface specified by link local address + _netdev=${_server##*%} + _server=${_server%%*} + _route=$(/sbin/ip -o route get to $_server dev $_netdev 2>&1) + [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1 + else + _route=$(/sbin/ip -o route get to $_server 2>&1) + [ $? != 0 ] && echo "Bad kdump location: $config_val" && exit 1 + # the field in the ip output changes if we go to another subnet + _netdev=$(get_ip_route_field "$_route" "dev") + fi _srcaddr=$(get_ip_route_field "$_route" "src") - _netdev=$(get_ip_route_field "$_route" "dev")
kdump_setup_netdev "${_netdev}" "${_srcaddr}"
@@ -573,10 +580,18 @@ kdump_setup_iscsi_device() {
[ -n "$username_in" ] && userpwd_in_str=":$username_in:$password_in"
- netdev=$(/sbin/ip route get to ${tgt_ipaddr} | \ - sed 's|.*dev (.*).*|\1|g') - srcaddr=$(echo $netdev | awk '{ print $3; exit }') - netdev=$(echo $netdev | awk '{ print $1; exit }') + if is_ipv6_link_local $tgt_ipaddr; then + # use network interface specified by link local address + netdev=${tgt_ipaddr##*%} + tgt_ipaddr_no_ifname=${tgt_ipaddr%%*} + route=$(/sbin/ip -o route get to $tgt_ipaddr_no_ifname dev $netdev 2>&1) + [ $? != 0 ] && echo "Bad iSCSI address: $tgt_ipaddr" && exit 1 + else + route=$(/sbin/ip -o route get to $tgt_ipaddr 2>&1) + [ $? != 0 ] && echo "Bad iSCSI address: $tgt_ipaddr" && exit 1 + netdev=$(get_ip_route_field "$route" "dev") + fi + srcaddr=$(get_ip_route_field "$route" "src")
kdump_setup_netdev $netdev $srcaddr
diff --git a/kdump-lib.sh b/kdump-lib.sh index 3f0af91..fb3e354 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -312,6 +312,11 @@ is_ipv6_address() echo $1 | grep -q ":" }
+is_ipv6_link_local() +{ + echo $1 | grep -q "^fe80::" +} + # get ip address or hostname from nfs/ssh config value get_remote_host() {