On 07/02/15 at 07:34pm, 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 | 39 ++++++++++++++++++++++++++++-----------
kdump-lib.sh | 5 +++++
2 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index d2f6a02..7cc3531 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -211,23 +211,40 @@ 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
+# cache '
+# ipv6:
+# _route='2001:11::11f from :: dev eth1 src 2001:11::120 metric 0
+# cache'
+# 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
+# cache '
+# ipv6:
+# _route='2001:10::120 from :: via 2001:11::11f dev eth1 src 2001:11::120
metric 0
+# cache'
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
+ is_ipv6=1
drop is_ipv6 and move _starget= here is better.
+ fi
+
+ if [ $is_ipv6 = 1 ]; then
+ _target="[$_target]"
+ fi
if `echo $_route | grep -q "via"`; then
# route going to a different subnet via a router
- _nexthop=`echo $_route | awk '{print $3}'`
+ if [ $is_ipv6 = 1 ]; then
+ _nexthop="[`echo $_route | awk '{print $5}'`]"
+ else
+ _nexthop=`echo $_route | awk '{print $3}'`
+ fi
I assume you want get the field after 'via' keyword? if so how about search
and parse the route output and just get the word after ' via ', then you do
not need depend on the field number.
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