Gennaro Cimmino 138fabb79f realtek: l3: do not invent an L2 entry for a next hop
When a route is programmed while the switch holds no L2 entry for the
gateway, rtldsa_l2_nexthop_add() invents one carrying the don't-care
port priv->r->port_ignore. Observed on an RTL9303: with such a next hop
the destination receives every forwarded frame twice, once from the
switch and once from the Linux stack. Where the route entry can trap,
do not invent the row, and trap the route to the CPU instead, which is
what otto_l3_fib_add_v4() already does for a host route with no
gateway.

The invented row is written static, so it does not age, and the software
bridge offers no replacement: dsa_user_fdb_event() drops an address
learned on an offloaded port before the driver sees it. Leaving the slot
to the address lets the switch learn it from the traffic the CPU routes,
and a later neighbour update programs a real port. From the code, not
tested: a gateway held as a permanent or NOARP neighbour produces no
such update, so its route stays in software. A route that only claims
entries the switch learned never clears the route count of the entry it
claims: that count may still hold routes forwarding through the entry.

Tested on an RTL9303 (Hasivo S1100W-8XGT-SE) against pristine main,
same board and same rig (main at 19ff245b92; this patch on c09e3f28ba,
which only adds an SPI backport): two hosts on one bridge port, one
untagged in VLAN 1 and one tagged in VLAN 3, a /32 route to each,
programmed after 340 s of neighbour silence so the gateways' L2 entries
have aged out. On main both get a static next hop with the don't-care
port, and five pings collect twelve duplicates: tcpdump at the
destination shows each echo request twice with the same IP id, once at
ttl 64 and once at ttl 63, and the entry is still static afterwards.
With this patch both routes are trapped and the five pings cross in
software without loss or duplicates, each request once at ttl 63. A
trapped route stays trapped while nothing crosses it (ten readings 30 s
apart); the pings let the switch learn the address, and after them the
route is back in hardware on a learned, dynamic entry with the real
port. Programmed while the neighbours are fresh, both kernels behave the
same: a real port and no duplicates. A /24 through the same gateway,
which lands in the prefix table rather than the host one, is trapped the
same way, and its five pings cross at ttl 63 without duplicates.

Not changed here, and the same on both kernels: an entry that ages
while a route already forwards through it keeps its next-hop bit with
the don't-care port, so after 340 s of silence the first of five pings
drew one duplicate before the switch learned the address again.

RTL838x and RTL931x never reach this code: their otto_l3_config carries
no .setup, and both notifiers return early without one, as does an
RTL930x built without CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD. RTL839x
reaches it, but routes through a PIE rule rather than a route entry with
an action, and what its switch does with a route rule that no longer
forwards is not something I could find in the SDK or test. The change is
therefore keyed on use_l3_tables: RTL839x still gets the invented entry
and a PIE rule forwarding through it, exactly as before. Whether it
shows the duplicates too was not tested.

Assisted-by: Claude:claude-opus-5
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Gennaro Cimmino <gcimmino@rayonra.net>
Link: https://github.com/openwrt/openwrt/pull/25353
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
2026-09-29 10:04:39 +02:00
2026-09-29 09:27:40 +02:00
2024-05-17 22:03:06 +03:00
2021-02-05 14:54:47 +01:00

OpenWrt logo

OpenWrt Project is a Linux operating system targeting embedded devices. Instead of trying to create a single, static firmware, OpenWrt provides a fully writable filesystem with package management. This frees you from the application selection and configuration provided by the vendor and allows you to customize the device through the use of packages to suit any application. For developers, OpenWrt is the framework to build an application without having to build a complete firmware around it; for users this means the ability for full customization, to use the device in ways never envisioned.

Sunshine!

Download

Built firmware images are available for many architectures and come with a package selection to be used as WiFi home router. To quickly find a factory image usable to migrate from a vendor stock firmware to OpenWrt, try the Firmware Selector.

If your device is supported, please follow the Info link to see install instructions or consult the support resources listed below.

An advanced user may require additional or specific package. (Toolchain, SDK, ...) For everything else than simple firmware download, try the wiki download page:

Development

To build your own firmware you need a GNU/Linux, BSD or macOS system (case sensitive filesystem required). Cygwin is unsupported because of the lack of a case sensitive file system.

Requirements

You need the following tools to compile OpenWrt, the package names vary between distributions. A complete list with distribution specific packages is found in the Build System Setup documentation.

binutils bzip2 diff find flex gawk gcc-6+ getopt grep install libc-dev libz-dev
make4.1+ perl python3.8+ rsync subversion unzip which

Quickstart

  1. Run ./scripts/feeds update -a to obtain all the latest package definitions defined in feeds.conf / feeds.conf.default

  2. Run ./scripts/feeds install -a to install symlinks for all obtained packages into package/feeds/

  3. Run make menuconfig to select your preferred configuration for the toolchain, target system & firmware packages.

  4. Run make to build your firmware. This will download all sources, build the cross-compile toolchain and then cross-compile the GNU/Linux kernel & all chosen applications for your target system.

The main repository uses multiple sub-repositories to manage packages of different categories. All packages are installed via the OpenWrt package manager called opkg. If you're looking to develop the web interface or port packages to OpenWrt, please find the fitting repository below.

  • LuCI Web Interface: Modern and modular interface to control the device via a web browser.

  • OpenWrt Packages: Community repository of ported packages.

  • OpenWrt Routing: Packages specifically focused on (mesh) routing.

  • OpenWrt Video: Packages specifically focused on display servers and clients (Xorg and Wayland).

Support Information

For a list of supported devices see the OpenWrt Hardware Database

Documentation

Support Community

  • Forum: For usage, projects, discussions and hardware advise.
  • Support Chat: Channel #openwrt on oftc.net.

Developer Community

License

OpenWrt is licensed under GPL-2.0

S
Description
This repository is a mirror of https://git.openwrt.org/openwrt/openwrt.git It is for reference only and is not active for check-ins. We will continue to accept Pull Requests here. They will be merged via staging trees then into openwrt.git.
Readme BSD-2-Clause BSD-3-Clause GPL-1 GPL-2 ISC Linux-syscall-note MIT
1.2 GiB
0 Stars 1 Watchers 0 Forks
Languages
C 60.5%
Makefile 23%
Shell 8.4%
UnrealScript 2.5%
Perl 2.5%
Other 2.8%