On Thu, Aug 07, 2014 at 05:46:17PM +0800, Baoquan He wrote:
In static route handling, one corner case is ignored. That is 2
machines
are directly connected while IPs configured are in the different subnet.
Say the IP of NIC1 on machine A is 192.168.10.1/24, the IP of NIC2 on
machine B is 192.168.20.1/24. Then on machine A, a route need be specified:
192.168.20.0/24 dev NIC1
On machine B:
192.168.10.0/24 dev NIC2
Without these routes connection from NIC1 to NIC2 can't be setup.
So if in machine A the dump target is set as machine B, route
"192.168.20.0/24 dev NIC1" has to be added in kdump kernel. But this is
ignored
in previous handling since we use below patch to find all routes:
/sbin/ip route show | grep -v default | grep "^[[:digit:]].*via.* $_netdev "
Now in this patch use "/sbin/ip route get to $_target" to get the exact route
to the target.
You need to explain why are you switching from "ip route show" to "ip
route get to".
sh> ip route get to 192.168.20.2
192.168.20.2 via 192.168.10.2 dev ens10 src 192.168.10.1
192.168.10.1 -> 192.168.20.2 -> 192.168.20.1 -> 192.168.20.2
So this is the actual output of "ip route get to". What is this second
line?
Who has ip addr 192.168.20.2 and 192.168.10.2 respectively? I thought
machine A had ip addr 192.168.10.1 and machine B had ip addr 192.168.20.1.
or
sh> ip route get to 192.168.20.2
192.168.20.2 dev ens10 src 192.168.10.1
192.168.10.1 -> 192.168.20.2
What's this alternative output. So output of "ip route get to" changes
now?
And write the static route to config file only if static ip address configured
on this network interface.
What's the relation between an interface having static ip and it having
static routes. Can't an interface having dhcp still have some static
routes going through it?
Signed-off-by: Baoquan He <bhe(a)redhat.com>
---
dracut-module-setup.sh | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 8fa59ca..3de2008 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -75,15 +75,24 @@ kdump_static_ip() {
local _ipaddr=$(ip addr show dev $_netdev permanent | \
awk "/ $_srcaddr\/.* $_netdev\$/{print \$2}")
if [ -n "$_ipaddr" ]; then
- _netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
- _gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
- echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
+ _netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
+ _gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
+ echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
+
+
Same question here. This function kdump_static_ip() seems to be doing
multiple things. It determines whether interface has static ip or not
and also saves static routes going through that function in a file. I
am wondering what's the correlation between two. Should these not be
in separate functions.
Thanks
Vivek
+ local _route
+ _route=`/sbin/ip route get to $_target 2>&1`
+ if [ -n "`echo $_route | 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
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() {
--
1.9.0