From 834403b97bf73634c5a2e0ecbca093ec6838a344 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Sat, 17 Oct 2026 14:51:06 +0100 Subject: [PATCH] Parking ports with only tagged membership into VLAN 4094 for now I think this should also resolve the work-flow where you can get a port's PVID and tagged membership to the same vlan --- html/app.js | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/html/app.js b/html/app.js index 613ff769..e636ddbf 100644 --- a/html/app.js +++ b/html/app.js @@ -1619,6 +1619,11 @@ function vlan2str(i, n, t, u) { function pvidcmd(i, p){ return "pvid " + p + " " + i; } +const parkingVLAN=4094; + function mySplit(a){ + if(a.trim()=="") return []; + return a.trim().split(","); + } function vlanApply() { var vid = $("vtitle").dataset.id; var vname = $("vtitle").dataset.name; @@ -1628,24 +1633,24 @@ function vlanApply() { } var top_cmds = [], tail_cmds = [], - thisVlanInStructure={id:vid, tagged:[], untagged:[]}; + thisVlanInStructure={id:vid, tagged:[], untagged:[]}, + vlansPerPort=[]; for (var p = 1; p <= S.n; p++) { var v = segVal(p); + vlansPerPort[p]={t:[],u:[]}; if (v === 1) { thisVlanInStructure.untagged.push(p); + vlansPerPort[p].u.push(vid); } else if (v === 2) { thisVlanInStructure.tagged.push(p); + vlansPerPort[p].t.push(vid); } } if (thisVlanInStructure.tagged.length + thisVlanInStructure.untagged.length == 0) { toast(t("v_nomember"), "err"); return; } - function mySplit(a){ - if(a=="") return []; - return a.split(","); - } for(const vlanRow of $("vtable").tBodies[0].rows){ var rowData = vlanRow.firstChild.firstChild.dataset, rowUntagged = mySplit(rowData.u), @@ -1656,11 +1661,23 @@ function vlanApply() { rowUntagged.splice(rowUntagged.indexOf(""+newVlanPort),1); } } + for(const rut of rowUntagged) { + vlansPerPort[rut].u.push(rowData.id); + } + for(const rt of rowTagged) { + vlansPerPort[rt].t.push(rowData.id) + } top_cmds.push(vlan2str(rowData.id,rowData.name,rowTagged,rowUntagged)); } tail_cmds.push(vlan2str(vid, vname, thisVlanInStructure.tagged, thisVlanInStructure.untagged)); - //TODO: if the PVID is equal to this vid, we need to set it something else (probably 1) - + + //park all ports with only tagged membership + for (p in vlansPerPort){ + if (vlansPerPort[p].u.length == 0 && vlansPerPort[p].t.length > 0) { + tail_cmds.push(pvidcmd(parkingVLAN, p)); + } + } + for(const up of thisVlanInStructure.untagged){ tail_cmds.push(pvidcmd(vid,up)); } @@ -1672,7 +1689,7 @@ function vlanApply() { vlanLoad(vid) }); } - +/* function ingressApply() { var cmd = "ingress", any = false; @@ -1689,6 +1706,7 @@ function ingressApply() { } postCmd(cmd).catch(function() {}); } +*/ $("vapply").addEventListener("click", vlanApply); $("vlan_add").addEventListener("click", function() { var body = h("div");