Skip to content

fw4: include virtual L3 devices in flowtables - #102

Open
dormancygrace wants to merge 1 commit into
openwrt:masterfrom
dormancygrace:fix/software-offload-virtual-l3-devices
Open

fw4: include virtual L3 devices in flowtables#102
dormancygrace wants to merge 1 commit into
openwrt:masterfrom
dormancygrace:fix/software-offload-virtual-l3-devices

Conversation

@dormancygrace

@dormancygrace dormancygrace commented Aug 9, 2026

Copy link
Copy Markdown

Some netifd protocols expose an l3_device but no underlying device.
WireGuard and QMI QMAP are examples. fw4 currently derives the flowtable
device list exclusively from device, so it omits the interface on which
decapsulated packets actually enter the stack. The affected direction cannot
use software flow offload.

Track two additional per-zone lists:

  • software flowtable devices, preferring the existing physical device and
    falling back to the logical L3 device only when no physical device exists;
  • virtual-only L3 devices, appended after hardware capability probing so a
    hardware-enabled flowtable can retain software fallback for unsupported
    virtual paths.

This deliberately preserves the existing device choice for Ethernet, bridges,
VLAN and PPPoE. It also deduplicates paired protocol instances: for example, a
wan6 instance without device cannot add pppoe-wan when the corresponding
IPv4 instance reports its physical device. The hardware resolver and its
lower-device probing remain unchanged.

Validation:

  • complete firewall4 test suite: 32/32 passed;
  • new mock matrix: Ethernet, bridge, VLAN, PPPoE, QMI QMAP, WireGuard, and a
    mixed hardware/software flowtable;
  • real MT7620, WireGuard over QMAP/LTE, fixed 18 Mbit/s download (median of
    three valid runs):
    • no offload: 72.94% CPU;
    • existing fw4 device list: 69.24% CPU;
    • this change: 51.88% CPU;
  • with hardware offload enabled, the mixed flowtable contained the physical
    PPE devices plus rmnet-wwan0 and wgtest. WireGuard conntrack used
    [OFFLOAD], not [HW_OFFLOAD], while an 80 Mbit/s Ethernet NAT control
    retained [HW_OFFLOAD] and about 81% router idle CPU. Both traffic classes
    therefore coexist in the same flags offload flowtable.

Related discussion: openwrt/openwrt#10224

Some netifd protocols, such as WireGuard and QMI QMAP, expose an
l3_device but no underlying device. This leaves related_physdevs empty
and omits the actual ingress device from software flowtables.

Track flowtable and virtual-only devices separately. Prefer the existing
physical device and fall back to the logical L3 device only when netifd
reports no physical device. Append virtual-only devices after hardware
capability probing so hardware and software offload can coexist in one
flowtable.

This preserves existing Ethernet, bridge, VLAN and PPPoE selection and
leaves hardware probing unchanged. Add mock coverage for those paths and
for mixed physical and virtual device resolution.

On an MT7620 router, WireGuard over QMAP/LTE at 18 Mbit/s reduced CPU
from 69.24% with the existing device list to 51.88%. An 80 Mbit/s
Ethernet NAT control remained hardware-offloaded.

Link: openwrt/openwrt#10224
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant