mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-28 17:12:22 +00:00
ucentral-event: Fix Modifying VLAN-ID Under LAN Port
This commit is an improvement over previous
commit 3598a243b3 which added a
fix for traffic disruption when vlan id of the lan port is
changed on devices with internal switches such as fap655,
CIG_WF186w,EAP-104.
This commit reconfigures the vlans for the mpsk clients on the
switch using the ucentral-event subsystem by tracking the
netifd_add events.
Fixes: WIFI-13797
Signed-off-by: joydeepbenison <joydeep.ghosh@benisontech.com>
This commit is contained in:
committed by
John Crispin
parent
45eb5c9a6b
commit
c51a24db43
@@ -26,6 +26,7 @@ let hapd_subscriber;
|
||||
let dhcp_subscriber;
|
||||
let dhcp_relay_subscriber;
|
||||
let log_subscriber;
|
||||
let netifd_subscriber;
|
||||
let ratelimit = false;
|
||||
let config;
|
||||
let wan_ports;
|
||||
@@ -82,6 +83,18 @@ function eth_get_bridge_vlan_id(ifname) {
|
||||
return vlan_id;
|
||||
}
|
||||
|
||||
|
||||
function configure_switch_vlan(vlan_id){
|
||||
let cmd = 'swconfig dev ' + config.config.swconfig + ' vlan ' + vlan_id + ' set ports \"' + join(' ', config.config.swconfig_ports) + '\"';
|
||||
system(cmd);
|
||||
}
|
||||
|
||||
function get_bridge_interfaces(bridge){
|
||||
let path = '/sys/class/net/'+bridge+'/brif';
|
||||
let dir = fs.lsdir(path);
|
||||
return dir;
|
||||
}
|
||||
|
||||
function event(object, verb, payload) {
|
||||
let type = object;
|
||||
if (verb)
|
||||
@@ -382,6 +395,46 @@ function log_subscriber_remove_cb(remove) {
|
||||
printf('dhcp remove: %.J\n', remove);
|
||||
}
|
||||
|
||||
function netifd_add_handler(notify){
|
||||
/*Listen to change in vlan id of upstream interfaces */
|
||||
if(!wildcard(notify.data.name,"up*"))
|
||||
return 0;
|
||||
/*get all the interfaces from up bridge*/
|
||||
let bridge_interfaces= get_bridge_interfaces("up");
|
||||
|
||||
if (!bridge_interfaces) {
|
||||
return 0;
|
||||
}
|
||||
for (let entry in bridge_interfaces) {
|
||||
/*filter only for wlan mpsk interfaces*/
|
||||
if(wildcard(entry,"wlan*-v*")){
|
||||
let wlan_vlan_string=split(entry,"-v");
|
||||
let wlan_vlan_id=wlan_vlan_string[1];
|
||||
/*reconfigure the switch for vlan id
|
||||
of mpsk clients */
|
||||
configure_switch_vlan(wlan_vlan_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function netifd_subscriber_notify_cb(notify) {
|
||||
if (notify.type != 'add'){
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(notify.data.name){
|
||||
netifd_add_handler(notify);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function netifd_subscriber_remove_cb(remove) {
|
||||
printf('remove: %.J\n', remove);
|
||||
}
|
||||
|
||||
function send_pending_events() {
|
||||
for (let payload in pending_events)
|
||||
ubus.call('ucentral', 'event', payload);
|
||||
@@ -416,6 +469,9 @@ function unsub_object(add, id, path) {
|
||||
} else
|
||||
ucentral_running = false;
|
||||
break;
|
||||
case 'network.device':
|
||||
netifd_subscriber.subscribe(path);
|
||||
break;
|
||||
}
|
||||
if (object[0] == 'hostapd' && object[1]) {
|
||||
if (add)
|
||||
@@ -509,6 +565,8 @@ hapd_subscriber = ubus.subscriber(hapd_subscriber_notify_cb, hapd_subscriber_rem
|
||||
dhcp_subscriber = ubus.subscriber(dhcp_subscriber_notify_cb, dhcp_subscriber_remove_cb);
|
||||
log_subscriber = ubus.subscriber(log_subscriber_notify_cb, log_subscriber_remove_cb);
|
||||
dhcp_relay_subscriber = ubus.subscriber(dhcp_relay_subscriber_notify_cb, dhcp_relay_subscriber_remove_cb);
|
||||
netifd_subscriber= ubus.subscriber(netifd_subscriber_notify_cb, netifd_subscriber_remove_cb);
|
||||
|
||||
|
||||
let list = ubus.list();
|
||||
for (let k, path in list)
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
From da1d005199f6485c37aed3ae15faf1b9ab79d88d Mon Sep 17 00:00:00 2001
|
||||
From: joydeepbenison <joydeep.ghosh@benisontech.com>
|
||||
Date: Mon, 27 May 2024 13:34:25 +0530
|
||||
Subject: [PATCH] WIFI-13428 Fix:Traffic Disruption for MPSK clients for
|
||||
yuncore_fap655
|
||||
|
||||
Fix Traffic Disruption for MPSK clients for yuncore_fap655 when
|
||||
vlan-id of the lan port is modified.Any change in swconfig resets the
|
||||
internal switch of FAP655 due to which all the dynamically added vlans
|
||||
for MPSK clients are lost. Configure the Dynamic Vlans for MPSK Clients
|
||||
again after switch reset.
|
||||
|
||||
Signed-off-by: joydeepbenison <joydeep.ghosh@benisontech.com>
|
||||
---
|
||||
.../files/etc/hotplug.d/net/50-switch-dvlan | 43 +++++++++++++++++++
|
||||
.../files/lib/functions/dyn_vlan_switch.sh | 33 ++++++++++++++
|
||||
2 files changed, 76 insertions(+)
|
||||
create mode 100644 package/base-files/files/etc/hotplug.d/net/50-switch-dvlan
|
||||
create mode 100644 package/base-files/files/lib/functions/dyn_vlan_switch.sh
|
||||
|
||||
diff --git a/package/base-files/files/etc/hotplug.d/net/50-switch-dvlan b/package/base-files/files/etc/hotplug.d/net/50-switch-dvlan
|
||||
new file mode 100644
|
||||
index 0000000000..f24329cfe6
|
||||
--- /dev/null
|
||||
+++ b/package/base-files/files/etc/hotplug.d/net/50-switch-dvlan
|
||||
@@ -0,0 +1,43 @@
|
||||
+#!/bin/sh
|
||||
+
|
||||
+. /lib/functions.sh
|
||||
+. /lib/functions/dyn_vlan_switch.sh
|
||||
+
|
||||
+debug() {
|
||||
+ logger -t HOTPLUG-DVLAN "$*"
|
||||
+}
|
||||
+
|
||||
+if [ "${INTERFACE:0:2}" != "up" ]; then
|
||||
+ exit 0
|
||||
+fi
|
||||
+
|
||||
+case "$(board_name)" in
|
||||
+ "yuncore,fap655")
|
||||
+ switch_dev="switch1"
|
||||
+ switch_wan_port=5t
|
||||
+ switch_cpu_port=6t
|
||||
+ ;;
|
||||
+ "cig,wf186w")
|
||||
+ switch_dev="switch0"
|
||||
+ switch_wan_port=4t
|
||||
+ switch_cpu_port=6t
|
||||
+ ;;
|
||||
+ "edgecore,eap104")
|
||||
+ switch_dev="switch1"
|
||||
+ switch_wan_port=
|
||||
+ switch_cpu_port=6t
|
||||
+ ;;
|
||||
+ *)
|
||||
+ 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 added on bridge ${INTERFACE:0:2}, configuring $switch_dev for dynamic vlans"
|
||||
+ configure_bridge_dyn_vlans ${INTERFACE:0:2} $switch_dev $switch_wan_port $switch_cpu_port
|
||||
+fi
|
||||
+
|
||||
diff --git a/package/base-files/files/lib/functions/dyn_vlan_switch.sh b/package/base-files/files/lib/functions/dyn_vlan_switch.sh
|
||||
new file mode 100644
|
||||
index 0000000000..5901a1537d
|
||||
--- /dev/null
|
||||
+++ b/package/base-files/files/lib/functions/dyn_vlan_switch.sh
|
||||
@@ -0,0 +1,33 @@
|
||||
+
|
||||
+configure_switch_dynamic_vlan(){
|
||||
+vid=$1
|
||||
+switch_dev=$2
|
||||
+switch_wan_port=$3
|
||||
+switch_cpu_port=$4
|
||||
+debug "configured switch $switch_dev ports $switch_wan_port $switch_cpu_port for dynamic vlans $vid"
|
||||
+swconfig dev ${switch_dev} vlan $vid set ports "${switch_wan_port} ${switch_cpu_port}"
|
||||
+
|
||||
+}
|
||||
+
|
||||
+
|
||||
+configure_bridge_dyn_vlans () {
|
||||
+interfaces=$(ls /sys/class/net/$1/brif)
|
||||
+
|
||||
+switch_dev=$2
|
||||
+switch_wan_port=$3
|
||||
+switch_cpu_port=$4
|
||||
+
|
||||
+# Convert the string into an array
|
||||
+IFS=' ' set -- $interfaces
|
||||
+
|
||||
+# Loop through the array and print each element
|
||||
+for interface in "$@"; do
|
||||
+ case "$interface" in
|
||||
+ wlan*-v*)
|
||||
+ # Use parameter expansion to extract the part after "wlan*-v"
|
||||
+ dyn_vlan_id="${interface#*wlan*-v}"
|
||||
+ configure_switch_dynamic_vlan $dyn_vlan_id $switch_dev $switch_wan_port $switch_cpu_port ;;
|
||||
+ esac
|
||||
+done
|
||||
+}
|
||||
+
|
||||
--
|
||||
2.34.1
|
||||
|
||||
Reference in New Issue
Block a user