From 05a3b1539b45f439a94024aaa4505e14f6496d89 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Wed, 14 Oct 2020 22:14:58 -0600 Subject: [PATCH] bridge: add support for bridge-vids (with inheritance), bridge-access and bridge-pvid --- executor-scripts/linux/bridge | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/executor-scripts/linux/bridge b/executor-scripts/linux/bridge index 4e4b767..9e2e0f2 100755 --- a/executor-scripts/linux/bridge +++ b/executor-scripts/linux/bridge @@ -123,6 +123,34 @@ set_bridge_opts() { [ -x /sbin/brctl ] && set_bridge_opts_brctl && return 0 } +set_bridge_default_vlans() { + [ -x /sbin/bridge ] || return 0 + + [ -z "$IF_BRIDGE_PORTS" ] && return 0 + for port in $IF_BRIDGE_PORTS; do + vids=$(ifquery -p bridge-vids $port) + [ -z "$vids" ] && vids="$IF_BRIDGE_VIDS" + + for vid in $vids; do + bridge vlan add vid $vid dev $port + done + done +} + +set_bridge_access_vlans() { + [ -z "$IF_BRIDGE_PORTS" ] || return 0 + [ -z "$IF_BRIDGE_ACCESS" ] && return 0 + [ -x /sbin/bridge ] || return 0 + + if [ "$IF_BRIDGE_PVID" = "$IF_BRIDGE_ACCESS" ]; then + PVID="pvid" + else + PVID="" + fi + + bridge vlan add vid $IF_BRIDGE_ACCESS $PVID untagged dev $IFACE +} + all_ports_ready() { local port= for port in $PORTS; do @@ -175,6 +203,8 @@ create) pre-up) wait_ports set_bridge_opts + set_bridge_default_vlans + set_bridge_access_vlans add_ports wait_bridge ;;