xen/xen-bonding.diff

66 lines
2.2 KiB
Diff
Raw Normal View History

Index: xen-3.0.4-testing/tools/examples/network-bridge
===================================================================
--- xen-3.0.4-testing.orig/tools/examples/network-bridge
+++ xen-3.0.4-testing/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 () {
@@ -185,10 +200,11 @@ using loopback.nloopbacks=<N> on the dom
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}
@@ -203,6 +219,13 @@ using loopback.nloopbacks=<N> on the dom
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
# old style without ${vdev}
transfer_addrs ${netdev} ${bridge}
@@ -241,6 +264,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