xen/bridge-vlan.diff

64 lines
2.2 KiB
Diff
Raw Normal View History

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,24 @@ antispoofing () {
iptables -A FORWARD -m physdev --physdev-in ${vif0} -j ACCEPT
}
+find_active_vlans() {
+ local netdev=$1
+ local vlan
+ local vlans
+ vlans=""
+ for vifcfg in /etc/sysconfig/network/ifcfg-vlan* ; do
+ vlan=${vifcfg/*\/ifcfg-}
+ if [ "$vlan" = "vlan*" ]; then
+ continue
+ fi
+ . $vifcfg
+ if [ "$ETHERDEVICE" = "$netdev" ] && link_exists "$vlan" ; then
+ vlans="$vlans $vlan"
+ fi
+ done
+ echo "$vlans"
+}
+
# Find the netdev that is associated with the bridge by matching MAC addresses.
find_bridged_netdev () {
local bridge=$1
@@ -221,6 +239,8 @@ using netloop.nloopbacks=<N> on the doma
if [ ! "$BONDING_MASTER" = yes ] && link_exists "$vdev"; then
mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'`
transfer_addrs ${netdev} ${vdev}
+ vlans=$(find_active_vlans "${netdev}")
+ for vlan in $vlans ; do ifdown $vlan ; done
if ! ifdown ${netdev}; then
# If ifdown fails, remember the IP details.
get_ip_info ${netdev}
@@ -238,6 +258,7 @@ using netloop.nloopbacks=<N> on the doma
add_to_bridge ${bridge} ${vif0}
add_to_bridge2 ${bridge} ${pdev}
do_ifup ${netdev}
+ for vlan in $vlans ; do ifup $vlan ; done
elif [ "$BONDING_MASTER" = yes ]; then
ip link set ${bridge} arp on
add_to_bridge ${bridge} ${vif0}
@@ -272,6 +293,8 @@ op_stop () {
ip link set dev ${vif0} down
mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'`
transfer_addrs ${netdev} ${pdev}
+ vlans=$(find_active_vlans "${netdev}")
+ for vlan in $vlans ; do ifdown $vlan ; done
if ! ifdown ${netdev}; then
get_ip_info ${netdev}
fi
@@ -288,6 +311,7 @@ op_stop () {
ip link set ${netdev} name ${vdev}
ip link set ${pdev} name ${netdev}
do_ifup ${netdev}
+ for vlan in $vlans ; do ifup $vlan ; done
else
if [ ${netdev} = ${bridge} ]; then
find_bridged_netdev ${bridge}