On 07/13/15 at 01:16pm, Minfei Huang wrote:
Introduce a lib function to get the specified route field.
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 | 43 +++++++++++++++++++++++++++++--------------
kdump-lib.sh | 5 +++++
2 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index d2f6a02..75737fd 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -211,26 +211,41 @@ kdump_setup_znet() {
echo rd.znet=${NETTYPE},${SUBCHANNELS}${_options} >
${initdir}/etc/cmdline.d/30znet.conf
}
+get_ip_route_field()
+{
+ if `echo $1 | grep -q $2`; then
+ echo ${1##*$2} | cut -d ' ' -f1
+ fi
+}
+
+#
+# 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
- _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 `echo $_route | grep -q "via"`; then
- # route going to a different subnet via a router
- _nexthop=`echo $_route | awk '{print $3}'`
- fi
+ _route=`/sbin/ip -o route get to $_target 2>&1`
+
+ # route going to a different subnet via a router
+ _nexthop=$(get_ip_route_field "$_route" "via")
_netdev=$(kdump_setup_ifname $_netdev)
+ if $(is_ipv6_address `echo $_route | cut -d " " -f1`); then
+ if [ -n $_nexthop ]; then
+ _nexthop="[$_nexthop]"
+ fi
+ _target="[$_target]"
+ fi
+
echo "rd.route=$_target:$_nexthop:$_netdev" >>
${initdir}/etc/cmdline.d/45route-static.conf
}
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
Ack
Thanks
Dave