Skip to content

gotc: tc qdisc and class show (increment 9) - #325

Merged
randomizedcoder merged 6 commits into
mainfrom
gotc/qdisc-class
Nov 24, 2026
Merged

randomizedcoder merged 6 commits into
mainfrom
gotc/qdisc-class

Conversation

@randomizedcoder

Copy link
Copy Markdown
Owner

Increment 9: gotc, a Go clone of tc qdisc show and tc class show (iproute2 7.2.0).

What's in it

Commit Task Result
5ef39f8 9S skeleton (V001) tc.c option loop in matches() order, dispatch, batch, psched and names seams
db1442d 9C captures (V002) tcqdisc / tcclass capture spaces, 224 rows
c98d68a 9P parsers (V003) xtcpnl decoders for per-kind options, stats2/compat stats, xstats; BuildTcDumpRequest byte-exact vs tc; tcmsg FamilyHdrLen modeled
e2e162d 9R renderer (V004) qdisc/class show for noqueue, mq, pfifo_fast/prio, fifos, fq_codel, fq, htb, tbf, sfq, netem, ingress, clsact; -s -d -r -p -g -j -iec -nm
2f33baf 9B findings (DOC001) docs/netlink/upstream/iproute2-tc-qdisc-class.md (not submitted to netdev)
a878238 9L live diff (V005) gotc vs tc 7.2.0 on the workbench

Results

  • Corpus replay: 224/224 rows byte-exact (stdout, stderr, rc).
  • tdc oracle: 216 qdisc/class readbacks render to verify.out exactly; 245 with out-of-slice kinds are refused (errNotImplemented naming the kind), counts pinned.
  • Live diff: 221/224 identical. The 3 others are expected: two writes gotc refuses, and Q34's heap-garbage stderr line.
  • xtcpnl: 1,373 in-slice messages from existing captures decode with 0 errors; fuzzers and benchmarks added.
  • internal/gotc coverage 82.4%; all 10 planned mutants killed.
  • Full go test ./... and test-go-race pass.

Notable iproute2 findings

  • Q36 (new): tc -g reads freed graph nodes when drawing nested class trees; the extra | bars come from that memory.
  • Q34: a second -g line in one batch double-frees (rc 134) and loses earlier output.
  • Q35 (new): prio's compat nest trusts its inner rta_len; a crafted message over-reads.
  • Q14 is already fixed upstream (9dd1bec6b863). Q10, Q23, Q32 dropped as unreachable on these paths.

Out of scope (refused): filter, chain, actions, monitor, exec, and all writes. Filters are increment 10.

🤖 Generated with Claude Code

randomizedcoder and others added 6 commits November 24, 2026 00:15
…9S, V001)

gotc is a read-only clone of iproute2 7.2.0's tc, modelled on gobridge.
This first task runs tc.c's main: the option loop in its matches()
order (-c is -cf, Q24; -b is -batch; a lone - is -stats; no "--"),
do_cmd's object dispatch, do_qdisc's and do_class's verbs (qdisc tests
link before list), usage, -batch with its ll_init_map before the file
opens, -force and -netns. tc_core_init's /proc/net/psched scan and
cls_names_init's class names databases (Q33: the -cf names are dropped
when neither default file exists) read through a sysFS root, so tests
are hermetic.

qdisc and class show return not-implemented until 9R; filter, chain,
actions, monitor, exec and every write are refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two spaces, tcqdisc (142 rows) and tcclass (82), over nine fixtures
covering noqueue, mq, pfifo_fast, prio, the fifos, fq_codel, fq, htb,
tbf, sfq, netem, ingress and clsact, every positive plain and -j, with
batches and refusals. Every qdisc has an explicit handle and netem a
fixed seed, so two batches on one boot agree on stdout, stderr, rc and
replies, apart from two named exceptions: the heap garbage of Q34's
abort, and fq's time_next_delayed_flow timestamp in TCA_XSTATS.

The capture found Q34: graph_cls_show frees the -g nodes but keeps the
static list heads, so a second -g line in a batch reads freed memory
and aborts with a double free (rc 134).

Corpus: pkg/xtcpnl/testdata/7_3_1/ws/tc{qdisc,class}, kernel 7.3.1,
tc 7.2.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, V003)

Decode each in-slice qdisc kind's TCA_OPTIONS and xstats the way its
tc/q_*.c printer reads them, TCA_STATS2 and the compat TCA_STATS the
way print_tcstats*_attr does (MIN-copy into a zeroed struct), and build
tc's qdisc and class dump requests byte for byte. FamilyHdrLen models
tcmsg for the qdisc and class messages; RTM_GETTFILTER is now the
unmodeled example. Every in-slice qdisc and class in the workbench
corpus decodes; other kinds are ErrTcKindUnknown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tc_qdisc_list/print_qdisc and tc_class_list/print_class with -g, the
statistics printers, the json_print port with print_size/print_rate,
and one printer per kind: prio/pfifo_fast, the fifos, ingress, clsact,
fq_codel, fq, htb, tbf, sfq and netem. A kind tc links but gotc does not
print is refused by name. All 224 tcqdisc/tcclass capture rows replay
byte for byte (Q34's stderr and the two write rows excepted), and 216
tdc readbacks render exactly; the 245 holding other kinds are refused
and pinned. Ten mutants killed; coverage 82.4%.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every bug-class lead from the plan read at v7.2.0 and confirmed or
dropped, with file:line, the pinning row, status at HEAD (GitHub mirror)
and how gotc handles it. New: Q36, -g reads freed graph nodes on every
nested tree, confirmed byte for byte by the corpus; Q35, the compat nest
parser trusts its inner rta_len. Q14 is fixed upstream by 9dd1bec6b863.
Recorded only; not submitted to netdev.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
All 224 capture commands run live as tc and as gotc over the 24
fixtures: 221 identical; the 3 that differ are the two refused writes
and Q34's heap-garbage stderr line. The VM was left as found.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@randomizedcoder
randomizedcoder merged commit 40dc098 into main Nov 24, 2026
1 check passed
@randomizedcoder
randomizedcoder deleted the gotc/qdisc-class branch November 27, 2026 23:25
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