From bf247cb56c9ebd71f1f0fe0f9afefa60ccc78ea6 Mon Sep 17 00:00:00 2001 From: Vivek Goyal Date: Tue, 22 May 2012 17:34:02 -0400 Subject: [PATCH] kdump: Move network device setup in a separate function BZ: 822701 This allows to reuse same function from iscsi setup code too. Also makes code more modular. [dyoung: add a missed space] Signed-off-by: Vivek Goyal Acked-by: Dave Young --- dracut-module-setup.sh | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index ff06112..5dcdfc5 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -39,6 +39,24 @@ kdump_is_bond() { [ -d /sys/class/net/"$1"/bonding ] } +# Setup dracut to bringup a given network interface +kdump_setup_netdev() { + local _netdev=$1 + + _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 + + if kdump_is_bridge "$_netdev"; then + echo " bridge=$_netdev:$(cd /sys/class/net/$_netdev/brif/; echo *)" > ${initdir}/etc/cmdline.d/41bridge.conf + elif kdump_is_bond "$_netdev"; then + echo " bond=$_netdev:\"$(cat /sys/class/net/$_netdev/bonding/slaves)\"" > ${initdir}/etc/cmdline.d/42bond.conf + #TODO + #echo "bondoptions=\"$bondoptions\"" >> /tmp/$$-bond + else + : + fi +} + #Function:kdump_install_net #$1: config values of net line in kdump.conf kdump_install_net() { @@ -68,18 +86,7 @@ kdump_install_net() { _netdev=`echo $_netdev|awk '{print $3}'|head -n 1` fi - _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 - - if kdump_is_bridge "$_netdev"; then - echo " bridge=$_netdev:$(cd /sys/class/net/$_netdev/brif/; echo *)" > ${initdir}/etc/cmdline.d/41bridge.conf - elif kdump_is_bond "$_netdev"; then - echo " bond=$_netdev:\"$(cat /sys/class/net/$_netdev/bonding/slaves)\"" > ${initdir}/etc/cmdline.d/42bond.conf - #TODO - #echo "bondoptions=\"$bondoptions\"" >> /tmp/$$-bond - else - : - fi + kdump_setup_netdev "${_netdev}" } #install kdump.conf and what user specifies in kdump.conf