Skip to content

fix: nftables interval end overflow EEXIST for max-address ranges - #4319

Closed
H-TTTTT wants to merge 1 commit into
SagerNet:testingfrom
H-TTTTT:fix/nftables-interval-end-overflow
Closed

fix: nftables interval end overflow EEXIST for max-address ranges#4319
H-TTTTT wants to merge 1 commit into
SagerNet:testingfrom
H-TTTTT:fix/nftables-interval-end-overflow

Conversation

@H-TTTTT

@H-TTTTT H-TTTTT commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • auto_redirect + route_exclude_address CIDRs whose upper bound is the address-family max (ff00::/8, 240.0.0.0/4, …) failed setup with nftables EEXIST (file exists).
  • Root cause is in sing-tun nftablesCreateIPSet: when To().Next() overflows, the end key was set equal to the start key.
  • This PR replaces github.com/sagernet/sing-tun with the fix from fix: omit nftables interval end when range hits max address sing-tun#83 (H-TTTTT/sing-tun@8775818), which omits the exclusive interval-end element so the range covers through the max address.

Note for maintainers: drop the replace and bump to an official sing-tun tag/commit once SagerNet/sing-tun#83 is merged.

Test plan

  • route_exclude_address: ["ff00::/8"] with auto_redirect: true starts cleanly
  • IPv4 240.0.0.0/4 / 224.0.0.0/3 also work
  • Normal exclude ranges unchanged

Fixes #4316

route_exclude_address ranges that reach 255.255.255.255 / ffff:...:ffff
made nftablesCreateIPSet encode a duplicate interval start/end key.
Point sing-tun at the fix that omits the exclusive end when Next()
overflows (H-TTTTT/sing-tun@8775818, SagerNet/sing-tun#83).

Fixes SagerNet#4316
@nekohasekai
nekohasekai force-pushed the testing branch 12 times, most recently from 3b9cd24 to 3fcfadd Compare July 22, 2026 02:36
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.

TUN auto_redirect: nftables EEXIST for excluded CIDRs reaching the max address (ff00::/8, 240.0.0.0/4)

2 participants