From 513eec1c5f79357f3a6ec2532ba2b4a107b4be85 Mon Sep 17 00:00:00 2001 From: Paul White Date: Sat, 2 Sep 2023 22:41:46 -0700 Subject: [PATCH] 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 --- .../base-files/etc/hotplug.d/net/50-dvlan | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 feeds/ipq807x/ipq807x/base-files/etc/hotplug.d/net/50-dvlan diff --git a/feeds/ipq807x/ipq807x/base-files/etc/hotplug.d/net/50-dvlan b/feeds/ipq807x/ipq807x/base-files/etc/hotplug.d/net/50-dvlan new file mode 100644 index 000000000..aa137fac8 --- /dev/null +++ b/feeds/ipq807x/ipq807x/base-files/etc/hotplug.d/net/50-dvlan @@ -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