Hi,

On Thu, Aug 24, 2017 at 4:47 PM, Xunlei Pang <xpang@redhat.com> wrote:
On 08/24/2017 at 02:00 PM, Ziyue Yang wrote:
> 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.
>
> This commit
> 1) adds a helper function is_ipv6_link_local to find out
> whether a host is a link local ipv6 address;
> 2) makes get_remote_host function remove network interface
> in link local ipv6 addresses if there are any to support
> host finding for link local ipv6 addresses.
>
> Signed-off-by: Ziyue Yang <ziyang@redhat.com>
> ---
>  kdump-lib.sh | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/kdump-lib.sh b/kdump-lib.sh
> index 3f0af91..e67efda 100755
> --- a/kdump-lib.sh
> +++ b/kdump-lib.sh
> @@ -312,6 +312,13 @@ is_ipv6_address()
>      echo $1 | grep -q ":"
>  }
>
> +is_ipv6_link_local()
> +{
> +    is_ipv6_address $1 && {
> +        echo $1 | grep -q "^fe80::"
> +    }
> +}
> +
>  # get ip address or hostname from nfs/ssh config value
>  get_remote_host()
>  {
> @@ -323,6 +330,10 @@ get_remote_host()
>      _config_val=${_config_val%:/*}
>      _config_val=${_config_val#[}
>      _config_val=${_config_val%]}
> +    # factor out network inteface segment in link local ipv6 address
> +    if is_ipv6_link_local $_config_val; then
> +        _config_val=${_config_val%\%*}
> +    fi

I think we better document the special link local format in /etc/kdump.conf or somewhere,
and add a sanity check in kdumpctl to ensure the correct format(i.e. appended with the zone idx).

Seems that sanity check for config values in kdumpctl is the same for all of them(i.e. check non empty). I think it's not worth to break the code here, since if the address is not in correct format, the ssh or ip command would fail and print out the invalid config value.
 

>      echo $_config_val
>  }
>