ipq807x: cig.wf186w: Add MPSK Dynamic VLAN support

When a MPSK VLAN netdev is created on the cig.wf186w board, this script
will configure switch0 via swconfig for the corresponding VLAN

Signed-off-by: Paul White <paul@shasta.cloud>
This commit is contained in:
Paul White
2023-09-02 22:41:46 -07:00
committed by John Crispin
parent 6a797e8a64
commit 513eec1c5f

View File

@@ -0,0 +1,40 @@
#!/bin/sh
. /lib/functions.sh
debug() {
logger -t HOTPLUG-DVLAN "$*"
}
if [ "${INTERFACE:0:4}" != "wlan" ]; then
exit 0
fi
case "$(board_name)" in
"cig,wf186w")
wan_iface="eth0"
switch_dev="switch0"
switch_wan_port=4
switch_cpu_port=6
;;
*)
exit 0
esac
VSTR="$(echo $INTERFACE | egrep -o 'v([0-9]+)$')"
[ -z "$VSTR" ] && exit 0
VID="${VSTR:1}"
[ $VID -lt 1 -o $VID -gt 4096 ] && exit 0
if [ "$ACTION" = "add" ]; then
debug "[$INTERFACE] Dynamic VLAN $VID added, configuring switch"
swconfig dev ${switch_dev} vlan $VID set ports "${switch_wan_port}t ${switch_cpu_port}t"
elif [ "$ACTION" = "remove" ]; then
let cnt="$(bridge vlan show vid $VID | egrep "^wlan" | wc -l)"
debug "[$INTERFACE] Dynamic VLAN interface removed, references left = $cnt"
if [ $cnt -eq 0 ]; then
debug "[$INTERFACE] No more references, removing $VID from switch"
swconfig dev ${switch_dev} vlan $VID set ports ""
fi
fi