diff mbox series

[RFC,3/5] tools/hotplug/Linux: Add bridge VLAN support

Message ID 20240503144124.12931-4-leigh@solinno.co.uk (mailing list archive)
State Superseded
Headers show
Series Add bridge VLAN support | expand

Commit Message

Leigh Brown May 3, 2024, 2:41 p.m. UTC
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 <leigh@solinno.co.uk>
---
 tools/hotplug/Linux/xen-network-common.sh | 9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox series

Patch

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"