[kexec-tools] Add static route into cmdline if target address is not local

WANG Chao wangchao at fedoraproject.org
Tue Aug 5 06:06:39 UTC 2014


commit f7f8361af9ffacea4891c48e19443c7934f04a9e
Author: Baoquan He <bhe at redhat.com>
Date:   Thu Jul 31 10:21:39 2014 +0800

    Add static route into cmdline if target address is not local
    
    If one target address is not local and its route is different than
    default gateway, the specific route to this target address need be
    added. E.g, target is 192.168.200.222.
    
    sh> ip route show
    default via 192.168.122.1 dev eth0  proto static  metric 1024
    192.168.200.0/24 via 192.168.100.222 dev ens10  proto static  metric 1
    
    In this patch, get the route to the specific target address and store
    it as cmdline, here is /etc/cmdline.d/45-route-static.conf. And the
    route options are separated by semicolon like below. Then the stored
    route can be parsed when kdump kernel boot up.
    
    192.168.200.0/24:192.168.100.222:ens10
    
    Signed-off-by: Baoquan He <bhe at redhat.com>
    Acked-by: Vivek Goyal <vgoyal at redhat.com>

 dracut-module-setup.sh |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 365d8f6..8fa59ca 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -79,6 +79,11 @@ 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() {


More information about the scm-commits mailing list