Repository navigation
fix(wireguard): keep forward accept rules out of mangle chains - #101
Conversation
ensureNFTForwarding inserts "iifname <wg> accept" rules at the top of every forward-hook base chain. That includes mangle chains such as iptables-nft's "table ip mangle" FORWARD, where Docker hosts keep TCP MSS clamping. The accept ends that chain before the clamping rule runs, so full-size TCP segments enter the tunnel, exceed the path MTU and get dropped: ping and DNS work, but TLS handshakes and streams stall. Skip forward chains in a table named "mangle" or at the mangle hook priority (-150, which also covers fw4's mangle_forward). Those chains alter packets rather than filter them, so they never need the accept. Rules from older versions are still removed on shutdown by the old process, as before. Fixes PasarGuard#98 (diagnosis by @levik62).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughForward-chain discovery now skips nftables chains in the ChangesMangle chain filtering
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to No merge-blocking risk is identified; merge after normal checks. Pre-merge checks |
|
…ts owner Main's decision G1 (B). None of these lines claims a port, or coverage by a branch that is not on main. - a3d2d2f (PasarGuard#101): owned by NODE-WG (wgnft), until 2026-11-10. - 33ab5fb (PasarGuard#58): owned by NODE-SYNC-055 and NODE-XRAY-RACE, until 2026-11-10. - xray 7da5dae: its verified port by NODE-MISC-XMUX is queued after this cut, until 2026-11-20. - xray b291961, 8d0a7cf and 72b4d0c, each on its upstream branch and scoped to it: reachability awaits NODE-MISC-UPX, until 2026-11-10. - sing-box 42cae14 and release v1.14.4: PUSH-GATE, with the sing-box 1.14 move, until 2026-11-20.
…Guard#101) ensureNFTForwarding inserts "iifname <wg> accept" rules at the top of every forward-hook base chain. That includes mangle chains such as iptables-nft's "table ip mangle" FORWARD, where Docker hosts keep TCP MSS clamping. The accept ends that chain before the clamping rule runs, so full-size TCP segments enter the tunnel, exceed the path MTU and get dropped: ping and DNS work, but TLS handshakes and streams stall. Skip forward chains in a table named "mangle" or at the mangle hook priority (-150, which also covers fw4's mangle_forward). Those chains alter packets rather than filter them, so they never need the accept. Rules from older versions are still removed on shutdown by the old process, as before. Fixes PasarGuard#98 (diagnosis by @levik62). (cherry picked from commit a3d2d2f)
…T-L-1) ensureNFTForwarding inserts the L2TP pool's MSS and "ip saddr <pool> accept" rules at the top of every forward-hook base chain that parseForwardBaseChains returns. That list still included mangle chains such as iptables-nft's "table ip mangle" FORWARD and fw4's mangle_forward, both at priority -150. On Docker hosts that chain holds TCP MSS clamping; the inserted accept ends the chain before the clamping rule runs, so full-size TCP segments leave for paths with a smaller MTU and get dropped: ping and DNS work, but TLS handshakes and streams stall. Upstream fixed the same bug for WireGuard in PasarGuard#101, cherry-picked here as c0e36fc9. This applies the same rule to the fork's L2TP copy: forward chains in a table named "mangle" or at the mangle hook priority (-150) are skipped. Those chains alter packets rather than filter them, so they never need the accept. As in the WireGuard fix, cleanup walks the same filtered list, so rules an older version left in a mangle chain are removed by that older process on shutdown, as before. Upstream: a3d2d2f (adapted to backend/l2tp)
… ledger 24e2b12 (PasarGuard#55) and a3d2d2f (PasarGuard#101) are ported on main by 3874446 and 3998a57, whose cherry-pick trailers the drift check reads, so their pending waivers are removed. The v0.5.6 version bump 675bdaa becomes not-applicable, as the panel's upstream-forks/node.md records it and as 47857d4 and 739eab9 already are. The 47857d4 reason now names NodeVersion 0.6.22, the value on main.
Fixes #98. Thanks to @levik62 for the precise diagnosis.
The kernel WireGuard backend inserts its forward
acceptrules at the top of every nftables forward-hook chain. On Docker hosts that includes iptables-nft'stable ip mangleFORWARD chain, where TCP MSS clamping lives. Theacceptends that chain before the clamp runs, so full-size segments enter the tunnel and get dropped: ping and DNS work, TLS handshakes and streams stall.This skips forward chains in a table named
mangleor at the mangle hook priority (-150, which also covers fw4'smangle_forward). They alter packets rather than filter them, so they never need the accept; every filter-stage chain still gets it.backend/wireguard/host_routing_linux.go: readpriofromnft -j list rulesetand skip mangle chains inparseNFTForwardBaseChains.backend/wireguard/host_routing_linux_test.go: new parser test (iptables-nft mangle, fw4mangle_forwardandforward,ip filter, and a non-numericpriothat must not fail).Upgrade note: an older node removes the rules it put into a mangle chain when it shuts down cleanly, and this version never adds them there. If the old process is killed before its cleanup finishes (Docker's default 10 s stop timeout matches the node's 10 s graceful stop), its rules stay in the mangle chain until a reboot. To remove them by hand:
nft -a list chain ip mangle FORWARD, thennft delete rule ip mangle FORWARD handle <N>for each rule whose comment starts withpg_node_wg.go vetandgo test ./backend/wireguard/pass.Summary by CodeRabbit
manglechains and chains with a priority of-150.