Browse Source

Handle multiple underlying devices of a bridge

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>
master
Cong Wang 13 years ago committed by Harald Hoyer
parent
commit
21928b97b0
  1. 5
      dracut.cmdline.7.asc
  2. 38
      modules.d/40network/ifup.sh
  3. 2
      modules.d/40network/net-genrules.sh
  4. 17
      modules.d/40network/parse-bridge.sh

5
dracut.cmdline.7.asc

@ -326,8 +326,9 @@ auto6::: do IPv6 autoconfiguration @@ -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

38
modules.d/40network/ifup.sh

@ -31,13 +31,15 @@ fi @@ -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 @@ -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() {

2
modules.d/40network/net-genrules.sh

@ -21,7 +21,7 @@ fix_bootif() { @@ -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)

17
modules.d/40network/parse-bridge.sh

@ -3,8 +3,9 @@ @@ -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() { @@ -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 @@ -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 @@ -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

Loading…
Cancel
Save