udevstats: add support for dynamic vlans

Fixes: WIFI-12582
Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2023-05-16 10:30:09 +02:00
parent 4688ba6996
commit e91f49bdbd
2 changed files with 16 additions and 0 deletions

View File

@@ -122,6 +122,7 @@ let handlers = {
vlan: [ `${notify.data.vlan_id}:t` ] vlan: [ `${notify.data.vlan_id}:t` ]
}; };
ubus.call('network.interface.up_none', 'add_device', msg); ubus.call('network.interface.up_none', 'add_device', msg);
ubus.call('udevstats', 'add_device', { device: wan, vlan: +notify.data.vlan_id });
} }
let msg = { let msg = {

View File

@@ -215,6 +215,21 @@ function run_service() {
}, },
args: {} args: {}
}, },
add_device: {
call: function(req) {
if (!req.args.device || !req.args.vlan)
return ubus.STATUS_INVALID_ARGUMENT;
if (!vlan_config[req.args.device])
vlan_config[req.args.device] = [];
push(vlan_config[req.args.device], [ req.args.vlan, "rx", "tx"]);
vlan_set_config(vlan_config);
return 0;
},
args: {
"device": "wlan0",
"vlan": 100,
}
},
reset: { reset: {
call: function(req) { call: function(req) {
let old_config = vlan_config; let old_config = vlan_config;