Hi, Minfei
On 07/13/15 at 02:11pm, Minfei Huang wrote:
Hi, Dave.
I would like putting the annotation in the kdump.conf.5.
I think add it in howto make more sense, because there's a lot of
types of supported targets, we can not add every details in manpage.
Just add a line in howto.txt about support ipv6 setup except link
scope addresses.
diff --git a/kdump.conf.5 b/kdump.conf.5
index f1c2a2c..4fe07c2 100644
--- a/kdump.conf.5
+++ b/kdump.conf.5
@@ -36,14 +36,16 @@ partition devices, such as /dev/vg/<devname>.
.RS
Will mount fs and copy /proc/vmcore to <mnt>/var/crash/%HOST-%DATE/,
supports DNS. Note that a fqdn should be used as the server name in the
-mount point
+mount point. For now, kdump only supports non-local ipv6 address, which
+is around with bracket "[]".
.RE
.B ssh <user@server>
.RS
Will scp /proc/vmcore to <user@server>:/var/crash/%HOST-%DATE/,
supports DNS. NOTE: make sure user has necessary write permissions on
-server and that a fqdn is used as the server name
+server and that a fqdn is used as the server name. For now, kdump only
+supports non-local ipv6 address, which is around with bracket "[]".
.RE
.B sshkey <path>
How do you think?
On 07/13/15 at 01:44pm, Dave Young wrote:
> On 07/13/15 at 01:16pm, Minfei Huang wrote:
> > Instroduce lib function get_remote_host to be used to strip the
> > characters around the ip address or hostname.
> >
> > Instroduce lib function is_hostname to identify the specified string is
> > ip address(ipv4/ipv6) or hostname. If the specified string is hostname,
> > we can use command "getent hosts" to parse it and get the ip
> > address(ipv4/ipv6).
> >
> > In order to setup the network in 2nd kernel, we need the network device
> > and target ip address. we use the command "ip route" to get the
route
> > info.
> >
> > Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
> > ---
> > dracut-module-setup.sh | 22 ++++++----------------
> > kdump-lib.sh | 28 ++++++++++++++++++++++++++++
> > 2 files changed, 34 insertions(+), 16 deletions(-)
> >
> > diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
> > index 75737fd..f47e57e 100755
> > --- a/dracut-module-setup.sh
> > +++ b/dracut-module-setup.sh
> > @@ -300,28 +300,18 @@ kdump_setup_netdev() {
> > #$1: config values of net line in kdump.conf
> > #$2: srcaddr of network device
> > kdump_install_net() {
> > - local _server _netdev _srcaddr
> > + local _server _netdev _srcaddr _route
> > 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 hosts $_server | head -n 1
| cut -d' ' -f1`
> >
> > - _netdev=`/sbin/ip route get to $_server 2>&1`
> > + _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 [ -n "`echo $_netdev | grep via`" ]
> > - then
> > - # we are going to a different subnet
> > - _srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
> > - _netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
> > - else
> > - # we are on the same subnet
> > - _srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1`
> > - _netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
> > - fi
> > + _srcaddr=$(get_ip_route_field "$_route" "src")
> > + _netdev=$(get_ip_route_field "$_route" "dev")
> >
> > kdump_setup_netdev "${_netdev}" "${_srcaddr}"
"${_server}"
> >
> > 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
>
> Since we do not support link scopt addresses yet, should remove the %eth0 comment
> and code, add some early check code to error out in case link scopt or document
> it somewhere ie in howto.txt.
>
> I missed this part last time, care to resend this patch only?
>
> Otherwise, ack the patch
>
> > + _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
> >