2007-02-11 11:48:10 +01:00
|
|
|
Index: xen-3.0.4-testing/tools/examples/network-bridge
|
2007-01-16 00:42:10 +01:00
|
|
|
===================================================================
|
2007-02-11 11:48:10 +01:00
|
|
|
--- xen-3.0.4-testing.orig/tools/examples/network-bridge
|
|
|
|
+++ xen-3.0.4-testing/tools/examples/network-bridge
|
|
|
|
@@ -143,6 +143,21 @@ antispoofing () {
|
2007-01-16 00:42:10 +01:00
|
|
|
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 () {
|
2007-02-11 11:48:10 +01:00
|
|
|
@@ -185,10 +200,11 @@ using loopback.nloopbacks=<N> on the dom
|
2007-01-16 00:42:10 +01:00
|
|
|
|
|
|
|
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}
|
2007-02-11 11:48:10 +01:00
|
|
|
@@ -203,6 +219,13 @@ using loopback.nloopbacks=<N> on the dom
|
2007-01-16 00:42:10 +01:00
|
|
|
add_to_bridge2 ${bridge} ${pdev}
|
2007-02-11 11:48:10 +01:00
|
|
|
ip link set ${netdev} up
|
2007-01-16 00:42:10 +01:00
|
|
|
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}
|
2007-02-11 11:48:10 +01:00
|
|
|
@@ -241,6 +264,10 @@ op_stop () {
|
2007-01-16 00:42:10 +01:00
|
|
|
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
|