On 01/05/15 at 10:41am, Dave Young wrote:
[snip]
..
[snip]
> > > @@ -121,9 +121,13 @@ get_host_ip()
> > > then
> > > kdumpnic=$(getarg kdumpnic=)
> > > [ -z "$kdumpnic" ] && echo "kdump: failed
to get kdumpnic!" && return 1
> > > - _host=`ip addr show dev $kdumpnic|grep 'inet '`
> > > + if is_ipv6_target; then
> > > + _host=`ip -6 addr show dev $kdumpnic|grep 'inet6'`
> > > + else
> > > + _host=`ip addr show dev $kdumpnic|grep 'inet '`
> > > + fi
> >
> > In Fedora 19 `ip addr show` will print both inet and inet6 addresses, so for
hostname
> > based configs it will choose anything which is ok.
> >
> > As for my test, it shows below, the inet6 addresses is a local link scope addr,
so
> > we should better use the ipv4 addresses if ipv4 is available.
> > [dyoung@dhcp-**-** kexec-tools]$ ip addr show eno1|grep inet
> > inet 10.66.128.45/23 brd 10.66.129.255 scope global eno1
> > inet6 fe80::82c1:6eff:fef7:da3c/64 scope link
> >
> > Another way is improve is_ipv6_target as is_ipv6_addr for ipv6 target which is
> > specified as ipv6 addresses in kdump.conf?
>
> We will use the ip address which specifies in the kdump.conf config. If
> the target value is domain/hostname, we will use command "get ahost
> $_server" to get the first returned ip address.
Sorry, I mixed up target and source, in this code path kdumpnic ip address means crashed
machine ip address. is_ipv6 stuff is another story.
Yes.
As for local ip address, what I want to make clear is if we can use ip addr show instead
of differenciate "ip" and "ip -6"
We will get the ipv6 address by using "ip -6", if specified the target
value is ipv6 adreess.
Fist of all, we will get the ip address in the kdump.conf config, if the
value is domain/hostname, parse the it by using command "getent ahosts".
>
> >
> > > [ $? -ne 0 ] && echo "kdump: wrong kdumpnic:
$kdumpnic" && return 1
> > > - _host="${_host##*inet }"
> > > + _host=`echo $_host | cut -d' ' -f2`
> > > _host="${_host%%/*}"
> > > [ -z "$_host" ] && echo "kdump: wrong
kdumpnic: $kdumpnic" && return 1
> > > HOST_IP=$_host
> > > diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
> > > index 10f7c83..072b6a5 100755
> > > --- a/dracut-module-setup.sh
> > > +++ b/dracut-module-setup.sh
> > > @@ -70,14 +70,25 @@ kdump_setup_dns() {
> > > #$2: srcaddr
> > > #if it use static ip echo it, or echo null
> > > kdump_static_ip() {
> > > - local _netmask _gateway
> > > + local _netmask _gateway _ipaddr
> > > local _netdev="$1" _srcaddr="$2"
> > > - local _ipaddr=$(ip addr show dev $_netdev permanent | \
> > > +
> > > + if is_ipv6_target; then
> >
> > ditto question about hostname and addresses
> >
>
> What the function is_ipv6_target does is to parse and verify the
> kdump.conf's target value. So I think whatever the function names
> is_ipv6_target or is_ipv6_address is okay.
is_ipv6_address is clearer if we only care about ip adresses instead of
both hostname (ipv6 configured) and addresses.
is_ipv6_address may imply to parse the parameter ip address which is
ipv6 or not. Due to the parameter is not only ip address, so I think
is_ipv6_target is fine.
>
> > > + _ipaddr=$(ip -6 addr show dev $_netdev permanent | \
> > > + awk "/ $_srcaddr\/.* /{print \$2}")
[snip]
...
[snip]
> > > kdump_setup_netdev "${_netdev}"
"${_srcaddr}" "${_server}"
> > > @@ -303,10 +349,15 @@ kdump_setup_currect_net() {
> > > kdump_install_net() {
> > > local config_val="$1" _server _need_dns
> > >
> > > - _server=`echo $config_val | sed 's/.*@//' | cut -d':'
-f1`
> > > + _server=`get_remote_host $config_val`
> > >
> > > - _need_dns=`echo $_server|grep "[a-zA-Z]"`
> > > - [ -n "$_need_dns" ] && _server=`getent hosts
$_server|cut -d' ' -f1`
> > > + if is_ipv6_target; then
> > > + _need_dns=`echo $_server|grep "[:]"`
> >
> > A new function such as is_hostname() or ! is_ip_addr() will be better here.
> >
>
> Do we need a function to implement it? just for a simple filter.
This is for differenciate hostname and ip addresses because current patch
is trying determine a hostname is ipv6 or ipv4. As long as this can be resolved
I do not think such as function is must.
We may mix up the ipv4 address and ipv6 address, if we wrap it to a
function. Following function can determine the hostname/domain or ip
address(ipv4 and ipv6).
is_hostname()
{
echo $1 | grep "[a-zA-Z]" | grep -q "."
}