pve-manager/bridgevlan
Alexandre Derumier 312ce78084 add vlan aware ifupdown script v3
This add support to enable vlan aware bridge,
and management interfaces

example: 1 bridge and 1 administration port on vlan 100

auto vmbr0
iface vmbr0 inet manual
        bridge_ports eth0
        bridge_stp off
        bridge_fd 0
        bridge_vlan_aware yes
        bridge_vids 10-15

auto vmbr0.100
iface vmbr0.100 inet static
        address X.X.X.X
        netmask 255.255.255.0
        gateway X.X.X.X

bridge_vids is optional, and allow on the specified vlans.(current take 1 value or range, need to be improve with list)
If not specified, the allowed vlan are 2-4094.
vlan 1 is the default pvid. (all untagged traffic is going to this vlan).

scripts:
- /etc/network/if-up.d/bridgevlan

manage bridge vlan aware configuration

- /etc/network/if-up.d/bridgevlanport

manage bridge vlan admin port

-/etc/network/if-pre-up.d/vlan
-/etc/network/if-post-down.d/vlan

replace current vlan package, without vconfig usage and cleanups
It's only needed to create vlan interface from bridge_ports.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2015-07-29 06:46:16 +02:00

55 lines
973 B
Bash
Executable File

#!/bin/sh
if [ ! -x /sbin/bridge ] && [ ! -f /sys/class/net/$IFACE/bridge/vlan_filtering ]
then
exit 0
fi
# Enabling vlan filtering feature
if [ "$MODE" = "start" ] ; then
if [ -n "$IF_BRIDGE_VLAN_AWARE" ]
then
echo 1 > /sys/class/net/$IFACE/bridge/vlan_filtering
else
exit 0
fi
fi
. /lib/bridge-utils/bridge-utils.sh
case "$IF_BRIDGE_PORTS" in
"")
exit 0
;;
none)
INTERFACES=""
;;
*)
INTERFACES="$IF_BRIDGE_PORTS"
;;
esac
all_interfaces= &&
unset all_interfaces &&
bridge_parse_ports $INTERFACES | while read i
do
for port in $i
do
if [ "$MODE" = "start" ] && [ -d /sys/class/net/$IFACE/brif/$port ]; then
#we allow vlan to pass through attached interface
if [[ $port =~ ^(eth|bond|wlan)[0-9]{1,2}$ ]]
then
if [ -n "$IF_BRIDGE_VIDS" ]
then
bridge vlan add dev $port vid $IF_BRIDGE_VIDS
else
bridge vlan add dev $port vid 2-4094
fi
fi
fi
done
done