Index: xen-3.1-testing/tools/examples/network-bridge =================================================================== --- xen-3.1-testing.orig/tools/examples/network-bridge +++ xen-3.1-testing/tools/examples/network-bridge @@ -160,6 +160,21 @@ antispoofing () { iptables -A FORWARD -m physdev --physdev-in ${vif0} -j ACCEPT } +# Find the netdev that is associated with the bridge by matching MAC addresses. +find_bridged_netdev () { + local bridge=$1 + + bmac=`ip link show ${bridge} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'` + for i in `ls /sys/class/net/${bridge}/brif` ; do + mac=`ip link show ${i} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'` + if [ "${bmac}" = "${mac}" ] && [ ! "${bridge}" = "${i}" ] ; then + netdev=${i} + return 0 + fi + done + return 1 +} + # Usage: show_status dev bridge # Print ifconfig and routes. show_status () { @@ -201,9 +216,10 @@ using netloop.nloopbacks= on the doma create_bridge ${bridge} - if link_exists "$vdev"; then + preiftransfer ${netdev} + . /etc/sysconfig/network/ifcfg-${netdev} + if [ ! "$BONDING_MASTER" = yes ] && link_exists "$vdev"; then mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'` - preiftransfer ${netdev} transfer_addrs ${netdev} ${vdev} if ! ifdown ${netdev}; then # If ifdown fails, remember the IP details. @@ -222,6 +238,13 @@ using netloop.nloopbacks= on the doma add_to_bridge ${bridge} ${vif0} add_to_bridge2 ${bridge} ${pdev} do_ifup ${netdev} + elif [ "$BONDING_MASTER" = yes ]; then + ip link set ${bridge} arp on + add_to_bridge ${bridge} ${vif0} + ip link set ${vif0} up + add_to_bridge2 ${bridge} ${netdev} + transfer_addrs ${netdev} ${bridge} + transfer_routes ${netdev} ${bridge} else ip link set ${bridge} arp on ip link set ${bridge} multicast on @@ -266,6 +289,10 @@ op_stop () { ip link set ${pdev} name ${netdev} do_ifup ${netdev} else + if [ ${netdev} = ${bridge} ]; then + find_bridged_netdev ${bridge} + fi + ip link set dev ${vif0} down transfer_routes ${bridge} ${netdev} ip link set ${bridge} down fi