[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] Patch fixing vlan handling when network-bridge script is used



We had problem using tagged vlans inside domU. Testing shows that this is 
caused by changing network interfaces in network-bridge script. Following patch 
should allow to use vlans in guest.

Testing scenario:
configure vlan network (e.g. vlan 1 on eth0 => eth0.1)
start xend
create domU and configure same vlan inside it

You can see that vlan is still <interface>.<vlan_id>. You can reach dom0 but 
not domU. After patch apply vlan is changed to <bridge>.<vlan_id> after xend 
start and you can reach both dom0 and domu.

Patch:
------
diff -r 9f49667fec71 tools/hotplug/Linux/network-bridge
--- a/tools/hotplug/Linux/network-bridge        Fri Jul 30 15:22:39 2010 +0100
+++ b/tools/hotplug/Linux/network-bridge        Wed Aug 18 13:33:05 2010 +0200
@@ -119,6 +119,36 @@
     fi
 }
 
+handle_vlan_start() {
+    for vlan in `ls /proc/net/vlan/${netdev}* 2>/dev/null`; do
+        vlan_id=$(echo ${vlan} | sed -e "s/.*${netdev}.\(.*\)/\1/")
+        vlan_if=${netdev}.${vlan_id}
+
+        get_ip_info ${vlan_if}
+
+        vconfig rem ${vlan_if}
+        sleep 1
+        vconfig add ${bridge} ${vlan_id}
+
+        do_ifup ${bridge}.${vlan_id}
+    done
+}
+
+handle_vlan_stop() {
+    for vlan in `ls /proc/net/vlan/${bridge}* 2>/dev/null`; do
+        vlan_id=$(echo ${vlan} | sed -e "s/.*${bridge}.\(.*\)/\1/")
+        vlan_if=${bridge}.${vlan_id}
+
+        get_ip_info ${vlan_if}
+
+        vconfig rem ${vlan_if}
+        sleep 1
+        vconfig add ${netdev} ${vlan_id}
+
+        do_ifup ${netdev}.${vlan_id}
+    done
+}
+
 # Usage: transfer_addrs src dst
 # Copy all IP addresses (including aliases) from device $src to device $dst.
 transfer_addrs () {
@@ -254,6 +284,8 @@
     add_to_bridge2 ${bridge} ${pdev}
     do_ifup ${bridge}
 
+    handle_vlan_start
+
     if [ ${antispoof} = 'yes' ] ; then
        antispoofing
     fi
@@ -289,6 +321,8 @@
     ip link set ${pdev} name ${netdev}
     do_ifup ${netdev}
 
+    handle_vlan_stop
+
     brctl delbr ${tdev}
 
     release_lock "network-bridge"
-- 
Miroslav Rezanina
Software Engineer - Virtualization Team - XEN kernel


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.