On 07/08/15 at 12:54pm, Minfei Huang wrote:
On 07/08/15 at 12:39pm, Dave Young wrote:
> On 07/08/15 at 11:10am, Minfei Huang wrote:
> > On 07/08/15 at 10:42am, Dave Young wrote:
> > > On 07/02/15 at 07:34pm, Minfei Huang wrote:
> > > > Get route to setup the network.
> > >
> > > The patch description is too short, what's the diffrence between this
one
> > > and previous for static route support?
> >
> > The patch is primary doing what the previous patch does.
>
> If it is the case then merge the two patches as one..
>
In the previous version, you memntioned that splitting the patch as two
patch is more readable.
But I failed to get what this patch is doing, patch description does not
tell much.
Thanks
Minfei
> >
> > In some situation, the result of "ip route" will contain the string
> > "from ::". So we shall take care of it carefully.
> >
> > >
> > > >
> > > > Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
> > > > ---
> > > > dracut-module-setup.sh | 39 ++++++++++++++++++++++++++++++---------
> > > > 1 file changed, 30 insertions(+), 9 deletions(-)
> > > >
> > > > diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
> > > > index 41c21f4..236b7bf 100755
> > > > --- a/dracut-module-setup.sh
> > > > +++ b/dracut-module-setup.sh
> > > > @@ -302,7 +302,7 @@ 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 _is_ipv6 _has_from
> > > > local config_val="$1"
> > > >
> > > > _server=$(get_remote_host $config_val)
> > > > @@ -312,16 +312,37 @@ kdump_install_net() {
> > > > _netdev=`/sbin/ip route get to $_server 2>&1`
> > > > [ $? != 0 ] && echo "Bad kdump location:
$config_val" && exit 1
> > > >
> > > > + if $(is_ipv6_address `echo $_netdev | head -1 | cut -d "
" -f1`); then
> > > > + _is_ipv6=1
> > > > + fi
> > > > +
> > > > + if `echo $_netdev | head -1 | cut -d " " -f2 | grep -q
"from"`; then
> > > > + _has_from=1
> > > > + fi
> > > > +
> > > > #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`
> > > > + if [ -n "`echo $_netdev | grep via`" ]; then
> > > > + if [[ $_is_ipv6 = 1 ]] && [[ $_has_from = 1 ]];
then
> > > > + # 2001:151::112 via 2001:150::121 from :: dev eth1 src
2001:150::120 metric 0
> > > > + _srcaddr=`echo $_netdev|awk '{print $9}'|head -n
1`
> > > > + _netdev=`echo $_netdev|awk '{print $7;}'|head -n
1`
> > >
> > > Since you wang the ' src ' field, parse and return the substring
after ' src ' is better
> > > instead of a lot of if else fi
> > >
> > > For _netdev, you can parse the string and get word after ' dev '
> > >
> >
> > ok. will do.
> >
> > > Ditto for latter chunks.
> > >
> > > > + else
> > > > + # 2001:151::112 via 2001:150::121 dev eth1 src
2001:150::120 metric 0
> > > > + # 192.168.151.215 via 192.168.150.137 dev kdump-eth1
src 192.168.150.129
> > > > + _srcaddr=`echo $_netdev|awk '{print $7}'|head -n
1`
> > > > + _netdev=`echo $_netdev|awk '{print $5;}'|head -n
1`
> > > > + fi
> > > > 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`
> > > > + if [[ $_is_ipv6 = 1 ]] && [[ $_has_from = 1 ]];
then
> > > > + # 2001:150::11f from :: dev eth1 src 2001:150::120
metric 0
> > > > + _srcaddr=`echo $_netdev|awk '{print $7}'|head -n
1`
> > > > + _netdev=`echo $_netdev|awk '{print $5}'|head -n
1`
> > > > + else
> > > > + # 2001:150::11f dev eth1 src 2001:150::120 metric 0
> > > > + # 192.168.150.137 dev eth1 src 192.168.150.129
> > > > + _srcaddr=`echo $_netdev|awk '{print $5}'|head -n
1`
> > > > + _netdev=`echo $_netdev|awk '{print $3}'|head -n
1`
> > > > + fi
> > > > fi
> > > >
> > > > kdump_setup_netdev "${_netdev}"
"${_srcaddr}" "${_server}"
> > > > --
> > > > 2.1.0
> > > >