Commit graph

8 commits

Author SHA1 Message Date
世界
ed63adda33
Add flow dispatcher 2026-07-27 23:11:48 +08:00
世界
a9027729be
Make gtcpip public for external use 2026-07-27 23:11:48 +08:00
世界
99fb96a4c8
Fix missing UDP and ICMP bypass for auto redirect 2026-07-27 23:11:22 +08:00
世界
8048acde1e
Fix nfqueue options 2026-07-27 10:25:59 +08:00
世界
46aa536b37
Fix lint errors 2026-07-27 10:23:30 +08:00
Andrew Novikov
0e4cdbbc61
fix: use NF_REPEAT for NFQUEUE bypass/reset verdicts
NF_ACCEPT is a terminal verdict in nftables — when a packet returns
from NFQUEUE with NF_ACCEPT, it exits the current chain immediately
and continues to the next hook priority. Rules placed after the queue
statement in the same chain are never evaluated.

This meant that the `ct mark set meta mark` rule (which saves the
bypass decision to conntrack for subsequent packets) was dead code.
The first SYN packet received the correct mark from NFQUEUE, but
conntrack never stored it, so all subsequent packets of the same
connection were redirected to sing-box userspace.

Fix: use NF_REPEAT instead of NF_ACCEPT for bypass and reset verdicts.
NF_REPEAT re-enters the chain from the beginning with the mark already
set on skb->mark. Reorder the prematch chain rules so mark-checking
rules (ct mark set, reject) come before the queue statement:

  1. meta mark == outputMark → ct mark set meta mark, return
  2. meta mark == resetMark → reject with tcp reset
  3. ct mark == outputMark → return
  4. TCP SYN → queue to NFQUEUE

This is the standard pattern used by Suricata and other NFQUEUE-based
systems (NF_REPEAT + mark-based skip).

Tested on Orange Pi Zero 3 (arm64, kernel 6.12.58) with sing-box 1.13.3.
Bypass correctly saves ct mark, subsequent packets skip NFQUEUE entirely.
2026-03-17 10:58:45 +08:00
世界
a5db80d710
Fix nfqueue fallback when kernel module unavailable 2025-12-31 03:47:36 +08:00
世界
a850c4f8a1
Add pre-matching support for auto redirect 2025-12-26 14:44:55 +08:00