On Mon, Aug 18, 2014 at 04:34:53PM +0800, Baoquan He wrote:
Previously for solving static route issues, all routes which go
through a specific dev will be saved in 1st kernel, and then added
in 2nd kernel. Because we use below search pattern, an exception
will happen:
/sbin/ip route show | grep -v default | grep "^[[:digit:]].*via.* $_netdev"
That exception is a corner case which happened when 2 machines connected
directly by cable and the 2 network interfaces are configured in
different network subnets. E.g there are 2 machines A and B:
A:ens10 < ------ > B:ens9
A:ens10 inet 192.168.100.111/24 scope global ens10
route need be added in A:
192.168.110.0/24 dev ens10
B:ens9 inet 192.168.110.222/24 scope global ens9
route need be added in B
192.168.100.0/24 dev ens9
Now if A want to dump to B, the route "192.168.110.0/24 dev ens10"
has to be saved and added in 2nd kernel.
So in this patch "ip route get to $target" command is executed, then
an exact route can be got for going to that target. By this, static
route works and the corner case can be fixed too.
Hi Bao,
Using "ip route get to" requires knowing the target. But that's little
different than bringing up an interface. There can be multiple static
routes going through an interface which lead to multiple targets.
I think this makes the whole mechanism less generic. I liked the previous
method better where if we bring an interface, all the static routes going
through that interface will come up too. (Instead of only one static
route coming up for the target).
So I would rather stick to the mechanism of determining all the routes
going through an interface and add the ones which are not present in
second kernel's routing table.
Thanks
Vivek
Signed-off-by: Baoquan He <bhe(a)redhat.com>
---
dracut-module-setup.sh | 31 +++++++++++++++++++++++--------
1 file changed, 23 insertions(+), 8 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 02a0557..9da1a41 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -79,11 +79,6 @@ kdump_static_ip() {
_gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
fi
-
- /sbin/ip route show | grep -v default | grep "^[[:digit:]].*via.* $_netdev
" |\
- while read line; do
- echo $line | awk '{printf("rd.route=%s:%s:%s\n", $1, $3,
$5)}'
- done >> ${initdir}/etc/cmdline.d/45route-static.conf
}
kdump_get_mac_addr() {
@@ -212,9 +207,27 @@ kdump_setup_znet() {
echo rd.znet=${NETTYPE},${SUBCHANNELS}${_options} >
${initdir}/etc/cmdline.d/30znet.conf
}
+get_routes() {
+ local _netdev="$1" _target="$2"
+ local _route
+
+ _route=`/sbin/ip route get to $_target 2>&1`
+ if /sbin/ip route get to $_target | grep "via";
+ then
+ # route going to a different subnet via a router
+ echo $_route | awk '{printf("rd.route=%s:%s:%s\n", $1, $3,
$5)}' \
+ >> ${initdir}/etc/cmdline.d/45route-static.conf
+ else
+ # route going to a different subnet though directly connected
+ echo $_route | awk '{printf("rd.route=%s::%s\n", $1, $3)}' \
+ >> ${initdir}/etc/cmdline.d/45route-static.conf
+ fi
+
+}
+
# Setup dracut to bringup a given network interface
kdump_setup_netdev() {
- local _netdev=$1 _srcaddr=$2
+ local _netdev=$1 _srcaddr=$2 _target=$3
local _static _proto _ip_conf _ip_opts _ifname_opts
if [ "$(uname -m)" = "s390x" ]; then
@@ -229,6 +242,8 @@ kdump_setup_netdev() {
_proto=dhcp
fi
+ get_routes $_netdev $_target
+
_ip_conf="${initdir}/etc/cmdline.d/40ip.conf"
_ip_opts=" ip=${_static}$(kdump_setup_ifname $_netdev):${_proto}"
@@ -281,7 +296,7 @@ kdump_install_net() {
_netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
fi
- kdump_setup_netdev "${_netdev}" "${_srcaddr}"
+ kdump_setup_netdev "${_netdev}" "${_srcaddr}"
"${_server}"
#save netdev used for kdump as cmdline
# Whoever calling kdump_install_net() is setting up the default gateway,
@@ -439,7 +454,7 @@ kdump_setup_iscsi_device() {
srcaddr=$(echo $netdev | awk '{ print $3; exit }')
netdev=$(echo $netdev | awk '{ print $1; exit }')
- kdump_setup_netdev $netdev $srcaddr
+ kdump_setup_netdev $netdev $srcaddr $tgt_ipaddr
# prepare netroot= command line
# FIXME: IPV6 addresses require explicit [] around $tgt_ipaddr
--
1.9.0
_______________________________________________
kexec mailing list
kexec(a)lists.fedoraproject.org
https://lists.fedoraproject.org/mailman/listinfo/kexec