On 08/07/14 at 04:26pm, Baoquan He wrote:
In static route handling, one corner case is ignored. That is 2
machines
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..fda50cd 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}::"
+
+
+ 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:%s\n", $1,
$3)}' \
This is wrong about the corner case. When route address and output
interface are only available, a intermediate semicolon is needed. I just
sendt an old version of my test patch.
Please review the v2 post.
+ >> ${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