[kexec-tools] fix and refactor bridge handling code

Dave Young yangrr at fedoraproject.org
Mon Jun 11 06:06:32 UTC 2012


commit 725dae14acab9f7aaabeb31da5a83cac62b10abe
Author: Cong Wang <amwang at redhat.com>
Date:   Sun Jun 10 18:24:34 2012 +0800

    fix and refactor bridge handling code
    
    This patch fixes dumping over a bridge interface,
    we should pass ifname= for all its underlying devices,
    which is required by dracut.
    
    And it separates the code into different functions,
    for later patches to use.
    
    Cc: Vivek Goyal <vgoyal at redhat.com>
    Signed-off-by: Cong Wang <amwang at redhat.com>
    Acked-by: Dave Young <dyoung at redhat.com>

 dracut-module-setup.sh |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 143dc6e..ab9675f 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -51,6 +51,18 @@ kdump_static_ip() {
     fi
 }
 
+kdump_get_mac_addr() {
+    echo `ip addr show $1 2>/dev/null|awk '/ether/{ print $2 }'`
+}
+
+kdump_setup_bridge() {
+    local _netdev=$1
+    for _dev in `ls /sys/class/net/$_netdev/brif/`; do
+        echo -n " ifname=$_dev:$(kdump_get_mac_addr $_dev)" >> ${initdir}/etc/cmdline.d/41bridge.conf
+    done
+    echo " bridge=$_netdev:$(cd /sys/class/net/$_netdev/brif/; echo * | sed -e 's/ /,/g')" >> ${initdir}/etc/cmdline.d/41bridge.conf
+}
+
 # Setup dracut to bringup a given network interface
 kdump_setup_netdev() {
     local _netdev=$1
@@ -64,16 +76,17 @@ kdump_setup_netdev() {
         _proto=dhcp
     fi
 
-    echo " ip=${_static}$_netdev:${_proto} ifname=$_netdev:$_netmac rd.neednet=1" > ${initdir}/etc/cmdline.d/40ip.conf
+    echo " ip=${_static}$_netdev:${_proto}" > ${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
+        kdump_setup_bridge "$_netdev"
     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
-        :
+        echo -n " ip=${_static}$_netdev:${_proto}" > ${initdir}/etc/cmdline.d/40ip.conf
+        echo " ifname=$_netdev:$(kdump_get_mac_addr $_netdev)" >> ${initdir}/etc/cmdline.d/40ip.conf
     fi
 }
 


More information about the scm-commits mailing list