On 07/08/15 at 12:38pm, Dave Young wrote:
On 07/08/15 at 10:48am, Minfei Huang wrote:
> On 07/08/15 at 10:39am, Dave Young wrote:
> > On 07/02/15 at 07:34pm, Minfei Huang wrote:
> > > Both getent hosts and getent ahosts can potentially print both IPv4 and
> > > IPv6 addresses, but they decide which address(es) to print differently.
> > >
> > > hosts calls gethostbyname2 (the IPv6-supporting variant of
> > > gethostbyname). The behavior is hard-coded: look up an IPv6 address, and
> > > if none exists, look up an IPv4 address.
> > >
> > > ahosts calls getaddrinfo. This function enumerates all protocols for a
> > > given name, so it can return both IPv4 and IPv6 addresses in the same
> > > call. What it returns is determined by the settings in /etc/gai.conf.
> > > Because many applications are still struggling to cope with IPv6, most
> > > distributions prefer IPv4 by default and only use IPv6 by explicit
> > > request.
> >
> > The above description still does not explain why do we need to change to
> > use ahosts, is is mandatory to ipv6 patches? why?
> >
>
> We will use the ip address which may be converted from the hostname to
> setup the static ip.
Ok, it is fine to me.
This patch has another two functions for hostname just split it as another patch.
You mean splitting the library function as another patch? Due to too
much more patch, it may does not readable.
Thanks
Minfei
>
> Thanks
> Minfei
>
> > >
> > > Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
> > > ---
> > > dracut-module-setup.sh | 5 ++---
> > > kdump-lib.sh | 28 ++++++++++++++++++++++++++++
> > > 2 files changed, 30 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
> > > index 7cc3531..41c21f4 100755
> > > --- a/dracut-module-setup.sh
> > > +++ b/dracut-module-setup.sh
> > > @@ -305,10 +305,9 @@ kdump_install_net() {
> > > local _server _netdev _srcaddr
> > > local config_val="$1"
> > >
> > > - _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`
> > > + is_hostname $_server && _server=`getent ahosts $_server |
head -1 | cut -d' ' -f1`
> > >
> > > _netdev=`/sbin/ip route get to $_server 2>&1`
> > > [ $? != 0 ] && echo "Bad kdump location:
$config_val" && exit 1
> > > diff --git a/kdump-lib.sh b/kdump-lib.sh
> > > index 1b98a6f..b83516b 100755
> > > --- a/kdump-lib.sh
> > > +++ b/kdump-lib.sh
> > > @@ -206,3 +206,31 @@ is_ipv6_address()
> > > {
> > > echo $1 | grep -q ":"
> > > }
> > > +
> > > +# get ip address or hostname from nfs/ssh config value
> > > +get_remote_host()
> > > +{
> > > + local _config_val=$1
> > > +
> > > + # in ipv6, the _config_val format is [xxxx:xxxx::xxxx%eth0]:/mnt/nfs
or
> > > + # username at xxxx:xxxx::xxxx%eth0. what we need is just
xxxx:xxxx::xxxx
> > > + _config_val=${_config_val#*@}
> > > + _config_val=${_config_val%:/*}
> > > + _config_val=${_config_val#[}
> > > + _config_val=${_config_val%]}
> > > + _config_val=${_config_val%\%*}
> > > + echo $_config_val
> > > +}
> > > +
> > > +# if the passed parameter is hostname/domain, it will be satisfied with
> > > +# condition which it is without colon ":", and contains the
[a-zA-Z]
> > > +# $1: hostname/ip address
> > > +is_hostname()
> > > +{
> > > + local _hostname=`echo $1 | grep ":"`
> > > +
> > > + if [ -n "$_hostname" ]; then
> > > + return 1
> > > + fi
> > > + echo $1 | grep -q "[a-zA-Z]"
> > > +}
> > > --
> > > 2.1.0
> > >