From aef4cf221567686d0cc91fb90ff1a7dd4ffcf938 Mon Sep 17 00:00:00 2001 From: Gennaro Cimmino Date: Sun, 11 Oct 2026 19:49:36 +0200 Subject: [PATCH] realtek: l3: rtl839x: trap packets to an aged-out gateway On RTL839x a route forwards through its gateway's L2 entry. A gateway that sends nothing lets that entry age out, and a packet routed through it then hits the routing entry age-out exception, whose action is forward after reset: the packet is routed and also reaches the CPU, which routes it a second time when IPv4 forwarding is on. Trap it instead (ROUTING_AGE, bits 15:14 of ROUTING_EXCPT_CTRL: 0 drop, 1 forward, 2 trap; Realtek GPL SDK, dal_cypress_trap.c, exception ROUTE_EXCEPTION_TYPE_ENTRY_AGE_OUT), as the TTL exception already does. The CPU routes such packets alone until the gateway sends again and its entry is learnt anew. Measured on an HPE 1920-48G (RTL8393), 10.99.0.0/16 via a gateway that sends nothing, 8 echo requests per case, once the age of its L2 entry had run down to 0 (about 4.5 minutes on the bench): - without this change: forwarding off, 8/8 routed and 8/8 at the CPU as well; forwarding on, 14 at the gateway, 8 from the switch and 6 from the kernel - with it: forwarding off, none routed, 8/8 at the CPU; forwarding on, 8 at the gateway, none of them twice With a fresh entry, 8/8 were routed in hardware and none reached the CPU, without and with this change. Both images also carried the pending switch MAC change for #25768 items 3 and 4 and bench debugfs files. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Gennaro Cimmino Link: https://github.com/openwrt/openwrt/pull/25821 Signed-off-by: Markus Stockhausen --- .../linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c index b0f157d7377..2f4ed8f1977 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/l3.c @@ -296,6 +296,13 @@ static int otto_l3_839x_setup(struct otto_l3_ctrl *ctrl) */ sw_w32_mask(0x3 << 2, 2 << 2, RTL839X_ROUTING_EXCPT_CTRL); + /* A packet routed through a gateway whose L2 entry has aged out goes + * to the CPU alone. Forwarded, the default, it is routed and reaches + * the CPU as well, which routes it a second time. ROUTING_AGE, bits + * 15:14, same encoding. + */ + sw_w32_mask(0x3 << 14, 2 << 14, RTL839X_ROUTING_EXCPT_CTRL); + return 0; }