Skip to content

gotc: tc monitor, live and from a file (increment 14) - #348

Merged
randomizedcoder merged 7 commits into
mainfrom
gotc/monitor
Nov 26, 2026
Merged

randomizedcoder merged 7 commits into
mainfrom
gotc/monitor

Conversation

@randomizedcoder

Copy link
Copy Markdown
Owner

Summary

Increment 14: tc monitor and tc monitor file F in gotc. Six tasks, one commit each, each recorded in docs/netlink/gotc-status.md (V023–V027, DOC007).

  • 14X, shared monitor core (V023): new internal/nlmon holds what ip monitor and tc monitor share: rtnl_listen, rtnl_from_file, print_timestamp, a replay clock, and the split of a capture into its startup dump and its events. goip now uses it, and its monitor tests pass. One text change: Cannot fopen now prints glibc's capitalised strerror, as ip does.
  • 14C, captures (V024): a new tcmonitor space of 27 rows (13 live, 8 from a file, 7 refusals) and a new xtcp2-nl-tcmon helper with a hermetic check (nlcap-tcmon). Two batches on one boot agree once stamps are masked.
  • 14P, decoding and benchmarks (V025): xtcpnl.TcEventKind. Every event in the corpus decodes with no problem through the existing tc parsers. Benchmark numbers are in V025.
  • 14R, gotc tc monitor (V026): live on RTNLGRP_TC, or from a file, with -timestamp/-tshort. The qdisc and action printers gain the event words tc prints (added/replaced/deleted, Added action, Flushed table, ...). nlmon.Replay applies rtnl_listen's 16 KiB buffer to replays, so a replay truncates where tc did. All 27 rows replay exactly once stamps are masked. Coverage: gotc 85.2%, nlmon 91.4%. All 12 mutants are killed.
  • 14B, write-up (DOC007): docs/netlink/upstream/iproute2-tc-monitor.md, not submitted to netdev. MO1–MO16 and kernel notes K19–K23. Every finding is present at upstream HEAD.
  • 14L, live diff (V027): gotc and tc side by side on the workbench, both subscribed at once and fed by one trigger: 27/27 identical once stamps are masked, MO5's Truncated message with exit 2 included.

Notable findings

  • K23 (kernel bug): mall_change ends with *arg = head where it should be new (cls_matchall.c:233, since fd62d9f5c575). So every matchall add event has handle 0 and no options. Recorded only.
  • MO5: rtnl_listen's 16 KiB buffer under a filter event that can grow to 64 KiB: a 2040-op cBPF filter's event kills the monitor with exit 2.
  • MO6/K19: qdisc added/replaced never print, because qdisc_notify never sends NLM_F_CREATE.
  • MO4: -j monitor prints text.
  • MO11, MO15, MO16: state carried across a batch (C16): a show's filter statics, the action printer's tab_flush, and exit() against return -1 under -force.

Test plan

  • go test ./...
  • nix build .#checks.x86_64-linux.test-go-race
  • nix build .#gotc .#goip .#test-go-unit at the commit
  • golangci-lint (comprehensive): 0 issues on xtcpnl, nlmon, gotc, nlcapgen
  • netlink-audit and kernel-citation-audit (pkg/xtcpnl)
  • Live diff on the workbench: 27/27 identical

🤖 Generated with Claude Code

randomizedcoder and others added 7 commits November 25, 2026 20:46
…023)

Move rtnl_listen, rtnl_from_file, print_timestamp, the replay clock and
the capture's notification split out of goip into internal/nlmon, so
gotc's tc monitor can use them. goip keeps thin adapters and its exit
sentinels. New: MSG_TRUNC handling as rtnl_listen has it, the unicast
echo of an NLM_F_ECHO request left out of a replay, and glibc's
strerror text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… (14C, V024)

27 rows: tc monitor live under a new helper that waits for the
RTNLGRP_TC subscription, runs a trigger and stops the monitor with
SIGTERM; tc monitor file over records built from corpus messages; and
the refusals. Two batches agree once stamps are masked. The captures
confirm the MO4-MO7, MO9, MO10 leads and found K23, a kernel bug that
empties every matchall add event (recorded only).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TcEventKind names a monitor event's tc object as accept_tcmsg
dispatches it. TestWsTcMonitor decodes every event in ws/tcmonitor,
live and in the record files, and pins K20, K22, K23 and MO5's event
sizes. BenchmarkWsTcMonitor, and a tcmonitor case for nlmon's
BenchmarkNotifications.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tc monitor subscribes to RTNLGRP_TC, runs ll_init_map on the
subscription and hands each event to the printers; tc monitor file F
walks raw records with no ll_init_map. -timestamp and -tshort stamp
each event; -j stays text as in tc. The qdisc and action printers gain
tc's event words, and action its tab_flush. nlmon records each
message's datagram offset and replays through rtnl_listen's 16 KiB
buffer, so a capture's oversized event is "Truncated message" as tc
saw it. All 27 tcmonitor rows replay exactly with stamps masked; 12
mutants killed.

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

New docs/netlink/upstream/iproute2-tc-monitor.md, not submitted to
netdev. MO1-MO14 are confirmed against v7.2.0 and the tcmonitor corpus;
MO5's lead is corrected to 2040 ops. MO15 (tab_flush outlives its
flush) and MO16 (a -force batch stops at a missing monitor file but
goes past a corrupt one) are added, with K19-K23, K23 being the
matchall `*arg = head` kernel bug. Every finding is present at HEAD.

Two TestGotcMonitorUnit rows pin MO16.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gotc monitor and tc monitor side by side on the workbench, both
subscribed at once and fed by one trigger for every live row, then the
offline and refusal rows: 27 of 27 identical once stamps are masked,
MO5's Truncated message and exit 2 included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s (14V, V028)

Two P2 review findings on PR 348:

- xtcp2-nl-tcmon ran the trigger once the monitor's socket showed the
  RTNLGRP_TC bit. tc runs ll_init_map's link dump on that socket after
  the bind, and rtnl_dump_filter drops non-dump messages, so early events
  could be lost while the until-EREs still matched. The helper now also
  waits for Dump 0, Rmem 0 and a monitor thread blocked in recvmsg(2),
  i.e. rtnl_listen. The hermetic check gains 4 rows. The recorded corpus
  has no tc message before the dump's DONE; TestGotcMonitorCorpus now
  checks that for each live row.

- nlmon.ReadFile read the whole file before walking it, and mapped read
  errors to ErrOpen, which ended a -force batch. FromFile is now
  rtnl_from_file's loop over an io.Reader (records handed on as read,
  one reused 16384-byte buffer). Read failures are ErrRead with
  "rtnl_from_file: fread: <strerror>" and return -1, as tc 7.2.0 does
  (checked on the host for a directory, plain and under -force -batch).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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