From 024c8cef492487567ec9731544144a361d678ef5 Mon Sep 17 00:00:00 2001 From: d00f Date: Thu, 13 Aug 2026 12:31:56 +0200 Subject: [PATCH] stp: arm the management failsafe only where an operator asked for it Your console session shows the shape of this better than I could have. STP found a loop, blocked the port, unblocked the other side of the pair, and then the failsafe turned STP off. It had been disarmed by your first console command and re-armed by the loop detection itself, so a mechanism that exists to protect against a lockout ended up removing loop protection while a loop was physically present. That is the part that did not make sense, and it wasn't the console. Two changes, both narrowing. Loop detection and root guard no longer arm the window. Those are the protocol doing its job on evidence off the wire. Nothing an operator did needs undoing there, and nobody is waiting to confirm anything. Typing on the serial console no longer disarms it. The failsafe asks one question, whether the operator can still reach management over the network, and serial activity doesn't answer it. It proves somebody is standing at the box, which is the one case where a lockout doesn't matter, and it took the safety net away from a remote operator on behalf of someone not using it. HTTP activity still confirms, because that is the path being measured, and the console in the web interface counts for the same reason. What is left arms on stp on, stp port N on and stp failsafe, each of them an operator choosing something whose outcome the protocol then decides. Gives back 61 bytes of BANK2, 31 of the common area and a byte of xdata. --- rtl837x_stp.c | 8 -------- rtlplayground.c | 6 ------ 2 files changed, 14 deletions(-) diff --git a/rtl837x_stp.c b/rtl837x_stp.c index d870af5..40e5bd4 100644 --- a/rtl837x_stp.c +++ b/rtl837x_stp.c @@ -276,10 +276,6 @@ static void stp_loop_hold_peer(uint8_t port) __reentrant print_string("STP: loop detected, blocking port "); print_port_nl(port); stp_state_set(port, 0b01); - if (stp_failsafe_s && !stp_failsafe_armed) { - stp_failsafe_armed = 1; - stp_failsafe_cnt = stp_failsafe_s; - } stp_pflags[port] &= ~STP_PF_OPEREDGE; stp_topology_change(port); } @@ -536,10 +532,6 @@ void stp_in(void) __banked print_string("STP: root guard blocking port "); print_port_nl(port); stp_state_set(port, 0b01); - if (stp_failsafe_s && !stp_failsafe_armed) { - stp_failsafe_armed = 1; - stp_failsafe_cnt = stp_failsafe_s; - } port_timers[port] = (uint16_t)stp_fwddelay_s * STP_HZ; stp_pflags[port] &= ~STP_PF_OPEREDGE; return; diff --git a/rtlplayground.c b/rtlplayground.c index 3b2d6b5..b24f8f5 100644 --- a/rtlplayground.c +++ b/rtlplayground.c @@ -123,7 +123,6 @@ __xdata uint8_t tx_seq; __xdata uint8_t stpEnabled; __xdata uint8_t igmpEnabled; extern __xdata uint8_t stp_failsafe_armed; -__xdata uint8_t fs_was_armed; __xdata char hostname[24]; /* device hostname, default set at boot, see rtl837x_common.h */ __code uint16_t bit_mask[16] = { @@ -1520,14 +1519,9 @@ void idle(void) // Check whether a command is waiting in the cmd_buffer and execute if (cmd_available) { cmd_available = 0; - fs_was_armed = stp_failsafe_armed; cmd_tokenize(); if (err_status == ERR_OK) cmd_parser(); - if (fs_was_armed && stp_failsafe_armed) { - stp_failsafe_armed = 0; - print_string("STP failsafe: console activity - disarmed\n"); - } print_cmd_prompt(); } }