[kexec-tools] static ip configuration support
Dave Young
yangrr at fedoraproject.org
Mon May 28 01:54:01 UTC 2012
commit 21398a5cddecd7a0b308b8132c783573c067db44
Author: Dave Young <dyoung at redhat.com>
Date: Fri May 25 14:16:20 2012 +0800
static ip configuration support
Resolves: bz822739
We hardcoded with dhcp in dracut cmdline before.
Fix it by parsing ifcfg to get the proper proto,
echo proper cmdline for both static and dhcp
[v1->v2]: amwang - handle PREFIX as well
Signed-off-by: Dave Young <dyoung at redhat.com>
Acked-by: Cong Wang <amwang at redhat.com>
Acked-by: Vivek Goyal <vgoyal at redhat.com>
dracut-module-setup.sh | 25 ++++++++++++++++++++++---
1 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 154faab..143dc6e 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -39,12 +39,32 @@ kdump_is_bond() {
[ -d /sys/class/net/"$1"/bonding ]
}
+#$1: netdev name
+#checking /etc/sysconfig/network-scripts/ifcfg-$1,
+#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}::"
+ fi
+}
+
# Setup dracut to bringup a given network interface
kdump_setup_netdev() {
local _netdev=$1
+ local _static _proto
_netmac=`ip addr show $_netdev 2>/dev/null|awk '/ether/{ print $2 }'`
- echo " ip=$_netdev:dhcp ifname=$_netdev:$_netmac rd.neednet=1" > ${initdir}/etc/cmdline.d/40ip.conf
+ _static=$(kdump_static_ip $_netdev)
+ if [ -n "$_static" ]; then
+ _proto=none
+ else
+ _proto=dhcp
+ fi
+
+ echo " ip=${_static}$_netdev:${_proto} ifname=$_netdev:$_netmac rd.neednet=1" > ${initdir}/etc/cmdline.d/40ip.conf
if kdump_is_bridge "$_netdev"; then
echo " bridge=$_netdev:$(cd /sys/class/net/$_netdev/brif/; echo *)" > ${initdir}/etc/cmdline.d/41bridge.conf
@@ -60,8 +80,7 @@ kdump_setup_netdev() {
#Function:kdump_install_net
#$1: config values of net line in kdump.conf
kdump_install_net() {
- local _server
- local _netdev
+ local _server _netdev
local config_val="$1"
if strstr "$config_val" "@"; then
More information about the scm-commits
mailing list