On 07/09/15 at 01:48pm, Minfei Huang wrote:
On 07/09/15 at 01:27pm, Dave Young wrote:
> On 07/09/15 at 11:18am, Minfei Huang wrote:
> > Previously, Kdump will save exact route to setup the network route in
> > 2nd kernel for ipv4 protocol. To support ipv6 protocol, make Kdump fetch
> > correct nexthop, since the ruturning format is different.
> >
> > Due to the different format between ipv4 and ipv6 protocol, quote the
> > ipv6 address with bracket "[]" to make dracut notify.
> >
> > Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
> > ---
> > dracut-module-setup.sh | 31 ++++++++++++++++++++-----------
> > kdump-lib.sh | 5 +++++
> > 2 files changed, 25 insertions(+), 11 deletions(-)
> >
> > diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
> > index d2f6a02..898229e 100755
> > --- a/dracut-module-setup.sh
> > +++ b/dracut-module-setup.sh
> > @@ -211,23 +211,32 @@ kdump_setup_znet() {
> > echo rd.znet=${NETTYPE},${SUBCHANNELS}${_options} >
${initdir}/etc/cmdline.d/30znet.conf
> > }
> >
> > +#
> > +# For the same subnet region, following is the route format
> > +# ipv4:
> > +# _route='192.168.200.137 dev eth1 src 192.168.200.129'
> > +# ipv6:
> > +# _route='2001:11::11f dev eth1 src 2001:11::120 metric 0'
> > +# For the different subnet region, following is the route format
> > +# ipv4:
> > +# _route='192.168.201.215 via 192.168.200.137 dev eth1 src
192.168.200.129'
> > +# ipv6:
> > +# _route='2001:10::120 via 2001:11::11f dev eth1 src 2001:11::120
metric 0'
> > get_routes() {
> > local _netdev="$1" _target="$2"
> > - local _route _nexthop
> > + local _route _nexthop _is_ipv6=0
> >
> > _route=`/sbin/ip route get to $_target 2>&1`
> > -#
> > -# in the same subnet region, following is the route format
> > -# _route='192.168.200.137 dev eth1 src 192.168.200.129
> > -# cache '
> > -#
> > -# in the different subnet region, following is the route format
> > -# _route='192.168.201.215 via 192.168.200.137 dev eth1 src
192.168.200.129
> > -# cache '
> > -#
> > + if $(is_ipv6_address `echo $_route | head -1 | cut -d " " -f1`);
then
For using only one line, there's an option '-o', seems in dracut they use
below:
ip -o route get to ..
> > + _is_ipv6=1
> > + _target="[$_target]"
> > + fi
> > +
>
> _is_ipv6 is not necessary, please drop it and merge the if else sections.
ok.
>
> > if `echo $_route | grep -q "via"`; then
> > - # route going to a different subnet via a router
Where did above comment go?
> > _nexthop=`echo $_route | awk '{print
$3}'`
>
> _nexthop can also use the latter patch function like get_route_field $_route
"via"
>
> So I still think merge these two patches is better
>
I think using the different patch to setup network and static route is
more readable. Each function which contains different function has a
single patch.
Ok
Thanks
Minfei
> > + if [ $_is_ipv6 = 1 ]; then
> > + _nexthop="[$_nexthop]"
> > + fi
move them in one if section for adding [ is fine so you can only use
is_ipv6_addr without _is_ipv6
> > fi
> > _netdev=$(kdump_setup_ifname $_netdev)
> >
> > diff --git a/kdump-lib.sh b/kdump-lib.sh
> > index e62b4e2..1b98a6f 100755
> > --- a/kdump-lib.sh
> > +++ b/kdump-lib.sh
> > @@ -201,3 +201,8 @@ is_atomic()
> > {
> > grep -q "ostree" /proc/cmdline
> > }
> > +
> > +is_ipv6_address()
> > +{
> > + echo $1 | grep -q ":"
> > +}
> > --
> > 2.1.0
> >