Index: xen-unstable/tools/examples/network-bridge =================================================================== --- xen-unstable.orig/tools/examples/network-bridge +++ xen-unstable/tools/examples/network-bridge @@ -143,6 +143,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 () { @@ -184,10 +199,11 @@ using netloop.nloopbacks= on the doma create_bridge ${bridge} - if link_exists "$vdev"; then + preiftransfer + . /etc/sysconfig/network/ifcfg-${hwddev} + if [ ! "$BONDING_MASTER" = yes ] && link_exists "$vdev"; then mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'` ifup ${netdev} # To ensure there is an IP to transfer - preiftransfer transfer_addrs ${netdev} ${vdev} ifdown ${netdev} ip link set ${netdev} name ${pdev} @@ -202,6 +218,13 @@ using netloop.nloopbacks= on the doma add_to_bridge2 ${bridge} ${pdev} ip link set ${netdev} up ifup ${hwddev} + 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 @@ -244,6 +267,10 @@ op_stop () { ip link set ${pdev} name ${netdev} 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