On Tue, May 20, 2014 at 02:31:27PM -0400, Marc Milgram wrote:
NetworkManager changed the format of ifcfg-device files. They may
define
static IP addresses with the following format:
IPADDR0=192.168.122.100
PREFIX0=24
There may be up to 255 ip addresses for a network device - each with a unique
number tagged to the end of IPADDR and PREFIX.
Prior to this fix, kdump only handled static ip addresses defined with
IPADDR=192.168.122.100
PREFIX=24
ie. without the number.
The solution is to use "ip" commands to find the correct network information.
Tested with both static and dynamic IP addresses.
v2: Fixed a local variable that was set incorrectly
Signed-off-by: Marc Milgram <mmilgram(a)redhat.com>
Acked-by: Vivek Goyal <vgoyal(a)redhat.com>
Vivek
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 2a16900..bfe1924 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -67,14 +67,17 @@ kdump_setup_dns() {
}
#$1: netdev name
-#checking /etc/sysconfig/network-scripts/ifcfg-$1,
+#$2: srcaddr
#if it use static ip echo it, or echo null
kdump_static_ip() {
- . /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}::"
+ local _netmask _gateway
+ local _netdev="$1" _srcaddr="$2"
+ 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}::"
fi
}
@@ -181,7 +184,7 @@ kdump_setup_znet() {
# Setup dracut to bringup a given network interface
kdump_setup_netdev() {
- local _netdev=$1
+ local _netdev=$1 _srcaddr=$2
local _static _proto _ip_conf _ip_opts _ifname_opts
if [ "$(uname -m)" = "s390x" ]; then
@@ -189,7 +192,7 @@ kdump_setup_netdev() {
fi
_netmac=$(kdump_get_mac_addr $_netdev)
- _static=$(kdump_static_ip $_netdev)
+ _static=$(kdump_static_ip $_netdev $_srcaddr)
if [ -n "$_static" ]; then
_proto=none
else
@@ -223,8 +226,9 @@ kdump_setup_netdev() {
#Function:kdump_install_net
#$1: config values of net line in kdump.conf
+#$2: srcaddr of network device
kdump_install_net() {
- local _server _netdev
+ local _server _netdev _srcaddr
local config_val="$1"
_server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
@@ -239,13 +243,15 @@ kdump_install_net() {
if [ -n "`echo $_netdev | grep via`" ]
then
# we are going to a different subnet
+ _srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
else
# we are on the same subnet
+ _srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1`
_netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
fi
- kdump_setup_netdev "${_netdev}"
+ kdump_setup_netdev "${_netdev}" "${_srcaddr}"
#save netdev used for kdump as cmdline
# Whoever calling kdump_install_net() is setting up the default gateway,
_______________________________________________
kexec mailing list
kexec(a)lists.fedoraproject.org
https://lists.fedoraproject.org/mailman/listinfo/kexec