]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Handle multiple underlying devices of a bridge
authorCong Wang <xiyou.wangcong@gmail.com>
Thu, 31 May 2012 14:07:38 +0000 (22:07 +0800)
committerHarald Hoyer <harald@redhat.com>
Mon, 4 Jun 2012 09:06:53 +0000 (11:06 +0200)
A bridge device with only one underlying ethernet device is almost
useless, for sure we want to support a bridge with multiple
underlying devices.

This patch adds the support by extending <ethname> in the original
bridge= cmdline to a comma-separated list of ethernet interfaces.

Cc: Harald Hoyer <harald@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
dracut.cmdline.7.asc
modules.d/40network/ifup.sh
modules.d/40network/net-genrules.sh
modules.d/40network/parse-bridge.sh

index 651582ddcd91a8a41bab2221404d39baa9ba66e6..8a74cf5986108648b0b09404b01969f2bd40e552 100644 (file)
@@ -326,8 +326,9 @@ auto6::: do IPv6 autoconfiguration
     then its values should be separated by semicolon.
     Bond without parameters assumes bond=bond0:eth0,eth1:mode=balance-rr
 
-**bridge=_<bridgename>_:_<ethname>_**::
-    Setup bridge <bridgename> with <ethname>. Bridge without parameters assumes bridge=br0:eth0
+**bridge=_<bridgename>_:_<ethnames>_**::
+    Setup bridge <bridgename> with <ethnames>. <ethnames> is a comma-separated
+    list of physical (ethernet) interfaces. Bridge without parameters assumes bridge=br0:eth0
 
 
 NFS
index 1aaa1a8164b0ec8f16b8d8875bcda9a6b39b6412..c9516bb3d544c4c4f8ca00c1134a42c0c1c382a7 100755 (executable)
@@ -31,13 +31,15 @@ fi
 # bridge this interface?
 if [ -e /tmp/bridge.info ]; then
     . /tmp/bridge.info
-    if [ "$netif" = "$ethname" ]; then
-        if [ "$netif" = "$bondname" ] && [ -n "$DO_BOND_SETUP" ] ; then
-            : # We need to really setup bond (recursive call)
-        else
-            netif="$bridgename"
+    for ethname in $ethnames ; do
+        if [ "$netif" = "$ethname" ]; then
+            if [ "$netif" = "$bondname" ] && [ -n "$DO_BOND_SETUP" ] ; then
+                : # We need to really setup bond (recursive call)
+            else
+                netif="$bridgename"
+            fi
         fi
-    fi
+    done
 fi
 
 if [ -e /tmp/vlan.info ]; then
@@ -175,18 +177,22 @@ fi
 
 # XXX need error handling like dhclient-script
 
+if [ -e /tmp/bridge.info ]; then
+    . /tmp/bridge.info
 # start bridge if necessary
-if [ "$netif" = "$bridgename" ] && [ ! -e /tmp/net.$bridgename.up ]; then
-    if [ "$ethname" = "$bondname" ] ; then
-        DO_BOND_SETUP=yes ifup $bondname
-    else
-        ip link set $ethname up
+    if [ "$netif" = "$bridgename" ] && [ ! -e /tmp/net.$bridgename.up ]; then
+        brctl addbr $bridgename
+        brctl setfd $bridgename 0
+        for ethname in $ethnames ; do
+            if [ "$ethname" = "$bondname" ] ; then
+                DO_BOND_SETUP=yes ifup $bondname
+            else
+                ip link set $ethname up
+            fi
+            wait_for_if_up $ethname
+            brctl addif $bridgename $ethname
+        done
     fi
-    wait_for_if_up $ethname
-    # Create bridge and add eth to bridge
-    brctl addbr $bridgename
-    brctl setfd $bridgename 0
-    brctl addif $bridgename $ethname
 fi
 
 get_vid() {
index ca47b2b0d72ab230e57cafdce6bc256d707c2f1c..2d3dff2656eab702604e895e37ace629604d552c 100755 (executable)
@@ -21,7 +21,7 @@ fix_bootif() {
     # bridge: attempt only the defined interface
     if [ -e /tmp/bridge.info ]; then
         . /tmp/bridge.info
-        IFACES=$ethname
+        IFACES=${ethnames%% *}
     fi
 
     # bond: attempt only the defined interface (override bridge defines)
index 6e1fee1b3d5ec0ac65104bb7d3a26dff9d231c21..5728fb6a348a1b3881777c1ca9889431c01d4a66 100755 (executable)
@@ -3,8 +3,9 @@
 # ex: ts=8 sw=4 sts=4 et filetype=sh
 #
 # Format:
-#       bridge=<bridgename>:<ethname>
+#       bridge=<bridgename>:<ethnames>
 #
+#       <ethnames> is a comma-separated list of physical (ethernet) interfaces
 #       bridge without parameters assumes bridge=br0:eth0
 #
 
@@ -24,16 +25,16 @@ parsebridge() {
         v=${v#*:}
     done
 
-    unset bridgename ethname
+    unset bridgename ethnames
     case $# in
-        0)  bridgename=br0; ethname=$iface ;;
+        0)  bridgename=br0; ethnames=$iface ;;
         1)  die "bridge= requires two parameters" ;;
-        2)  bridgename=$1; ethname=$2 ;;
+        2)  bridgename=$1; ethnames=$(echo $2|tr "," " ") ;;
         *)  die "bridge= requires two parameters" ;;
     esac
 }
 
-unset bridgename ethname
+unset bridgename ethnames
 
 iface=eth0
 if [ -e /tmp/bond.info ]; then
@@ -43,7 +44,7 @@ if [ -e /tmp/bond.info ]; then
     fi
 fi
 
-# Parse bridge for bridgename and ethname
+# Parse bridge for bridgename and ethnames
 if bridge="$(getarg bridge)"; then
     # Read bridge= parameters if they exist
     if [ -n "$bridge" ]; then
@@ -52,9 +53,9 @@ if bridge="$(getarg bridge)"; then
     # Simple default bridge
     if [ -z "$bridgename" ]; then
         bridgename=br0
-        ethname=$iface
+        ethnames=$iface
     fi
     echo "bridgename=$bridgename" > /tmp/bridge.info
-    echo "ethname=$ethname" >> /tmp/bridge.info
+    echo "ethnames=\"$ethnames\"" >> /tmp/bridge.info
     return
 fi