Skip to content

gotc: ematch writes for basic, cgroup and flow match (increment 21) - #373

Merged
randomizedcoder merged 7 commits into
mainfrom
gotc/ematch
Nov 30, 2026
Merged

randomizedcoder merged 7 commits into
mainfrom
gotc/ematch

Conversation

@randomizedcoder

@randomizedcoder randomizedcoder commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

Increment 21: dry-run ematch writes for tc 7.2.0. This covers tc filter with kind basic and kind cgroup, and flow's match. The parts ported are tc's ematch lexer and grammar, plus the cmp, nbyte, u32, meta and canid modules.

  • 21C: a new tcematch capture space with 257 rows. Two batches on one boot agree (V055).
  • 21P: Append encoders for the ematch tree and match headers and for cmp, nbyte, canid and meta, plus AttrBuilder.PutRaw (tc's addraw_l) (V056).
  • 21W: gotc writes for basic, cgroup and flow match (V057).
    • 243 of the 257 rows replay byte for byte. The other 14 are refused by name:
      • police, ipt and ipset;
      • the cases where tc reads or writes memory it doesn't own (W123, W125, W126);
      • two trees too big for tc's request buffer, which tc sends truncated.
    • Process state carried across -batch lines is modelled, as tc does it (W124, W128, W129).
    • tcfwrite ec-114, ec-115 and ec-118 now match, and 245 tdc filter writes match.
    • 10/10 mutants killed; internal/gotc coverage is 85.1%. Two fuzz targets ran 60s each with no findings.
  • 21B: iproute2 leads W123–W155 and kernel notes K56–K62 are in the new docs/netlink/upstream/iproute2-tc-ematch-write.md. Not sent to netdev (DOC014).
    • W124: tc keeps every quoted string in one shared buffer, so meta("a" eq "b") is sent as "b" eq "b". When that buffer grows, tc sends freed heap bytes.
    • K62: tc can't list a filter whose dump is bigger than about one page.
  • 21L: a live diff on the workbench. 246 of 260 rows match, and every request sent is identical. The other 14 rows are the refusals above (V058).
  • 21R (review fixes, V059):
    • A trailing police now gives tc's Command line is not complete, rc 255, for basic, cgroup, fw, route, u32 and flow. tc 7.2.0 on the host gives the same.
    • Two new rows pin the parser's depth limit. 4995 nested ( still parse; 4996 gives memory exhausted, and gotc's stderr matches tc's byte for byte.
    • The tree header now sets ProgID to TcfEmProgTc explicitly.
    • Both new mutants were killed.
  • Read-side fix: meta's vlan id is 46, not 48.

Gates: go test ./..., test-go-race, lint-baseline (tiers 0-2), no-write-encoders and nix build .#gotc pass.

🤖 Generated with Claude Code

randomizedcoder and others added 7 commits November 29, 2026 19:45
257 rows (144 writes, 113 refusals) of basic and cgroup writes and
flow's match: the ematch grammar, every cmp, nbyte, u32, meta and canid
keyword, the leads W123-W155 that a capture can end on, F25, W95 and
W97, and the refusals by name (police, ipset, ipt). Each rc was checked
on the host tc first; two workbench batches on one boot agree.

The workbench kernel (7.3.1) dumps a 4095-byte nbyte with its header
alone: tcf_em_tree_dump ignored nla_put_nohdr's failure until
528de6832b21 (v7.4-rc1). TestWsTcFilterKinds accepts such a match, and
W151's 16 KiB refusal is ParseNlMsgErr's new largest pick.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Append for the ematch tree and match headers and the cmp, nbyte, canid
and meta structs, laid out as the v7.4-rc4 uapi headers have them, and
PutRaw, iproute2's addraw_l. TestBuildTcEmatchWrite builds fifteen
tcematch requests and matches tc's captured bytes, including the
flattened nested tree, W136's 4096-byte needle and W124's shared strbuf.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tc's ematch lexer and parser (flex's buffer, bison's LALR tables, the
state a batch carries between lines), the cmp, nbyte, u32, meta and
canid modules, and basic's and cgroup's parse_fopt with flow's match
arm. ipset, ipt and police are refused by name, and so are the leads
where tc reads or writes memory it doesn't own, or hangs (W123-W128,
W132). Fixes the read side's meta vlan id (46, not 48).

243 of 257 tcematch rows replay byte for byte (14 refused by name);
tcfwrite ec-114/115/118 now match; 245 tdc filter writes match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/netlink/upstream/iproute2-tc-ematch-write.md: W123-W155 and
K56-K62, each with file:line at v7.2.0 / v7.4-rc4, its tcematch
pinning row and gotc's behaviour; every lead is present at HEAD. F25,
K2, W95 and W97 gain increment-21 extensions where they live, and the
filter-write doc points at the new one. Not submitted to netdev.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gocritic's nilValReturn: the word is nil on that path, so say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the workbench, tc and the gotc_write build agree on 246 of 260 rows
(the 257 tcematch rows and tcfwrite ec-114/115/118): every request
byte for byte; the other 14 are the refusals by name. A size probe pins
K62: tc can't list a filter whose dump outgrows a page-sized first skb
(between 3600 and 3800 bytes of canid rules). W155's non-root message
is checked on the host. The VM was left as found.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A trailing police is NEXT_ARG's exit, as in every kind's parse_opt:
  `Command line is not complete`, rc 255, for basic, cgroup, fw, route,
  u32 and flow (errPolice becomes runner.policeArm).
- Two rows pin bison's YYMAXDEPTH: 4995 nested parens parse, 4996 give
  tc 7.2.0's `memory exhausted` stderr byte for byte (host bisect).
- The tree header sets ProgID to the new xtcpnl.TcfEmProgTc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@randomizedcoder
randomizedcoder merged commit defa100 into main Nov 30, 2026
1 check passed
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