In order to enhance kdump to support ipv6, support the static route with
ipv6, which ipv4 has supported already.
Due to the different format with ipv4 and ipv6, dracut uses bracket "[]"
to quote the ipv6 address to identify it in the 2nd kernel.
Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
Acked-by: Baoquan He <bhe(a)redhat.com>
---
dracut-module-setup.sh | 50 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 34 insertions(+), 16 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 9381996..95b73f8 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -195,27 +195,45 @@ 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
- _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
- _netdev=$(kdump_setup_ifname $_netdev)
+ if is_ipv6_address $_target; then
+ _route=`/sbin/ip -6 route get to $_target 2>&1`
+ _netdev=$(kdump_setup_ifname $_netdev)
+ if `echo $_route | grep -q "via"`; then
+ # route going to a different subnet via a router
+ _nexthop=`echo $_route | awk '{print $5}'`
+ echo "rd.route=[$_target]:[$_nexthop]:$_netdev" >>
${initdir}/etc/cmdline.d/45route-static.conf
+ else
+ echo "rd.route=[$_target]::$_netdev" >>
${initdir}/etc/cmdline.d/45route-static.conf
+ fi
+ else
+ _route=`/sbin/ip route get to $_target 2>&1`
+ if `echo $_route | grep -q "via"`; then
+ # route going to a different subnet via a router
+ _nexthop=`echo $_route | awk '{print $3}'`
+ fi
+ _netdev=$(kdump_setup_ifname $_netdev)
- echo "rd.route=$_target:$_nexthop:$_netdev" >>
${initdir}/etc/cmdline.d/45route-static.conf
+ echo "rd.route=$_target:$_nexthop:$_netdev" >>
${initdir}/etc/cmdline.d/45route-static.conf
+ fi
}
# Setup dracut to bringup a given network interface
--
1.9.3