Skip to content

Commit

Permalink
WIFI-13797:Fix Modifying VLAN-ID Under LAN Port : using event handling
Browse files Browse the repository at this point in the history
Fixes WIFI-13797: This commit is an improvement over previous
commit 3598a24 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.

Signed-off-by: joydeepbenison <joydeep.ghosh@benisontech.com>
  • Loading branch information
joydeepbenison committed Jul 2, 2024
1 parent a449f08 commit bda3572
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 111 deletions.
58 changes: 58 additions & 0 deletions feeds/ucentral/ucentral-event/files/ucentral-event
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

This file was deleted.

0 comments on commit bda3572

Please sign in to comment.