Skip to content

Patch Tailscale for nftables fwmark endianness issue#1

Open
admonstrator wants to merge 5 commits intoGLiNet-Community-Scripts:mainfrom
admonstrator:main
Open

Patch Tailscale for nftables fwmark endianness issue#1
admonstrator wants to merge 5 commits intoGLiNet-Community-Scripts:mainfrom
admonstrator:main

Conversation

@admonstrator
Copy link
Copy Markdown

This pull request introduces a patch to address nftables fwmark endianness issues on GL.iNet routers, updates the build workflow to apply this patch, and makes minor documentation improvements. The patch ensures that nftables rules use the correct byte order for fwmark masks, preventing routing issues on little-endian systems. Special thanks are added for the contributor of the patch.

The most important changes are:

nftables fwmark endianness patch:

  • Added patches/0001-fix-nftables-fwmark-endianness.patch to fix nftables fwmark mask byte order, ensuring it is native-endian for correct operation on all architectures. This patch modifies how fwmark masks are generated and updates test cases accordingly.
  • Updated the build workflow in .github/workflows/build-tailscale.yaml to check out the patch repository and apply the fwmark endianness patch during the build process.

Documentation updates:

  • Added a special thanks entry in both readme.md and readme.template.md for Dongming Han (GL.iNet) for implementing the fwmark patch. [1] [2]
  • Updated the project’s star count badge and the last updated date in readme.md. [1] [2]

handongming and others added 4 commits May 6, 2026 10:09
- Add patches/0001-fix-nftables-fwmark-endianness.patch.
- Keep upstream build logic unchanged; minimally add checkout for this repo and apply
  patch before go mod download/cross-compile.

Refs: tailscale/tailscale#11803
Refs: tailscale/tailscale#19601
Signed-off-by: Dongming Han <handongming@gl-inet.com>
…1) (#82)

## Problem

On **little-endian** hosts (arm64, amd64), Tailscale’s **nftables**
netfilter backend built fwmark **mask/value** bytes for `meta mark` /
`Bitwise` expressions using the **wrong byte order**. Rules that should
match **`0x40000 / 0xff0000`** (third byte) instead behaved like
**`0x00000400 / 0x0000ff00`** — i.e. the mask effectively hits the
**wrong 8-bit lane**.

That collides with **policy-routing marks in the `0x8000 / 0xf000`
nibble** (e.g. OpenWrt **fw4 / `vpn_table`** style marks on GL.iNet
firmware). **Tailscale’s `0x80000/0xff0000` and GL’s `0x8000/0xf000` are
meant to be non-overlapping in `ip rule`**, but the nft bug shifts the
bitfield so they **fight the same mark bits**.

Typical symptom: **first packet of a flow passes, later packets break**
(e.g. LAN ping gets one reply then silence) once **connmark
save/restore** paths run on **ESTABLISHED** traffic — consistent with
[tailscale#11803](tailscale/tailscale#11803).

Workaround users may try: `tailscale set --netfilter-mode=off` (trade
off Tailscale’s netfilter integration). Proper fix:
**`encoding/binary.NativeEndian`** in `util/linuxfw` — same direction as
[tailscale#19601](tailscale/tailscale#19601).

## This PR

- Adds `patches/0001-fix-nftables-fwmark-endianness.patch` (from the
#11803 / #19601 fix).
- In `build-tailscale.yaml`, after checking out `tailscale/tailscale`,
checks out this repo under `repo/` and runs `patch -p1 <
repo/patches/0001-...` **before** `go mod download` / cross-compile.

**No change** to feature tags, UPX publishing, or release flow — only
the Tailscale sources are patched before build.

## When to drop this

Remove the patch + checkout/apply steps after **#19601** is merged
**and** the Tailscale release you build already contains the fix.
@admonstrator admonstrator self-assigned this May 6, 2026
@admonstrator
Copy link
Copy Markdown
Author

@copilot resolve the merge conflicts in this pull request, discard build-tailscale.yaml - not needed in this repo.

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.

2 participants