Update add_to_bridge shell function to read the vid parameter
from xenstore and set the bridge LAN for the VID to the given
value. This only works when using the iproute2 bridge command,
so a warning is issued if using the legacy brctl command and a
vid is set.

Signed-off-by: Leigh Brown <le...@solinno.co.uk>
---
 tools/hotplug/Linux/xen-network-common.sh | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/hotplug/Linux/xen-network-common.sh 
b/tools/hotplug/Linux/xen-network-common.sh
index 42fa704e8d..19a8b3c7e5 100644
--- a/tools/hotplug/Linux/xen-network-common.sh
+++ b/tools/hotplug/Linux/xen-network-common.sh
@@ -125,14 +125,23 @@ create_bridge () {
 add_to_bridge () {
     local bridge=$1
     local dev=$2
+    local vid=$(xenstore_read_default "$XENBUS_PATH/vid" "")
 
     # Don't add $dev to $bridge if it's already on the bridge.
     if [ ! -e "/sys/class/net/${bridge}/brif/${dev}" ]; then
         log debug "adding $dev to bridge $bridge"
         if which brctl >&/dev/null; then
             brctl addif ${bridge} ${dev}
+            if [ -n "${vid}" ] ;then
+                log warning "bridge command not available, ignoring vid"
+            fi
         else
             ip link set ${dev} master ${bridge}
+            if [ -n "${vid}" ] ;then
+                log debug "Assigning $dev to vid $vid"
+                bridge vlan del dev ${dev} vid 1
+                bridge vlan add dev ${dev} vid ${vid} pvid untagged
+            fi
         fi
     else
         log debug "$dev already on bridge $bridge"
-- 
2.39.2


Reply via email to