If configuration for a network interface is static, and one target
address is not local and the gateway field is not provided, the static
route need be added.
In this patch, get that route and write it into /etc/route-$netif, it
looks like below:
192.168.200.222 via 192.168.100.222 dev eth0
---
dracut-module-setup.sh | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 2a16900..3467d35 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -70,11 +70,20 @@ kdump_setup_dns() {
#checking /etc/sysconfig/network-scripts/ifcfg-$1,
#if it use static ip echo it, or echo null
kdump_static_ip() {
+ local _gateway
+ local _target=$2 _f="/etc/sysconfig/network-scripts/route-$1"
+
. /etc/sysconfig/network-scripts/ifcfg-$1
if [ -n "$IPADDR" ]; then
- [ -z "$NETMASK" -a -n "$PREFIX" ] && \
- NETMASK=$(ipcalc -m $IPADDR/$PREFIX | cut -d'=' -f2)
- echo -n "${IPADDR}::${GATEWAY}:${NETMASK}::"
+ if [ -z "$GATEWAY" ]; then
+ [ -n "$_target" ] && _gateway=$(ip route get to $_target|grep via|cut -d' ' -f1,2,3,4,5)
+ #[ -n "$_gateway" ] && echo $_gateway > ${initdir}/etc/route-$1
+ [ -n "$_gateway" ] && [ -e "$_f" ]&& cp $_f ${initdir}/etc/route-$1
+ fi
+
+ [ -z "$NETMASK" -a -n "$PREFIX" ] && \
+ NETMASK=$(ipcalc -m $IPADDR/$PREFIX | cut -d'=' -f2)
+ echo -n "${IPADDR}::${GATEWAY}:${NETMASK}::"
fi
}
@@ -183,13 +192,14 @@ kdump_setup_znet() {
kdump_setup_netdev() {
local _netdev=$1
local _static _proto _ip_conf _ip_opts _ifname_opts
+ local _target=$2
if [ "$(uname -m)" = "s390x" ]; then
kdump_setup_znet $_netdev
fi
_netmac=$(kdump_get_mac_addr $_netdev)
- _static=$(kdump_static_ip $_netdev)
+ _static=$(kdump_static_ip $_netdev $_target)
if [ -n "$_static" ]; then
_proto=none
else
@@ -245,7 +255,7 @@ kdump_install_net() {
_netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
fi
- kdump_setup_netdev "${_netdev}"
+ kdump_setup_netdev "${_netdev}" "${_server}"
#save netdev used for kdump as cmdline
# Whoever calling kdump_install_net() is setting up the default gateway,
@@ -400,7 +410,7 @@ kdump_setup_iscsi_device() {
netdev=$(/sbin/ip route get to ${tgt_ipaddr} | \
sed 's|.*dev \(.*\).*|\1|g' | awk '{ print $1; exit }')
- kdump_setup_netdev $netdev
+ kdump_setup_netdev $netdev ${tgt_ipaddr}
# prepare netroot= command line
# FIXME: IPV6 addresses require explicit [] around $tgt_ipaddr
--
1.9.0