From 8b7306f995f7efc5ef43e46d5f834f1af972db28 Mon Sep 17 00:00:00 2001 From: d00f <8052722+DrDoof@users.noreply.github.com> Date: Sat, 5 Sep 2026 17:01:08 +0200 Subject: [PATCH] l2: name the group a learned address sits behind A device on an aggregate is learned against whichever member the frame came in on, and the hash moves that around: the same address changes port every time the flow mix changes. The table was telling the truth and there was no way to read it, since nothing on the page or the console says those two ports are one link. port_lag_of() already exists and already knows the answer, so both views ask it. The console prints LAG1 in place of the member, and /l2.json carries a "lag" field beside the port, 0 when the port stands alone, which is the shape /stp.json already uses. Costs 151 bytes of BANK1. --- html/l2.js | 12 ++++++++++-- httpd/page_impl.c | 4 ++++ rtl837x_port.c | 9 ++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/html/l2.js b/html/l2.js index 3d41d89a..9df0c75d 100644 --- a/html/l2.js +++ b/html/l2.js @@ -68,7 +68,11 @@ var l2SortCol = 'port'; var l2SortDir = 1; function l2Key(e, col) { - if (col === 'port') return e.port === 'CPU' ? Number.MAX_SAFE_INTEGER : Number(e.port); + if (col === 'port') { + if (e.port === 'CPU') return Number.MAX_SAFE_INTEGER; + if (e.lag) return 100 + e.lag; + return Number(e.port); + } if (col === 'vlan') return Number(e.vlan); return String(e[col]).toLowerCase(); } @@ -114,7 +118,11 @@ function fillL2(s) return; s.sort(l2CMP); s = uniq(s); - l2All = s; + l2All = s.map(function(e) { + if (e.lag) + e.port = 'LAG' + e.lag; + return e; + }); renderL2(); } diff --git a/httpd/page_impl.c b/httpd/page_impl.c index 313a652e..b99f0b9b 100644 --- a/httpd/page_impl.c +++ b/httpd/page_impl.c @@ -359,6 +359,7 @@ void send_l2(uint16_t idx) while (1) { entries_left--; uint8_t port = 0; + uint8_t lag; reg_read_m(RTL837x_TBL_DATA_0); REG_WRITE(RTL837x_TBL_DATA_0, sfr_data[0], sfr_data[1] & 0xfc, sfr_data[2] | (TBL_LUTREAD_NEXT_L2UC << 6), sfr_data[3]); @@ -402,6 +403,9 @@ void send_l2(uint16_t idx) port |= (sfr_data[3] & 0x3) << 2; itoa_html(port); + slen += strtox(outbuf + slen, ",\"lag\":"); + lag = port_lag_of(port); + itoa_html(lag == PORT_LAG_NONE ? 0 : lag + 1); } // Index diff --git a/rtl837x_port.c b/rtl837x_port.c index 1c966728..950766eb 100644 --- a/rtl837x_port.c +++ b/rtl837x_port.c @@ -381,6 +381,7 @@ void port_l2_learned(void) __banked while (1) { uint8_t port = 0; + uint8_t lag; reg_read_m(RTL837x_TBL_DATA_0); REG_WRITE(RTL837x_TBL_DATA_0, sfr_data[0], sfr_data[1],sfr_data[2] | 0xc0, sfr_data[3]); @@ -422,7 +423,13 @@ void port_l2_learned(void) __banked print_string("\tlearned\t"); port |= (sfr_data[3] & 0x3) << 2; - print_phys_port(port); + lag = port_lag_of(port); + if (lag == PORT_LAG_NONE) { + print_phys_port(port); + } else { + print_string("LAG"); + itoa(lag + 1); + } } entry++;