diff --git a/docs/netlink/gotc-status.md b/docs/netlink/gotc-status.md index f06a033b9..2c397b55f 100644 --- a/docs/netlink/gotc-status.md +++ b/docs/netlink/gotc-status.md @@ -1,6 +1,6 @@ # gotc (tc qdisc, class, filter, flower, chain and actions show): implementation status -**Last updated:** 2026-11-24 +**Last updated:** 2026-11-25 **Summary:** - The design and task plan are in [gotc.md](gotc.md); this document tracks progress @@ -147,6 +147,35 @@ two `-netns` reads), byte for byte on stdout, stderr and exit code, the `-s` rows' timers included. The other three are the planned refusal of the write and the two `get`-then-`ls` batches. In those, gotc and tc each print exactly what the kernel sent, but the kernel's answer to a get changes once a dump has run: K18 (V022). +- **14X (shared monitor core): done.** New `internal/nlmon` holds what `ip monitor` and `tc monitor` share: + rtnl_listen (`Listen`, `Datagram`), rtnl_from_file (`ReadFile`, `WalkFile`), print_timestamp, a replay clock, and + the split of an nlmon capture into a startup dump and the events a subscriber was sent (`PcapMsgs`, `DumpEnd`, + `Notifications`). goip now uses it; its monitor tests pass, with one text change: `Cannot fopen` now prints + glibc's capitalised strerror, as `ip` does (V023). +- **14C (captures): done.** The `tcmonitor` space has 27 rows. Twelve run `tc monitor` live under a new helper, + `xtcp2-nl-tcmon`, which waits for the RTNLGRP_TC subscription, runs a trigger, and stops the monitor with SIGTERM once + its output matches. Eight run `tc monitor file` over records built from real corpus messages, plus a batch; seven + are refusals. Two batches on one boot agree once stamps are masked. The captures confirm MO4–MO7, MO9, MO10, K20 + and K22, and found K23: a kernel bug that empties every matchall add event (V024). +- **14P (decoding and benchmarks): done.** `xtcpnl.TcEventKind` names the object of a monitor event as tc's + accept_tcmsg dispatches it. Every event in `ws/tcmonitor`, live and in the record files, decodes with no problem + through the existing tc parsers, and the corpus pins K20, K22, K23 and MO5's event sizes (V025). +- **14R (gotc `tc monitor`): done.** `tc monitor` and `tc monitor file F` run, live on RTNLGRP_TC or from a replay, + with `-timestamp` and `-tshort`. All 27 tcmonitor rows replay exactly once stamps are masked, MO5's `Truncated + message` among them. The qdisc and action printers gain the event words tc prints (V026). +- **14B (write-up): done.** [upstream/iproute2-tc-monitor.md](upstream/iproute2-tc-monitor.md), not submitted to + netdev. MO1–MO14 are confirmed, none dropped; MO15 (from 14R) and MO16 are added, with K19–K23. MO5's lead is + corrected from 4096 ops to 2040, since tc can't send 4096. K23 is a kernel bug: every matchall add event is + empty. Every finding is present at HEAD (DOC007). +- **14L (live diff): done.** On the workbench, nix-built `gotc monitor` and `tc monitor` ran side by side, both + subscribed at once and fed by one trigger, for every live row, then the offline and refusal rows. All 27 are + identical on stdout, stderr and exit status once stamps are masked, MO5's `Truncated message` and exit 2 included + (V027). +- **14V (review fixes): done.** Two fixes from the PR 348 review: + - `xtcp2-nl-tcmon` now waits until tc's link dump is done and it is in rtnl_listen before running the trigger. Before, + a trigger could run during the dump and lose events. The recorded corpus is clean, and a corpus test now guards it. + - `monitor file` reads records as they arrive, rather than at EOF. A read error returns -1, as tc's fread does, so it + no longer ends a `-force` batch (V028). ## Ledger @@ -181,6 +210,13 @@ | DOC005 | 13B | **Write-up:** `docs/netlink/upstream/iproute2-tc-action.md`, extended for increment 13 (status header, reachability, contents, 33 summary rows, six sections, K9–K17). Not submitted to netdev. **Leads:** confirmed in tcaction2: AC39 (ec-004), AC42–AC44 (pw-001, ec-002), AC48 (pw-016, pw-017), AC49 (pw-013), AC51 (ec-018, pw-018), AC53 (pw-018), AC56 (ec-031, pw-031), AC57 (pw-030), AC59 (pw-033), AC61 (ec-037), AC65 (ec-040), AC66 (ec-044, pw-044). Latent, with unit rows: AC40, AC41, AC45–AC47, AC50, AC52, AC54, AC55, AC58, AC60, AC62–AC64. AC55's threshold corrected to a 64-byte label (13P); AC54 extended with the else-if fall-through (13R). **New:** AC67 (m_pedit.c:841-844, ec-002), AC68 (m_tunnel_key.c:696, 710, 713, ec-010), AC69 (m_gate.c:488, ec-033/pw-033), AC70 (m_ife.c:117, 127, 137, 179, seen in the 13C pre steps), AC71 (f_bpf.c:249-252 with m_police.c:363-366, pw-044). **Kernel (v7.4-rc4):** K9–K12 confirmed at the lines the plan gave (K10 act_pedit.c:536-546, K11 act_gate.c:594-611, K12 act_bpf.c:102-130); K13 from 13C; new K14 (ENC_KEY_ID is NLA_U32 and dumped be32, act_tunnel_key.c:337, 749, against the header's be64), K15 (ife always puts TYPE, act_ife.c:674), K16 (ct puts ZONE under CONFIG_NF_CONNTRACK_ZONES, act_ct.c:1616-1619), K17 (tunnel_key set always puts NO_CSUM, act_tunnel_key.c:755-756). **At HEAD:** `gh api repos/iproute2/iproute2/commits?path=...&since=2026-08-17` (mirror at `5d13122576d6`, 2026-11-25): none for the six printers, f_bpf.c, bpf_legacy.c, tc_util.c or inet_proto.c; one for json_print.c, `ce764a619c7a`, which changes how `print_uint_name_value` builds its format but not its output. **Corrections to V019:** ife's parser chatter goes to stderr, not stdout (AC70); `-br`'s `bpf \t index 2` is the generic brief layout (`mirred \t index 1`, AC37), not a finding. **New bug classes:** none; every finding fits C1–C15. **Test:** `TestGotcAction2Unit` +1 row (AC50, a t_action of 3 prints `tunnel_key pipe`), 29 rows. | | V022 | 13L | **Live diff** on the workbench (kernel 7.3.1, tc 7.2.0): `gotc` from `nix build .#gotc` at `0c5a805d2` (`/nix/store/c7idq6xb48n67yhxywlf5r8lkwp0w8qp-gotc-0.2.1`; 13B changed only a test and docs) beside `tc` (`/nix/store/x1pwsbz5cm23hk58b7fcpn3hhg9j7gwh-iproute2-7.2.0`), with `GOTC_CONF_USR_DIR` set to tc's `share/iproute2`. The script is generated from `nix/microvms/workbench/tcaction2.rows.jsonl`: the row's modules are loaded once, then each row runs its pre steps in a fresh named namespace, in its own directory (so the batch rows' `b.txt` is there), then tc and gotc in turn. That is all 105 rows, plus two reads from the root namespace with `-netns`: `actions ls action pedit` over `acped` (bind 0) and `filter show dev d0 ingress` over `acbpf` (the bpf filters, and the matchall holding all six kinds at bind 1). **Result:** 107 rows, 104 identical on stdout, stderr and exit code, the 14 `-s` rows' timers included. **The other three:** ng-007 (`actions delete action pedit index 9`) is the planned refusal: tc prints the kernel's `TC action with specified index not found.`, `We have an error talking to the kernel` and AC8's `Command "action" is unknown`, rc 255; gotc `not implemented: tc actions delete`, rc 255. ec-049 and pw-049 (`-batch`: `actions get action ct index 8`, then `actions ls action ct`): gotc's get has a `used_hw_stats disabled` line tc's lacks. Swapping the order (gotc first, then tc) swaps the difference, so each prints what the kernel sent. **K18 (new):** only `tcf_dump_walker` calls `tcf_action_update_hw_stats` (act_api.c:596), which sets `used_hw_stats_valid` (act_api.c:315-316). So a get before an action's first dump carries no `TCA_ACT_USED_HW_STATS`, and every get after it does. tc's batch ran the first dump between the two gets. The corpus is not affected: each captured row builds its fixture afresh. **Pre-checks:** the workbench was down (powered off at 11:28 by another session), so it was booted with `nix run .#nlcap-ws -- up` (2.3G guest; 34G available on the host); port 12061 was free; the fresh guest had no namespaces, no core files, and nf_conntrack and sch_fq_codel loaded. **Cleanup:** the run added 18 modules (the 11 act/cls/sch_ingress of the row list, act_meta_mark, act_meta_skbprio, act_meta_skbtcindex, ife, nf_conntrack_ftp, nf_flow_table, nf_nat); all were removed with `modprobe -r`, leaving lsmod equal to the boot baseline. No namespaces, no core files, `/tmp/t13l*` removed. Only this session's ssh was connected, so the VM was powered off again with `down`, as found. **Docs:** K18 added to `upstream/iproute2-tc-action.md`. | | DOC006 | K18 | **Write-up:** `docs/netlink/upstream/kernel-act-get-skips-hw-stats.md`, K18 on its own: only `tcf_dump_walker` (act_api.c:596) and the flower/matchall stats dump (`tcf_exts_hw_stats_update`, pkt_cls.h:304-326) call `tcf_action_update_hw_stats`, which sets `used_hw_stats_valid` (act_api.c:315-316); the get path (`tca_action_gd` → `tcf_get_notify` → `tca_get_fill`) never does, so a get carries `TCA_ACT_USED_HW_STATS` only once a dump has run. Since c7a66f8d8a94 (2021-12-19); unchanged at v7.4-rc4 and net-next `46fec1c3029b`. From the code, an offloaded action's counters in a get are likewise as of the last dump (not checked on hardware). Pinned by tcaction2/ec-049, pw-049 (V022). Not submitted to netdev. | +| V023 | 14X | **Code:** new `internal/nlmon` (`nlmon.go`, `replay.go`), moved from goip's `source_monitor.go` and `obj_monitor.go` (`listenFd`, `listenNsid`, `monitorDatagram`, `monitorReadFile`, `timestampText`, `nowFuncFromEnv`, `replayNotifications`, `replayDumpEnd`, `isRtmGet`). goip keeps thin adapters to its `monitorMsg` and its sentinels (`ErrMonitorAbort` for an fopen failure, `ErrMonitorFile` for the rest), and `goipMayImport` and the closure pin gain `internal/nlmon`. Errors are `*nlmon.Error{Kind, Text}`: the text is the C's message, and the kind (`ErrOpen`, `ErrFileTruncated`, `ErrMalformed`, `ErrTruncated`, `ErrRemnant`, `ErrRecv`) sets a clone's exit status. **New behaviour, beyond goip's:** (1) `Datagram` takes MSG_TRUNC, as rtnl_listen does: a message cut short is `Truncated message` (tc's -1, exit 2, MO5), and a truncated datagram whose messages fit skips the remnant check while `Listen` prints `Message truncated` and carries on. (2) `Notifications` drops the unicast echo of a request with NLM_F_ECHO: nlmsg_notify sends the requester the same bytes as the multicast. (3) `Strerror` is glibc's text, so goip's `Cannot fopen: no such file or directory` becomes `No such file or directory`, as `ip` prints it; 3 goip test expectations changed for that and nothing else. **Deviation from the plan:** the classifier went to `internal/nlmon`, not `internal/wsreplay`. wsreplay is transaction-based, and the classifier works on the raw message list, which `PcapMsgs` now gives. **Tests** (`internal/nlmon`): TestDatagram (9 rows + fn's error), TestWalkFile (7), TestReadFile (3), TestTimestamp (5), TestNowFunc (3), TestListenNsid (6), TestListen (4, over a SEQPACKET socketpair, the cut datagram included), TestListenErrors (2), TestStrerror (4), TestNotifications (14: the goip rows plus a qdisc lifecycle, a tc filter event with the request's flags (K22), the trigger's add and ack, a GETTFILTER's answer and two echo rows), TestDumpEnd (7), TestIsRtmGet (8), TestPcapMsgs (3, goip's `monitor_all` capture), and TestAllocs (4 rows, all at 0 allocs). goip's moved tests (TestMonitorDatagram, TestListenNsid, TestReplayNotifications, TestReplayDumpEnd) are deleted, since their rows are in nlmon. `TestMonitorMatchesIp`, `TestRunMonitorFile` and the xfrm, ioam and mptcp monitor tests pass. **Benchmarks** (`go test ./internal/nlmon/ -bench . -benchmem -count 3`): Datagram (40 × 400-byte events) 427–457 ns/op, 10.7–11.4 ns/msg, 0 allocs; WalkFile (1000 records) 8.37–8.44 µs/op, 8.4 ns/msg, 0 allocs; Notifications (goip's `monitor_all`, 57 messages) 468–475 ns/op, 8.2–8.3 ns/msg, 3 allocs. **Coverage:** `internal/nlmon` 90.7%. **Gates:** `go test ./internal/nlmon/ ./internal/goip/`; `CGO_ENABLED=0 go build ./...`; golangci-lint (comprehensive) reports 0 issues on `internal/nlmon` and `internal/goip`. | +| V024 | 14C | **Helper:** `xtcp2-nl-tcmon [until-ERE...]` in `nix/microvms/netlink-capture.nix`, on `xtcp2-nlcap`'s PATH. It counts the monitor as subscribed when `/proc/net/netlink` shows a proto-0 socket with Groups bit 0x8 (RTNLGRP_TC); a row's namespace is fresh, so that socket is the monitor's. It runs the trigger with its output kept apart (shown only on failure), waits up to 10 s for each ERE over the monitor's stdout and stderr, then sends SIGTERM. A monitor that ends by itself passes on its exit status. With no ERE, it waits up to 10 s for the monitor to end. stdout is the monitor's stdout; stderr is the monitor's stderr, then the helper's complaints. **Hermetic check** `nix/checks/nlcap-tcmon.nix` (`checks.x86_64-linux.nlcap-tcmon`): a fake tc (`NLCAP_TC`) over a fake `/proc/net/netlink` (`NLCAP_PROC_NETLINK`); 10 rows (positive: one and two events; negative: never subscribes, a socket on other groups, a failing trigger, a missing event; boundary: a self-ending monitor's status passed on, with and without an ERE; corner: a monitor refusing its args, usage). **Space** `tools/nlcapgen/matrix_tcmonitor.go`, registered as `tcmonitor`; rows in `nix/microvms/workbench/tcmonitor.rows.jsonl`, corpus in `pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/` (27 rows, 708K). Modules: sch_htb, sch_ingress, sch_fq_codel, cls_basic, cls_matchall, cls_bpf, cls_fw, act_gact, act_mirred. **Live rows (12):** the qdisc lifecycle (fq_codel add, change, replace with htb, del), class add/change/del, filter add/replace/change/del with a gact, chain add/del, a matchall holding gact and mirred, actions add/replace/del/add/flush, `-s`, `-d`, `-t`, `-tshort`, `-j`, a rename of d0 to d1, and a 2038-op bpf filter. **Offline rows (8):** `monitor file m.bin` plain and under `-t`, `-tshort`, `-j` and `-s -d`, over six records (htb qdisc, htb class, fw filter, gact add, a second qdisc, a qdisc delete; the bodies come from tcqdisc/ec-035, tcclass/ec-013, tcfilter/ec-024 and tcaction/ec-057, with ifindexes rewritten); `-t` over DONE, ERROR, NOOP and NEWLINK records; an empty file; and the batch `qdisc show dev d0` then `monitor file m.bin`. **Negatives (7):** a 2040-op bpf filter (rc 2), `monitor help`, `monitor bogus`, `monitor file` with no value, `monitor file /nonexistent`, a file cut inside a record, and a record of length 8 (each rc 255). **Fixes during the capture:** htb has no `change` (the kernel says "Change operation not supported by specified qdisc"), so the qdisc lifecycle uses fq_codel. tc cannot send a 4096-op bpf filter: `addattr_l ERROR: message exceeded bound of 16384`. The ec-012 capture shows tc's request for an n-op filter is 60 + 8n bytes and the kernel's event 76 + 8n. So 2040 ops is the edge: the request fits tc's 16384-byte buffer and the event does not fit rtnl_listen's. At 2038 the event is 16380 and fits. **Determinism:** two batches on one boot, 27/27 OK each; stdout, stderr and rc identical once the `Timestamp: ... usec` and `[...]` stamps are masked; the pcaps differ (pids and sequence numbers), 19 of 27. **Confirmed live:** MO4 (`-j monitor` prints text, ec-010); MO5 (`Truncated message`, rc 2, ng-001); MO6 (no qdisc event says `added` or `replaced`, ec-001); MO7 (filter add `added`, replace `replaced`, change nothing, ec-003); MO9 (`total acts 0` ahead of each action event, `Added action `, `Replaced action `, `Deleted action `, `Flushed table gact (1 entries)`, ec-005); MO10 (after `ip link set d0 name d1`, the delete still says `dev d0`, ec-011); K20 (a qdisc add on the dummy's noqueue root prints `deleted qdisc noqueue 0: dev d0 root refcnt 2` then the new qdisc); K22 (the filter event carries the request's flags, 0x605, and the requester's pid). **K23 (new, kernel bug):** `mall_change` ends with `*arg = head;` (cls_matchall.c:233 at v7.4-rc4 and net-next), but `head` is the old root, which the function has already required to be NULL (`if (head) return -EEXIST;`). It should be `new`. So `tfilter_notify` gets fh NULL, and every matchall add is announced as handle 0 with no TCA_OPTIONS: tc prints `added filter dev d0 ingress protocol all pref 2 matchall chain 0`, with no handle and no actions (ec-004), although a dump shows both. Since fd62d9f5c575 (2017-02-01, "net/sched: matchall: Fix configuration race"). Recorded only (14B). **Cleanup:** the VM was off and was booted for this; act_gact, act_mirred, cls_basic, cls_bpf, cls_fw, cls_matchall, sch_htb, sch_ingress, and bridge, stp, llc, ib_core and unix_diag (loaded by the runner) were removed with `modprobe -r`, leaving lsmod equal to the boot baseline; no namespaces, no core files, no tc processes; powered off again. **Tests:** `TestTcMonitorSpace` (27 rows pinned; 24 table rows on kind, rc, refusal, mode and ERE count; every live row under the helper and every other a `tc` command; triggers for all five objects; each NEW/DEL/replace/change/flush form, the rename and both op counts present; no eBPF word; both record files written and walkable; deterministic). **Gates:** `go test ./tools/nlcapgen/ ./pkg/xtcpnl/ ./internal/gotc/` (`TestWsCorpusRows` holds the 27); golangci-lint (comprehensive) reports 0 issues on `tools/nlcapgen`; `nix build .#checks.x86_64-linux.nlcap-tcmon`. | +| V025 | 14P | **`pkg/xtcpnl/xtcpnl_tc_event.go`:** `TcObj` (none, qdisc, class, filter, chain, action) and `TcEventKind(type) (TcObj, isDel)`. It follows accept_tcmsg (tc/tc_monitor.c), not the uapi families of four: NEW and DEL of qdisc, class, filter and chain, and GET, NEW and DEL of action, are events. RTM_GETQDISC, GETTCLASS, GETTFILTER and GETCHAIN are not; tc prints `Unknown message` for them. Chains are kept apart from filters, though tc hands both to print_filter. No new attributes: events reuse the decoders from increments 10–13. **Tests** (`xtcpnl_tc_event_test.go`): `TestTcEventKind`, 21 rows (positive: the ten NEW/DEL types; negative: RTM_NEWLINK, DONE, ERROR, and the four GETs that are not events; boundary: 35, 51, 0xffff, and RTM_GETCHAIN 102, the highest tc type; corner: RTM_GETACTION is an action). `TestWsTcMonitor` reads all 27 rows. A row's events are its capture less the trigger's requests (NLM_F_REQUEST with pid 0), the startup link dump (NLM_F_MULTI) and the acks, plus the `ec-` rows' record files. Each event decodes with no problem: the header and top-level attributes (O6), TCA_STATS2, the qdisc's or class's options (`ParseTcQopt`), the filter's options (`ParseTcFopt`) with each matchall, bpf or fw action, and the gact and mirred options; an action event goes through `ParseTcAction` with each action's options. Seen: qdisc 21 NEW and 16 DEL, class 8 and 1, filter 14 and 2, chain 7 and 3, action 9 and 2. Its 8 rows: positive, all five objects as NEW and DEL; positive, K22 (ec-003's filter event has flags 0x605 and a nonzero pid); positive, K20 (ec-001 has a datagram holding DELQDISC then NEWQDISC); negative, K23 (ec-004's matchall add event has handle 0 and no TCA_OPTIONS; the row fails once the kernel is fixed); boundary, MO5 (ec-012's 2038-op bpf event is 16380 bytes, ng-001's 2040-op event 16396); corner, ec-013's file holds six events and ec-018's four records that are no tc event. The test holds its own copy of the classifier because `internal/nlmon` imports this package; no row has a get or an echo. **Benchmarks** (24 cores): `BenchmarkWsTcMonitor` 1622 ns per event (510 MB/s, 487 allocs per pass over the live captures, as the parsers copy); `BenchmarkTcEventKind` 7.1 ns for 5 types, 0 allocs; `internal/nlmon`: `BenchmarkDatagram` 8.8 ns/msg, `BenchmarkWalkFile` 8.3 ns/msg, both 0 allocs (`TestAllocs`, 14X, pins them); `BenchmarkNotifications` gains a `tcmonitor` case over all 27 captures, 6.6 ns/msg (13 allocs in all), next to `ipmonitor` 8.5 ns/msg (3 allocs). The 14X numbers have not moved by more than 10%. **Gates:** `go test ./pkg/xtcpnl/ ./internal/nlmon/`; golangci-lint (comprehensive) reports 0 issues on both packages (goconst: TcObjNone prints `not tc`, since a third `"none"` literal would collide with `bondNameNoneCst`); netlink-audit and kernel-citation-audit, no findings; gofmt -s. | +| V026 | 14R | **`internal/gotc/monitor.go`** (tc/tc_monitor.c): `doMonitor` parses `file F`, `help` (MO1's usage, exit 255), an unknown word (exit 255) and `file` with no value (incomplete_command). `monitorFile` is `nlmon.ReadFile` with no ll_init_map: `Cannot fopen: ` exits 255, a truncated or malformed file prints nlmon's text and returns -1 (exit 255, or a failed batch line). `monitorLive` subscribes to `nl_mgrp(RTNLGRP_TC)` = 0x8, runs ll_init_map on the subscription, then listens. A malformed message or a remnant exits 1, `Truncated message` and receive errors exit 2, and the end of a replay exits 0. stdout is flushed after each event, as rtnl_listen's `fflush` does. `acceptTcmsg` prints the stamp first (MO2), then dispatches by `xtcpnl.TcEventKind`: chains go to the filter printer, and an unknown type gets `Unknown message: length %08d type %08x flags %08x` (MO3). **Options:** `-timestamp` adds one to `timestamp`; `-tshort` adds one to both `timestamp` and `timestamp_short`. The clock is `GOTC_NOW` (RFC3339) or the wall clock (`config.now` in tests). JSON stays off under `-j`, because monitor never opens the JSON object (MO4). The batch statics carry into `monitor file` (MO11). **Sources** (`source_monitor.go`): `MonitorSource.Subscribe(groups, errOut)`. On a `LiveSource` it opens a new socket with rtnl_open's buffers (SO_SNDBUF 32768, SO_RCVBUF 1 MiB) and NETLINK_EXT_ACK, bound to the groups. Its `Talk` skips messages not to its port id with the request's sequence number, as rtnl_dump_filter does on a subscribed socket. On a `ReplaySource` (which now keeps its path) it reads the capture again with `nlmon.PcapMsgs`. `Talk` finds the monitor's dump by type, flags and body, not through the in-order replay, because the trigger's requests sit between. `Listen` is `nlmon.Notifications` from the end of that dump. **Printers:** qdisc gains `replaced` (CREATE and REPLACE) and `added` (CREATE and EXCL), which no kernel event reaches (MO6, K19); this is `printQdiscEvent`. Action gains `Added action `, `Replaced action `, `Deleted action ` and `Flushed table ` through fprintf, and `tab_flush`: after a flush event, a table holding order 0 alone is `tc_print_action_flush`'s ` ( entries)`. Filter's and class's event branches were already there. **New lead MO15** (for 14B): tab_flush is cleared only on the flush path, so a flush event whose table is not order 0 alone leaves it set, and the next table of order 0 alone prints as a flush. The kernel's flush is always order 0 alone, so this is latent. **`internal/nlmon`:** `Msg.Off`, each message's offset in its datagram, which `Datagram` sets. New `Replay(msgs, notes, start, bufSize, fn)` plays notifications through rtnl_listen's buffer: a message that would not fit from its offset is `Truncated message` (ErrTruncated). nlmon records the 16396-byte event whole, so without this the replay printed what tc never read (ng-001). goip's replay does not use it yet: no goip capture has an event that large. **Tests:** `TestGotcMonitorCorpus` replays all 27 rows (13 under the helper, with the monitor's arguments from its first word; 14 plain `tc`). It masks both stamp forms and holds stdout, stderr and rc; an offline row must ask every recorded request. The rows stay out of `TestGotcCorpus`, whose rows must start with `tc` and match unmasked, so the count of 27 is pinned here. `TestShellWords`, 5 rows. `TestGotcMonitorUnit` uses a fake subscription that plays datagrams through a 16384-byte receive, plus a fake main socket. Its 29 rows: **positive** (9): a flags-0 qdisc event; DEL+NEW in one datagram (K20); filter add, replace, change and delete (MO7); action add, replace, delete and flush (MO9); NEWCHAIN and DELCHAIN; `-t`; `-tshort` alone; group 0x8 with ll_init_map on the subscription; one write per event. **Negative** (7): `bogus`, `help`, `file` with no value, no such file, a failing subscribe (exit 1), a cut file, a record of length 8. **Boundary** (3): a 16385-byte message (exit 2 after the event before it), a 16384-byte one (delivered), an empty file. **Corner** (10): `-j` is text; a stamped DONE; a NEWLINK in a file (`00000032`); crafted CREATE with EXCL or REPLACE reaching `added`/`replaced`; EXCL or REPLACE without CREATE reaching neither; the batch filter (MO11); a class DEL under `-j` (MO8); one RTM_GETLINK for an unknown index in file mode (MO12); MO15; an order-0 table after a printed flush. Plus a source that cannot subscribe (exit 255). Two older rows in `unit_test.go` now expect `tc monitor on this source`. **Mutants** (12, each under `systemd-run --user --scope -p MemoryMax=6G`, `-timeout=180s`), all killed: the stamp after the type test; `-j` opening JSON; qdisc `added` without the CREATE test (killed once the EXCL-only row was added); filter `replaced` on REPLACE; `total acts` left out of events; a 65536-byte replay buffer; `Unknown message` with `%d`; the batch statics reset; the classifier keyed on NLM_F_REQUEST alone; `-tshort` not stamping; tab_flush never cleared (killed once the order-0-after-flush row was added); a replay's end exiting 1. **Coverage:** internal/gotc 85.2%, internal/nlmon 91.4%. **Gates:** `go test ./internal/gotc/ ./internal/nlmon/ ./internal/goip/`; golangci-lint (comprehensive) reports 0 issues on gotc and nlmon (printQdiscBody's event words moved to a helper for gocyclo; the subscription errors wrap errLive); gofmt -s. | +| DOC007 | 14B | **Write-up:** `docs/netlink/upstream/iproute2-tc-monitor.md` (status header, reachability, contents, 16 summary rows, seven sections, K19–K23). Not submitted to netdev. **Leads:** read at v7.2.0 (`tc_monitor.c`, `tc.c`, the qdisc, class, filter and action printers, `libnetlink.c`, `ll_map.c`, `utils.c`) and against the tcmonitor corpus. **Confirmed in the corpus:** MO1 (ng-002), MO2 and MO3 (ec-018), MO4 (ec-010, ec-016), MO5 (ng-001; ec-012 fits), MO6 (ec-001), MO7 (ec-003), MO9 (ec-005, which also shows AC4 live and the two spaces of `Flushed table gact`), MO10 (ec-011), MO11 (ec-020), MO12 (ec-013's two RTM_GETLINK gets, one per unknown ifindex; none in ec-020, whose `qdisc show` had dumped the links), MO13 (ng-006, ng-007), MO14 (ng-003, ng-004). **Latent, unit rows:** MO8, MO15. **Corrected:** MO5's sweep said 4096 ops; tc's 16384-byte request bound stops it at 2041, so the rows use 2040 and 2038. **New:** MO16 (C16/C8): in a `-force` batch, `monitor file` on a missing file calls `exit(-1)` and ends the batch, while a truncated file returns -1, prints `Command failed` and goes on. Two new `TestGotcMonitorUnit` rows pin both (31 table rows now). gotc already reproduced it. **Kernel (v7.4-rc4):** K19 (qdisc_notify flags 0 or REPLACE, sch_api.c:1109-1116), K20 (DEL and NEW in one skb, :1104-1117), K21 (only filter events grow past NLMSG_GOODSIZE, cls_api.c:2138-2160), K22 (filter and action add events copy the request's flags and portid, cls_api.c:2147-2148, act_api.c:2151), K23 (`mall_change`'s `*arg = head`, cls_matchall.c:233, since fd62d9f5c575). **HEAD** (GitHub mirror `5d13122576d6`, `gh api .../commits?path=...&since=2026-08-17`): no commit touches `tc_monitor.c`, `tc.c`, the four printers or `ll_map.c`; `utils.c`'s three don't touch `print_timestamp` or `do_batch`. In `libnetlink.c`, `rtnl_from_file` is unchanged, and `rtnl_listen` (`9bfcf2480387`, `c6d58ffbb7f7`) keeps the 16384-byte buffer and `Truncated message`; only its bad-length text becomes `!!!Remnant of size N`. Every finding is present at HEAD. **Bug classes:** none new (MO15 and MO16 are C16). **Gates:** `go test ./internal/gotc/`. | +| V027 | 14L | **Live diff** on the workbench (kernel 7.3.1, tc 7.2.0): `gotc` from `nix build .#gotc` at `4bfc37bb9` (`/nix/store/9dk3iipdfv1g42i7vfsrjkraw7rq20sz-gotc-0.2.1`) beside `tc` (`/nix/store/x1pwsbz5cm23hk58b7fcpn3hhg9j7gwh-iproute2-7.2.0`), with `GOTC_CONF_USR_DIR` set to tc's `share/iproute2`. The guest script is generated from `nix/microvms/workbench/tcmonitor.rows.jsonl`: the rows' modules are loaded once, then each row runs its pre steps in a fresh named namespace, in its own directory. **Live rows (13):** `tc ` and `gotc ` start together in the namespace; the script waits until `/proc/net/netlink` shows two NETLINK_ROUTE sockets with Groups bit 0x8, waits 0.5 s more so both link dumps are done, runs the row's trigger once, waits up to 10 s for the row's until-ERE in both outputs (ng-001: for both to exit), then sends SIGTERM to both. **Offline and refusal rows (14):** tc, then gotc, with stdin from /dev/null. **Result:** 27 of 27 identical on stdout, stderr and exit status once both stamp forms are masked. The live rows end 143 for both (SIGTERM; the capture helper reports 0); ng-001 is `Truncated message`, rc 2, for both (MO5); the refusals are 255 for both. **tc against the corpus:** the same as the capture except ec-003, where the kernel gave the changed filter's new gact index 3 rather than 1, and the offline rows, whose records' ifindexes name d0 and d1 here, where the capture namespace had nlmon0. gotc followed tc in both: MO11's batch still drops the other device's qdisc events and prints d0's without `dev`. **Pre-checks:** the workbench was down, so it was booted with `nix run .#nlcap-ws -- up` (63G available on the host); port 12061 was free; no other VM process; the fresh guest had no namespaces and no core files. **Cleanup:** the run added act_gact, act_mirred, cls_basic, cls_bpf, cls_fw, cls_matchall, sch_htb and sch_ingress, all removed with `modprobe -r`, leaving lsmod equal to the baseline. No namespaces, no core files, no monitor processes, `/tmp/t14l` removed. Only this session's ssh was connected, so the VM was powered off again with `down`, as found. | +| V028 | 14V | **Review fixes (PR 348, two P2 findings at `0a1a7cf6`).** **1. Capture readiness race:** `xtcp2-nl-tcmon` counted the monitor ready once its socket showed Groups bit 0x8, but tc_monitor.c runs ll_init_map's link dump on that socket after the bind, and rtnl_dump_filter drops what is not the dump's. So a trigger run during the dump lost its first events, and the capture still passed if a later event matched the until-ERE. Ready now also needs the socket's Dump column 0 and Rmem 0, plus a monitor thread blocked in recvmsg(2) (`/proc//task/*/syscall`, 47 on x86_64, 212 on aarch64). tc makes no recvmsg before its dump request, and its dump reads only while a part is queued or running, so the three together mean rtnl_listen. A monitor that subscribes but never gets there is `the monitor never finished its link dump`, rc 1. The hermetic check gains `NLCAP_PROC` and `NLCAP_RECVMSG_NR`, and its fake drops events raised while it "dumps", as tc does. 4 new rows (14 now): positive, a slow dump is waited out and the event after it is seen; negative, a dump that never ends; boundary, a queued reply (Rmem 320); corner, blocked in a syscall other than recvmsg. Mutant (ready on Groups alone, the old helper) fails all 4. **Corpus:** none of the 13 live rows has a tc message before its dump's NLMSG_DONE, so the recorded captures did not hit the race and are kept. `TestGotcMonitorCorpus` now checks that for each live row (`checkTriggerAfterDump`); widening its window by one message makes it fail. V027's 14L diff waited a fixed 0.5 s instead and was not re-run. Its 27/27 match holds unless both tools lost the same event. **2. File reading:** `nlmon.ReadFile` read the whole file with `os.ReadFile` before walking it, so records from a pipe or a growing file were held back until EOF. Its read errors were also `ErrOpen`, which gotc maps to exit(-1); that ended a `-force` batch and printed `Cannot fopen: Is a directory` for a directory. tc's fopen succeeds on a directory, its fread fails, and rtnl_from_file prints `rtnl_from_file: fread: Is a directory` and returns -1. Now `ReadFile` opens the file, and the new `FromFile(io.Reader, fn)` replaces `WalkFile`. It is rtnl_from_file's loop: a header, then a padded body, into one reused 16384-byte buffer, each record handed on as read. A read failure is the new `ErrRead`, perror's text; EOF inside a record is `ErrFileTruncated`; ftell offsets are kept for malformed lengths. goip's `monitorReadFile` already sends every non-open error to ErrMonitorFile. **Checked against tc 7.2.0** on the host: `tc monitor file /` prints `rtnl_from_file: fread: Is a directory`, rc 255. Under `-force -batch` it prints that plus `Command failed -:1`, then the same for line 2, rc 1. gotc now matches both. **Tests:** `TestFromFile` (11 rows: adds a 16384-byte record, EIO between records after the one before, EIO inside a body as fread's error rather than truncated, and an error with no errno); `TestFromFileStreams` (a pipe whose writer sends record 2 only after fn has seen record 1; a reader that waits for EOF deadlocks); the `TestReadFile` directory row is now `ErrRead`; `TestGotcMonitorUnit` gains `monitor file /` (rc 255) and the `-force` batch going past it (rc 1), 33 rows. Mutant (read everything, then walk) fails `TestFromFile` and `TestFromFileStreams`. **Bench:** `BenchmarkFromFile` (was `BenchmarkWalkFile`), 1000 records: 28 ns/msg, 1 alloc (the buffer) per file. It was 13.5 ns/msg and 0 allocs over a slice that was already in memory; the copy is the cost of streaming. `TestAllocs` budget for the file row: 1. | ## Findings (9B write-up: [upstream/iproute2-tc-qdisc-class.md](upstream/iproute2-tc-qdisc-class.md)) diff --git a/docs/netlink/upstream/iproute2-tc-monitor.md b/docs/netlink/upstream/iproute2-tc-monitor.md new file mode 100644 index 000000000..def8153aa --- /dev/null +++ b/docs/netlink/upstream/iproute2-tc-monitor.md @@ -0,0 +1,225 @@ +# iproute2 `tc monitor`: a 16 KiB receive under a 64 KiB event, event words that never print, `-j` ignored, and statics that outlive their command + +**Status (2026-11-25, increment 14):** + +- **Not submitted to netdev.** These are drafts for the user's review, recorded here only, like the other write-ups in + this directory. No patch, no PR, no sign-off. +- **Source:** + - Line numbers are iproute2 **v7.2.0** (`880505966c17`, 2026-08-17): `tc/tc_monitor.c`, `tc/tc.c`, + `tc/tc_qdisc.c`, `tc/tc_class.c`, `tc/tc_filter.c`, `tc/m_action.c`, `lib/libnetlink.c`, `lib/ll_map.c` and + `lib/utils.c`. That is the version the corpus was captured with. + - **"At HEAD"** means the GitHub mirror's `main` at `5d13122576d6` (2026-11-25), checked with + `gh api repos/iproute2/iproute2/commits?path=...&since=2026-08-17` for each of those files and + `include/libnetlink.h`. + - No commit since v7.2.0 touches `tc_monitor.c`, `tc.c`, the four printers or `ll_map.c`. + - `lib/utils.c` has three (`552d9842b1f4`, `e11870d5b941`, `fde561a2a135`). None touches `print_timestamp` or + `do_batch`'s handling of a failed line. + - `lib/libnetlink.c` has seven. `rtnl_from_file` is unchanged. `rtnl_listen` is changed by `9bfcf2480387` + (messages not from the kernel are skipped) and `c6d58ffbb7f7` (`NLMSG_OK`/`NLMSG_NEXT`). The 16384-byte buffer + and `Truncated message` with -1 stay, so MO5 is present. What changes is a bad length without MSG_TRUNC: it was + `!!!malformed message: len=N` and is now `!!!Remnant of size N`, both exit 1. gotc follows v7.2.0. + - Every finding below is present at HEAD. +- **How they were found:** in increment 14 ([gotc.md](../gotc.md), [gotc-status.md](../gotc-status.md)). + - The plan's bug-class sweep listed leads MO1–MO14 and kernel notes K19–K22. + - The capture (14C, V024) confirmed MO4–MO7, MO9, MO10, K20 and K22, corrected MO5's op count, and found K23. + - The decoders (14P, V025) pinned K20, K22, K23 and MO5's event sizes. + - The clone (14R, V026) confirmed the rest and found MO15. This write-up (14B) added MO16. + - `gotc` replays all 27 rows exactly once stamps are masked. So every captured finding below is reproduced by an + independent implementation, not just read from the source. +- **Kernel cross-check:** `net/sched/sch_api.c`, `cls_api.c`, `act_api.c` and `cls_matchall.c` at v7.4-rc4. See + K19–K23. K1–K18 are in [iproute2-tc-action.md](iproute2-tc-action.md#k1k18-kernel-notes). +- **Corpus:** `pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/` (27 rows), kernel 7.3.1, tc 7.2.0, cited below as + `tcmonitor/`. + - **Live rows (ec-001 to ec-012, ng-001)** run `tc monitor` under `xtcp2-nl-tcmon`, which waits for the RTNLGRP_TC + subscription, runs a trigger, and sends SIGTERM once the output matches. + - **Offline rows (ec-013 to ec-020, ng-006, ng-007)** run `tc monitor file m.bin` over records built from real corpus + messages. + - **Bare rows (ng-002 to ng-005)** are argument refusals. +- **Reachability:** + - **In the corpus:** MO1–MO7, MO9–MO14. + - **Latent, with unit rows** in `internal/gotc/monitor_test.go` (`TestGotcMonitorUnit`): MO8, MO15. The kernel + never sends what reaches them; a crafted or future message does. + - **Source and unit rows** (too long for a capture row): MO16. + - **Dropped:** none. + +## Contents + +- [Summary](#summary) +- [MO1, MO14. Arguments](#mo1-mo14-arguments) +- [MO2, MO3, MO12. The dispatch and the stamp](#mo2-mo3-mo12-the-dispatch-and-the-stamp) +- [MO4. `-j` ignored](#mo4--j-ignored) +- [MO5. A 16 KiB receive under a 64 KiB event](#mo5-a-16-kib-receive-under-a-64-kib-event) +- [MO6–MO9. The event words](#mo6mo9-the-event-words) +- [MO10, MO11, MO15, MO16. State that outlives its command](#mo10-mo11-mo15-mo16-state-that-outlives-its-command) +- [MO13. File errors](#mo13-file-errors) +- [K19–K23. Kernel notes](#k19k23-kernel-notes) + +## Summary + +| ID | File:line (v7.2.0) | Class | Finding | Pinned by | At HEAD | gotc | +|---|---|---|---|---|---|---| +| MO1 | tc_monitor.c:27-28 | C10/C8 | the usage `tc [-timestamp [-tshort] monitor` leaves its `[` open and leaves out `file`; `help` exits 255 | tcmonitor/ng-002 | present | reproduces | +| MO2 | tc_monitor.c:37-38 | C14 | the stamp prints before the type test, so a DONE, ERROR, NOOP or unknown record gets a stamp with no event after it | tcmonitor/ec-018 | present | reproduces | +| MO3 | tc_monitor.c:62 | C10 | `Unknown message: length %08d`: the decimal length is zero-padded beside hex type and flags | tcmonitor/ec-018 | present | reproduces | +| MO4 | tc_monitor.c:68-115; tc.c:313 | C5 | monitor never calls `new_json_obj`, so `-j monitor` prints text, live and from a file | tcmonitor/ec-010, ec-016 | present | reproduces | +| MO5 | libnetlink.c:1211, 1267-1269 | C11 | rtnl_listen's 16384-byte buffer, while a filter event grows past it (K21): a 2040-op cBPF filter's 16396-byte event gives `Truncated message` and exit 2, and the monitor is gone | tcmonitor/ng-001 (ec-012 at 2038 ops fits) | present | reproduces | +| MO6 | tc_qdisc.c:252-260 | C14 | qdisc `replaced` needs CREATE\|REPLACE and `added` CREATE\|EXCL, but qdisc_notify sends 0 or REPLACE (K19), so neither ever prints | tcmonitor/ec-001 | present | reproduces | +| MO7 | tc_qdisc.c:252-254; tc_filter.c:286-296; m_action.c:575-582 | C14 | three rules for "replaced": qdisc CREATE&REPLACE, filter CREATE&!EXCL, action REPLACE; `filter change` (flags 0) prints neither word | tcmonitor/ec-003 | present | reproduces | +| MO8 | tc_class.c:334 | C7 | class `deleted` is `print_null` (`"deleted":null`) where qdisc and filter print a bool; only a DEL event reaches it, and monitor's JSON is off (MO4) | TestGotcMonitorUnit (crafted) | present | reproduces | +| MO9 | m_action.c:555-558, 566-582, 486 | C5/C10 | every action event prints `total acts 0` first (events carry no ROOT_COUNT, K1); the event words go out through `fprintf`; a flush reads `Flushed table gact (1 entries)`, two spaces | tcmonitor/ec-005 | present | reproduces | +| MO10 | tc_monitor.c:103-106; ll_map.c:308-320 | C16/C14 | the link cache is filled once and the monitor doesn't join RTNLGRP_LINK, so a renamed device keeps its old name | tcmonitor/ec-011 | present | reproduces | +| MO11 | tc_qdisc.c:208, 231, 272, 419; tc_filter.c:240, 310, 545, 709; tc_class.c:152, 346, 450 | C16 | in `-batch`, `qdisc show dev d0` leaves qdisc's `filter_ifindex` set: a following `monitor file` drops other devices' qdisc events and leaves `dev d0` off d0's | tcmonitor/ec-020 | present | reproduces | +| MO12 | tc_monitor.c:89-101 | C14 | file mode skips ll_init_map, so each unknown ifindex costs an RTM_GETLINK; `-t` stamps the replay's time, not the record's | tcmonitor/ec-013, ec-014 | present | reproduces | +| MO13 | libnetlink.c:1310-1335 | C10/C8 | `rtnl-from_file: truncated message` beside `rtnl_from_file: fread`; `@%lu` is the offset after the header; a bad length exits 255 from a file and 1 live | tcmonitor/ng-006, ng-007 | present | reproduces | +| MO14 | tc_monitor.c:74-85 | C9 | an unknown word exits 255 with `try "tc monitor help"`; `file` with no value is NEXT_ARG's incomplete command | tcmonitor/ng-003, ng-004 | present | reproduces | +| MO15 | m_action.c:31, 487, 508, 569 | C16 | a flush event sets the static `tab_flush`, which only the flush printer clears; a flush whose tab isn't order 0 alone leaves it set, and the next event with order 0 alone prints as a flush | TestGotcMonitorUnit (crafted) | present | reproduces | +| MO16 | tc_monitor.c:79-84, 93-96, 98-100; utils.c:1755-1785 | C16/C8 | in a `-force` batch, `monitor file` on a missing file calls `exit(-1)` and ends the batch, while a truncated file returns -1, prints `Command failed` and goes on | TestGotcMonitorUnit | present | reproduces | + +## MO1, MO14. Arguments + +- **MO1:** `usage()` prints `Usage: tc [-timestamp [-tshort] monitor` (tc_monitor.c:27). The first `[` is never closed, + and `file FILE`, the one argument the parser takes, is not shown. `help` goes through `usage()`, which calls + `exit(-1)`: rc 255 for asking for help (ng-002). +- **MO14:** an unknown word prints `Argument "bogus" is unknown, try "tc monitor help".` and calls `exit(-1)` + (tc_monitor.c:82-83, ng-003). `file` with no value goes through NEXT_ARG: `Command line is not complete. Try option + "help"`, rc 255 (ng-004). The parser is `matches()`, so `f`, `fi` and `fil` are `file`, and `h` is `help`. + +## MO2, MO3, MO12. The dispatch and the stamp + +- **MO2:** `accept_tcmsg` prints the stamp (tc_monitor.c:37-38) before it knows whether the message is an event. A + DONE, ERROR or NOOP record is then dropped silently, and an unknown type goes to stderr, so stdout has a stamp with + nothing under it. ec-018's file of DONE, ERROR, NOOP and NEWLINK records prints four stamps and nothing else on + stdout. +- **MO3:** the unknown-type line is `Unknown message: length %08d type %08x flags %08x` (tc_monitor.c:62). The length + is decimal, zero-padded to eight digits, beside two hex fields: ec-018's 32-byte NEWLINK reads `length 00000032 type + 00000010`. The padding suggests `%08x` was meant. +- **MO12:** the file branch (tc_monitor.c:89-101) calls `rtnl_from_file` without `ll_init_map`. Every ifindex a + record names is then a cache miss, and `ll_index_to_name` sends an RTM_GETLINK for it (ll_map.c:320): ec-013's six + records over two ifindexes cost two gets. In ec-020 the batch's `qdisc show` had already dumped the links, so the + file costs none. The names printed are today's, not the recording's. `-t` stamps `gettimeofday` at replay + (utils.c:1276), so a file's stamps say when it was read, not when it was recorded (ec-014). + +## MO4. `-j` ignored + +`-json` sets `json` (tc.c:313), but a JSON context only exists once `new_json_obj` runs, and every show calls it in +its own list function. `do_tcmonitor` (tc_monitor.c:68-115) never does, so `is_json_context()` stays false and every +printer takes its text branch. `-j monitor` prints the same text as `monitor`, live (ec-010) and from a file +(ec-016), with rc 0. A consumer asking for JSON gets text it can't parse, and nothing says so. + +## MO5. A 16 KiB receive under a 64 KiB event + +- **The bug:** `rtnl_listen` receives into `char buf[16384]` (libnetlink.c:1211). A message longer than the datagram + it came in, with MSG_TRUNC set, prints `Truncated message` and returns -1 (libnetlink.c:1267-1269). + `do_tcmonitor` then exits 2 (tc_monitor.c:108-110). The monitor stops for good at the first large event. +- **Why it's reachable:** a filter event is sized to fit its message and may grow to U16_MAX plus NLMSG_GOODSIZE + (K21). The ec-012 capture shows tc's request for an n-op cBPF filter is 60 + 8n bytes and the event 76 + 8n. tc's + own request buffer is 16384 bytes too (`addattr_l ERROR: message exceeded bound of 16384` at 4096 ops), so with tc + alone the window is 2039 to 2041 ops: the request fits and the event does not. + - **ng-001:** 2040 ops gives a 16396-byte event, `Truncated message`, and rc 2. + - **ec-012:** 2038 ops gives a 16380-byte event, which prints. + - Any other client, or a filter with large actions, reaches it more easily. +- **Correction to the lead:** the plan's sweep said 4096 ops. tc can't send that, so the rows use 2040 and 2038. +- **At HEAD** (`c6d58ffbb7f7`): the buffer and the truncation path are unchanged. Only the malformed branch's text + changed (see the status above). +- **Fix direction, recorded only:** `rtnl_recvmsg`, which the dumps use, already peeks the length with + MSG_PEEK|MSG_TRUNC and allocates to fit (libnetlink.c:831). `rtnl_listen` could do the same. + +## MO6–MO9. The event words + +- **MO6:** `print_qdisc` prints `replaced` for NEWQDISC with CREATE and REPLACE, and `added` for CREATE and EXCL + (tc_qdisc.c:252-260). The kernel never sends either combination. qdisc_notify passes 0 for a new qdisc and + NLM_F_REPLACE for one that replaced another, never the request's flags (K19). So no qdisc event says `added` or + `replaced`. In ec-001 the fq_codel add, its change and the htb replace all print a bare `qdisc ...`, and the + replace is visible only as the `deleted qdisc fq_codel` line before it (K20). +- **MO7:** the three printers disagree on "replaced": + - qdisc wants CREATE&REPLACE (tc_qdisc.c:252-254); + - filter and chain want CREATE&!EXCL (tc_filter.c:286-290); + - action wants REPLACE (m_action.c:579-580). + + Filter and action events copy the request's flags (K22), so what prints is decided by which tc command was typed. + `filter add` (CREATE|EXCL) is `added`, `filter replace` (CREATE) is `replaced`, and `filter change` (flags 0) prints + neither, though it replaced the filter (ec-003). +- **MO8:** `print_class` marks a DEL with `print_null(PRINT_ANY, "deleted", ...)` (tc_class.c:334): in JSON that's + `"deleted":null`, where `print_qdisc` and `print_filter` use `print_bool`, `"deleted":true`. Only a monitor prints + DEL events, and the monitor's JSON is off (MO4), so it never shows. A fix for MO4 would expose it. +- **MO9:** in `print_action`: + - `total acts %u` prints before anything else (m_action.c:555-558). Events carry no TCA_ROOT_COUNT (K1), so every + event starts `total acts 0`, a header that counts nothing (ec-005). + - The event words `Flushed table `, `Deleted action `, `Added action ` and `Replaced action ` are `fprintf(fp, ...)` + (m_action.c:566-582), outside any JSON object. This is AC4 in + [iproute2-tc-action.md](iproute2-tc-action.md#ac4-ac5-ac11-the-writes-messages), now seen live. + - A flush prints `Flushed table ` and the flush printer starts with a space too (`" %s (%d entries)\n"`, + m_action.c:486). The line reads `Flushed table gact (1 entries)`, with two spaces and `1 entries`. + - TCA_FCNT is read with no presence check (AC5). + +## MO10, MO11, MO15, MO16. State that outlives its command + +- **MO10:** live mode fills the link cache once (`ll_init_map`, tc_monitor.c:106) and subscribes only to RTNLGRP_TC. + `ll_index_to_name` answers from the cache when it has the index (ll_map.c:308-318), so a rename never reaches it. + In ec-011, after `ip link set d0 name d1`, the `tc qdisc del dev d1` event still prints `dev d0`. A deleted and + reused ifindex would print the old device's name the same way. +- **MO11:** `tc_qdisc.c`, `tc_class.c` and `tc_filter.c` each keep a file-scope `filter_ifindex`. The `show dev X` of + each sets it (tc_qdisc.c:419, tc_class.c:450, tc_filter.c:545, 709), and nothing resets it. The printers test it + on every message: + - qdisc drops another device's message (tc_qdisc.c:231) and leaves `dev` off X's (tc_qdisc.c:272); + - class leaves `dev` off X's (tc_class.c:346); + - filter leaves `dev` off X's (tc_filter.c:310). + + In a batch, a later `monitor file` inherits all of it. In ec-020, `qdisc show dev d0` then `monitor file m.bin` + drops the two qdisc events on the other ifindex and prints d0's as `qdisc htb 1: root ...`. Class and filter + events are untouched, as only qdisc's static was set. This is the bridge B28 pattern (C16), seen through a monitor. +- **MO15:** `print_action` sets the static `tab_flush` on a DELACTION with NLM_F_ROOT (m_action.c:31, 569). + `tc_dump_action` sends the tab to the flush printer only `if (tab_flush && tb[0] && !tb[1])` (m_action.c:508). The + flush printer is the only place that clears it (m_action.c:487), and it returns early, still set, for a missing + kind. A flush whose tab is anything other than order 0 alone prints as an ordinary table (TCA_FCNT, 6, reads as + TCA_ACT_COOKIE) and leaves `tab_flush` set. The next event whose tab is order 0 alone, which may be an add, is then + printed as ` gact (N entries)`. The kernel's flush puts order 0 alone (`tcf_del_walker`, act_api.c:665), so this is latent. The + unit row sends a flush with orders 0 and 1, then an add with order 0. +- **MO16:** `do_tcmonitor` has two ways to fail and they differ in a batch. + - Usage, an unknown word and a failed fopen call `exit(-1)` (tc_monitor.c:79-84, 93-96), which ends the process. + - A truncated or malformed file returns `rtnl_from_file`'s -1 (tc_monitor.c:98-100). `do_batch` prints `Command + failed -:N` and, under `-force`, goes on (utils.c:1781). + + So `tc -force -batch` goes past a corrupt file but stops at a missing one, rc 255 with nothing after it. Live mode + never returns: it exits 0, 1 or 2, so a `monitor` line ends any batch. That is expected for a command that runs + until killed. This is the bridge B30 pattern (C16). gotc reproduces it: `exitCode` ends a batch, `retCode` is a + failed line. Two unit rows pin both. + +## MO13. File errors + +`rtnl_from_file` (libnetlink.c:1296-1340): + +- **The text:** a short read prints `rtnl-from_file: truncated message` (libnetlink.c:1315, 1334). That's a hyphen, + beside `perror("rtnl_from_file: fread")` two lines above with an underscore (ng-006). +- **The offset:** a bad length prints `!!!malformed message: len=%d @%lu` with `ftell` (libnetlink.c:1323). That's + the offset after the header just read, not the record's start: the first record reads `@16` (ng-007). +- **The exit code:** both return -1, so main exits 255. The same bad length received live exits 1 inside + `rtnl_listen` (libnetlink.c:1273). At HEAD it prints `!!!Remnant` instead, still exit 1. +- **Not a finding:** the body read is `NLMSG_ALIGN(l)` bytes (libnetlink.c:1328), so a last record whose length + isn't a multiple of 4 must be padded in the file. `rtmon`, the writer, pads, so the two agree. + +## K19–K23. Kernel notes + +- **K19:** `qdisc_notify` builds the NEWQDISC with flags `old ? NLM_F_REPLACE : 0` and the DELQDISC with 0 + (sch_api.c:1109-1116). The request's flags never reach a qdisc event. That is the cause of MO6. +- **K20:** a qdisc that replaces another, including a new root over a device's default noqueue, is sent as DELQDISC + then NEWQDISC in one skb (sch_api.c:1104-1117). In ec-001 the first add prints `deleted qdisc noqueue 0: dev d0 + root` before `qdisc fq_codel 1:`. Pinned by `TestWsTcMonitor`. +- **K21:** `tfilter_notify_prep` sizes a filter event's skb to `max(NLMSG_GOODSIZE, oskb->len)` and grows it by + NLMSG_GOODSIZE on -EMSGSIZE up to U16_MAX + NLMSG_GOODSIZE (cls_api.c:2138-2160). Qdisc (sch_api.c:1104) and chain + (cls_api.c:3069, 3101) events use a fixed NLMSG_GOODSIZE. So only filter events grow past rtnl_listen's 16 KiB + (MO5). +- **K22:** filter events pass the request's `nlmsg_flags` and the requester's portid (cls_api.c:2147-2148). So do + action add and replace events (`tcf_add_notify`, act_api.c:2151). An event therefore carries NLM_F_REQUEST and a + nonzero pid: ec-003's filter add is flags 0x605 (REQUEST|ACK|EXCL|CREATE). Action deletes pass 0 + (act_api.c:2026), and a flush sets NLM_F_ROOT (act_api.c:1859). An implicit chain 0 is announced CREATE|EXCL by the + kernel (cls_api.c:671), so it prints `added chain`. A replay can't tell events from requests by NLM_F_REQUEST alone; + `nlmon.Notifications` also checks the pid. Pinned by `TestWsTcMonitor` and `TestReplay`. +- **K23** (new, a kernel bug): `mall_change` ends with `*arg = head;` (cls_matchall.c:233). But `head` is the old + root, which the function has already required to be NULL (`if (head) return -EEXIST;`, cls_matchall.c:178). It + should be `new`. So `tfilter_notify` gets fh NULL, and every matchall add is announced with handle 0 and no + TCA_OPTIONS. tc prints `added filter dev d0 ingress protocol all pref 2 matchall chain 0`, with no handle and no + actions (ec-004), though a dump of the same filter shows both. + - **Since** fd62d9f5c575 (2017-02-01, "net/sched: matchall: Fix configuration race"). + - **Still present** at v7.4-rc4 and in net-next. + - **Pinned** by `TestWsTcMonitor`, whose row fails if a future capture shows a handle ("K23 fixed?"). diff --git a/internal/goip/imports_test.go b/internal/goip/imports_test.go index 5bb04d42b..2eb021b61 100644 --- a/internal/goip/imports_test.go +++ b/internal/goip/imports_test.go @@ -46,6 +46,7 @@ var goipMayImport = map[string]string{ "pkg/nlparity as the answer. The plan's import set listed only xtcpnl; this is the one addition, and it " + "satisfies the same §16 property.", modulePath + "/internal/jsonw": "jsonw_puts, the one string escaper json_writer.c's ports share with gordma; stdlib only", + modulePath + "/internal/nlmon": "rtnl_listen, rtnl_from_file and the capture's notification split, shared with gotc's tc monitor; xtcpnl and x/sys only", modulePath + "/internal/tnlsys": "the tunnel and tuntap sidecar (8S): the SIOCGET* ioctls, the tun sysfs props and " + "the /dev/net/tun /proc walk, live or from a tnlsnap snapshot. It imports only pkg/cint and x/sys/unix.", "github.com/cilium/ebpf": "`encap bpf` and seg6local `endpoint` load an object's program as ip's libbpf does " + @@ -175,6 +176,7 @@ func TestGoipImportSetIsHermetic(t *testing.T) { modulePath + "/pkg/cint": "the C int conversions; stdlib only", modulePath + "/pkg/strpolicy": "reached through pkg/xtcpnl's congestion-name decoder; stdlib only", modulePath + "/internal/jsonw": "jsonw_puts, shared with gordma; stdlib only", + modulePath + "/internal/nlmon": "the monitor core, shared with gotc; xtcpnl and x/sys only", modulePath + "/internal/tnlsys": "the tunnel and tuntap sidecar; pkg/cint and x/sys/unix only", modulePath + "/gen/go/xtcp_flat_record": "reached through pkg/xtcpnl's inet_diag decoders, which " + "write into the generated proto. This is where grpc and protobuf enter the closure.", diff --git a/internal/goip/obj_monitor.go b/internal/goip/obj_monitor.go index def98a6fa..cf98b13ef 100644 --- a/internal/goip/obj_monitor.go +++ b/internal/goip/obj_monitor.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" "io" - "os" "strconv" "strings" "time" @@ -12,6 +11,7 @@ import ( "github.com/randomizedcoder/xtcp2/internal/goip/model" "github.com/randomizedcoder/xtcp2/internal/goip/render" "github.com/randomizedcoder/xtcp2/internal/goip/service" + "github.com/randomizedcoder/xtcp2/internal/nlmon" "github.com/randomizedcoder/xtcp2/pkg/xtcpnl" "golang.org/x/sys/unix" ) @@ -67,8 +67,6 @@ const ( monitorDeletedCst = "Deleted " monitorAllNsidCst = "all-nsid" monitorHelpCst = "help" - // monitorBufCst is rtnl_from_file's buffer, the longest message it reads. - monitorBufCst = 16384 // nlmsgTstampCst is NLMSG_TSTAMP (include/libnetlink.h), the record // rtmon writes ahead of each batch in its file. nlmsgTstampCst = 15 @@ -464,17 +462,8 @@ func (m *monitor) headers(label string, nsid int32) string { // asctimeLayoutCst is asctime's "%.3s %.3s%3d %.2d:%.2d:%.2d %d". const asctimeLayoutCst = "Mon Jan _2 15:04:05 2006" -// timestampText is print_timestamp: asctime of the local time and the -// microseconds on a line of their own, or under -ts the ISO form in -// brackets ahead of the label. -func timestampText(t time.Time, short bool) string { - t = t.Local() - usec := t.Nanosecond() / 1000 - if short { - return fmt.Sprintf("[%s.%06d] ", t.Format("2006-01-02T15:04:05"), usec) - } - return fmt.Sprintf("Timestamp: %s %d usec\n", t.Format(asctimeLayoutCst), usec) -} +// timestampText is print_timestamp (nlmon.Timestamp). +func timestampText(t time.Time, short bool) string { return nlmon.Timestamp(t, short) } // tstampText is print_nlmsg_timestamp, an NLMSG_TSTAMP record's seconds and // microseconds, two u32s. `ip` reads them whatever the length; a short body @@ -713,40 +702,17 @@ func (m *monitor) fromFile(path string) error { return monitorReadFile(path, m.accept) } -// monitorReadFile is rtnl_from_file over path, each message handed to fn, -// as fromFile describes; `ip xfrm monitor file` walks it the same way. +// monitorReadFile is nlmon.ReadFile with goip's sentinels: a file it +// cannot open is ErrMonitorAbort, any other failure ErrMonitorFile. func monitorReadFile(path string, fn func(monitorMsg) error) error { - data, err := os.ReadFile(path) - if err != nil { - var errno unix.Errno - if errors.As(err, &errno) { - return fmt.Errorf("%w: Cannot fopen: %s", ErrMonitorAbort, errno.Error()) - } - return fmt.Errorf("%w: Cannot fopen: %w", ErrMonitorAbort, err) - } - off := 0 - for off < len(data) { - if len(data)-off < xtcpnl.NlMsgHdrSizeCst { - return fmt.Errorf("%w: rtnl-from_file: truncated message", ErrMonitorFile) - } - var h xtcpnl.NlMsgHdr - if _, err := xtcpnl.DeserializeNlMsgHdr(data[off:], &h); err != nil { - return fmt.Errorf("%w: %w", ErrMonitorFile, err) - } - if h.Len < xtcpnl.NlMsgHdrSizeCst || h.Len > monitorBufCst { - return fmt.Errorf("%w: !!!malformed message: len=%d @%d", ErrMonitorFile, - int32(h.Len), off+xtcpnl.NlMsgHdrSizeCst) - } - l := int(h.Len) - xtcpnl.NlMsgHdrSizeCst - end := off + xtcpnl.NlMsgHdrSizeCst + nlmsgAlign(l) - if end > len(data) { - return fmt.Errorf("%w: rtnl-from_file: truncated message", ErrMonitorFile) - } - body := data[off+xtcpnl.NlMsgHdrSizeCst : off+xtcpnl.NlMsgHdrSizeCst+l] - if err := fn(monitorMsg{hdr: h, body: body, nsid: -1}); err != nil { - return fmt.Errorf("%w: %w", ErrMonitorFile, err) - } - off = end + err := nlmon.ReadFile(path, func(m nlmon.Msg) error { + return fn(monitorMsg{hdr: m.Hdr, body: m.Body, nsid: m.Nsid}) + }) + switch { + case err == nil: + return nil + case errors.Is(err, nlmon.ErrOpen): + return fmt.Errorf("%w: %w", ErrMonitorAbort, err) } - return nil + return fmt.Errorf("%w: %w", ErrMonitorFile, err) } diff --git a/internal/goip/obj_monitor_run_test.go b/internal/goip/obj_monitor_run_test.go index 3dd576472..54079cad7 100644 --- a/internal/goip/obj_monitor_run_test.go +++ b/internal/goip/obj_monitor_run_test.go @@ -58,7 +58,7 @@ func TestRunMonitorFile(t *testing.T) { {"negative: an unknown argument exits 255", "monitor bogus", result{rc: ExitMinusOne, stderr: "goip: monitor: Argument \"bogus\" is unknown, try \"ip monitor help\"\n"}}, {"negative: no such file exits 255", "monitor file " + file + ".none", - result{rc: ExitMinusOne, stderr: "goip: monitor: Cannot fopen: no such file or directory\n"}}, + result{rc: ExitMinusOne, stderr: "goip: monitor: Cannot fopen: No such file or directory\n"}}, {"corner: -j still prints text", "-j monitor file " + file, result{stdout: addr}}, {"negative: a truncated file exits 1, rtnl_from_file's -1 negated", "monitor file " + short16, result{rc: ExitUsage, stderr: "goip: monitor file: rtnl-from_file: truncated message\n"}}, diff --git a/internal/goip/obj_monitor_test.go b/internal/goip/obj_monitor_test.go index bf50ddb08..601a0f86b 100644 --- a/internal/goip/obj_monitor_test.go +++ b/internal/goip/obj_monitor_test.go @@ -2,16 +2,14 @@ package goip import ( "bytes" - "encoding/binary" "errors" - "fmt" "os" "path/filepath" "strings" "testing" "time" - "github.com/randomizedcoder/xtcp2/pkg/nlparity" + "github.com/randomizedcoder/xtcp2/internal/nlmon" "github.com/randomizedcoder/xtcp2/pkg/xtcpnl" "golang.org/x/sys/unix" ) @@ -511,13 +509,13 @@ func TestMonitorFromFile(t *testing.T) { result{errText: "rtnl-from_file: truncated message", exit: ExitUsage}}, {"negative: a length under the header's", monFileRecord(unix.RTM_NEWADDR, nil, 8), result{errText: "!!!malformed message: len=8 @16", exit: ExitUsage}}, - {"boundary: a length over the 16384-byte buffer", monFileRecord(unix.RTM_NEWADDR, nil, monitorBufCst+1), + {"boundary: a length over the 16384-byte buffer", monFileRecord(unix.RTM_NEWADDR, nil, nlmon.RecvBufCst+1), result{errText: "!!!malformed message: len=16385 @16", exit: ExitUsage}}, {"corner: a short route stops the walk with -1", catBytes( monFileRecord(unix.RTM_NEWROUTE, make([]byte, 4), 20), rec(addr)), result{errText: errMonitorStop.Error(), exit: ExitUsage}}, {"negative: no such file is fopen's exit(-1)", nil, - result{errText: "Cannot fopen: no such file or directory", exit: ExitMinusOne}}, + result{errText: "Cannot fopen: No such file or directory", exit: ExitMinusOne}}, } for _, tc := range tests { t.Run(tc.description, func(t *testing.T) { @@ -543,167 +541,3 @@ func TestMonitorFromFile(t *testing.T) { }) } } - -// TestMonitorDatagram is rtnl_listen's walk of one datagram: each message -// to the callback with the datagram's nsid, and the malformed and remnant -// refusals. -// -// go test ./internal/goip/ -run TestMonitorDatagram -func TestMonitorDatagram(t *testing.T) { - msg := func(typ uint16, body []byte) []byte { - return monFileRecord(typ, body, uint32(xtcpnl.NlMsgHdrSizeCst+len(body))) - } - type result struct { - types string - errText string - } - tests := []struct { - description string - datagram []byte - expected result - }{ - {"positive: two messages", catBytes(msg(unix.RTM_NEWLINK, le32(1)), msg(unix.RTM_NEWADDR, nil)), - result{types: "16/5 20/5 "}}, - {"boundary: an empty datagram", nil, result{}}, - {"positive: the last body unpadded", msg(unix.RTM_NEWLINK, []byte{1})[:17], result{types: "16/5 "}}, - {"negative: a length past the datagram", monFileRecord(unix.RTM_NEWLINK, nil, 64), - result{errText: "!!!malformed message: len=64"}}, - {"negative: a length under the header's", monFileRecord(unix.RTM_NEWLINK, nil, 4), - result{errText: "!!!malformed message: len=4"}}, - {"corner: a remnant under a header", catBytes(msg(unix.RTM_NEWLINK, nil), []byte{1, 2, 3, 4}), - result{types: "16/5 ", errText: "!!!Remnant of size 4"}}, - } - for _, tc := range tests { - t.Run(tc.description, func(t *testing.T) { - var types strings.Builder - err := monitorDatagram(tc.datagram, 5, func(m monitorMsg) error { - fmt.Fprintf(&types, "%d/%d ", m.hdr.Type, m.nsid) - return nil - }) - got := result{types: types.String()} - if err != nil { - got.errText = err.Error() - } - if got != tc.expected { - t.Errorf("got %+v, want %+v", got, tc.expected) - } - }) - } -} - -// TestListenNsid is the nsid a NETLINK_LISTEN_ALL_NSID control message -// carries. -// -// go test ./internal/goip/ -run TestListenNsid -func TestListenNsid(t *testing.T) { - // cmsg is a cmsghdr on a 64-bit host, its length a size_t, then data - // padded to 8 bytes. - cmsg := func(level, typ int32, data []byte) []byte { - b := catBytes(binary.LittleEndian.AppendUint64(nil, uint64(unix.CmsgLen(len(data)))), - le32(uint32(level)), le32(uint32(typ)), data) - return append(b, make([]byte, unix.CmsgSpace(len(data))-len(b))...) - } - tests := []struct { - description string - oob []byte - expected int32 - }{ - {"positive: nsid 9", cmsg(unix.SOL_NETLINK, unix.NETLINK_LISTEN_ALL_NSID, le32(9)), 9}, - {"boundary: none is -1", nil, -1}, - {"negative: another level is -1", cmsg(unix.SOL_SOCKET, unix.NETLINK_LISTEN_ALL_NSID, le32(9)), -1}, - {"negative: a short value is -1", cmsg(unix.SOL_NETLINK, unix.NETLINK_LISTEN_ALL_NSID, []byte{9}), -1}, - {"corner: the last of two", catBytes(cmsg(unix.SOL_NETLINK, unix.NETLINK_LISTEN_ALL_NSID, le32(9)), - cmsg(unix.SOL_NETLINK, unix.NETLINK_LISTEN_ALL_NSID, le32(2))), 2}, - {"negative: garbage is -1", []byte{1, 2, 3}, -1}, - } - for _, tc := range tests { - t.Run(tc.description, func(t *testing.T) { - if got := listenNsid(tc.oob); got != tc.expected { - t.Errorf("got %d, want %d", got, tc.expected) - } - }) - } -} - -// TestReplayNotifications is which of a capture's messages a subscriber -// was sent: requests, dump parts, errors and a get's answer left out. -// -// go test ./internal/goip/ -run TestReplayNotifications -func TestReplayNotifications(t *testing.T) { - m := func(typ, flags uint16, seq, pid uint32, body ...byte) nlparity.Msg { - return nlparity.Msg{Hdr: xtcpnl.NlMsgHdr{Type: typ, Flags: flags, Seq: seq, Pid: pid}, Body: body} - } - errFor := func(typ uint16, seq uint32) nlparity.Msg { - return m(unix.NLMSG_ERROR, 0, seq, 100, catBytes(le32(0), monHdr(typ, seq, xtcpnl.NlMsgHdrSizeCst))...) - } - const ( - req = unix.NLM_F_REQUEST - dump = unix.NLM_F_REQUEST | unix.NLM_F_DUMP - ) - tests := []struct { - description string - msgs []nlparity.Msg - expected []int - }{ - {"positive: notifications alone", []nlparity.Msg{m(unix.RTM_NEWADDR, 0, 0, 0), m(unix.RTM_DELADDR, 0, 0, 0)}, - []int{0, 1}}, - {"negative: a dump and its parts", []nlparity.Msg{m(unix.RTM_GETLINK, dump, 1, 0), - m(unix.RTM_NEWLINK, unix.NLM_F_MULTI, 1, 100), m(unix.NLMSG_DONE, unix.NLM_F_MULTI, 1, 100), - m(unix.RTM_NEWLINK, 0, 0, 0)}, []int{3}}, - {"positive: a nexthop event carries REQUEST and the requester's port", []nlparity.Msg{ - m(unix.RTM_NEWNEXTHOP, req|unix.NLM_F_CREATE, 5, 0), errFor(unix.RTM_NEWNEXTHOP, 5), - m(unix.RTM_NEWNEXTHOP, req|unix.NLM_F_CREATE, 5, 4242)}, []int{2}}, - {"negative: a get's answer", []nlparity.Msg{m(unix.RTM_GETNSID, req, 7, 0), m(unix.RTM_NEWNSID, 0, 7, 100), - m(unix.RTM_NEWNSID, 0, 0, 0)}, []int{2}}, - {"corner: a get's answer is the first of its type and seq alone", []nlparity.Msg{ - m(unix.RTM_GETNSID, req, 7, 0), m(unix.RTM_NEWADDR, 0, 7, 0), m(unix.RTM_NEWNSID, 0, 7, 100), - m(unix.RTM_NEWNSID, 0, 7, 100)}, []int{1, 3}}, - {"corner: a refused get waits for no answer", []nlparity.Msg{m(unix.RTM_GETNSID, req, 7, 0), - errFor(unix.RTM_GETNSID, 7), m(unix.RTM_NEWNSID, 0, 7, 0)}, []int{2}}, - {"boundary: a short error names nothing", []nlparity.Msg{m(unix.RTM_GETNSID, req, 7, 0), - m(unix.NLMSG_ERROR, 0, 7, 0, 0, 0, 0, 0), m(unix.RTM_NEWNSID, 0, 7, 0)}, nil}, - {"boundary: none", nil, nil}, - } - for _, tc := range tests { - t.Run(tc.description, func(t *testing.T) { - got := replayNotifications(tc.msgs) - if fmt.Sprint(got) != fmt.Sprint(tc.expected) { - t.Errorf("got %v, want %v", got, tc.expected) - } - }) - } -} - -// TestReplayDumpEnd is the index past a recorded dump's NLMSG_DONE, where a -// replayed monitor's notifications begin. -// -// go test ./internal/goip/ -run TestReplayDumpEnd -func TestReplayDumpEnd(t *testing.T) { - m := func(typ, flags uint16, seq, pid uint32) nlparity.Msg { - return nlparity.Msg{Hdr: xtcpnl.NlMsgHdr{Type: typ, Flags: flags, Seq: seq, Pid: pid}} - } - dump := uint16(unix.NLM_F_REQUEST | unix.NLM_F_DUMP) - tests := []struct { - description string - msgs []nlparity.Msg - expected int - }{ - {"positive: past the DONE", []nlparity.Msg{m(unix.RTM_NEWADDR, 0, 0, 0), m(unix.RTM_GETLINK, dump, 3, 0), - m(unix.RTM_NEWADDR, 0, 0, 0), m(unix.NLMSG_DONE, 2, 3, 100), m(unix.RTM_NEWADDR, 0, 0, 0)}, 4}, - {"negative: no dump is 0", []nlparity.Msg{m(unix.RTM_NEWADDR, 0, 0, 0)}, 0}, - {"negative: a dump with no DONE is 0", []nlparity.Msg{m(unix.RTM_GETLINK, dump, 3, 0)}, 0}, - {"corner: a DONE of another seq is not the dump's", []nlparity.Msg{m(unix.RTM_GETLINK, dump, 3, 0), - m(unix.NLMSG_DONE, 2, 2, 100), m(unix.NLMSG_DONE, 2, 3, 100)}, 3}, - {"corner: a get of the type is not a dump", []nlparity.Msg{m(unix.RTM_GETLINK, unix.NLM_F_REQUEST, 3, 0), - m(unix.NLMSG_DONE, 2, 3, 100)}, 0}, - {"boundary: a reply from the kernel is not the request", []nlparity.Msg{m(unix.RTM_GETLINK, dump, 3, 100), - m(unix.NLMSG_DONE, 2, 3, 100)}, 0}, - } - for _, tc := range tests { - t.Run(tc.description, func(t *testing.T) { - if got := replayDumpEnd(tc.msgs, unix.RTM_GETLINK); got != tc.expected { - t.Errorf("got %d, want %d", got, tc.expected) - } - }) - } -} diff --git a/internal/goip/source.go b/internal/goip/source.go index a659462b2..06301ec49 100644 --- a/internal/goip/source.go +++ b/internal/goip/source.go @@ -8,6 +8,7 @@ import ( "strconv" "time" + "github.com/randomizedcoder/xtcp2/internal/nlmon" "github.com/randomizedcoder/xtcp2/pkg/nlparity" "github.com/randomizedcoder/xtcp2/pkg/xtcpnl" "golang.org/x/sys/unix" @@ -517,9 +518,4 @@ func nowFromEnv() time.Time { // nowFuncFromEnv is the clock a monitor stamps each message with: GOIP_NOW's // instant when it parses, for a replay, else the wall clock, read per message. -func nowFuncFromEnv() func() time.Time { - if t, err := time.Parse(time.RFC3339, os.Getenv("GOIP_NOW")); err == nil { - return func() time.Time { return t } - } - return time.Now -} +func nowFuncFromEnv() func() time.Time { return nlmon.NowFunc("GOIP_NOW") } diff --git a/internal/goip/source_monitor.go b/internal/goip/source_monitor.go index 044f31137..beaa546c6 100644 --- a/internal/goip/source_monitor.go +++ b/internal/goip/source_monitor.go @@ -5,6 +5,7 @@ import ( "fmt" "io" + "github.com/randomizedcoder/xtcp2/internal/nlmon" "github.com/randomizedcoder/xtcp2/pkg/nlparity" "github.com/randomizedcoder/xtcp2/pkg/xtcpnl" "golang.org/x/sys/unix" @@ -27,12 +28,6 @@ type MonitorConn interface { Close() error } -// monitorRecvBufCst is rtnl_listen's buffer. -const monitorRecvBufCst = 16384 - -// monitorCmsgBufCst is room for rtnl_listen's one control message, an int. -const monitorCmsgBufCst = 64 - // Subscribe is rtnl_open with the groups, then each rtnl_add_nl_group and, // for all-nsid, rtnl_listen_all_nsid. The socket is a new one, as `ip`'s // is after rtnl_close: the source's own socket keeps answering the dumps. @@ -105,93 +100,26 @@ func (c *netlinkMonitorConn) Listen(fn func(monitorMsg) error) error { return listenFd(c.fd, c.allNsid, c.errOut, fn) } -// listenFd is rtnl_listen: EINTR and EAGAIN are retried, ENOBUFS, the -// kernel's word for messages dropped on a full queue, is reported and -// retried, and any other receive error ends the listen. +// listenFd is nlmon.Listen with each message as a monitorMsg. func listenFd(fd int, allNsid bool, errOut io.Writer, fn func(monitorMsg) error) error { - buf := make([]byte, monitorRecvBufCst) - oob := make([]byte, monitorCmsgBufCst) - for { - n, oobn, _, _, err := unix.Recvmsg(fd, buf, oob, 0) - switch { - case errors.Is(err, unix.EINTR), errors.Is(err, unix.EAGAIN): - continue - case errors.Is(err, unix.ENOBUFS): - if _, werr := fmt.Fprintf(errOut, "netlink receive error %s (%d)\n", unix.ENOBUFS.Error(), int(unix.ENOBUFS)); werr != nil { - return werr - } - continue - case err != nil: - return fmt.Errorf("netlink receive error %w", err) - case n == 0: - return errors.New("EOF on netlink") - } - nsid := int32(-1) - if allNsid { - nsid = listenNsid(oob[:oobn]) - } - if err := monitorDatagram(buf[:n], nsid, fn); err != nil { - return err - } - } -} - -// listenNsid is the netns id a NETLINK_LISTEN_ALL_NSID control message -// carries, the last one if more came, or -1. -func listenNsid(oob []byte) int32 { - nsid := int32(-1) - cmsgs, err := unix.ParseSocketControlMessage(oob) - if err != nil { - return nsid - } - for _, cm := range cmsgs { - if cm.Header.Level == unix.SOL_NETLINK && cm.Header.Type == unix.NETLINK_LISTEN_ALL_NSID && - len(cm.Data) >= 4 { - nsid = int32(xtcpnl.NativeEndian().Uint32(cm.Data[:4])) - } - } - return nsid -} - -// monitorDatagram is rtnl_listen's walk of one datagram: each message to -// fn, until one's length is under its header or past the datagram. -func monitorDatagram(b []byte, nsid int32, fn func(monitorMsg) error) error { - for len(b) >= xtcpnl.NlMsgHdrSizeCst { - var h xtcpnl.NlMsgHdr - if _, err := xtcpnl.DeserializeNlMsgHdr(b, &h); err != nil { - return err - } - if h.Len < xtcpnl.NlMsgHdrSizeCst || int(h.Len) > len(b) { - return fmt.Errorf("!!!malformed message: len=%d", int32(h.Len)) - } - if err := fn(monitorMsg{hdr: h, body: b[xtcpnl.NlMsgHdrSizeCst:h.Len], nsid: nsid}); err != nil { - return err - } - next := nlmsgAlign(int(h.Len)) - if next > len(b) { - return nil - } - b = b[next:] - } - if len(b) != 0 { - return fmt.Errorf("!!!Remnant of size %d", len(b)) - } - return nil + return nlmon.Listen(fd, nlmon.ListenOpts{AllNsid: allNsid, ErrOut: errOut}, func(m nlmon.Msg) error { + return fn(monitorMsg{hdr: m.Hdr, body: m.Body, nsid: m.Nsid}) + }) } // Subscribe on a replay is its capture's notifications, whatever the // groups: the capture holds what the kernel sent the subscriber that was // running, and nothing in a message says which group it came on. func (s *ReplaySource) Subscribe(monitorSub) (MonitorConn, error) { - msgs := s.cap.Msgs() - return &replayMonitorConn{src: s, msgs: msgs, notes: replayNotifications(msgs)}, nil + msgs := nlmonMsgs(s.cap.Msgs()) + return &replayMonitorConn{src: s, msgs: msgs, notes: nlmon.Notifications(msgs)}, nil } // replayMonitorConn plays notifications: those from start on, start being // past the end of the dump run on it. type replayMonitorConn struct { src *ReplaySource - msgs []nlparity.Msg + msgs []nlmon.Msg notes []int start int } @@ -203,27 +131,11 @@ type replayMonitorConn struct { func (c *replayMonitorConn) Dump(request []byte, msgType uint16) ([][]byte, error) { if len(request) >= xtcpnl.NlMsgHdrSizeCst { typ := xtcpnl.NativeEndian().Uint16(request[4:6]) - c.start = max(c.start, replayDumpEnd(c.msgs, typ)) + c.start = max(c.start, nlmon.DumpEnd(c.msgs, typ)) } return c.src.Dump(request, msgType) } -// replayDumpEnd is the index past a recorded dump of typ's NLMSG_DONE, or -// 0 when the capture has none. -func replayDumpEnd(msgs []nlparity.Msg, typ uint16) int { - req := -1 - for i := range msgs { - h := &msgs[i].Hdr - switch { - case req < 0 && h.Type == typ && h.Flags&unix.NLM_F_DUMP == unix.NLM_F_DUMP && h.Pid == 0: - req = i - case req >= 0 && h.Type == unix.NLMSG_DONE && h.Seq == msgs[req].Hdr.Seq: - return i + 1 - } - } - return 0 -} - // Listen hands each notification from start on to fn, as from a socket // with no NETLINK_LISTEN_ALL_NSID. func (c *replayMonitorConn) Listen(fn func(monitorMsg) error) error { @@ -242,65 +154,11 @@ func (c *replayMonitorConn) Listen(fn func(monitorMsg) error) error { // Close has nothing to release. func (c *replayMonitorConn) Close() error { return nil } -// replayNotifications is what of a capture a subscriber was sent, by -// index: the messages to user space, less the answers to requests. -// -// nlmon records a multicast once per socket it is delivered to, and a -// unicast answer once, with nothing on either to say which it was. What is -// left out: -// -// - a request: NLM_F_REQUEST with nlmsg_pid 0. nexthop_notify copies the -// request's flags into its notification (net/ipv4/nexthop.c), so a -// NEWNEXTHOP event has NLM_F_REQUEST too; it carries the requester's -// port id, which a request does not; -// - a dump's part, NLM_F_MULTI, its NLMSG_DONE among them; -// - an NLMSG_ERROR, an ack or a refusal; -// - the answer to a get: the first message after a request of an RTM -// GET type (a type 2 past the NEW of its family of four) with the -// request's sequence number and the NEW type. A refusal of the get, an -// NLMSG_ERROR naming it, ends the wait as well. -func replayNotifications(msgs []nlparity.Msg) []int { - type pending struct { - seq uint32 - typ uint16 - } - var gets []pending - answered := func(seq uint32, typ uint16) bool { - for i, g := range gets { - if g.seq == seq && g.typ == typ { - gets = append(gets[:i], gets[i+1:]...) - return true - } - } - return false - } - var out []int +// nlmonMsgs is a capture's messages as nlmon walks them. +func nlmonMsgs(msgs []nlparity.Msg) []nlmon.Msg { + out := make([]nlmon.Msg, len(msgs)) for i := range msgs { - m := &msgs[i] - h := m.Hdr - switch { - case h.Flags&unix.NLM_F_REQUEST != 0 && h.Pid == 0: - if isRtmGet(h.Type) && h.Flags&unix.NLM_F_DUMP != unix.NLM_F_DUMP { - gets = append(gets, pending{h.Seq, h.Type - 2}) - } - case h.Flags&unix.NLM_F_MULTI != 0: - case h.Type == unix.NLMSG_ERROR: - if len(m.Body) >= 4+xtcpnl.NlMsgHdrSizeCst { - var orig xtcpnl.NlMsgHdr - if _, err := xtcpnl.DeserializeNlMsgHdr(m.Body[4:], &orig); err == nil && isRtmGet(orig.Type) { - answered(orig.Seq, orig.Type-2) - } - } - case answered(h.Seq, h.Type): - default: - out = append(out, i) - } + out[i] = nlmon.Msg{Hdr: msgs[i].Hdr, Body: msgs[i].Body, Nsid: -1} } return out } - -// isRtmGet is an RTM_GET* type: the third of its family's four, NEW, DEL, -// GET and SET, from RTM_BASE. -func isRtmGet(t uint16) bool { - return t >= unix.RTM_BASE && (t-unix.RTM_BASE)%4 == 2 -} diff --git a/internal/gotc/action.go b/internal/gotc/action.go index cac536403..20389ed66 100644 --- a/internal/gotc/action.go +++ b/internal/gotc/action.go @@ -45,8 +45,8 @@ func (r *runner) printActions(nest []byte) error { const actTabMaxCst = 1024 // dumpAction is tc_dump_action: tot of 0 is TCA_ACT_MAX_PRIO, and the -// table holds orders 0..tot. The flush-reply path (tab_flush) follows -// only RTM_DELACTION, which gotc does not send. +// table holds orders 0..tot. After a flush event (tab_flush), a table of +// order 0 alone is the flush's count. func (r *runner) dumpAction(nest []byte, tot uint16, bind bool) error { o := r.o if tot == 0 { @@ -56,6 +56,9 @@ func (r *runner) dumpAction(nest []byte, tot uint16, bind bool) error { return fmt.Errorf("%w: an action table of %d orders", errNotImplemented, tot) } tb := r.nested(nest, tot) + if r.tabFlush && tb.Has(0) && !tb.Has(1) { + return r.printActionFlush(tb.Bytes(0)) + } o.openArray(printJSON, "actions") for i := range tot + 1 { if !tb.Has(i) { @@ -77,6 +80,30 @@ func (r *runner) dumpAction(nest []byte, tot uint16, bind bool) error { return nil } +// printActionFlush is tc_print_action_flush: a flush event's order-0 +// nest, parsed as TCA_* (not TCA_ACT_*), so its count is TCA_FCNT, printed +// with %d. It clears tab_flush only on this path: a flush whose table is +// not order 0 alone leaves it set for the next table (MO15). tc +// dereferences a missing TCA_FCNT; gotc refuses it, and a kind tc does not +// link, which tc would name gact (L22). +func (r *runner) printActionFlush(nest []byte) error { + tb := r.nested(nest, xtcpnl.TcaMaxKnown) + if !tb.Has(xtcpnl.TcaKind) { + r.errf("NULL Action!\n") + return nil + } + kind, _ := tb.Str(xtcpnl.TcaKind) + if _, ok := actionUtils[kind]; !ok { + return fmt.Errorf("%w: action kind %q", errNotImplemented, kind) + } + if !tb.Has(xtcpnl.TcaFcnt) { + return fmt.Errorf("%w: a flush event with no TCA_FCNT", errNotImplemented) + } + r.o.raw(" " + kind + " (" + strconv.FormatInt(int64(cint.Int(attrU32(tb, xtcpnl.TcaFcnt))), 10) + " entries)\n") + r.tabFlush = false + return nil +} + // actPrinter is an action_util's print_aopt: its options (nil when // TCA_ACT_OPTIONS is absent, has false) and tc's return. type actPrinter func(r *runner, opt []byte, has bool) (int, error) diff --git a/internal/gotc/action_cmd.go b/internal/gotc/action_cmd.go index 215bcbe2a..279e0d3b4 100644 --- a/internal/gotc/action_cmd.go +++ b/internal/gotc/action_cmd.go @@ -197,6 +197,8 @@ func (r *runner) actList(args []string) error { // unchecked (here MIN-copied) and absent from a get's reply, so a get // prints 0 (AC2); it prints before the tab is checked (AC3), as a JSON // object of its own whose key has a space (AC1). The actions are unbound. +// A monitor's events add a word: Added, Replaced or Deleted action, or +// Flushed table. func (r *runner) printAction(m Msg) (int, error) { o := r.o if len(m.Body) < xtcpnl.TcaMsgSizeCst { @@ -219,6 +221,20 @@ func (r *runner) printAction(m Msg) (int, error) { } return -1, nil } + // The event words go out through fprintf, outside any JSON (MO9). + // NLM_F_ROOT and NLM_F_REPLACE are both 0x100: a delete's flag space is + // a get's. + switch { + case m.Type == unix.RTM_DELACTION && m.Flags&unix.NLM_F_ROOT != 0: + o.raw("Flushed table ") + r.tabFlush = true + case m.Type == unix.RTM_DELACTION: + o.raw("Deleted action ") + case m.Type == unix.RTM_NEWACTION && m.Flags&unix.NLM_F_CREATE != 0 && m.Flags&unix.NLM_F_REPLACE == 0: + o.raw("Added action ") + case m.Type == unix.RTM_NEWACTION && m.Flags&unix.NLM_F_REPLACE != 0: + o.raw("Replaced action ") + } o.openObject("") if err := r.dumpAction(tb.Bytes(xtcpnl.TcaRootTab), tot, false); err != nil { return 0, err diff --git a/internal/gotc/gotc.go b/internal/gotc/gotc.go index 4e02d6bf9..213e95bd9 100644 --- a/internal/gotc/gotc.go +++ b/internal/gotc/gotc.go @@ -21,6 +21,7 @@ import ( "os" "strconv" "strings" + "time" ) // exitCode is tc leaving with exit(code), or main returning it; -1 is 255. @@ -77,6 +78,11 @@ type runner struct { cf classFilter // tc_class.c's statics, kept across batch lines (Q30) ff filterFilter // tc_filter.c's statics, kept across batch lines (Q29f) + timestamp int // timestamp: -timestamp and -tshort each add one + tshort int // timestamp_short: -tshort + now func() time.Time // the monitor's clock (GOTC_NOW for a replay) + tabFlush bool // m_action.c's static tab_flush: a flush event's, kept until printed (MO15) + fProto uint16 // f_proto: the last filter's htons'd protocol, u32 -p's key realms rtRealmTab // rt_names.c's realm table } @@ -96,8 +102,9 @@ func Run(args []string, stdout, stderr io.Writer) int { type config struct { src Source // overrides replay when set replay string - stdin io.Reader // -batch - - sys sysFS // /proc/net/psched and the class names files + stdin io.Reader // -batch - + sys sysFS // /proc/net/psched and the class names files + now func() time.Time // the monitor's clock; nil is GOTC_NOW, else the wall clock } func run(cfg config, args []string, stdout, stderr io.Writer) int { @@ -108,7 +115,10 @@ func run(cfg config, args []string, stdout, stderr io.Writer) int { // runWith is run, keeping the runner for the tests to look at. func runWith(cfg config, args []string, stdout, stderr io.Writer) (*runner, int) { w := bufio.NewWriter(stdout) - r := &runner{o: newOut(w), stderr: stderr, sys: cfg.sys} + r := &runner{o: newOut(w), stderr: stderr, sys: cfg.sys, now: cfg.now} + if r.now == nil { + r.now = nowFunc() + } r.o.under = stdout return r, r.exit(r.main(cfg, args), w) } @@ -321,8 +331,12 @@ func (r *runner) options(args []string, st *options) ([]string, error) { r.confFile = &args[0] } case matchesColor(opt, &st.color): - case matches(opt, "-timestamp"), matches(opt, "-tshort"): - // Only monitor prints a timestamp, and gotc refuses monitor. + case matches(opt, "-timestamp"): + r.timestamp++ + case matches(opt, "-tshort"): + // ++timestamp; ++timestamp_short: -tshort alone stamps. + r.timestamp++ + r.tshort++ case matches(opt, "-json"): st.json++ case matches(opt, "-oneline"): @@ -357,7 +371,7 @@ func (r *runner) doCmd(obj string, args []string) error { {"filter", r.doFilter}, {"chain", r.doChain}, {"actions", r.doAction}, - {"monitor", r.refuse("monitor")}, + {"monitor", r.doMonitor}, {"exec", r.refuse("exec")}, {helpWord, func([]string) error { r.usage(); return nil }}, } { diff --git a/internal/gotc/imports_test.go b/internal/gotc/imports_test.go index 5c17e0d96..1dcbe573e 100644 --- a/internal/gotc/imports_test.go +++ b/internal/gotc/imports_test.go @@ -28,6 +28,7 @@ var gotcMayImport = map[string]string{ modulePath + "/pkg/cint": "the C integer conversions tc's scans and prints make (int of a u32, s64 of a u64)", modulePath + "/internal/wsreplay": "the ws pcap replay core shared with the other read-only clones; xtcpnl only", modulePath + "/internal/jsonw": "json_writer.c's string escaping, shared with gobridge; stdlib only", + modulePath + "/internal/nlmon": "the monitor core shared with goip: rtnl_listen, rtnl_from_file, the stamp; xtcpnl only", } // gotcClosure is the first-party closure of gotc's non-test files. @@ -35,6 +36,7 @@ var gotcClosure = []string{ modulePath + "/cmd/gotc", modulePath + "/internal/gotc", modulePath + "/pkg/xtcpnl", modulePath + "/internal/wsreplay", modulePath + "/pkg/cint", modulePath + "/internal/jsonw", + modulePath + "/internal/nlmon", // Reached through xtcpnl's congestion-name decoder; stdlib only. modulePath + "/pkg/strpolicy", // Reached through xtcpnl's inet_diag decoders; see internal/gordma. diff --git a/internal/gotc/monitor.go b/internal/gotc/monitor.go new file mode 100644 index 000000000..62488f52c --- /dev/null +++ b/internal/gotc/monitor.go @@ -0,0 +1,168 @@ +package gotc + +import ( + "errors" + "fmt" + "io" + "time" + + "github.com/randomizedcoder/xtcp2/internal/nlmon" + "github.com/randomizedcoder/xtcp2/pkg/xtcpnl" + "golang.org/x/sys/unix" +) + +// This is tc/tc_monitor.c: `tc monitor`, live on RTNLGRP_TC, or `tc +// monitor file F` over raw nlmsghdr records, each event handed to the +// printers the shows use. The receive loop, the file walk and the stamp +// are internal/nlmon's, shared with goip. + +// rtnlgrpTCCst is RTNLGRP_TC (linux/include/uapi/linux/rtnetlink.h); +// nl_mgrp makes it the bind mask 1 << (4 - 1), 0x8. +const rtnlgrpTCCst = unix.RTNLGRP_TC + +// nlMgrp is lib/libnetlink.h nl_mgrp: the bind mask of a group up to 31. +func nlMgrp(group uint32) uint32 { return 1 << (group - 1) } + +// MonitorSource is a Source that can subscribe to multicast groups. +type MonitorSource interface { + Subscribe(groups uint32, errOut io.Writer) (MonitorConn, error) +} + +// MonitorConn is one subscription. Talk runs a request on it, as +// ll_init_map's dump runs on the monitor's own socket; Listen hands every +// message after to fn until fn fails or the source ends: a socket ends only +// on an error, a replay at the end of its capture. +type MonitorConn interface { + Source + Listen(fn func(nlmon.Msg) error) error + Close() error +} + +// monitorUsage is tc_monitor.c usage, which exits -1. Its `[` is never +// closed, and it leaves out `file` (MO1). +const monitorUsage = "Usage: tc [-timestamp [-tshort] monitor\n" + +// doMonitor is do_tcmonitor. +func (r *runner) doMonitor(args []string) error { + file, hasFile := "", false + for len(args) > 0 { + switch w := args[0]; { + case matches(w, "file"): + if len(args) < 2 { + return r.incomplete() // NEXT_ARG + } + args = args[1:] + file, hasFile = args[0], true + case matches(w, helpWord): + r.errf("%s", monitorUsage) + return exitCode(-1) + default: + r.errf("Argument \"%s\" is unknown, try \"tc monitor help\".\n", w) + return exitCode(-1) + } + args = args[1:] + } + if hasFile { + return r.monitorFile(file) + } + return r.monitorLive() +} + +// monitorFile is the file branch: fopen, then rtnl_from_file with no +// ll_init_map, so a name the cache lacks is an RTM_GETLINK per index +// (MO12). Records are printed as they are read, so a pipe is followed as +// it comes. rtnl_from_file's -1 (a read error, a truncated or malformed +// record) is do_cmd's: main exits 255, a batch line fails and -force goes +// on. Only fopen's failure exits. +func (r *runner) monitorFile(path string) error { + err := nlmon.ReadFile(path, r.acceptTcmsg) + var ne *nlmon.Error + switch { + case err == nil: + return nil + case errors.As(err, &ne) && errors.Is(err, nlmon.ErrOpen): + r.errf("%s\n", ne.Text) // perror("Cannot fopen"); exit(-1) + return exitCode(-1) + case errors.As(err, &ne): + r.errf("%s\n", ne.Text) + return retCode(-1) + } + return err +} + +// monitorLive is rtnl_open with RTNLGRP_TC, ll_init_map on that socket, +// then rtnl_listen, whose failure exits 2. +func (r *runner) monitorLive() error { + ms, ok := r.src.(MonitorSource) + if !ok { + return fmt.Errorf("%w: tc monitor on this source", errNotImplemented) + } + conn, err := ms.Subscribe(nlMgrp(rtnlgrpTCCst), r.stderr) + if err != nil { + r.errf("%v\n", err) + return exitCode(1) + } + defer func() { + if cerr := conn.Close(); cerr != nil && r.errOut == nil { + r.errOut = cerr + } + }() + main := r.src + r.src = conn + err = r.initMap() + r.src = main + if err != nil { + return err + } + err = conn.Listen(func(m nlmon.Msg) error { + if err := r.acceptTcmsg(m); err != nil { + return err + } + r.o.flush() // rtnl_listen's fflush(stdout) after each message + return nil + }) + var ne *nlmon.Error + switch { + case err == nil: + return exitCode(0) + case errors.As(err, &ne) && (errors.Is(err, nlmon.ErrMalformed) || errors.Is(err, nlmon.ErrRemnant)): + r.errf("%s\n", ne.Text) // exit(1) inside rtnl_listen + return exitCode(1) + case errors.As(err, &ne): + r.errf("%s\n", ne.Text) // Truncated message, EOF, a receive error + return exitCode(2) + } + return err +} + +// acceptTcmsg is accept_tcmsg: the stamp first, whatever follows (MO2), +// then the printer by type. A chain goes to print_filter. A type that is +// none of tc's, and not ERROR, NOOP or DONE, is reported with its length +// zero-padded in decimal (MO3). The printers' returns are dropped, as +// accept_tcmsg returns 0 whatever they say. +func (r *runner) acceptTcmsg(nm nlmon.Msg) error { + if r.timestamp > 0 { + r.o.raw(nlmon.Timestamp(r.now(), r.tshort > 0)) + } + m := Msg{Type: nm.Hdr.Type, Flags: nm.Hdr.Flags, Seq: nm.Hdr.Seq, PID: nm.Hdr.Pid, Body: nm.Body} + var err error + switch obj, _ := xtcpnl.TcEventKind(m.Type); obj { + case xtcpnl.TcObjFilter, xtcpnl.TcObjChain: + _, err = r.printFilter(m) + case xtcpnl.TcObjClass: + _, err = r.printClass(m) + case xtcpnl.TcObjQdisc: + _, err = r.printQdisc(m) + case xtcpnl.TcObjAction: + _, err = r.printAction(m) + case xtcpnl.TcObjNone: + if m.Type != unix.NLMSG_ERROR && m.Type != unix.NLMSG_NOOP && m.Type != unix.NLMSG_DONE { + r.errf("Unknown message: length %08d type %08x flags %08x\n", nm.Hdr.Len, m.Type, m.Flags) + } + } + return err +} + +// nowFunc is the monitor's clock: GOTC_NOW (RFC3339) for a replay, else +// the wall clock. +func nowFunc() func() time.Time { return nlmon.NowFunc("GOTC_NOW") } diff --git a/internal/gotc/monitor_corpus_test.go b/internal/gotc/monitor_corpus_test.go new file mode 100644 index 000000000..72d70212e --- /dev/null +++ b/internal/gotc/monitor_corpus_test.go @@ -0,0 +1,174 @@ +package gotc + +import ( + "os" + "path/filepath" + "regexp" + "strconv" + "strings" + "testing" + + "github.com/randomizedcoder/xtcp2/internal/nlmon" + "github.com/randomizedcoder/xtcp2/pkg/xtcpnl" + "golang.org/x/sys/unix" +) + +// monitorStampRe matches both of print_timestamp's forms: the asctime line +// and the -tshort prefix. +var monitorStampRe = regexp.MustCompile(`(?m)^Timestamp: .* usec$|^\[[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9:.]+\] `) + +func maskStamps(s string) string { + return monitorStampRe.ReplaceAllStringFunc(s, func(m string) string { + if strings.HasPrefix(m, "[") { + return "[STAMP] " + } + return "Timestamp: STAMP" + }) +} + +// checkTriggerAfterDump fails a live row whose trigger ran before tc's +// ll_init_map dump ended: any tc message, request or event, ahead of the +// dump's NLMSG_DONE. rtnl_dump_filter drops an event that lands during the +// dump, so such a capture can lose events and still match its until-EREs; +// xtcp2-nl-tcmon waits for rtnl_listen to prevent it. +func checkTriggerAfterDump(t *testing.T, pcap string) { + t.Helper() + msgs, err := nlmon.PcapMsgs(pcap) + if err != nil { + t.Fatal(err) + } + end := nlmon.DumpEnd(msgs, unix.RTM_GETLINK) + if end == 0 { + t.Fatalf("%s: no link dump", pcap) + } + for i, m := range msgs[:end] { + if obj, _ := xtcpnl.TcEventKind(m.Hdr.Type); obj != xtcpnl.TcObjNone { + t.Fatalf("%s: message %d, type %d, comes before the dump ends at %d", pcap, i, m.Hdr.Type, end) + } + } +} + +// shellWords splits a command line the way the rows write them: words +// apart on spaces, and '...' quoting. +func shellWords(s string) []string { + var out []string + var w strings.Builder + in, quoted := false, false + for i := 0; i < len(s); i++ { + c := s[i] + switch { + case quoted && c == '\'': + quoted = false + case quoted: + w.WriteByte(c) + case c == '\'': + quoted, in = true, true + case c == ' ': + if in { + out = append(out, w.String()) + w.Reset() + in = false + } + default: + w.WriteByte(c) + in = true + } + } + if in { + out = append(out, w.String()) + } + return out +} + +// TestShellWords holds the row splitter to the forms the rows use. +func TestShellWords(t *testing.T) { + tests := []struct { + description string + in string + expected string // words joined by | + }{ + {"positive: bare words", "tc monitor file m.bin", "tc|monitor|file|m.bin"}, + {"positive: quoted words", "xtcp2-nl-tcmon '-s monitor' 'tc qdisc add dev d0' 'qdisc'", "xtcp2-nl-tcmon|-s monitor|tc qdisc add dev d0|qdisc"}, + {"boundary: empty", "", ""}, + {"corner: an empty quoted word", "a '' b", "a||b"}, + {"corner: doubled spaces", "a b", "a|b"}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + if got := strings.Join(shellWords(tc.in), "|"); got != tc.expected { + t.Errorf("got %q, want %q", got, tc.expected) + } + }) + } +} + +// TestGotcMonitorCorpus replays every tcmonitor row (gotc 14R): the live +// rows with the monitor's arguments from the helper's first word, the +// offline rows as they are. stdout, stderr and the exit status are held to +// tc's once both stamp forms are masked. An offline row must ask every +// request it recorded; a live row's capture holds the trigger's too. +// +// go test ./internal/gotc/ -run TestGotcMonitorCorpus +func TestGotcMonitorCorpus(t *testing.T) { + base, err := filepath.Abs("../../pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor") + if err != nil { + t.Fatal(err) + } + pschedContent = readFile(t, pschedRow) + entries, err := os.ReadDir(base) + if err != nil { + t.Fatal(err) + } + rows, live := 0, 0 + for _, e := range entries { + if !e.IsDir() { + continue + } + dir := filepath.Join(base, e.Name()) + c := readCmdJSON(t, dir) + rows++ + words := shellWords(c.Cmd) + isLive := len(words) > 0 && words[0] == "xtcp2-nl-tcmon" + if isLive { + live++ + } + t.Run(c.ID, func(t *testing.T) { + if c.Result.Status != "OK" { + t.Fatalf("row status %s", c.Result.Status) + } + var args []string + switch { + case isLive && len(words) >= 3: + args = strings.Fields(words[1]) + case len(words) > 0 && words[0] == "tc": + args = words[1:] + default: + t.Fatalf("cmd %q is neither tc nor the helper", c.Cmd) + } + if isLive { + checkTriggerAfterDump(t, filepath.Join(dir, "ip.pcap")) + } + t.Chdir(dir) + got := replayIn(t, dir, strings.NewReader(""), args...) + wantRC, err := strconv.Atoi(strings.TrimSpace(readFile(t, filepath.Join(dir, "ip.rc")))) + if err != nil { + t.Fatal(err) + } + want := result{ + stdout: maskStamps(readFile(t, filepath.Join(dir, "ip.out"))), + stderr: maskStamps(readFile(t, filepath.Join(dir, "ip.err"))), + rc: wantRC, + } + got.stdout, got.stderr = maskStamps(got.stdout), maskStamps(got.stderr) + if isLive { + got.pending = 0 + } + if got != want { + t.Fatalf("%s\n got %#v\n want %#v", c.Cmd, got, want) + } + }) + } + if rows != 27 || live != 13 { + t.Errorf("%d rows, %d live; want 27, 13", rows, live) + } +} diff --git a/internal/gotc/monitor_test.go b/internal/gotc/monitor_test.go new file mode 100644 index 000000000..bc930f7d5 --- /dev/null +++ b/internal/gotc/monitor_test.go @@ -0,0 +1,293 @@ +package gotc + +import ( + "bytes" + "encoding/binary" + "errors" + "io" + "os" + "path/filepath" + "strings" + "testing" + "time" + + "github.com/randomizedcoder/xtcp2/internal/nlmon" + "github.com/randomizedcoder/xtcp2/pkg/cint" + "github.com/randomizedcoder/xtcp2/pkg/xtcpnl" + "golang.org/x/sys/unix" +) + +// fakeMonSource is a fakeSource (the main socket: link gets) that can +// subscribe: the subscription answers ll_init_map with dump, then plays +// datagrams through a receive of nlmon.RecvBufCst bytes, as the kernel +// would cut them. +type fakeMonSource struct { + fakeSource + dump Reply + dgs [][]byte + subErr error + groups uint32 + connReqs int +} + +func (f *fakeMonSource) Subscribe(groups uint32, _ io.Writer) (MonitorConn, error) { + f.groups = groups + if f.subErr != nil { + return nil, f.subErr + } + return &fakeMonConn{f}, nil +} + +type fakeMonConn struct{ f *fakeMonSource } + +func (c *fakeMonConn) Talk([]byte) (Reply, error) { + c.f.connReqs++ + return c.f.dump, nil +} + +func (c *fakeMonConn) Listen(fn func(nlmon.Msg) error) error { + for _, dg := range c.f.dgs { + n := min(len(dg), nlmon.RecvBufCst) + if err := nlmon.Datagram(dg[:n], len(dg) > n, -1, fn); err != nil { + return err + } + } + return nil +} + +func (c *fakeMonConn) Close() error { return nil } + +// nlm is a whole netlink message: header, then body, padded. +func nlm(typ, flags uint16, body []byte) []byte { + n, _ := cint.U32(nlHeaderLen + len(body)) + b := binary.LittleEndian.AppendUint32(nil, n) + b = binary.LittleEndian.AppendUint16(b, typ) + b = binary.LittleEndian.AppendUint16(b, flags) + b = append(b, make([]byte, 8)...) // seq, pid + b = append(b, body...) + for len(b)%4 != 0 { + b = append(b, 0) + } + return b +} + +// recordWriter counts the writes that reach it: one per flush. +type recordWriter struct { + bytes.Buffer + writes int +} + +func (w *recordWriter) Write(p []byte) (int, error) { + w.writes++ + return w.Buffer.Write(p) +} + +const ( + tcHMinIngressCst = 0xFFFFFFF2 // TC_H_MAKE(TC_H_CLSACT, TC_H_MIN_INGRESS): "ingress" + tcHRootCst = 0xFFFFFFFF + monCreate = unix.NLM_F_CREATE + monExcl = unix.NLM_F_EXCL + monReplace = unix.NLM_F_REPLACE +) + +// TestGotcMonitorUnit holds doTcMonitor, acceptTcmsg and the printers' +// event branches to tc_monitor.c with crafted events, live (a fake +// subscription) and from files. +// +// go test ./internal/gotc/ -run TestGotcMonitorUnit +func TestGotcMonitorUnit(t *testing.T) { + noqueue := tcBody(2, 0, tcHRootCst, 1, kind("noqueue")) // refcnt 1 is not printed + noqueueD1 := tcBody(3, 0, tcHRootCst, 1, kind("noqueue")) + matchall := tcBody(2, 0, tcHMinIngressCst, 2<<16|0x0300, kind("matchall"), attr(xtcpnl.TcaChain, le32(0))) + chain1 := tcBody(2, 0, 0xFFFF0000, 0, attr(xtcpnl.TcaChain, le32(1))) + gact := func(index uint32) []byte { + return cat(make([]byte, xtcpnl.TcaMsgSizeCst), attr(xtcpnl.TcaRootTab, + actOrder(1, "gact", attr(xtcpnl.TcaGactParms, genB(index, 0, 1, 0))))) + } + flushBody := func(orders ...uint16) []byte { + var tab []byte + for _, o := range orders { + tab = cat(tab, nest(o, attr(xtcpnl.TcaKind, str0("gact")), attr(xtcpnl.TcaFcnt, le32(3)))) + } + return cat(make([]byte, xtcpnl.TcaMsgSizeCst), attr(xtcpnl.TcaRootTab, tab)) + } + classDel := tcBody(2, 0x10001, 0x10000, 0, kind("htb")) + big := func(total int) []byte { return nlm(unix.RTM_NEWLINK, 0, make([]byte, total-nlHeaderLen)) } + + const ( + qNoqueue = "qdisc noqueue 0: dev d0 root \n" + gactLines = "\taction order 1: gact action pass\n\t random type none pass val 0\n\t index 7 ref 1 bind 0\n" + ) + stamp := "Timestamp: Wed Nov 25 10:00:00 2026 123 usec\n" + stampShort := "[2026-11-25T10:00:00.000123] " + + type want struct { + stdout, stderr string + rc int + } + tests := []struct { + description string + args []string + dgs [][]byte // live events, one datagram each + file []byte // written to F, which "F" in args names + stdin string // -batch - + replies []Reply // the main socket's + check func(*fakeMonSource, *recordWriter) string // "" when fine + expected want + }{ + // Positive. + {"positive: a NEWQDISC event with flags 0 says neither added nor replaced (MO6)", []string{"monitor"}, + [][]byte{nlm(unix.RTM_NEWQDISC, 0, noqueue)}, nil, "", nil, nil, want{stdout: qNoqueue}}, + {"positive: DELQDISC and NEWQDISC in one datagram (K20)", []string{"monitor"}, + [][]byte{cat(nlm(unix.RTM_DELQDISC, 0, noqueue), nlm(unix.RTM_NEWQDISC, monReplace, noqueue))}, nil, "", nil, nil, + want{stdout: "deleted " + qNoqueue + qNoqueue}}, + {"positive: filter add (CREATE|EXCL), replace (CREATE), change (0), delete (MO7)", []string{"monitor"}, + [][]byte{nlm(unix.RTM_NEWTFILTER, monCreate|monExcl, matchall), nlm(unix.RTM_NEWTFILTER, monCreate, matchall), + nlm(unix.RTM_NEWTFILTER, 0, matchall), nlm(unix.RTM_DELTFILTER, 0, matchall)}, nil, "", nil, nil, + want{stdout: "added filter dev d0 ingress protocol all pref 2 matchall chain 0 \n" + + "replaced filter dev d0 ingress protocol all pref 2 matchall chain 0 \n" + + "filter dev d0 ingress protocol all pref 2 matchall chain 0 \n" + + "deleted filter dev d0 ingress protocol all pref 2 matchall chain 0 \n"}}, + {"positive: action add, replace, delete and flush, each after total acts 0 (MO9)", []string{"monitor"}, + [][]byte{nlm(unix.RTM_NEWACTION, monCreate|monExcl, gact(7)), nlm(unix.RTM_NEWACTION, monCreate|monReplace, gact(7)), + nlm(unix.RTM_DELACTION, 0, gact(7)), nlm(unix.RTM_DELACTION, unix.NLM_F_ROOT, flushBody(0))}, nil, "", nil, nil, + want{stdout: "total acts 0\nAdded action \n" + gactLines + "total acts 0\nReplaced action \n" + gactLines + + "total acts 0\nDeleted action \n" + gactLines + "total acts 0\nFlushed table gact (3 entries)\n"}}, + {"positive: NEWCHAIN and DELCHAIN go to print_filter", []string{"monitor"}, + [][]byte{nlm(unix.RTM_NEWCHAIN, monCreate|monExcl, chain1), nlm(unix.RTM_DELCHAIN, 0, chain1)}, nil, "", nil, nil, + want{stdout: "added chain dev d0 parent ffff: chain 1 \ndeleted chain dev d0 parent ffff: chain 1 \n"}}, + {"positive: -t puts a line ahead of each event", []string{"-t", "monitor"}, + [][]byte{nlm(unix.RTM_NEWQDISC, 0, noqueue)}, nil, "", nil, nil, want{stdout: stamp + qNoqueue}}, + {"positive: -tshort alone stamps, in brackets ahead", []string{"-tshort", "monitor"}, + [][]byte{nlm(unix.RTM_NEWQDISC, 0, noqueue)}, nil, "", nil, nil, want{stdout: stampShort + qNoqueue}}, + {"positive: the subscription is RTNLGRP_TC, and ll_init_map runs on it", []string{"monitor"}, + [][]byte{nlm(unix.RTM_NEWQDISC, 0, noqueue)}, nil, "", nil, + func(f *fakeMonSource, _ *recordWriter) string { + if f.groups != 0x8 || f.connReqs != 1 || len(f.reqs) != 0 { + return "groups, subscription requests or main requests wrong" + } + return "" + }, want{stdout: qNoqueue}}, + {"positive: stdout is flushed after each event", []string{"monitor"}, + [][]byte{nlm(unix.RTM_NEWQDISC, 0, noqueue), nlm(unix.RTM_NEWQDISC, 0, noqueue)}, nil, "", nil, + func(_ *fakeMonSource, w *recordWriter) string { + if w.writes != 2 { + return "not one write per event" + } + return "" + }, want{stdout: qNoqueue + qNoqueue}}, + // Negative. + {"negative: an unknown word (MO14)", []string{"monitor", "bogus"}, nil, nil, "", nil, nil, + want{stderr: "Argument \"bogus\" is unknown, try \"tc monitor help\".\n", rc: 255}}, + {"negative: help, whose usage leaves a [ open (MO1)", []string{"monitor", "help"}, nil, nil, "", nil, nil, + want{stderr: monitorUsage, rc: 255}}, + {"negative: file with no value", []string{"monitor", "file"}, nil, nil, "", nil, nil, + want{stderr: "Command line is not complete. Try option \"help\"\n", rc: 255}}, + {"negative: no such file", []string{"monitor", "file", "/nonexistent/m.bin"}, nil, nil, "", nil, nil, + want{stderr: "Cannot fopen: No such file or directory\n", rc: 255}}, + {"negative: a directory opens, then its fread fails, which returns -1", []string{"monitor", "file", "/"}, nil, nil, "", nil, nil, + want{stderr: "rtnl_from_file: fread: Is a directory\n", rc: 255}}, + {"negative: a subscription that fails exits 1", []string{"monitor"}, nil, nil, "", nil, nil, + want{stderr: "subscribe failed\n", rc: 1}}, + {"negative: a file cut inside a record (MO13)", []string{"monitor", "file", "F"}, nil, + nlm(unix.RTM_NEWQDISC, 0, noqueue)[:30], "", nil, nil, + want{stderr: "rtnl-from_file: truncated message\n", rc: 255}}, + {"negative: a record of length 8 (MO13)", []string{"monitor", "file", "F"}, nil, + cat(le32(8), make([]byte, 12)), "", nil, nil, want{stderr: "!!!malformed message: len=8 @16\n", rc: 255}}, + // Boundary. + {"boundary: a 16385-byte event is cut: Truncated message, exit 2 (MO5)", []string{"monitor"}, + [][]byte{nlm(unix.RTM_NEWQDISC, 0, noqueue), big(16385)}, nil, "", nil, nil, + want{stdout: qNoqueue, stderr: "Truncated message\n", rc: 2}}, + {"boundary: a 16384-byte message fits", []string{"monitor"}, [][]byte{big(16384)}, nil, "", nil, nil, + want{stderr: "Unknown message: length 00016384 type 00000010 flags 00000000\n"}}, + {"boundary: an empty file", []string{"monitor", "file", "F"}, nil, []byte{}, "", nil, nil, want{}}, + // Corner. + {"corner: -j monitor prints text (MO4)", []string{"-j", "monitor"}, + [][]byte{nlm(unix.RTM_NEWQDISC, 0, noqueue)}, nil, "", nil, nil, want{stdout: qNoqueue}}, + {"corner: -t over a DONE record stamps with nothing after (MO2)", []string{"-t", "monitor", "file", "F"}, nil, + nlm(unix.NLMSG_DONE, 0, le32(0)), "", nil, nil, want{stdout: stamp}}, + {"corner: an RTM_NEWLINK in a file, its length zero-padded decimal (MO3)", []string{"monitor", "file", "F"}, nil, + nlm(unix.RTM_NEWLINK, 0, make([]byte, 16)), "", nil, nil, + want{stderr: "Unknown message: length 00000032 type 00000010 flags 00000000\n"}}, + {"corner: crafted CREATE|EXCL and CREATE|REPLACE qdisc events reach added and replaced (MO6)", []string{"monitor"}, + [][]byte{nlm(unix.RTM_NEWQDISC, monCreate|monExcl, noqueue), nlm(unix.RTM_NEWQDISC, monCreate|monReplace, noqueue)}, + nil, "", nil, nil, want{stdout: "added " + qNoqueue + "replaced " + qNoqueue}}, + {"corner: EXCL or REPLACE without CREATE is neither added nor replaced (MO6)", []string{"monitor"}, + [][]byte{nlm(unix.RTM_NEWQDISC, monExcl, noqueue), nlm(unix.RTM_NEWQDISC, monReplace, noqueue)}, + nil, "", nil, nil, want{stdout: qNoqueue + qNoqueue}}, + {"corner: after a flush is printed, an order-0 table prints as actions", []string{"monitor"}, + [][]byte{nlm(unix.RTM_DELACTION, unix.NLM_F_ROOT, flushBody(0)), nlm(unix.RTM_NEWACTION, 0, + cat(make([]byte, xtcpnl.TcaMsgSizeCst), attr(xtcpnl.TcaRootTab, actOrder(0, "gact", attr(xtcpnl.TcaGactParms, genB(7, 0, 1, 0))))))}, + nil, "", nil, nil, want{stdout: "total acts 0\nFlushed table gact (3 entries)\ntotal acts 0\n\n" + + strings.Replace(gactLines, "order 1", "order 0", 1)}}, + {"corner: a batch's qdisc show dev d0 filters the file's qdisc events (MO11)", []string{"-batch", "-"}, nil, + cat(nlm(unix.RTM_NEWQDISC, 0, noqueueD1), nlm(unix.RTM_NEWQDISC, 0, noqueue)), "qdisc show dev d0\nmonitor file F\n", + []Reply{links(), rep(done())}, nil, want{stdout: "qdisc noqueue 0: root \n"}}, + {"corner: a -force batch goes on past a truncated file, which returns -1 (MO16)", []string{"-force", "-batch", "-"}, nil, + nlm(unix.RTM_NEWQDISC, 0, noqueue)[:30], "monitor file F\nmonitor file F\n", []Reply{links()}, nil, + want{stderr: "rtnl-from_file: truncated message\nCommand failed -:1\nrtnl-from_file: truncated message\nCommand failed -:2\n", rc: 1}}, + {"corner: a -force batch goes on past a read error, which returns -1 as a truncated file does (MO16)", []string{"-force", "-batch", "-"}, nil, + nil, "monitor file /\nmonitor file /\n", []Reply{links()}, nil, + want{stderr: "rtnl_from_file: fread: Is a directory\nCommand failed -:1\nrtnl_from_file: fread: Is a directory\nCommand failed -:2\n", rc: 1}}, + {"corner: a -force batch ends at a missing file, whose fopen failure calls exit (MO16)", []string{"-force", "-batch", "-"}, nil, + nil, "monitor file /nonexistent/m.bin\nmonitor file /nonexistent/m.bin\n", []Reply{links()}, nil, + want{stderr: "Cannot fopen: No such file or directory\n", rc: 255}}, + {"corner: a class DEL under -j is text; the null branch is unreachable (MO8)", []string{"-j", "monitor"}, + [][]byte{nlm(unix.RTM_DELTCLASS, 0, classDel)}, nil, "", nil, nil, + want{stdout: "deleted class htb 1:1 dev d0 parent 1: \n"}}, + {"corner: file mode skips ll_init_map; an unknown ifindex is one RTM_GETLINK (MO12)", []string{"monitor", "file", "F"}, nil, + nlm(unix.RTM_NEWQDISC, 0, noqueue), "", []Reply{rep(linkMsg(2, "x2"))}, + func(f *fakeMonSource, _ *recordWriter) string { + if len(f.reqs) != 1 || f.connReqs != 0 { + return "not one link get on the main socket" + } + if typ := binary.LittleEndian.Uint16(f.reqs[0][4:6]); typ != unix.RTM_GETLINK { + return "the request is not RTM_GETLINK" + } + return "" + }, want{stdout: "qdisc noqueue 0: dev x2 root \n"}}, + {"corner: a flush table that is not order 0 alone leaves tab_flush set for the next (MO15)", []string{"monitor"}, + [][]byte{nlm(unix.RTM_DELACTION, unix.NLM_F_ROOT, flushBody(0, 1)), nlm(unix.RTM_NEWACTION, 0, flushBody(0))}, nil, "", nil, nil, + // In an ordinary table TCA_FCNT (6) reads as TCA_ACT_COOKIE. + want{stdout: "total acts 0\nFlushed table \n\taction order 0: gact \tcookie 03000000\n\n\taction order 1: gact \tcookie 03000000\n" + + "total acts 0\n gact (3 entries)\n"}}, + } + now := time.Date(2026, 11, 25, 10, 0, 0, 123000, time.Local) + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + src := &fakeMonSource{fakeSource: fakeSource{replies: tc.replies}, dump: links(), dgs: tc.dgs} + if strings.HasPrefix(tc.expected.stderr, "subscribe failed") { + src.subErr = errors.New("subscribe failed") + } + args := tc.args + if tc.file != nil { + dir := t.TempDir() + path := filepath.Join(dir, "F") + if err := os.WriteFile(path, tc.file, 0o600); err != nil { + t.Fatal(err) + } + t.Chdir(dir) + } + var out recordWriter + var errb bytes.Buffer + cfg := config{src: src, stdin: strings.NewReader(tc.stdin), sys: emptySys(t), now: func() time.Time { return now }} + rc := run(cfg, args, &out, &errb) + got := want{stdout: out.String(), stderr: errb.String(), rc: rc} + if got != tc.expected { + t.Fatalf("tc %q\n got %#v\n want %#v", args, got, tc.expected) + } + if tc.check != nil { + if msg := tc.check(src, &out); msg != "" { + t.Error(msg) + } + } + }) + } + t.Run("negative: a source with no monitor support is refused", func(t *testing.T) { + var out, errb bytes.Buffer + rc := run(config{src: &fakeSource{}, sys: emptySys(t)}, []string{"monitor"}, &out, &errb) + if rc != 255 || !strings.Contains(errb.String(), "not implemented: tc monitor on this source") { + t.Errorf("rc %d stderr %q", rc, errb.String()) + } + }) +} diff --git a/internal/gotc/print.go b/internal/gotc/print.go index 1028f29ec..8e816900f 100644 --- a/internal/gotc/print.go +++ b/internal/gotc/print.go @@ -84,6 +84,13 @@ func (o *out) raw(s string) { func (o *out) printf(s string) { o.raw(s) } +// flush is fflush(stdout). +func (o *out) flush() { + if err := o.w.Flush(); err != nil && o.err == nil { + o.err = err + } +} + // newJSONObj is new_json_obj: with -j, open the writer and its array. func (o *out) newJSONObj() { if o.json { diff --git a/internal/gotc/qdisc.go b/internal/gotc/qdisc.go index 43ca879cb..0679bcc9f 100644 --- a/internal/gotc/qdisc.go +++ b/internal/gotc/qdisc.go @@ -286,12 +286,25 @@ func hasAttr(attrs []uint16, t uint16) bool { return false } -func (r *runner) printQdiscBody(m Msg, ti *xtcpnl.TcInfo, q *qdiscUtil) error { - o, t := r.o, ti.Hdr - o.openObject("") +// printQdiscEvent is print_qdisc's event words. replaced and added both +// need NLM_F_CREATE, which qdisc_notify never sends: its flags are 0 or +// NLM_F_REPLACE (MO6, K19), so only a crafted event reaches them. +func printQdiscEvent(o *out, m Msg) { if m.Type == unix.RTM_DELQDISC { o.boolean(printAny, "deleted", "deleted ", true) } + if m.Type == unix.RTM_NEWQDISC && m.Flags&unix.NLM_F_CREATE != 0 && m.Flags&unix.NLM_F_REPLACE != 0 { + o.boolean(printAny, "replaced", "replaced ", true) + } + if m.Type == unix.RTM_NEWQDISC && m.Flags&unix.NLM_F_CREATE != 0 && m.Flags&unix.NLM_F_EXCL != 0 { + o.boolean(printAny, "added", "added ", true) + } +} + +func (r *runner) printQdiscBody(m Msg, ti *xtcpnl.TcInfo, q *qdiscUtil) error { + o, t := r.o, ti.Hdr + o.openObject("") + printQdiscEvent(o, m) o.str(printAny, colorNone, "kind", "qdisc "+ti.Kind, ti.Kind) h := u32hex(t.Handle>>16) + ":" o.str(printAny, colorNone, "handle", " "+h, h) diff --git a/internal/gotc/source.go b/internal/gotc/source.go index 083207024..54ca8d19d 100644 --- a/internal/gotc/source.go +++ b/internal/gotc/source.go @@ -26,7 +26,10 @@ type Source interface { var ErrReplay = errors.New("gotc: replay") // ReplaySource answers from a ws pcap capture, request by request. -type ReplaySource struct{ *wsreplay.Replay } +type ReplaySource struct { + *wsreplay.Replay + path string // the capture, which a monitor's Subscribe reads again +} // NewReplaySource opens the ws pcap at path. func NewReplaySource(path string) (*ReplaySource, error) { @@ -34,7 +37,7 @@ func NewReplaySource(path string) (*ReplaySource, error) { if err != nil { return nil, err } - return &ReplaySource{Replay: r}, nil + return &ReplaySource{Replay: r, path: path}, nil } // errLive wraps a live socket failure. diff --git a/internal/gotc/source_monitor.go b/internal/gotc/source_monitor.go new file mode 100644 index 000000000..f25d05039 --- /dev/null +++ b/internal/gotc/source_monitor.go @@ -0,0 +1,172 @@ +package gotc + +import ( + "bytes" + "errors" + "fmt" + "io" + + "github.com/randomizedcoder/xtcp2/internal/nlmon" + "github.com/randomizedcoder/xtcp2/internal/wsreplay" + "github.com/randomizedcoder/xtcp2/pkg/xtcpnl" + "golang.org/x/sys/unix" +) + +// rcvbufCst and sndbufCst are rtnl_open's socket buffers +// (lib/libnetlink.c: rcvbuf = 1024 * 1024, sndbuf = 32768). +const ( + rcvbufCst = 1 << 20 + sndbufCst = 32768 +) + +// Subscribe is rtnl_open(&rth, groups): a new socket bound to the groups, +// with rtnl_open's buffers and extended acks. errOut takes what +// rtnl_listen prints and carries on after. +func (s *LiveSource) Subscribe(groups uint32, errOut io.Writer) (MonitorConn, error) { + fd, err := unix.Socket(unix.AF_NETLINK, unix.SOCK_RAW|unix.SOCK_CLOEXEC, unix.NETLINK_ROUTE) + if err != nil { + return nil, fmt.Errorf("%w: socket: %w", errLive, err) + } + c := &liveMonitorConn{fd: fd, errOut: errOut, buf: make([]byte, 1<<20)} + abandon := func(cause error) error { return errors.Join(cause, c.Close()) } + if err := unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_SNDBUF, sndbufCst); err != nil { + return nil, abandon(fmt.Errorf("%w: SO_SNDBUF: %w", errLive, err)) + } + if err := unix.SetsockoptInt(fd, unix.SOL_SOCKET, unix.SO_RCVBUF, rcvbufCst); err != nil { + return nil, abandon(fmt.Errorf("%w: SO_RCVBUF: %w", errLive, err)) + } + if err := unix.SetsockoptInt(fd, unix.SOL_NETLINK, unix.NETLINK_EXT_ACK, 1); err != nil { + return nil, abandon(fmt.Errorf("%w: NETLINK_EXT_ACK: %w", errLive, err)) + } + if err := unix.Bind(fd, &unix.SockaddrNetlink{Family: unix.AF_NETLINK, Groups: groups}); err != nil { + return nil, abandon(fmt.Errorf("%w: bind: %w", errLive, err)) + } + sa, err := unix.Getsockname(fd) + if err != nil { + return nil, abandon(fmt.Errorf("%w: getsockname: %w", errLive, err)) + } + if nl, ok := sa.(*unix.SockaddrNetlink); ok { + c.pid = nl.Pid + } + return c, nil +} + +// liveMonitorConn is the subscribed socket. +type liveMonitorConn struct { + fd int + pid uint32 // the socket's port id, rth->local.nl_pid + errOut io.Writer + buf []byte +} + +// Close releases the socket. +func (c *liveMonitorConn) Close() error { + if c.fd < 0 { + return nil + } + err := unix.Close(c.fd) + c.fd = -1 + return err +} + +// Talk sends req and reads its reply as rtnl_dump_filter does on a +// subscribed socket: a message not to this socket's port id with the +// request's sequence number is a notification, and is skipped. +func (c *liveMonitorConn) Talk(req []byte) (Reply, error) { + if len(req) < nlHeaderLen { + return Reply{}, fmt.Errorf("%w: a request of %d bytes", errLive, len(req)) + } + seq := xtcpnl.NativeEndian().Uint32(req[8:12]) + if err := unix.Sendto(c.fd, req, 0, &unix.SockaddrNetlink{Family: unix.AF_NETLINK}); err != nil { + return Reply{}, fmt.Errorf("%w: send: %w", errLive, err) + } + var rep Reply + for { + n, _, err := unix.Recvfrom(c.fd, c.buf, 0) + if err != nil { + return Reply{}, fmt.Errorf("%w: recv: %w", errLive, err) + } + for _, m := range wsreplay.SplitMsgs(c.buf[:n]) { + if m.PID != c.pid || m.Seq != seq { + continue + } + m.Body = append([]byte(nil), m.Body...) + rep.Msgs = append(rep.Msgs, m) + if m.Type == unix.NLMSG_DONE || m.Type == unix.NLMSG_ERROR || m.Flags&unix.NLM_F_MULTI == 0 { + return rep, nil + } + } + } +} + +// Listen is rtnl_listen on the socket. +func (c *liveMonitorConn) Listen(fn func(nlmon.Msg) error) error { + return nlmon.Listen(c.fd, nlmon.ListenOpts{ErrOut: c.errOut}, fn) +} + +// Subscribe on a replay is its capture's notifications, as internal/nlmon +// classifies them, whatever the groups: the capture holds what the kernel +// sent the monitor that ran, the trigger's requests and acks among it. +func (s *ReplaySource) Subscribe(uint32, io.Writer) (MonitorConn, error) { + msgs, err := nlmon.PcapMsgs(s.path) + if err != nil { + return nil, errors.Join(ErrReplay, err) + } + return &replayMonitorConn{msgs: msgs, notes: nlmon.Notifications(msgs)}, nil +} + +// replayMonitorConn plays a monitor capture: the dump run on the +// subscription, then the notifications after it. +type replayMonitorConn struct { + msgs []nlmon.Msg + notes []int + start int // past the last dump answered: what came before is lost +} + +// Talk answers a dump from the capture: the first request from start on +// with the same type and flags and the same body, then every message with +// its sequence number that is not a request, through its NLMSG_DONE or +// NLMSG_ERROR. The trigger's requests in between are another process's, +// so this does not go through the source's in-order replay. +func (c *replayMonitorConn) Talk(req []byte) (Reply, error) { + if len(req) < nlHeaderLen { + return Reply{}, fmt.Errorf("%w: a request of %d bytes", ErrReplay, len(req)) + } + ne := xtcpnl.NativeEndian() + typ, flags := ne.Uint16(req[4:6]), ne.Uint16(req[6:8]) + at := -1 + for i := c.start; i < len(c.msgs); i++ { + h := &c.msgs[i].Hdr + if h.Type == typ && h.Flags == flags && h.Pid == 0 && bytes.Equal(c.msgs[i].Body, req[nlHeaderLen:]) { + at = i + break + } + } + if at < 0 { + return Reply{}, fmt.Errorf("%w: the monitor's request %x is not in the capture", ErrReplay, req) + } + seq := c.msgs[at].Hdr.Seq + var rep Reply + for i := at + 1; i < len(c.msgs); i++ { + m := &c.msgs[i] + h := m.Hdr + if h.Seq != seq || (h.Flags&unix.NLM_F_REQUEST != 0 && h.Pid == 0) { + continue + } + rep.Msgs = append(rep.Msgs, Msg{Type: h.Type, Flags: h.Flags, Seq: h.Seq, PID: h.Pid, Body: m.Body}) + if h.Type == unix.NLMSG_DONE || h.Type == unix.NLMSG_ERROR || h.Flags&unix.NLM_F_MULTI == 0 { + c.start = i + 1 + return rep, nil + } + } + return Reply{}, fmt.Errorf("%w: the monitor's dump has no NLMSG_DONE", ErrReplay) +} + +// Listen hands each notification from start on to fn, through +// rtnl_listen's 16384-byte buffer (MO5). +func (c *replayMonitorConn) Listen(fn func(nlmon.Msg) error) error { + return nlmon.Replay(c.msgs, c.notes, c.start, 0, fn) +} + +// Close has nothing to release. +func (c *replayMonitorConn) Close() error { return nil } diff --git a/internal/gotc/unit_test.go b/internal/gotc/unit_test.go index e65f78828..c6be761dd 100644 --- a/internal/gotc/unit_test.go +++ b/internal/gotc/unit_test.go @@ -130,8 +130,10 @@ func TestGotcOptions(t *testing.T) { want{stderr: "Object \"bogus\" is unknown, try \"tc help\".\n", rc: 255}}, {"negative: actions list with no kind is act_usage, no request sent", []string{"actions", "list"}, nil, want{stderr: actUsageText, rc: 255}}, - {"negative: monitor and exec are refused", []string{"mon"}, nil, - want{stderr: notImpl + "tc monitor\n", rc: 255}}, + {"negative: a live monitor on a source that cannot subscribe is refused", []string{"mon"}, nil, + want{stderr: notImpl + "tc monitor on this source\n", rc: 255}}, + {"negative: exec is refused", []string{"exec"}, nil, + want{stderr: notImpl + "tc exec\n", rc: 255}}, {"negative: a qdisc write is refused", []string{"qdisc", "add", "dev", "d0", "root", "fq"}, nil, want{stderr: notImpl + "tc qdisc add\n", rc: 255}}, {"negative: a class write is refused", []string{"class", "change"}, nil, @@ -258,7 +260,7 @@ func TestGotcBatch(t *testing.T) { {"negative: a failed link dump exits 1", []string{"-batch", "-"}, "qdisc help\n", []Reply{rep(nlErr(unix.EPERM))}, want{stderr: "RTNETLINK answers: Operation not permitted\nDump terminated\n", rc: 1, reqs: 1}}, {"negative: a refused object ends even a -force batch", []string{"-force", "-batch", "-"}, "monitor\nqdisc help\n", - []Reply{links()}, want{stderr: notImpl + "tc monitor\n", rc: 255, reqs: 1}}, + []Reply{links()}, want{stderr: notImpl + "tc monitor on this source\n", rc: 255, reqs: 1}}, {"boundary: an empty batch", []string{"-batch", "-"}, "", []Reply{links()}, want{reqs: 1}}, {"boundary: Command failed counts physical lines", []string{"-batch", "-"}, "\n# c\nqdisc \\\nhelp\nbogus\n", []Reply{links()}, want{stderr: qdiscUsageText + "Object \"bogus\" is unknown, try \"tc help\".\nCommand failed -:5\n", rc: 1, reqs: 1}}, diff --git a/internal/nlmon/bench_test.go b/internal/nlmon/bench_test.go new file mode 100644 index 000000000..09d5efc00 --- /dev/null +++ b/internal/nlmon/bench_test.go @@ -0,0 +1,132 @@ +package nlmon + +import ( + "bytes" + "path/filepath" + "testing" + + "github.com/randomizedcoder/xtcp2/pkg/xtcpnl" + "golang.org/x/sys/unix" +) + +// qdiscEvents is n NEWQDISC events of 400 bytes each in one datagram, about +// what a 16 KiB receive holds. +func qdiscEvents(n int) []byte { + b := make([]byte, 0, 400*n) + for range n { + b = append(b, rec(unix.RTM_NEWQDISC, make([]byte, 400-xtcpnl.NlMsgHdrSizeCst))...) + } + return b +} + +// fileOf is n records for FromFile. +func fileOf(n int) []byte { + b := make([]byte, 0, 116*n) + for range n { + b = append(b, rec(unix.RTM_NEWTFILTER, make([]byte, 100))...) + } + return b +} + +func discard(Msg) error { return nil } + +// BenchmarkDatagram is rtnl_listen's walk of a full datagram. +// +// go test ./internal/nlmon/ -run '^$' -bench Datagram -benchmem +func BenchmarkDatagram(b *testing.B) { + dg := qdiscEvents(40) + b.ReportAllocs() + b.SetBytes(int64(len(dg))) + for b.Loop() { + if err := Datagram(dg, false, -1, discard); err != nil { + b.Fatal(err) + } + } + b.ReportMetric(float64(b.Elapsed().Nanoseconds())/float64(b.N*40), "ns/msg") +} + +// BenchmarkFromFile is rtnl_from_file over 1000 records. +// +// go test ./internal/nlmon/ -run '^$' -bench FromFile -benchmem +func BenchmarkFromFile(b *testing.B) { + f := fileOf(1000) + var r bytes.Reader + b.ReportAllocs() + b.SetBytes(int64(len(f))) + for b.Loop() { + r.Reset(f) + if err := FromFile(&r, discard); err != nil { + b.Fatal(err) + } + } + b.ReportMetric(float64(b.Elapsed().Nanoseconds())/float64(b.N*1000), "ns/msg") +} + +// BenchmarkNotifications classifies goip's monitor capture and every +// tcmonitor capture (gotc 14P). +// +// go test ./internal/nlmon/ -run '^$' -bench Notifications -benchmem +func BenchmarkNotifications(b *testing.B) { + tcPcaps, err := filepath.Glob("../../pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/*/ip.pcap") + if err != nil || len(tcPcaps) == 0 { + b.Fatalf("tcmonitor pcaps: %d, %v", len(tcPcaps), err) + } + for _, bc := range []struct { + name string + pcaps []string + }{{"ipmonitor", []string{monitorAllPcap}}, {"tcmonitor", tcPcaps}} { + caps := make([][]Msg, 0, len(bc.pcaps)) + n := 0 + for _, p := range bc.pcaps { + ms, err := PcapMsgs(p) + if err != nil { + b.Fatal(err) + } + caps = append(caps, ms) + n += len(ms) + } + b.Run(bc.name, func(b *testing.B) { + b.ReportAllocs() + for b.Loop() { + for _, ms := range caps { + Notifications(ms) + } + } + b.ReportMetric(float64(b.Elapsed().Nanoseconds())/float64(b.N*n), "ns/msg") + }) + } +} + +// TestAllocs pins the walks' allocations: the bodies are subslices, so a +// walk allocates nothing per message; a file walk allocates its one buffer. +// +// go test ./internal/nlmon/ -run TestAllocs +func TestAllocs(t *testing.T) { + big := rec(unix.RTM_NEWTFILTER, make([]byte, RecvBufCst-xtcpnl.NlMsgHdrSizeCst)) + dg40, file1000 := qdiscEvents(40), fileOf(1000) + var r bytes.Reader + tests := []struct { + description string + run func() + budget float64 + }{ + {"positive: a datagram of 40 events", func() { mustNil(t, Datagram(dg40, false, -1, discard)) }, 0}, + {"positive: a file of 1000 records, one buffer for all", func() { r.Reset(file1000); mustNil(t, FromFile(&r, discard)) }, 1}, + {"boundary: a 16384-byte message", func() { mustNil(t, Datagram(big, false, -1, discard)) }, 0}, + {"corner: an empty datagram", func() { mustNil(t, Datagram(nil, false, -1, discard)) }, 0}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + if got := testing.AllocsPerRun(100, tc.run); got > tc.budget { + t.Errorf("%v allocs, budget %v", got, tc.budget) + } + }) + } +} + +func mustNil(t *testing.T, err error) { + t.Helper() + if err != nil { + t.Fatal(err) + } +} diff --git a/internal/nlmon/nlmon.go b/internal/nlmon/nlmon.go new file mode 100644 index 000000000..4e5734be7 --- /dev/null +++ b/internal/nlmon/nlmon.go @@ -0,0 +1,298 @@ +// Package nlmon is the monitor core the iproute2 clones share (goip's +// `ip monitor` and its xfrm, genl and mptcp siblings, gotc's `tc monitor`): +// lib/libnetlink.c's rtnl_listen and rtnl_from_file, lib/utils.c's +// print_timestamp, and the split of an nlmon capture into what a subscriber +// was sent. +// +// Errors carry the tool's own text, so a clone prints err.Error() as the C +// prints its message, and a Kind sentinel a clone maps to its exit status. +package nlmon + +import ( + "errors" + "fmt" + "io" + "os" + "strings" + "time" + + "github.com/randomizedcoder/xtcp2/pkg/xtcpnl" + "golang.org/x/sys/unix" +) + +// RecvBufCst is rtnl_listen's and rtnl_from_file's `char buf[16384]`. +const RecvBufCst = 16384 + +// cmsgBufCst is room for rtnl_listen's one control message, an int. +const cmsgBufCst = 64 + +// Msg is one message a monitor's accept function is handed: its header, +// its body past the header, and the netns id a NETLINK_LISTEN_ALL_NSID +// socket names it with, -1 for none. Off is where it starts in its +// datagram, so a replay can tell what a receive buffer would have cut. +type Msg struct { + Hdr xtcpnl.NlMsgHdr + Body []byte + Nsid int32 + Off int +} + +// Kinds of Error, for a clone's exit status. +var ( + // ErrOpen is rtnl_from_file's caller failing to fopen the file. + ErrOpen = errors.New("nlmon: open") + // ErrRead is rtnl_from_file's fread failing (ferror): -1. + ErrRead = errors.New("nlmon: read") + // ErrFileTruncated is rtnl_from_file's short read: -1. + ErrFileTruncated = errors.New("nlmon: file truncated") + // ErrMalformed is a length under the header's or past the data: in + // rtnl_listen exit(1), in rtnl_from_file -1. + ErrMalformed = errors.New("nlmon: malformed") + // ErrTruncated is rtnl_listen's MSG_TRUNC on a message cut short: -1. + ErrTruncated = errors.New("nlmon: truncated") + // ErrRemnant is rtnl_listen's bytes left past the last message: exit(1). + ErrRemnant = errors.New("nlmon: remnant") + // ErrRecv is rtnl_listen's receive error or EOF: -1. + ErrRecv = errors.New("nlmon: receive") +) + +// Error is a failure with the C's message as its text. +type Error struct { + Kind error + Text string +} + +// Error is the C's message. +func (e *Error) Error() string { return e.Text } + +// Unwrap is the kind. +func (e *Error) Unwrap() error { return e.Kind } + +func errorf(kind error, format string, a ...any) error { + return &Error{Kind: kind, Text: fmt.Sprintf(format, a...)} +} + +// align is NLMSG_ALIGN. +func align(n int) int { return (n + 3) &^ 3 } + +// Datagram is rtnl_listen's walk of one datagram: each message to fn, in +// order, until fn fails. A length under the header's or past the datagram +// is ErrTruncated when the datagram was cut short (MSG_TRUNC), else +// ErrMalformed. A truncated datagram whose messages all fit ends with nil +// and no remnant check, as rtnl_listen's `continue` skips it; the caller +// prints "Message truncated". Otherwise bytes left over are ErrRemnant. +func Datagram(b []byte, truncated bool, nsid int32, fn func(Msg) error) error { + off := 0 + for len(b) >= xtcpnl.NlMsgHdrSizeCst { + var h xtcpnl.NlMsgHdr + if _, err := xtcpnl.DeserializeNlMsgHdr(b, &h); err != nil { + return err + } + if h.Len < xtcpnl.NlMsgHdrSizeCst || int(h.Len) > len(b) { + if truncated { + return errorf(ErrTruncated, "Truncated message") + } + return errorf(ErrMalformed, "!!!malformed message: len=%d", int32(h.Len)) + } + if err := fn(Msg{Hdr: h, Body: b[xtcpnl.NlMsgHdrSizeCst:h.Len], Nsid: nsid, Off: off}); err != nil { + return err + } + next := align(int(h.Len)) + if next > len(b) { + return nil + } + b = b[next:] + off += next + } + if truncated { + return nil + } + if len(b) != 0 { + return errorf(ErrRemnant, "!!!Remnant of size %d", len(b)) + } + return nil +} + +// ListenOpts is what differs between rtnl_listen's callers. +type ListenOpts struct { + // BufSize is the receive buffer; 0 is RecvBufCst. + BufSize int + // AllNsid reads the netns id from each datagram's control message. + AllNsid bool + // ErrOut takes the messages rtnl_listen prints and carries on after. + ErrOut io.Writer +} + +// Listen is rtnl_listen on fd: EINTR and EAGAIN are retried; ENOBUFS, the +// kernel's word for messages dropped on a full queue, is reported and +// retried; any other receive error, or EOF, ends it with ErrRecv. +func Listen(fd int, o ListenOpts, fn func(Msg) error) error { + size := o.BufSize + if size == 0 { + size = RecvBufCst + } + buf := make([]byte, size) + oob := make([]byte, cmsgBufCst) + for { + n, oobn, flags, _, err := unix.Recvmsg(fd, buf, oob, 0) + switch { + case errors.Is(err, unix.EINTR), errors.Is(err, unix.EAGAIN): + continue + case errors.Is(err, unix.ENOBUFS): + if _, werr := fmt.Fprintf(o.ErrOut, "netlink receive error %s (%d)\n", Strerror(unix.ENOBUFS), int(unix.ENOBUFS)); werr != nil { + return werr + } + continue + case err != nil: + var errno unix.Errno + if errors.As(err, &errno) { + return errorf(ErrRecv, "netlink receive error %s (%d)", Strerror(errno), int(errno)) + } + return fmt.Errorf("netlink receive error %w", err) + case n == 0: + return errorf(ErrRecv, "EOF on netlink") + } + nsid := int32(-1) + if o.AllNsid { + nsid = ListenNsid(oob[:oobn]) + } + truncated := flags&unix.MSG_TRUNC != 0 + if err := Datagram(buf[:min(n, len(buf))], truncated, nsid, fn); err != nil { + return err + } + if truncated { + if _, werr := io.WriteString(o.ErrOut, "Message truncated\n"); werr != nil { + return werr + } + } + } +} + +// Strerror is glibc's strerror: x/sys/unix's strings, which are glibc's +// with the first letter lowered, raised again, and glibc's "Unknown error +// N" for one it has no text for. +func Strerror(errno unix.Errno) string { + if errno == 0 { + return "Success" + } + s := errno.Error() + if strings.HasPrefix(s, "errno ") { + return "Unknown error " + strings.TrimPrefix(s, "errno ") + } + return strings.ToUpper(s[:1]) + s[1:] +} + +// ListenNsid is the netns id a NETLINK_LISTEN_ALL_NSID control message +// carries, the last one if more came, or -1. +func ListenNsid(oob []byte) int32 { + nsid := int32(-1) + cmsgs, err := unix.ParseSocketControlMessage(oob) + if err != nil { + return nsid + } + for _, cm := range cmsgs { + if cm.Header.Level == unix.SOL_NETLINK && cm.Header.Type == unix.NETLINK_LISTEN_ALL_NSID && + len(cm.Data) >= 4 { + nsid = int32(xtcpnl.NativeEndian().Uint32(cm.Data[:4])) + } + } + return nsid +} + +// ReadFile is the fopen and rtnl_from_file over path: an fopen failure is +// ErrOpen with perror's "Cannot fopen: "; the rest is FromFile's. +func ReadFile(path string, fn func(Msg) error) error { + f, err := os.Open(path) + if err != nil { + return freadError(ErrOpen, "Cannot fopen", err) + } + err = FromFile(f, fn) + if cerr := f.Close(); cerr != nil && err == nil { + return freadError(ErrRead, "rtnl_from_file: fread", cerr) + } + return err +} + +// FromFile is rtnl_from_file over r: each header, then its body to the +// 4-byte boundary, each handed to fn as soon as it is read, so a pipe or a +// growing file is walked as it comes, until r ends between messages. Body +// is valid only until fn returns: as the C's, the buffer is reused. A read +// failing is ErrRead with perror's "rtnl_from_file: fread: "; a +// header or body cut short by the end of r is ErrFileTruncated; a length +// under the header's or over the buffer is ErrMalformed naming the offset +// past the header, ftell's; fn's error ends it as it is. +func FromFile(r io.Reader, fn func(Msg) error) error { + buf := make([]byte, RecvBufCst) + off := 0 + for { + n, err := io.ReadFull(r, buf[:xtcpnl.NlMsgHdrSizeCst]) + switch { + case n == 0 && errors.Is(err, io.EOF): + return nil + case err != nil: + return fileReadError(err) + } + off += n + var h xtcpnl.NlMsgHdr + if _, err := xtcpnl.DeserializeNlMsgHdr(buf, &h); err != nil { + return err + } + if h.Len < xtcpnl.NlMsgHdrSizeCst || h.Len > RecvBufCst { + return errorf(ErrMalformed, "!!!malformed message: len=%d @%d", int32(h.Len), off) + } + l := int(h.Len) - xtcpnl.NlMsgHdrSizeCst + end := xtcpnl.NlMsgHdrSizeCst + align(l) // at most 16384, as l is at most 16368 + n, err = io.ReadFull(r, buf[xtcpnl.NlMsgHdrSizeCst:end]) + off += n + if err != nil { + return fileReadError(err) + } + if err := fn(Msg{Hdr: h, Body: buf[xtcpnl.NlMsgHdrSizeCst : xtcpnl.NlMsgHdrSizeCst+l], Nsid: -1}); err != nil { + return err + } + } +} + +// fileReadError is a short fread: the end of the file is feof's +// "truncated message", anything else ferror's perror. +func fileReadError(err error) error { + if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) { + return errorf(ErrFileTruncated, "rtnl-from_file: truncated message") + } + return freadError(ErrRead, "rtnl_from_file: fread", err) +} + +// freadError is perror(prefix) of err as kind: strerror of its errno, or +// the error's own text when it carries none. +func freadError(kind error, prefix string, err error) error { + var errno unix.Errno + if errors.As(err, &errno) { + return errorf(kind, "%s: %s", prefix, Strerror(errno)) + } + return errorf(kind, "%s: %s", prefix, err.Error()) +} + +// asctimeLayoutCst is asctime's "%.3s %.3s%3d %.2d:%.2d:%.2d %d". +const asctimeLayoutCst = "Mon Jan _2 15:04:05 2006" + +// Timestamp is print_timestamp's text: asctime of the local time and the +// microseconds on a line of their own, or under -tshort the ISO form in +// brackets ahead of what follows. +func Timestamp(t time.Time, short bool) string { + t = t.Local() + usec := t.Nanosecond() / 1000 + if short { + return fmt.Sprintf("[%s.%06d] ", t.Format("2006-01-02T15:04:05"), usec) + } + return fmt.Sprintf("Timestamp: %s %d usec\n", t.Format(asctimeLayoutCst), usec) +} + +// NowFunc is the clock a monitor stamps each message with: the instant the +// environment variable env holds (RFC3339) when it parses, for a replay, +// else the wall clock, read per message. +func NowFunc(env string) func() time.Time { + if t, err := time.Parse(time.RFC3339, os.Getenv(env)); err == nil { + return func() time.Time { return t } + } + return time.Now +} diff --git a/internal/nlmon/nlmon_test.go b/internal/nlmon/nlmon_test.go new file mode 100644 index 000000000..f896939c1 --- /dev/null +++ b/internal/nlmon/nlmon_test.go @@ -0,0 +1,468 @@ +package nlmon + +import ( + "bytes" + "encoding/binary" + "errors" + "fmt" + "io" + "os" + "path/filepath" + "strings" + "testing" + "time" + + "github.com/randomizedcoder/xtcp2/pkg/xtcpnl" + "golang.org/x/sys/unix" +) + +func le32(v uint32) []byte { return binary.LittleEndian.AppendUint32(nil, v) } + +func cat(bs ...[]byte) []byte { + var out []byte + for _, b := range bs { + out = append(out, b...) + } + return out +} + +// hdr is an nlmsghdr with the given length field. +func hdr(typ, flags uint16, seq, pid, length uint32) []byte { + b := le32(length) + b = binary.LittleEndian.AppendUint16(b, typ) + b = binary.LittleEndian.AppendUint16(b, flags) + b = binary.LittleEndian.AppendUint32(b, seq) + return binary.LittleEndian.AppendUint32(b, pid) +} + +// rec is a message with body, its length right, padded to 4 bytes. +func rec(typ uint16, body []byte) []byte { + b := cat(hdr(typ, 0, 0, 0, uint32(xtcpnl.NlMsgHdrSizeCst+len(body))), body) + return append(b, make([]byte, align(len(b))-len(b))...) +} + +// types is the walk's "type/nsid " trace. +func types(walk func(func(Msg) error) error) (string, error) { + var b strings.Builder + err := walk(func(m Msg) error { + fmt.Fprintf(&b, "%d/%d ", m.Hdr.Type, m.Nsid) + return nil + }) + return b.String(), err +} + +// TestDatagram is rtnl_listen's walk of one datagram. +// +// go test ./internal/nlmon/ -run TestDatagram +func TestDatagram(t *testing.T) { + type result struct { + types string + err string + kind error + } + big := rec(unix.RTM_NEWTFILTER, make([]byte, RecvBufCst-xtcpnl.NlMsgHdrSizeCst)) + tests := []struct { + description string + datagram []byte + truncated bool + expected result + }{ + {"positive: three messages in order", cat(rec(unix.RTM_NEWQDISC, le32(1)), rec(unix.RTM_DELQDISC, nil), + rec(unix.RTM_NEWTFILTER, nil)), false, result{types: "36/5 37/5 44/5 "}}, + {"boundary: an empty datagram", nil, false, result{}}, + {"positive: the last body unpadded", rec(unix.RTM_NEWLINK, []byte{1})[:17], false, result{types: "16/5 "}}, + {"negative: a length past the datagram", hdr(unix.RTM_NEWLINK, 0, 0, 0, 64), false, + result{err: "!!!malformed message: len=64", kind: ErrMalformed}}, + {"negative: a length under the header's", hdr(unix.RTM_NEWLINK, 0, 0, 0, 4), false, + result{err: "!!!malformed message: len=4", kind: ErrMalformed}}, + {"negative: a length past a truncated datagram", cat(rec(unix.RTM_NEWQDISC, nil), hdr(unix.RTM_NEWTFILTER, 0, 0, 0, 40000)), + true, result{types: "36/5 ", err: "Truncated message", kind: ErrTruncated}}, + {"corner: a remnant under a header", cat(rec(unix.RTM_NEWLINK, nil), []byte{1, 2, 3}), false, + result{types: "16/5 ", err: "!!!Remnant of size 3", kind: ErrRemnant}}, + {"corner: a truncated datagram skips the remnant check", cat(rec(unix.RTM_NEWLINK, nil), []byte{1, 2, 3}), true, + result{types: "16/5 "}}, + {"boundary: a message of exactly the buffer", big, false, result{types: "44/5 "}}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + s, err := types(func(fn func(Msg) error) error { return Datagram(tc.datagram, tc.truncated, 5, fn) }) + got := result{types: s} + if err != nil { + got.err = err.Error() + if !errors.Is(err, tc.expected.kind) { + t.Errorf("error %v is not %v", err, tc.expected.kind) + } + got.kind = tc.expected.kind + } + if got != tc.expected { + t.Errorf("got %+v, want %+v", got, tc.expected) + } + }) + } + t.Run("corner: fn's error ends the walk as it is", func(t *testing.T) { + stop := errors.New("stop") + n := 0 + err := Datagram(cat(rec(1, nil), rec(2, nil), rec(3, nil)), false, -1, func(Msg) error { + n++ + if n == 2 { + return stop + } + return nil + }) + if !errors.Is(err, stop) || n != 2 { + t.Errorf("got %v after %d, want stop after 2", err, n) + } + }) +} + +// failAfter is a reader that hands out data, then fails with err instead +// of ending, as an fread that meets EIO partway. +type failAfter struct { + data []byte + err error +} + +func (f *failAfter) Read(p []byte) (int, error) { + if len(f.data) == 0 { + return 0, f.err + } + n := copy(p, f.data) + f.data = f.data[n:] + return n, nil +} + +// TestFromFile is rtnl_from_file. +// +// go test ./internal/nlmon/ -run TestFromFile +func TestFromFile(t *testing.T) { + type result struct { + types string + err string + } + two := cat(rec(unix.RTM_NEWQDISC, le32(1)), rec(unix.RTM_NEWTFILTER, []byte{1})) + tests := []struct { + description string + data []byte + failWith error // the read past data fails with this, not EOF + kind error + expected result + }{ + {"positive: two records", two, nil, nil, result{types: "36/-1 44/-1 "}}, + {"boundary: an empty file", nil, nil, nil, result{}}, + {"boundary: a 16384-byte record, the buffer's size", rec(unix.RTM_NEWTFILTER, make([]byte, RecvBufCst-16)), nil, nil, + result{types: "44/-1 "}}, + {"negative: cut inside the header", two[:len(two)-20+4], nil, ErrFileTruncated, + result{types: "36/-1 ", err: "rtnl-from_file: truncated message"}}, + {"negative: cut inside the body", two[:len(two)-1], nil, ErrFileTruncated, + result{types: "36/-1 ", err: "rtnl-from_file: truncated message"}}, + {"negative: a length of 8", cat(rec(unix.RTM_NEWQDISC, nil), hdr(unix.RTM_NEWQDISC, 0, 0, 0, 8)), nil, ErrMalformed, + result{types: "36/-1 ", err: "!!!malformed message: len=8 @32"}}, + {"boundary: a length over the buffer", hdr(unix.RTM_NEWQDISC, 0, 0, 0, RecvBufCst+1), nil, ErrMalformed, + result{err: "!!!malformed message: len=16385 @16"}}, + {"corner: the last body unpadded is cut short", rec(unix.RTM_NEWLINK, []byte{1})[:17], nil, ErrFileTruncated, + result{err: "rtnl-from_file: truncated message"}}, + {"negative: a read error between records is fread's perror, after the records before it", rec(unix.RTM_NEWQDISC, nil), + unix.EIO, ErrRead, result{types: "36/-1 ", err: "rtnl_from_file: fread: Input/output error"}}, + {"corner: a read error inside a body is fread's perror, not truncated", two[:len(two)-1], unix.EIO, ErrRead, + result{types: "36/-1 ", err: "rtnl_from_file: fread: Input/output error"}}, + {"corner: a read error with no errno keeps its own text", nil, errors.New("boom"), ErrRead, + result{err: "rtnl_from_file: fread: boom"}}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + var r io.Reader = bytes.NewReader(tc.data) + if tc.failWith != nil { + r = &failAfter{data: tc.data, err: tc.failWith} + } + s, err := types(func(fn func(Msg) error) error { return FromFile(r, fn) }) + got := result{types: s} + if err != nil { + got.err = err.Error() + } + if got != tc.expected { + t.Errorf("got %+v, want %+v", got, tc.expected) + } + if (err == nil) != (tc.kind == nil) || (tc.kind != nil && !errors.Is(err, tc.kind)) { + t.Errorf("error %v, want kind %v", err, tc.kind) + } + }) + } +} + +// TestFromFileStreams pins that a record is handed on as soon as it is +// read, as fread's loop does, not once the file ends: the writer sends the +// second record only after fn has seen the first, which deadlocks a reader +// that waits for EOF. +// +// go test ./internal/nlmon/ -run TestFromFileStreams +func TestFromFileStreams(t *testing.T) { + pr, pw, err := os.Pipe() + if err != nil { + t.Fatal(err) + } + seen := make(chan uint16, 2) + done := make(chan error, 1) + go func() { + done <- FromFile(pr, func(m Msg) error { seen <- m.Hdr.Type; return nil }) + }() + write := func(b []byte) { + if _, err := pw.Write(b); err != nil { + t.Fatal(err) + } + } + timeout := time.After(10 * time.Second) + write(rec(unix.RTM_NEWQDISC, nil)) + for _, want := range []uint16{unix.RTM_NEWQDISC, unix.RTM_DELQDISC} { + select { + case got := <-seen: + if got != want { + t.Fatalf("got type %d, want %d", got, want) + } + case <-timeout: + t.Fatalf("type %d not handed on before the file ended", want) + } + if want == unix.RTM_NEWQDISC { + write(rec(unix.RTM_DELQDISC, nil)) + if err := pw.Close(); err != nil { + t.Fatal(err) + } + } + } + if err := <-done; err != nil { + t.Errorf("got %v at the end, want nil", err) + } +} + +// TestReadFile is the fopen ahead of rtnl_from_file. +// +// go test ./internal/nlmon/ -run TestReadFile +func TestReadFile(t *testing.T) { + dir := t.TempDir() + good := filepath.Join(dir, "f") + if err := os.WriteFile(good, rec(unix.RTM_NEWQDISC, nil), 0o600); err != nil { + t.Fatal(err) + } + tests := []struct { + description string + path string + types, err string + kind error + }{ + {"positive: a file of one record", good, "36/-1 ", "", nil}, + {"negative: a missing file", filepath.Join(dir, "none"), "", "Cannot fopen: No such file or directory", ErrOpen}, + {"negative: a directory opens, as fopen's does, then its read fails", dir, "", "rtnl_from_file: fread: Is a directory", ErrRead}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + s, err := types(func(fn func(Msg) error) error { return ReadFile(tc.path, fn) }) + var e string + if err != nil { + e = err.Error() + } + if s != tc.types || e != tc.err { + t.Errorf("got %q %q, want %q %q", s, e, tc.types, tc.err) + } + if tc.kind != nil && !errors.Is(err, tc.kind) { + t.Errorf("error %v is not %v", err, tc.kind) + } + }) + } +} + +// TestTimestamp is print_timestamp's two forms. +// +// go test ./internal/nlmon/ -run TestTimestamp +func TestTimestamp(t *testing.T) { + t.Setenv("TZ", "UTC") + at := time.Date(2026, 11, 25, 10, 0, 0, 123456789, time.UTC) + tests := []struct { + description string + t time.Time + short bool + expected string + }{ + {"positive: long", at, false, "Timestamp: Wed Nov 25 10:00:00 2026 123456 usec\n"}, + {"positive: short", at, true, "[2026-11-25T10:00:00.123456] "}, + {"boundary: no microseconds", at.Truncate(time.Second), false, "Timestamp: Wed Nov 25 10:00:00 2026 0 usec\n"}, + {"corner: a one-digit day pads with a space", time.Date(2026, 11, 5, 1, 2, 3, 7000, time.UTC), false, + "Timestamp: Thu Nov 5 01:02:03 2026 7 usec\n"}, + {"corner: short pads the microseconds to six", time.Date(2026, 11, 5, 1, 2, 3, 7000, time.UTC), true, + "[2026-11-05T01:02:03.000007] "}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + if got := Timestamp(tc.t.In(time.Local), tc.short); got != tc.expected { + t.Errorf("got %q, want %q", got, tc.expected) + } + }) + } +} + +// TestNowFunc is the replay clock. +// +// go test ./internal/nlmon/ -run TestNowFunc +func TestNowFunc(t *testing.T) { + tests := []struct { + description string + env string + fixed bool + }{ + {"positive: an RFC3339 instant pins it", "2026-11-25T10:00:00Z", true}, + {"negative: garbage is the wall clock", "yesterday", false}, + {"boundary: unset is the wall clock", "", false}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + t.Setenv("NLMON_TEST_NOW", tc.env) + got := NowFunc("NLMON_TEST_NOW")() + want := time.Date(2026, 11, 25, 10, 0, 0, 0, time.UTC) + if got.Equal(want) != tc.fixed { + t.Errorf("got %v, fixed %v", got, tc.fixed) + } + }) + } +} + +// TestListenNsid is the nsid a NETLINK_LISTEN_ALL_NSID control message +// carries. +// +// go test ./internal/nlmon/ -run TestListenNsid +func TestListenNsid(t *testing.T) { + // cmsg is a cmsghdr on a 64-bit host, its length a size_t, then data + // padded to 8 bytes. + cmsg := func(level, typ int32, data []byte) []byte { + b := cat(binary.LittleEndian.AppendUint64(nil, uint64(unix.CmsgLen(len(data)))), + le32(uint32(level)), le32(uint32(typ)), data) + return append(b, make([]byte, unix.CmsgSpace(len(data))-len(b))...) + } + tests := []struct { + description string + oob []byte + expected int32 + }{ + {"positive: nsid 9", cmsg(unix.SOL_NETLINK, unix.NETLINK_LISTEN_ALL_NSID, le32(9)), 9}, + {"boundary: none is -1", nil, -1}, + {"negative: another level is -1", cmsg(unix.SOL_SOCKET, unix.NETLINK_LISTEN_ALL_NSID, le32(9)), -1}, + {"negative: a short value is -1", cmsg(unix.SOL_NETLINK, unix.NETLINK_LISTEN_ALL_NSID, []byte{9}), -1}, + {"corner: the last of two", cat(cmsg(unix.SOL_NETLINK, unix.NETLINK_LISTEN_ALL_NSID, le32(9)), + cmsg(unix.SOL_NETLINK, unix.NETLINK_LISTEN_ALL_NSID, le32(2))), 2}, + {"negative: garbage is -1", []byte{1, 2, 3}, -1}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + if got := ListenNsid(tc.oob); got != tc.expected { + t.Errorf("got %d, want %d", got, tc.expected) + } + }) + } +} + +// TestListen is rtnl_listen over a socketpair standing in for the netlink +// socket: datagrams in order, then the receive error that ends it. +// +// go test ./internal/nlmon/ -run TestListen +func TestListen(t *testing.T) { + tests := []struct { + description string + datagrams [][]byte + bufSize int + types string + errOut string + err string + }{ + {"positive: two datagrams, then EOF", [][]byte{cat(rec(unix.RTM_NEWQDISC, nil), rec(unix.RTM_DELQDISC, nil)), + rec(unix.RTM_NEWTFILTER, nil)}, 0, "36/-1 37/-1 44/-1 ", "", "EOF on netlink"}, + {"boundary: a datagram over the buffer is cut, then Truncated message", [][]byte{ + rec(unix.RTM_NEWTFILTER, make([]byte, 64))}, 32, "", "", "Truncated message"}, + {"corner: a truncated datagram whose messages fit carries on", [][]byte{ + cat(rec(unix.RTM_NEWQDISC, nil), make([]byte, 40))}, 24, "36/-1 ", "Message truncated\n", "EOF on netlink"}, + {"negative: a malformed message", [][]byte{hdr(unix.RTM_NEWQDISC, 0, 0, 0, 8)}, 0, "", "", + "!!!malformed message: len=8"}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + fds, err := unix.Socketpair(unix.AF_UNIX, unix.SOCK_SEQPACKET|unix.SOCK_CLOEXEC, 0) + if err != nil { + t.Fatal(err) + } + for _, d := range tc.datagrams { + if _, err := unix.Write(fds[1], d); err != nil { + t.Fatal(err) + } + } + if err := unix.Close(fds[1]); err != nil { + t.Fatal(err) + } + defer func() { + if err := unix.Close(fds[0]); err != nil { + t.Error(err) + } + }() + var errOut strings.Builder + s, err := types(func(fn func(Msg) error) error { + return Listen(fds[0], ListenOpts{BufSize: tc.bufSize, ErrOut: &errOut}, fn) + }) + var e string + if err != nil { + e = err.Error() + } + if s != tc.types || errOut.String() != tc.errOut || e != tc.err { + t.Errorf("got %q %q %q, want %q %q %q", s, errOut.String(), e, tc.types, tc.errOut, tc.err) + } + }) + } +} + +// TestListenErrors is rtnl_listen's other endings and its all-nsid path. +// +// go test ./internal/nlmon/ -run TestListenErrors +func TestListenErrors(t *testing.T) { + t.Run("negative: a closed descriptor is a receive error", func(t *testing.T) { + err := Listen(-1, ListenOpts{}, func(Msg) error { return nil }) + if err == nil || err.Error() != "netlink receive error Bad file descriptor (9)" || !errors.Is(err, ErrRecv) { + t.Errorf("got %v", err) + } + }) + t.Run("boundary: all-nsid with no control message names -1", func(t *testing.T) { + fds, err := unix.Socketpair(unix.AF_UNIX, unix.SOCK_SEQPACKET|unix.SOCK_CLOEXEC, 0) + if err != nil { + t.Fatal(err) + } + if _, err := unix.Write(fds[1], rec(unix.RTM_NEWQDISC, nil)); err != nil { + t.Fatal(err) + } + if err := unix.Close(fds[1]); err != nil { + t.Fatal(err) + } + s, err := types(func(fn func(Msg) error) error { return Listen(fds[0], ListenOpts{AllNsid: true}, fn) }) + if s != "36/-1 " || err == nil || err.Error() != "EOF on netlink" { + t.Errorf("got %q %v", s, err) + } + if err := unix.Close(fds[0]); err != nil { + t.Error(err) + } + }) +} + +// TestStrerror is glibc's text for an errno. +// +// go test ./internal/nlmon/ -run TestStrerror +func TestStrerror(t *testing.T) { + tests := []struct { + description string + errno unix.Errno + expected string + }{ + {"positive: ENOENT", unix.ENOENT, "No such file or directory"}, + {"positive: ENOBUFS", unix.ENOBUFS, "No buffer space available"}, + {"boundary: 0 is Success", 0, "Success"}, + {"corner: an errno Go has no text for", unix.Errno(4000), "Unknown error 4000"}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + if got := Strerror(tc.errno); got != tc.expected { + t.Errorf("got %q, want %q", got, tc.expected) + } + }) + } +} diff --git a/internal/nlmon/replay.go b/internal/nlmon/replay.go new file mode 100644 index 000000000..1cabbdbd1 --- /dev/null +++ b/internal/nlmon/replay.go @@ -0,0 +1,185 @@ +package nlmon + +import ( + "bytes" + "errors" + "os" + + "github.com/randomizedcoder/xtcp2/pkg/xtcpnl" + "golang.org/x/sys/unix" +) + +// ErrPcap is a capture PcapMsgs cannot read. +var ErrPcap = errors.New("nlmon: pcap") + +// PcapMsgs is every NETLINK_ROUTE message of the nlmon pcap at path, in +// capture order, each datagram walked as rtnl_listen walks it; a message +// that does not fit ends its datagram. +func PcapMsgs(path string) ([]Msg, error) { + data, err := os.ReadFile(path) + if err != nil { + return nil, errors.Join(ErrPcap, err) + } + _, recs, err := xtcpnl.ParseNetlinkPcap(data) + if err != nil { + return nil, errors.Join(ErrPcap, err) + } + var out []Msg + for _, r := range recs { + family, dg, perr := r.NetlinkPayload() + if perr != nil { + return nil, errors.Join(ErrPcap, perr) + } + if family != unix.NETLINK_ROUTE { + continue + } + collect := func(m Msg) error { + out = append(out, m) + return nil + } + // A datagram cut short in the capture ends where it stops making + // sense; what came before it stays. + if derr := Datagram(dg, true, -1, collect); derr != nil && !errors.Is(derr, ErrTruncated) { + return nil, errors.Join(ErrPcap, derr) + } + } + return out, nil +} + +// DumpEnd is the index past a recorded dump of typ's NLMSG_DONE: the first +// request of typ with NLM_F_DUMP and nlmsg_pid 0, then the first DONE after +// it with its sequence number; 0 when the capture has none. +func DumpEnd(msgs []Msg, typ uint16) int { + req := -1 + for i := range msgs { + h := &msgs[i].Hdr + switch { + case req < 0 && h.Type == typ && h.Flags&unix.NLM_F_DUMP == unix.NLM_F_DUMP && h.Pid == 0: + req = i + case req >= 0 && h.Type == unix.NLMSG_DONE && h.Seq == msgs[req].Hdr.Seq: + return i + 1 + } + } + return 0 +} + +// Notifications is what of a capture a subscriber was sent, by index: the +// messages to user space, less the answers to requests. +// +// nlmon records a multicast once per socket it is delivered to, and a +// unicast answer once, with nothing on either to say which it was. What is +// left out: +// +// - a request: NLM_F_REQUEST with nlmsg_pid 0. nexthop_notify, and tc's +// filter and action notifications (tfilter_notify, tcf_add_notify), +// copy the request's flags into the notification, so those carry +// NLM_F_REQUEST too; they carry the requester's port id, which a +// request does not; +// - a dump's part, NLM_F_MULTI, its NLMSG_DONE among them; +// - an NLMSG_ERROR, an ack or a refusal; +// - the answer to a get: the first message after a request of an RTM +// GET type (a type 2 past the NEW of its family of four) with the +// request's sequence number and the NEW type. A refusal of the get, an +// NLMSG_ERROR naming it, ends the wait as well; +// - the echo of a request with NLM_F_ECHO: nlmsg_notify unicasts the +// requester a copy of the multicast, the same bytes, so of two equal +// messages with the request's sequence number after it, one is the +// echo. +func Notifications(msgs []Msg) []int { + type pending struct { + seq uint32 + typ uint16 + } + var gets []pending + answered := func(seq uint32, typ uint16) bool { + for i, g := range gets { + if g.seq == seq && g.typ == typ { + gets = append(gets[:i], gets[i+1:]...) + return true + } + } + return false + } + type echo struct { + seq uint32 + seen int // the index of the first copy, or -1 + } + var echoes []echo + echoed := func(i int) bool { + m := &msgs[i] + for k, e := range echoes { + if e.seq != m.Hdr.Seq { + continue + } + if e.seen < 0 { + echoes[k].seen = i + return false + } + f := &msgs[e.seen] + if f.Hdr == m.Hdr && bytes.Equal(f.Body, m.Body) { + echoes = append(echoes[:k], echoes[k+1:]...) + return true + } + } + return false + } + var out []int + for i := range msgs { + m := &msgs[i] + h := m.Hdr + switch { + case h.Flags&unix.NLM_F_REQUEST != 0 && h.Pid == 0: + if IsRtmGet(h.Type) && h.Flags&unix.NLM_F_DUMP != unix.NLM_F_DUMP { + gets = append(gets, pending{h.Seq, h.Type - 2}) + } + if h.Flags&unix.NLM_F_ECHO != 0 && !IsRtmGet(h.Type) { + echoes = append(echoes, echo{seq: h.Seq, seen: -1}) + } + case h.Flags&unix.NLM_F_MULTI != 0: + case h.Type == unix.NLMSG_ERROR: + if len(m.Body) >= 4+xtcpnl.NlMsgHdrSizeCst { + var orig xtcpnl.NlMsgHdr + if _, err := xtcpnl.DeserializeNlMsgHdr(m.Body[4:], &orig); err == nil && IsRtmGet(orig.Type) { + answered(orig.Seq, orig.Type-2) + } + } + case answered(h.Seq, h.Type): + case echoed(i): + default: + out = append(out, i) + } + } + return out +} + +// IsRtmGet is an RTM_GET* type: the third of its family's four, NEW, DEL, +// GET and SET, from RTM_BASE. The tc types keep the rule: GETQDISC 38, +// GETTCLASS 42, GETTFILTER 46, GETACTION 50, GETCHAIN 102. +func IsRtmGet(t uint16) bool { + return t >= unix.RTM_BASE && (t-unix.RTM_BASE)%4 == 2 +} + +// Replay hands fn each notification of msgs at or past start, by the +// indexes Notifications gave, as rtnl_listen with a buffer of bufSize (0 +// is RecvBufCst) would: a message that does not fit in the buffer from its +// offset in its datagram is the receive's MSG_TRUNC, which ends the listen +// with ErrTruncated, "Truncated message". nlmon records the datagram +// whole, so the capture has what the listener could not read. +func Replay(msgs []Msg, notes []int, start, bufSize int, fn func(Msg) error) error { + if bufSize == 0 { + bufSize = RecvBufCst + } + for _, i := range notes { + if i < start { + continue + } + m := msgs[i] + if m.Off+int(m.Hdr.Len) > bufSize { + return errorf(ErrTruncated, "Truncated message") + } + if err := fn(m); err != nil { + return err + } + } + return nil +} diff --git a/internal/nlmon/replay_test.go b/internal/nlmon/replay_test.go new file mode 100644 index 000000000..8d24d151c --- /dev/null +++ b/internal/nlmon/replay_test.go @@ -0,0 +1,285 @@ +package nlmon + +import ( + "errors" + "fmt" + "os" + "strings" + "testing" + + "github.com/randomizedcoder/xtcp2/pkg/xtcpnl" + "golang.org/x/sys/unix" +) + +func msg(typ, flags uint16, seq, pid uint32, body ...byte) Msg { + return Msg{Hdr: xtcpnl.NlMsgHdr{Type: typ, Flags: flags, Seq: seq, Pid: pid}, Body: body, Nsid: -1} +} + +// errFor is an NLMSG_ERROR naming a request of typ and seq. +func errFor(typ uint16, seq uint32) Msg { + return msg(unix.NLMSG_ERROR, 0, seq, 100, cat(le32(0), hdr(typ, 0, seq, 0, xtcpnl.NlMsgHdrSizeCst))...) +} + +// TestNotifications is which of a capture's messages a subscriber was +// sent: requests, dump parts, errors, a get's answer and an echo left out. +// +// go test ./internal/nlmon/ -run TestNotifications +func TestNotifications(t *testing.T) { + const ( + req = unix.NLM_F_REQUEST + dump = unix.NLM_F_REQUEST | unix.NLM_F_DUMP + add = unix.NLM_F_REQUEST | unix.NLM_F_CREATE | unix.NLM_F_EXCL + ) + tests := []struct { + description string + msgs []Msg + expected []int + }{ + {"positive: notifications alone", []Msg{msg(unix.RTM_NEWADDR, 0, 0, 0), msg(unix.RTM_DELADDR, 0, 0, 0)}, + []int{0, 1}}, + {"negative: a dump and its parts", []Msg{msg(unix.RTM_GETLINK, dump, 1, 0), + msg(unix.RTM_NEWLINK, unix.NLM_F_MULTI, 1, 100), msg(unix.NLMSG_DONE, unix.NLM_F_MULTI, 1, 100), + msg(unix.RTM_NEWLINK, 0, 0, 0)}, []int{3}}, + {"positive: a link dump, then three qdisc events", []Msg{msg(unix.RTM_GETLINK, dump, 1, 0), + msg(unix.RTM_NEWLINK, unix.NLM_F_MULTI, 1, 100), msg(unix.NLMSG_DONE, unix.NLM_F_MULTI, 1, 100), + msg(unix.RTM_NEWQDISC, 0, 9, 4242), msg(unix.RTM_DELQDISC, 0, 10, 4242), msg(unix.RTM_NEWQDISC, unix.NLM_F_REPLACE, 10, 4242)}, + []int{3, 4, 5}}, + {"positive: a nexthop event carries REQUEST and the requester's port", []Msg{ + msg(unix.RTM_NEWNEXTHOP, req|unix.NLM_F_CREATE, 5, 0), errFor(unix.RTM_NEWNEXTHOP, 5), + msg(unix.RTM_NEWNEXTHOP, req|unix.NLM_F_CREATE, 5, 4242)}, []int{2}}, + {"positive: a tc filter event carries the request's flags and port (K22)", []Msg{ + msg(unix.RTM_NEWTFILTER, add, 7, 0), msg(unix.RTM_NEWTFILTER, add, 7, 4242), errFor(unix.RTM_NEWTFILTER, 7)}, + []int{1}}, + {"negative: the trigger's own qdisc add and its ack", []Msg{msg(unix.RTM_NEWQDISC, add, 3, 0), + errFor(unix.RTM_NEWQDISC, 3), msg(unix.RTM_NEWQDISC, 0, 3, 4242)}, []int{2}}, + {"negative: a get's answer", []Msg{msg(unix.RTM_GETNSID, req, 7, 0), msg(unix.RTM_NEWNSID, 0, 7, 100), + msg(unix.RTM_NEWNSID, 0, 0, 0)}, []int{2}}, + {"negative: a GETTFILTER's answer is dropped once", []Msg{msg(unix.RTM_GETTFILTER, req|unix.NLM_F_ECHO, 8, 0), + msg(unix.RTM_NEWTFILTER, 0, 8, 100), msg(unix.RTM_NEWTFILTER, 0, 8, 100)}, []int{2}}, + {"corner: a get's answer is the first of its type and seq alone", []Msg{ + msg(unix.RTM_GETNSID, req, 7, 0), msg(unix.RTM_NEWADDR, 0, 7, 0), msg(unix.RTM_NEWNSID, 0, 7, 100), + msg(unix.RTM_NEWNSID, 0, 7, 100)}, []int{1, 3}}, + {"corner: a refused get waits for no answer", []Msg{msg(unix.RTM_GETNSID, req, 7, 0), + errFor(unix.RTM_GETNSID, 7), msg(unix.RTM_NEWNSID, 0, 7, 0)}, []int{2}}, + {"boundary: a short error names nothing", []Msg{msg(unix.RTM_GETNSID, req, 7, 0), + msg(unix.NLMSG_ERROR, 0, 7, 0, 0, 0, 0, 0), msg(unix.RTM_NEWNSID, 0, 7, 0)}, nil}, + {"corner: an echoed add's unicast copy is left out", []Msg{msg(unix.RTM_NEWTFILTER, add|unix.NLM_F_ECHO, 4, 0), + msg(unix.RTM_NEWTFILTER, add|unix.NLM_F_ECHO, 4, 4242, 1), msg(unix.RTM_NEWTFILTER, add|unix.NLM_F_ECHO, 4, 4242, 1), + errFor(unix.RTM_NEWTFILTER, 4)}, []int{1}}, + {"corner: an echo's copies must be equal", []Msg{msg(unix.RTM_NEWTFILTER, add|unix.NLM_F_ECHO, 4, 0), + msg(unix.RTM_NEWTFILTER, add, 4, 4242, 1), msg(unix.RTM_NEWTFILTER, add, 4, 4242, 2)}, []int{1, 2}}, + {"boundary: none", nil, nil}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + got := Notifications(tc.msgs) + if fmt.Sprint(got) != fmt.Sprint(tc.expected) { + t.Errorf("got %v, want %v", got, tc.expected) + } + }) + } +} + +// TestDumpEnd is the index past a recorded dump's NLMSG_DONE, where a +// replayed monitor's notifications begin. +// +// go test ./internal/nlmon/ -run TestDumpEnd +func TestDumpEnd(t *testing.T) { + m := func(typ, flags uint16, seq, pid uint32) Msg { return msg(typ, flags, seq, pid) } + dump := uint16(unix.NLM_F_REQUEST | unix.NLM_F_DUMP) + tests := []struct { + description string + msgs []Msg + expected int + }{ + {"positive: past the DONE", []Msg{m(unix.RTM_NEWADDR, 0, 0, 0), m(unix.RTM_GETLINK, dump, 3, 0), + m(unix.RTM_NEWADDR, 0, 0, 0), m(unix.NLMSG_DONE, 2, 3, 100), m(unix.RTM_NEWADDR, 0, 0, 0)}, 4}, + {"negative: no dump is 0", []Msg{m(unix.RTM_NEWADDR, 0, 0, 0)}, 0}, + {"negative: a dump with no DONE is 0", []Msg{m(unix.RTM_GETLINK, dump, 3, 0)}, 0}, + {"corner: a DONE of another seq is not the dump's", []Msg{m(unix.RTM_GETLINK, dump, 3, 0), + m(unix.NLMSG_DONE, 2, 2, 100), m(unix.NLMSG_DONE, 2, 3, 100)}, 3}, + {"corner: a get of the type is not a dump", []Msg{m(unix.RTM_GETLINK, unix.NLM_F_REQUEST, 3, 0), + m(unix.NLMSG_DONE, 2, 3, 100)}, 0}, + {"boundary: a reply from the kernel is not the request", []Msg{m(unix.RTM_GETLINK, dump, 3, 100), + m(unix.NLMSG_DONE, 2, 3, 100)}, 0}, + {"boundary: an event during the dump is before the end, so lost", []Msg{m(unix.RTM_GETLINK, dump, 3, 0), + m(unix.RTM_NEWQDISC, 0, 9, 4242), m(unix.NLMSG_DONE, 2, 3, 100)}, 3}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + if got := DumpEnd(tc.msgs, unix.RTM_GETLINK); got != tc.expected { + t.Errorf("got %d, want %d", got, tc.expected) + } + }) + } +} + +// TestIsRtmGet is the GET of each family of four, the tc ones included. +// +// go test ./internal/nlmon/ -run TestIsRtmGet +func TestIsRtmGet(t *testing.T) { + tests := []struct { + description string + typ uint16 + expected bool + }{ + {"positive: GETLINK", unix.RTM_GETLINK, true}, + {"positive: GETQDISC", unix.RTM_GETQDISC, true}, + {"positive: GETTFILTER", unix.RTM_GETTFILTER, true}, + {"positive: GETACTION", unix.RTM_GETACTION, true}, + {"boundary: GETCHAIN, the highest tc one", unix.RTM_GETCHAIN, true}, + {"negative: NEWQDISC", unix.RTM_NEWQDISC, false}, + {"negative: DELACTION", unix.RTM_DELACTION, false}, + {"boundary: under RTM_BASE", unix.NLMSG_DONE, false}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + if got := IsRtmGet(tc.typ); got != tc.expected { + t.Errorf("got %v, want %v", got, tc.expected) + } + }) + } +} + +// monitorAllPcap is goip's `ip monitor all` capture: a link dump on the +// monitor's socket, then the trigger's requests and the events. +const monitorAllPcap = "../../pkg/xtcpnl/testdata/7_1_4/link-write/rtnl/monitor_all/ip.pcap" + +// TestPcapMsgs is a capture's NETLINK_ROUTE messages. +// +// go test ./internal/nlmon/ -run TestPcapMsgs +func TestPcapMsgs(t *testing.T) { + dir := t.TempDir() + garbage := dir + "/garbage.pcap" + if err := os.WriteFile(garbage, []byte("not a pcap"), 0o600); err != nil { + t.Fatal(err) + } + tests := []struct { + description string + path string + check func([]Msg) string + err bool + }{ + {"positive: the monitor capture splits into a dump and its events", monitorAllPcap, func(ms []Msg) string { + end := DumpEnd(ms, unix.RTM_GETLINK) + n := 0 + for _, i := range Notifications(ms) { + if i >= end { + n++ + } + } + if end == 0 || n == 0 { + return fmt.Sprintf("dump end %d, %d events after it", end, n) + } + return "" + }, false}, + {"negative: a missing file", dir + "/none", nil, true}, + {"negative: not a pcap", garbage, nil, true}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + ms, err := PcapMsgs(tc.path) + if (err != nil) != tc.err { + t.Fatalf("error %v, want error %v", err, tc.err) + } + if err != nil && !errors.Is(err, ErrPcap) { + t.Errorf("error %v is not ErrPcap", err) + } + if tc.check != nil { + if s := tc.check(ms); s != "" { + t.Error(s) + } + } + }) + } +} + +// TestReplay is a capture's notifications played through rtnl_listen's +// buffer: the offsets Datagram records decide what a receive would cut. +// +// go test ./internal/nlmon/ -run TestReplay +func TestReplay(t *testing.T) { + type result struct { + types string + err string + } + // sized is a message of n bytes in all at offset off. + sized := func(typ uint16, n uint32, off int) Msg { + return Msg{Hdr: xtcpnl.NlMsgHdr{Len: n, Type: typ}, Nsid: -1, Off: off} + } + stop := errors.New("stop") + tests := []struct { + description string + msgs []Msg + notes []int + start, buf int + fn func(Msg) error + expected result + }{ + {"positive: every notification in order", []Msg{sized(36, 20, 0), sized(16, 20, 0), sized(37, 20, 0)}, + []int{0, 2}, 0, 0, nil, result{types: "36 37 "}}, + {"positive: those before start are lost", []Msg{sized(36, 20, 0), sized(37, 20, 0)}, + []int{0, 1}, 1, 0, nil, result{types: "37 "}}, + {"negative: a 16396-byte event is cut (MO5)", []Msg{sized(100, 36, 0), sized(44, 16396, 0)}, + []int{0, 1}, 0, 0, nil, result{types: "100 ", err: "Truncated message"}}, + {"negative: fn's error ends it as it is", []Msg{sized(36, 20, 0), sized(37, 20, 0)}, + []int{0, 1}, 0, 0, func(Msg) error { return stop }, result{err: "stop"}}, + {"boundary: a 16384-byte event fits", []Msg{sized(44, RecvBufCst, 0)}, []int{0}, 0, 0, nil, result{types: "44 "}}, + {"boundary: a 16380-byte event at offset 4 fits; at 8 it does not", []Msg{sized(44, 16380, 4), sized(44, 16380, 8)}, + []int{0, 1}, 0, 0, nil, result{types: "44 ", err: "Truncated message"}}, + {"boundary: no notifications", []Msg{sized(36, 20, 0)}, nil, 0, 0, nil, result{}}, + {"corner: a smaller buffer cuts sooner", []Msg{sized(36, 20, 0), sized(37, 40, 0)}, []int{0, 1}, 0, 32, nil, + result{types: "36 ", err: "Truncated message"}}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + var b strings.Builder + fn := tc.fn + if fn == nil { + fn = func(m Msg) error { + fmt.Fprintf(&b, "%d ", m.Hdr.Type) + return nil + } + } + err := Replay(tc.msgs, tc.notes, tc.start, tc.buf, fn) + got := result{types: b.String()} + if err != nil { + got.err = err.Error() + if got.err == "Truncated message" && !errors.Is(err, ErrTruncated) { + t.Errorf("%v is not ErrTruncated", err) + } + } + if got != tc.expected { + t.Errorf("got %+v, want %+v", got, tc.expected) + } + }) + } +} + +// TestDatagramOffsets pins Off: each message's start in its datagram, +// past the padding of those before it. +func TestDatagramOffsets(t *testing.T) { + tests := []struct { + description string + datagram []byte + expected string + }{ + {"positive: three messages", cat(rec(1, le32(1)), rec(2, nil), rec(3, nil)), "0 20 36 "}, + {"boundary: one message", rec(1, nil), "0 "}, + {"corner: a padded body moves the next", cat(rec(1, []byte{1}), rec(2, nil)), "0 20 "}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + var b strings.Builder + if err := Datagram(tc.datagram, false, -1, func(m Msg) error { + fmt.Fprintf(&b, "%d ", m.Off) + return nil + }); err != nil { + t.Fatal(err) + } + if b.String() != tc.expected { + t.Errorf("got %q, want %q", b.String(), tc.expected) + } + }) + } +} diff --git a/nix/checks/default.nix b/nix/checks/default.nix index 800572cf0..65b798515 100644 --- a/nix/checks/default.nix +++ b/nix/checks/default.nix @@ -94,6 +94,7 @@ in # xtcp2-nlcap wait-linkwatch (nix/microvms/netlink-capture.nix), the # settle wait goip-parity.exp runs after each Setup, on a fake sysfs. nlcap-wait-linkwatch = import ./nlcap-wait-linkwatch.nix { inherit pkgs; }; + nlcap-tcmon = import ./nlcap-tcmon.nix { inherit pkgs; }; # proto-lint: NOT in the default check set. `buf lint` reaches out to # buf.build for module deps (protovalidate, googleapis), which the hermetic # Nix sandbox blocks. Run `buf lint` directly from `nix develop`, where buf diff --git a/nix/checks/nlcap-tcmon.nix b/nix/checks/nlcap-tcmon.nix new file mode 100644 index 000000000..eff2b4252 --- /dev/null +++ b/nix/checks/nlcap-tcmon.nix @@ -0,0 +1,143 @@ +# nix/checks/nlcap-tcmon.nix +# +# Hermetic check for `xtcp2-nl-tcmon` (nix/microvms/netlink-capture.nix), +# the helper the tcmonitor workbench rows run `tc monitor` under. The real +# helper runs a fake tc (NLCAP_TC) that "subscribes" by writing its socket +# to a fake /proc/net/netlink (NLCAP_PROC_NETLINK), "listens" by writing a +# recvmsg to a fake /proc//task//syscall (NLCAP_PROC), and prints +# what the trigger appends to an events file once it listens; what is +# appended before, while it "dumps", is lost, as rtnl_dump_filter drops it. +# Each row asserts the exit status, stdout and stderr. Whether tc behaves as +# the fake does is what the workbench rows themselves record. +{ pkgs }: + +let + nlcap = import ../microvms/netlink-capture.nix { inherit pkgs; }; + fakeTc = pkgs.writeShellScript "fake-tc" '' + # fake-tc : monitor | slow-dump | dumping | queued | elsewhere | + # never | other-group | trunc | die + proc=$NLCAP_PROC_NETLINK + task=$NLCAP_PROC/$$/task/$$ + # sub : the socket's /proc/net/netlink line. + sub() { + printf 'sk Eth Pid Groups Rmem Wmem Dump Locks Drops Inode\nffff0001 0 4242 %s %s 0 %s 2 0 1\n' "$1" "$2" "$3" >"$proc" + } + # sys : the one thread's syscall, as the kernel shows a blocked one. + sys() { + mkdir -p "$task" + echo "$1 0x3 0x7ffc0000 0x0 0x0 0x0 0x0 0x7ffc0000 0x7f0000000000" >"$task/syscall" + } + case $1 in + monitor) sub 00000008 0 0; sys 47 ;; + slow-dump) sub 00000008 0 1 ;; + dumping) sub 00000008 0 1; sys 47 ;; + queued) sub 00000008 320 0; sys 47 ;; + elsewhere) sub 00000008 0 0; sys 7 ;; + other-group) sub 00000001 0 0; sys 47 ;; + trunc) sub 00000008 0 0; sys 47 ;; + never) ;; + die) echo 'Argument "die" is unknown, try "tc monitor help".' >&2; exit 255 ;; + esac + seen=0 + if [ "$1" = slow-dump ]; then + # The dump runs for a while; whatever the trigger appends meanwhile is + # not the dump's and is dropped. Then it listens. + sleep 0.5 + [ -f "$EVENTS" ] && seen=$(wc -l <"$EVENTS") + sub 00000008 0 0 + sys 47 + fi + while :; do + if [ -f "$EVENTS" ]; then + n=$(wc -l <"$EVENTS") + if [ "$n" -gt "$seen" ]; then + if [ "$1" = trunc ]; then + echo "Truncated message" >&2 + exit 2 + fi + tail -n +"$((seen + 1))" "$EVENTS" | head -n "$((n - seen))" + seen=$n + fi + fi + sleep 0.02 + done + ''; +in +pkgs.runCommand "xtcp2-nlcap-tcmon" + { + nativeBuildInputs = with pkgs; [ + bash + coreutils + gnugrep + nlcap.tcmon + ]; + } + '' + bash ${pkgs.writeText "tcmon-test.bash" '' + set -u + fails=0 + work=$(mktemp -d) + export NLCAP_PROC_NETLINK=$work/netlink NLCAP_PROC=$work/proc NLCAP_RECVMSG_NR=47 \ + NLCAP_TC=${fakeTc} EVENTS=$work/events + out=$work/out + err=$work/err + + # row + # An ERE of - wants the stream empty. + row() { + local category=$1 desc=$2 want_rc=$3 want_out=$4 want_err=$5 rc ok=1 + shift 5 + : >"$NLCAP_PROC_NETLINK" + rm -rf "$EVENTS" "$NLCAP_PROC" + rc=0 + xtcp2-nl-tcmon "$@" >"$out" 2>"$err" || rc=$? + [ "$rc" -eq "$want_rc" ] || ok=0 + if [ "$want_out" = - ]; then [ ! -s "$out" ] || ok=0; else grep -Eq -- "$want_out" "$out" || ok=0; fi + if [ "$want_err" = - ]; then [ ! -s "$err" ] || ok=0; else grep -Eq -- "$want_err" "$err" || ok=0; fi + if [ "$ok" -eq 1 ]; then + echo "ok $category: $desc (rc=$rc)" + else + echo "FAIL $category: $desc: rc=$rc (want $want_rc); stdout (want /$want_out/):" + cat "$out" + echo "stderr (want /$want_err/):" + cat "$err" + fails=$((fails + 1)) + fi + } + + row positive "one event, matched, then SIGTERM" 0 '^qdisc noqueue 0: dev d0$' - \ + monitor "echo 'qdisc noqueue 0: dev d0' >>$EVENTS" '^qdisc noqueue' + row positive "two events, both waited for" 0 '^deleted qdisc htb' - \ + monitor "echo 'qdisc htb 1: dev d0' >>$EVENTS; echo 'deleted qdisc htb 1: dev d0' >>$EVENTS" '^qdisc htb' '^deleted' + row positive "a monitor still dumping is waited for; the event raised after is seen" 0 '^qdisc noqueue 0: dev d0$' - \ + slow-dump "echo 'qdisc noqueue 0: dev d0' >>$EVENTS" '^qdisc noqueue' + row negative "a monitor whose dump never ends is not ready" 1 - 'never finished its link dump' \ + dumping "echo x >>$EVENTS" x + row boundary "a reply still queued (Rmem 320) is not ready" 1 - 'never finished its link dump' \ + queued "echo x >>$EVENTS" x + row corner "a monitor blocked in another syscall than recvmsg is not ready" 1 - 'never finished its link dump' \ + elsewhere "echo x >>$EVENTS" x + row negative "a monitor that never subscribes" 1 - 'never subscribed' \ + never "echo x >>$EVENTS" x + row negative "a socket on other groups is not the monitor" 1 - 'never subscribed' \ + other-group "echo x >>$EVENTS" x + row negative "a failing trigger is shown, with its output" 1 - 'the trigger failed: boom' \ + monitor "echo boom; false" + row negative "an event that never comes" 1 - 'no match for .never' \ + monitor "true" '^never$' + row boundary "a monitor that ends by itself passes its status on" 2 - '^Truncated message$' \ + trunc "echo big >>$EVENTS" 'Truncated message' + row boundary "and needs no ERE" 2 - '^Truncated message$' \ + trunc "echo big >>$EVENTS" + row corner "a monitor refusing its arguments exits with its own status, no complaint" 255 - '^Argument "die" is unknown' \ + die "true" + row corner "usage: fewer than two arguments" 2 - '^usage: xtcp2-nl-tcmon' monitor + + rm -rf "$work" + if [ "$fails" -ne 0 ]; then + echo "$fails row(s) failed" + exit 1 + fi + ''} + touch $out + '' diff --git a/nix/microvms/netlink-capture.nix b/nix/microvms/netlink-capture.nix index d1df4ddc0..648142813 100644 --- a/nix/microvms/netlink-capture.nix +++ b/nix/microvms/netlink-capture.nix @@ -10,7 +10,7 @@ # # This exports ONE thing: `xtcp2-nlcap`, a helper installed on the guest's # PATH (with `xtcp2-nl-mcdump`, `xtcp2-nl-ipmon`, `xtcp2-nl-brmon`, -# `xtcp2-nl-xfrmmon`, `xtcp2-nl-espinudp`, `xtcp2-nl-ra`, `xtcp2-nl-tcp`, +# `xtcp2-nl-tcmon`, `xtcp2-nl-xfrmmon`, `xtcp2-nl-espinudp`, `xtcp2-nl-ra`, `xtcp2-nl-tcp`, # `xtcp2-nl-ioam` and `xtcp2-nl-mptcp`, below, on its own PATH) # and invoked one subcommand at a time by a host driver # (nix/microvms/scripts/capture-netlink-dumps.exp, goip-parity.exp, @@ -415,6 +415,179 @@ let ''; }; + # xtcp2-nl-tcmon [until-ERE...] + # + # `tc ` (a `monitor`, with any global options ahead of it) in the + # background while runs, for the tcmonitor workbench rows + # (docs/netlink/gotc-status.md, 14C), as xtcp2-nl-xfrmmon is for + # `ip xfrm monitor`. + # + # Ready means listening, not only subscribed. tc_monitor.c binds + # RTNLGRP_TC, group 4, then runs ll_init_map's link dump on that same + # socket before rtnl_listen, and rtnl_dump_filter drops whatever is not + # the dump's, so an event the trigger raises during the dump is lost while + # the until-EREs can still match on later ones. So ready is all of: + # - a NETLINK_ROUTE (0) socket in /proc/net/netlink whose Groups column + # has bit 0x8 (a row's namespace is fresh, so it is the monitor's), + # - with its Dump column 0 (no dump running) and Rmem 0 (nothing queued, + # the dump's NLMSG_DONE included, as no TC event comes before the + # trigger), + # - and a thread of the monitor blocked in recvmsg(2): tc's dump reads + # only while a part is queued or the dump runs, and makes no recvmsg + # before its dump request, so the three together are rtnl_listen. + # NLCAP_PROC_NETLINK points the socket read at a file, NLCAP_PROC the + # /proc//task/*/syscall reads at a tree, NLCAP_RECVMSG_NR names + # recvmsg's number (else x86_64's or aarch64's), and NLCAP_TC the monitor + # at another binary, for the hermetic check (nix/checks/nlcap-tcmon.nix). + # + # Then runs with `bash -c`, its output kept apart and shown only + # if it fails, and the monitor is stopped with SIGTERM once its stdout or + # stderr matches every , each within 10 s; with none, once it + # ends by itself or 10 s pass. A monitor that ends by itself (tc's rtnl_listen failing: `Truncated message`, exit 2) stops + # the wait, and its exit status is the helper's. stdout is the monitor's + # stdout, stderr the monitor's stderr then the helper's own complaints. + # A monitor that never subscribes or never finishes its dump, a failed + # trigger or a timeout exits 1; a usage error exits 2. + tcmon = pkgs.writeShellApplication { + name = "xtcp2-nl-tcmon"; + runtimeInputs = with pkgs; [ + bash + coreutils + gawk + gnugrep + iproute2 + ]; + text = '' + [ $# -ge 2 ] || { + echo "usage: xtcp2-nl-tcmon [until-ERE...]" >&2 + exit 2 + } + read -ra tc_args <<<"$1" + trigger=$2 + shift 2 + proc=''${NLCAP_PROC_NETLINK:-/proc/net/netlink} + procdir=''${NLCAP_PROC:-/proc} + tc=''${NLCAP_TC:-tc} + nr=''${NLCAP_RECVMSG_NR:-} + if [ -z "$nr" ]; then + case $(uname -m) in + x86_64) nr=47 ;; + aarch64) nr=212 ;; + *) + echo "xtcp2-nl-tcmon: no recvmsg number for $(uname -m); set NLCAP_RECVMSG_NR" >&2 + exit 2 + ;; + esac + fi + + out=$(mktemp) + err=$(mktemp) + tout=$(mktemp) + trap 'rm -f "$out" "$err" "$tout"' EXIT + "$tc" "''${tc_args[@]}" >"$out" 2>"$err" & + mpid=$! + + # wait_match : poll the monitor's stdout and stderr, + # giving up early once the monitor has ended. + wait_match() { + local i + for ((i = 0; i < $2 * 2; i++)); do + grep -Eq -- "$1" "$out" "$err" && return 0 + kill -0 "$mpid" 2>/dev/null || { + grep -Eq -- "$1" "$out" "$err" + return + } + sleep 0.05 + done + return 1 + } + + # sock_state: "listening" for the monitor's socket with no dump + # running and nothing queued, "subscribed" for it otherwise, else + # nothing. Columns: sk Eth Pid Groups Rmem Wmem Dump ... + sock_state() { + awk '$2 == 0 && and(strtonum("0x" $4), 8) { + s = ($5 == 0 && $7 == 0) ? "listening" : "subscribed" + } + END { print s }' "$proc" + } + # in_recvmsg: a thread of the monitor is blocked in recvmsg(2). + in_recvmsg() { + local f n + for f in "$procdir/$mpid"/task/*/syscall; do + read -r n _ 2>/dev/null <"$f" || continue + [ "$n" = "$nr" ] && return 0 + done + return 1 + } + + ready=0 + subscribed=0 + for _ in $(seq 1 100); do + case $(sock_state) in + listening) + subscribed=1 + if in_recvmsg; then + ready=1 + break + fi + ;; + subscribed) subscribed=1 ;; + esac + kill -0 "$mpid" 2>/dev/null || break + sleep 0.05 + done + + rc=0 + complaints=() + if [ "$ready" -ne 1 ]; then + if kill -0 "$mpid" 2>/dev/null; then + if [ "$subscribed" -eq 1 ]; then + complaints+=("xtcp2-nl-tcmon: the monitor never finished its link dump") + else + complaints+=("xtcp2-nl-tcmon: the monitor never subscribed") + fi + fi + rc=1 + else + if ! bash -c "$trigger" >"$tout" 2>&1; then + complaints+=("xtcp2-nl-tcmon: the trigger failed: $(cat "$tout")") + rc=1 + fi + for re in "$@"; do + if ! wait_match "$re" 100; then + complaints+=("xtcp2-nl-tcmon: no match for $re") + rc=1 + fi + done + # With no ERE, the row expects the monitor to end by itself: give + # it the same 10 s. + if [ $# -eq 0 ]; then + for _ in $(seq 1 200); do + kill -0 "$mpid" 2>/dev/null || break + sleep 0.05 + done + fi + fi + + if kill -0 "$mpid" 2>/dev/null; then + kill -TERM "$mpid" 2>/dev/null || true + wait "$mpid" 2>/dev/null || true + else + mrc=0 + wait "$mpid" || mrc=$? + rc=$mrc + fi + cat "$out" + cat "$err" >&2 + if [ ''${#complaints[@]} -gt 0 ]; then + printf '%s\n' "''${complaints[@]}" >&2 + [ "$rc" -ne 0 ] || rc=1 + fi + exit "$rc" + ''; + }; + # xtcp2-nl-brmon ... # # `bridge ` (a `monitor fdb vlan` or `monitor vlan`) in the @@ -1048,6 +1221,7 @@ pkgs.writeShellApplication { passthru = { inherit brmon + tcmon xfrmmon espinudp ra @@ -1060,6 +1234,7 @@ pkgs.writeShellApplication { mcdump ipmon brmon + tcmon xfrmmon espinudp ra diff --git a/nix/microvms/workbench/tcmonitor.rows.jsonl b/nix/microvms/workbench/tcmonitor.rows.jsonl new file mode 100644 index 000000000..fc4529261 --- /dev/null +++ b/nix/microvms/workbench/tcmonitor.rows.jsonl @@ -0,0 +1,30 @@ +# Generated by `nlcapgen matrix -family tcmonitor -seed 1 -random 0`. +# Do not edit; regenerate. tools/nlcapgen/matrix.go explains the strategies. +# 27 rows. +{"id":"tcmonitor/ec-001","desc":"positive: cmd=qdisc:live:monitor","cmd":"xtcp2-nl-tcmon 'monitor' 'tc qdisc add dev d0 root handle 1: fq_codel && tc qdisc change dev d0 root handle 1: fq_codel limit 500 && tc qdisc replace dev d0 root handle 2: htb && tc qdisc del dev d0 root' 'deleted qdisc htb 2:'","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"qdisc","mode":"live","trigger":"tc qdisc add dev d0 root handle 1: fq_codel && tc qdisc change dev d0 root handle 1: fq_codel limit 500 && tc qdisc replace dev d0 root handle 2: htb && tc qdisc del dev d0 root","until":"deleted qdisc htb 2:","words":"monitor"}} +{"id":"tcmonitor/ec-002","desc":"positive: cmd=class:live:monitor","cmd":"xtcp2-nl-tcmon 'monitor' 'tc class add dev d0 parent 1: classid 1:10 htb rate 1mbit && tc class change dev d0 parent 1: classid 1:10 htb rate 2mbit && tc class del dev d0 classid 1:10' 'deleted class htb 1:10'","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up","tc qdisc add dev d0 root handle 1: htb"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"class","mode":"live","trigger":"tc class add dev d0 parent 1: classid 1:10 htb rate 1mbit && tc class change dev d0 parent 1: classid 1:10 htb rate 2mbit && tc class del dev d0 classid 1:10","until":"deleted class htb 1:10","words":"monitor"}} +{"id":"tcmonitor/ec-003","desc":"positive: cmd=filter:live:monitor","cmd":"xtcp2-nl-tcmon 'monitor' 'tc filter add dev d0 ingress pref 1 handle 1 protocol all basic action gact pass && tc filter replace dev d0 ingress pref 1 handle 1 protocol all basic action gact drop && tc filter change dev d0 ingress pref 1 handle 1 protocol all basic action gact pipe && tc filter del dev d0 ingress pref 1 handle 1 protocol all basic && tc chain add dev d0 ingress chain 3 && tc chain del dev d0 ingress chain 3' 'deleted chain'","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up","tc qdisc add dev d0 clsact"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"filter","mode":"live","trigger":"tc filter add dev d0 ingress pref 1 handle 1 protocol all basic action gact pass && tc filter replace dev d0 ingress pref 1 handle 1 protocol all basic action gact drop && tc filter change dev d0 ingress pref 1 handle 1 protocol all basic action gact pipe && tc filter del dev d0 ingress pref 1 handle 1 protocol all basic && tc chain add dev d0 ingress chain 3 && tc chain del dev d0 ingress chain 3","until":"deleted chain","words":"monitor"}} +{"id":"tcmonitor/ec-004","desc":"positive: cmd=filteracts:live:monitor","cmd":"xtcp2-nl-tcmon 'monitor' 'tc filter add dev d0 ingress pref 2 handle 2 protocol all matchall action gact pass action mirred egress redirect dev d0 && tc filter del dev d0 ingress pref 2' 'deleted filter'","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up","tc qdisc add dev d0 clsact"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"filteracts","mode":"live","trigger":"tc filter add dev d0 ingress pref 2 handle 2 protocol all matchall action gact pass action mirred egress redirect dev d0 && tc filter del dev d0 ingress pref 2","until":"deleted filter","words":"monitor"}} +{"id":"tcmonitor/ec-005","desc":"positive: cmd=actions:live:monitor","cmd":"xtcp2-nl-tcmon 'monitor' 'tc actions add action gact pass index 7 && tc actions replace action gact drop index 7 && tc actions del action gact index 7 && tc actions add action gact pass index 8 && tc actions flush action gact' 'Flushed table'","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"actions","mode":"live","trigger":"tc actions add action gact pass index 7 && tc actions replace action gact drop index 7 && tc actions del action gact index 7 && tc actions add action gact pass index 8 && tc actions flush action gact","until":"Flushed table","words":"monitor"}} +{"id":"tcmonitor/ec-006","desc":"positive: cmd=stats:live:-s_monitor","cmd":"xtcp2-nl-tcmon '-s monitor' 'tc qdisc add dev d0 root handle 1: htb && tc filter add dev d0 parent 1: pref 1 handle 1 protocol all basic classid 1:1' 'added filter'","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"stats","mode":"live","trigger":"tc qdisc add dev d0 root handle 1: htb && tc filter add dev d0 parent 1: pref 1 handle 1 protocol all basic classid 1:1","until":"added filter","words":"-s monitor"}} +{"id":"tcmonitor/ec-007","desc":"positive: cmd=details:live:-d_monitor","cmd":"xtcp2-nl-tcmon '-d monitor' 'tc qdisc add dev d0 root handle 1: htb && tc filter add dev d0 parent 1: pref 1 handle 1 protocol all basic classid 1:1' 'added filter'","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"details","mode":"live","trigger":"tc qdisc add dev d0 root handle 1: htb && tc filter add dev d0 parent 1: pref 1 handle 1 protocol all basic classid 1:1","until":"added filter","words":"-d monitor"}} +{"id":"tcmonitor/ec-008","desc":"corner: cmd=stamp:live:-t_monitor","cmd":"xtcp2-nl-tcmon '-t monitor' 'tc qdisc add dev d0 root handle 1: htb' 'qdisc htb 1:'","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"stamp","mode":"live","trigger":"tc qdisc add dev d0 root handle 1: htb","until":"qdisc htb 1:","words":"-t monitor"}} +{"id":"tcmonitor/ec-009","desc":"corner: cmd=stampshort:live:-tshort_monitor","cmd":"xtcp2-nl-tcmon '-tshort monitor' 'tc qdisc add dev d0 root handle 1: htb' 'qdisc htb 1:'","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"stampshort","mode":"live","trigger":"tc qdisc add dev d0 root handle 1: htb","until":"qdisc htb 1:","words":"-tshort monitor"}} +{"id":"tcmonitor/ec-010","desc":"corner: cmd=json:live:-j_monitor","cmd":"xtcp2-nl-tcmon '-j monitor' 'tc qdisc add dev d0 root handle 1: htb' 'qdisc htb 1:'","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"json","mode":"live","trigger":"tc qdisc add dev d0 root handle 1: htb","until":"qdisc htb 1:","words":"-j monitor"}} +{"id":"tcmonitor/ec-011","desc":"corner: cmd=rename:live:monitor","cmd":"xtcp2-nl-tcmon 'monitor' 'tc qdisc add dev d0 root handle 1: htb && ip link set d0 down && ip link set d0 name d1 && tc qdisc del dev d1 root' 'deleted qdisc htb'","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"rename","mode":"live","trigger":"tc qdisc add dev d0 root handle 1: htb && ip link set d0 down && ip link set d0 name d1 && tc qdisc del dev d1 root","until":"deleted qdisc htb","words":"monitor"}} +{"id":"tcmonitor/ec-012","desc":"boundary: cmd=under:live:monitor","cmd":"xtcp2-nl-tcmon 'monitor' 'tc filter add dev d0 ingress pref 1 handle 1 protocol all bpf bytecode-file ops.txt' 'bytecode'","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up","tc qdisc add dev d0 clsact","{ printf '2038'; i=0; while [ $i -lt 2038 ]; do printf ',6 0 0 0'; i=$((i+1)); done; echo; } > ops.txt"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"under","mode":"live","trigger":"tc filter add dev d0 ingress pref 1 handle 1 protocol all bpf bytecode-file ops.txt","until":"bytecode","words":"monitor"}} +{"id":"tcmonitor/ec-013","desc":"positive: cmd=file:monitor_file_m.bin","cmd":"tc monitor file m.bin","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up","echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | base64 -d > m.bin"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"file","mode":"file","words":"monitor file m.bin"}} +{"id":"tcmonitor/ec-014","desc":"corner: cmd=file:-t_monitor_file_m.bin","cmd":"tc -t monitor file m.bin","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up","echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7AAAACgAAAAAAAAAAAAAAAAAAAACAAAAEAABAAEAAQAAAAAACAABAGh0YgA0AAIAMAABAAABAAAAAAAASOgBAAABAAAAAAAAkNADAABMHQCghgEAAF7QsgAAAAACAAAASAAHABQAAQAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAEAAAAAAAAAAAAAAAAAABMHQCghgEALAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAQAAAAAAAAAAAAAAAAAAEwdAKCGAQBAAAAALAAABgAAAAAAAAAAAAAAAAMAAAAFAAAAAAABAAgACgAHAAEAZncAAAgACwAAAAAADAACAAgAAQABAAEAtAAAADAAAAYAAAAAAAAAAAAAAACgAAEAnAABAAkAAQBnYWN0AAAAAEQABAAUAAEAAAAAAAAAAAAAAAAAAAAAABQABwAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAKAAAAAABAAAIAGAACACEAAAAAAAAAAgAAAAEAAAAAAAAAJAABABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACQAAAAAAAAAAAAAAAAAAAADAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACUAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | base64 -d > m.bin"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"file","mode":"file","words":"-t monitor file m.bin"}} +{"id":"tcmonitor/ec-015","desc":"corner: cmd=file:-tshort_monitor_file_m.bin","cmd":"tc -tshort monitor file m.bin","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up","echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAU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AFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | base64 -d > m.bin"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"file","mode":"file","words":"-tshort monitor file m.bin"}} +{"id":"tcmonitor/ec-016","desc":"corner: cmd=file:-j_monitor_file_m.bin","cmd":"tc -j monitor file m.bin","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up","echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7AAAACgAAAAAAAAAAAAAAAAAAAACAAAAEAABAAEAAQAAAAAACAABAGh0YgA0AAIAMAABAAABAAAAAAAASOgBAAABAAAAAAAAkNADAABMHQCghgEAAF7QsgAAAAACAAAASAAHABQAAQAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAEAAAAAAAAAAAAAAAAAABMHQCghgEALAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAQAAAAAAAAAAAAAAAAAAEwdAKCGAQBAAAAALAAABgAAAAAAAAAAAAAAAAMAAAAFAAAAAAABAAgACgAHAAEAZncAAAgACwAAAAAADAACAAgAAQABAAEAtAAAADAAAAYAAAAAAAAAAAAAAACgAAEAnAABAAkAAQBnYWN0AAAAAEQABAAUAAEAAAAAAAAAAAAAAAAAAAAAABQABwAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAKAAAAAABAAAIAGAACACEAAAAAAAAAAgAAAAEAAAAAAAAAJAABABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACQAAAAAAAAAAAAAAAAAAAADAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACUAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | base64 -d > m.bin"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"file","mode":"file","words":"-j monitor file m.bin"}} +{"id":"tcmonitor/ec-017","desc":"corner: cmd=file:-s_-d_monitor_file_m.bin","cmd":"tc -s -d monitor file m.bin","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up","echo tAAAACQAAAAAAAA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AAAAAAAAAAtAAAACUAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | base64 -d > m.bin"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"file","mode":"file","words":"-s -d monitor file m.bin"}} +{"id":"tcmonitor/ec-018","desc":"corner: cmd=nonevents:-t_monitor_file_m.bin","cmd":"tc -t monitor file m.bin","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up","echo FAAAAAMAAgAAAAAAAAAAAAAAAAAkAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAAAAAAAIAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= | base64 -d > m.bin"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"nonevents","mode":"file","words":"-t monitor file m.bin"}} +{"id":"tcmonitor/ec-019","desc":"boundary: cmd=empty:monitor_file_m.bin","cmd":"tc monitor file m.bin","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up",": > m.bin"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"fix":"empty","mode":"file","words":"monitor file m.bin"}} +{"id":"tcmonitor/ec-020","desc":"corner: cmd=file:batch:show-then-file","cmd":"tc -batch b.txt","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up","echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7AAAACgAAAAAAAAAAAAAAAAAAAACAAAAEAABAAEAAQAAAAAACAABAGh0YgA0AAIAMAABAAABAAAAAAAASOgBAAABAAAAAAAAkNADAABMHQCghgEAAF7QsgAAAAACAAAASAAHABQAAQAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAEAAAAAAAAAAAAAAAAAABMHQCghgEALAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAQAAAAAAAAAAAAAAAAAAEwdAKCGAQBAAAAALAAABgAAAAAAAAAAAAAAAAMAAAAFAAAAAAABAAgACgAHAAEAZncAAAgACwAAAAAADAACAAgAAQABAAEAtAAAADAAAAYAAAAAAAAAAAAAAACgAAEAnAABAAkAAQBnYWN0AAAAAEQABAAUAAEAAAAAAAAAAAAAAAAAAAAAABQABwAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAKAAAAAABAAAIAGAACACEAAAAAAAAAAgAAAAEAAAAAAAAAJAABABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACQAAAAAAAAAAAAAAAAAAAADAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACUAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | base64 -d > m.bin","printf '%s\\n' 'qdisc show dev d0' 'monitor file m.bin' > b.txt"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":0,"refused_by":"none"},"axes":{"batch":"show-then-file","fix":"file","mode":"file","words":"-batch b.txt"}} +{"id":"tcmonitor/ng-001","desc":"negative: cmd=big:live:monitor: a 2040-op filter's event is past rtnl_listen's 16 KiB though its request fit tc's: Truncated message, exit 2 (MO5)","cmd":"xtcp2-nl-tcmon 'monitor' 'tc filter add dev d0 ingress pref 1 handle 1 protocol all bpf bytecode-file ops.txt'","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up","tc qdisc add dev d0 clsact","{ printf '2040'; i=0; while [ $i -lt 2040 ]; do printf ',6 0 0 0'; i=$((i+1)); done; echo; } > ops.txt"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":2,"refused_by":"ack-then-fail"},"axes":{"fix":"big","mode":"live","trigger":"tc filter add dev d0 ingress pref 1 handle 1 protocol all bpf bytecode-file ops.txt","until":"","words":"monitor"}} +{"id":"tcmonitor/ng-002","desc":"negative: cmd=ng:bare:monitor_help: help prints the usage and exits 255 (MO1)","cmd":"tc monitor help","modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":255,"refused_by":"iproute2"},"axes":{"fix":"bare","mode":"file","words":"monitor help"}} +{"id":"tcmonitor/ng-003","desc":"negative: cmd=ng:bare:monitor_bogus: an unknown word (MO14)","cmd":"tc monitor bogus","modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":255,"refused_by":"iproute2"},"axes":{"fix":"bare","mode":"file","words":"monitor bogus"}} +{"id":"tcmonitor/ng-004","desc":"negative: cmd=ng:bare:monitor_file: file with no value (MO14)","cmd":"tc monitor file","modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":255,"refused_by":"iproute2"},"axes":{"fix":"bare","mode":"file","words":"monitor file"}} +{"id":"tcmonitor/ng-005","desc":"negative: cmd=ng:bare:monitor_file_/nonexistent: Cannot fopen (MO13)","cmd":"tc monitor file /nonexistent","modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":255,"refused_by":"iproute2"},"axes":{"fix":"bare","mode":"file","words":"monitor file /nonexistent"}} +{"id":"tcmonitor/ng-006","desc":"negative: cmd=ng:trunc:monitor_file_m.bin: a record cut inside its body (MO13)","cmd":"tc monitor file m.bin","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up","echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== | base64 -d > m.bin"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":255,"refused_by":"iproute2"},"axes":{"fix":"trunc","mode":"file","words":"monitor file m.bin"}} +{"id":"tcmonitor/ng-007","desc":"negative: cmd=ng:malformed:monitor_file_m.bin: a record whose length is under the header's (MO13)","cmd":"tc monitor file m.bin","pre":["ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up","echo CAAAACQAAAAAAAAAAAAAAA== | base64 -d > m.bin"],"modules":["sch_htb","sch_ingress","sch_fq_codel","cls_basic","cls_matchall","cls_bpf","cls_fw","act_gact","act_mirred"],"proto":"route","expect":{"rc":255,"refused_by":"iproute2"},"axes":{"fix":"malformed","mode":"file","words":"monitor file m.bin"}} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-001/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-001/cmd.json new file mode 100644 index 000000000..8afd2daf5 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-001/cmd.json @@ -0,0 +1,52 @@ +{ + "axes": { + "fix": "qdisc", + "mode": "live", + "trigger": "tc qdisc add dev d0 root handle 1: fq_codel && tc qdisc change dev d0 root handle 1: fq_codel limit 500 && tc qdisc replace dev d0 root handle 2: htb && tc qdisc del dev d0 root", + "until": "deleted qdisc htb 2:", + "words": "monitor" + }, + "cmd": "xtcp2-nl-tcmon 'monitor' 'tc qdisc add dev d0 root handle 1: fq_codel && tc qdisc change dev d0 root handle 1: fq_codel limit 500 && tc qdisc replace dev d0 root handle 2: htb && tc qdisc del dev d0 root' 'deleted qdisc htb 2:'", + "desc": "positive: cmd=qdisc:live:monitor", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-001", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-001/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-001/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-001/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-001/ip.out new file mode 100644 index 000000000..9c1a23f19 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-001/ip.out @@ -0,0 +1,6 @@ +deleted qdisc noqueue 0: dev d0 root +qdisc fq_codel 1: dev d0 root refcnt 2 limit 10240p flows 1024 quantum 1514 target 5ms interval 100ms memory_limit 32Mb ecn drop_batch 64 +qdisc fq_codel 1: dev d0 root refcnt 2 limit 500p flows 1024 quantum 1514 target 5ms interval 100ms memory_limit 32Mb ecn drop_batch 64 +deleted qdisc fq_codel 1: dev d0 root refcnt 2 limit 500p flows 1024 quantum 1514 target 5ms interval 100ms memory_limit 32Mb ecn drop_batch 64 +qdisc htb 2: dev d0 root r2q 10 default 0 direct_packets_stat 0 direct_qlen 1000 +deleted qdisc htb 2: dev d0 root r2q 10 default 0 direct_packets_stat 0 direct_qlen 1000 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-001/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-001/ip.pcap new file mode 100644 index 000000000..13683949e Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-001/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-001/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-001/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-001/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-002/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-002/cmd.json new file mode 100644 index 000000000..6f7c15bf2 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-002/cmd.json @@ -0,0 +1,57 @@ +{ + "axes": { + "fix": "class", + "mode": "live", + "trigger": "tc class add dev d0 parent 1: classid 1:10 htb rate 1mbit && tc class change dev d0 parent 1: classid 1:10 htb rate 2mbit && tc class del dev d0 classid 1:10", + "until": "deleted class htb 1:10", + "words": "monitor" + }, + "cmd": "xtcp2-nl-tcmon 'monitor' 'tc class add dev d0 parent 1: classid 1:10 htb rate 1mbit && tc class change dev d0 parent 1: classid 1:10 htb rate 2mbit && tc class del dev d0 classid 1:10' 'deleted class htb 1:10'", + "desc": "positive: cmd=class:live:monitor", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-002", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up", + "tc qdisc add dev d0 root handle 1: htb" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up", + "rc": 0 + }, + { + "cmd": "tc qdisc add dev d0 root handle 1: htb", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-002/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-002/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-002/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-002/ip.out new file mode 100644 index 000000000..44ccc53bb --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-002/ip.out @@ -0,0 +1,3 @@ +class htb 1:10 dev d0 root prio 0 rate 1Mbit ceil 1Mbit burst 1600b cburst 1600b +class htb 1:10 dev d0 root prio 0 rate 2Mbit ceil 2Mbit burst 1600b cburst 1600b +deleted class htb 1:10 dev d0 root prio 0 rate 2Mbit ceil 2Mbit burst 1600b cburst 1600b diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-002/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-002/ip.pcap new file mode 100644 index 000000000..0b75f0e85 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-002/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-002/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-002/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-002/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-003/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-003/cmd.json new file mode 100644 index 000000000..2437e8fbe --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-003/cmd.json @@ -0,0 +1,57 @@ +{ + "axes": { + "fix": "filter", + "mode": "live", + "trigger": "tc filter add dev d0 ingress pref 1 handle 1 protocol all basic action gact pass && tc filter replace dev d0 ingress pref 1 handle 1 protocol all basic action gact drop && tc filter change dev d0 ingress pref 1 handle 1 protocol all basic action gact pipe && tc filter del dev d0 ingress pref 1 handle 1 protocol all basic && tc chain add dev d0 ingress chain 3 && tc chain del dev d0 ingress chain 3", + "until": "deleted chain", + "words": "monitor" + }, + "cmd": "xtcp2-nl-tcmon 'monitor' 'tc filter add dev d0 ingress pref 1 handle 1 protocol all basic action gact pass && tc filter replace dev d0 ingress pref 1 handle 1 protocol all basic action gact drop && tc filter change dev d0 ingress pref 1 handle 1 protocol all basic action gact pipe && tc filter del dev d0 ingress pref 1 handle 1 protocol all basic && tc chain add dev d0 ingress chain 3 && tc chain del dev d0 ingress chain 3' 'deleted chain'", + "desc": "positive: cmd=filter:live:monitor", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-003", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up", + "tc qdisc add dev d0 clsact" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up", + "rc": 0 + }, + { + "cmd": "tc qdisc add dev d0 clsact", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-003/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-003/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-003/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-003/ip.out new file mode 100644 index 000000000..64958bfa2 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-003/ip.out @@ -0,0 +1,24 @@ +added chain dev d0 parent ffff: chain 0 +added filter dev d0 ingress protocol all pref 1 basic chain 0 handle 0x1 + action order 1: gact action pass + random type none pass val 0 + index 1 ref 1 bind 1 + +replaced filter dev d0 ingress protocol all pref 1 basic chain 0 handle 0x1 + action order 1: gact action drop + random type none pass val 0 + index 2 ref 1 bind 1 + +filter dev d0 ingress protocol all pref 1 basic chain 0 handle 0x1 + action order 1: gact action pipe + random type none pass val 0 + index 1 ref 1 bind 1 + +deleted filter dev d0 ingress protocol all pref 1 basic chain 0 handle 0x1 + action order 1: gact action pipe + random type none pass val 0 + index 1 ref 1 bind 1 + +deleted chain dev d0 parent ffff: chain 0 +added chain dev d0 parent ffff: chain 3 +deleted chain dev d0 parent ffff: chain 3 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-003/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-003/ip.pcap new file mode 100644 index 000000000..88c4b8c6a Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-003/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-003/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-003/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-003/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-004/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-004/cmd.json new file mode 100644 index 000000000..55b5cf912 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-004/cmd.json @@ -0,0 +1,57 @@ +{ + "axes": { + "fix": "filteracts", + "mode": "live", + "trigger": "tc filter add dev d0 ingress pref 2 handle 2 protocol all matchall action gact pass action mirred egress redirect dev d0 && tc filter del dev d0 ingress pref 2", + "until": "deleted filter", + "words": "monitor" + }, + "cmd": "xtcp2-nl-tcmon 'monitor' 'tc filter add dev d0 ingress pref 2 handle 2 protocol all matchall action gact pass action mirred egress redirect dev d0 && tc filter del dev d0 ingress pref 2' 'deleted filter'", + "desc": "positive: cmd=filteracts:live:monitor", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-004", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up", + "tc qdisc add dev d0 clsact" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up", + "rc": 0 + }, + { + "cmd": "tc qdisc add dev d0 clsact", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-004/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-004/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-004/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-004/ip.out new file mode 100644 index 000000000..638331955 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-004/ip.out @@ -0,0 +1,4 @@ +added chain dev d0 parent ffff: chain 0 +added filter dev d0 ingress protocol all pref 2 matchall chain 0 +deleted filter dev d0 ingress protocol all pref 2 matchall chain 0 +deleted chain dev d0 parent ffff: chain 0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-004/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-004/ip.pcap new file mode 100644 index 000000000..3fd19ebb3 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-004/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-004/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-004/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-004/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-005/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-005/cmd.json new file mode 100644 index 000000000..943461f7d --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-005/cmd.json @@ -0,0 +1,52 @@ +{ + "axes": { + "fix": "actions", + "mode": "live", + "trigger": "tc actions add action gact pass index 7 && tc actions replace action gact drop index 7 && tc actions del action gact index 7 && tc actions add action gact pass index 8 && tc actions flush action gact", + "until": "Flushed table", + "words": "monitor" + }, + "cmd": "xtcp2-nl-tcmon 'monitor' 'tc actions add action gact pass index 7 && tc actions replace action gact drop index 7 && tc actions del action gact index 7 && tc actions add action gact pass index 8 && tc actions flush action gact' 'Flushed table'", + "desc": "positive: cmd=actions:live:monitor", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-005", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-005/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-005/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-005/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-005/ip.out new file mode 100644 index 000000000..cc8ba0026 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-005/ip.out @@ -0,0 +1,26 @@ +total acts 0 +Added action + action order 1: gact action pass + random type none pass val 0 + index 7 ref 1 bind 0 + not_in_hw +total acts 0 +Replaced action + action order 1: gact action drop + random type none pass val 0 + index 7 ref 2 bind 0 + not_in_hw +total acts 0 +Deleted action + action order 1: gact action drop + random type none pass val 0 + index 7 ref 0 bind 0 + not_in_hw +total acts 0 +Added action + action order 1: gact action pass + random type none pass val 0 + index 8 ref 1 bind 0 + not_in_hw +total acts 0 +Flushed table gact (1 entries) diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-005/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-005/ip.pcap new file mode 100644 index 000000000..eb7b494b6 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-005/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-005/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-005/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-005/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-006/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-006/cmd.json new file mode 100644 index 000000000..ffc6406cc --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-006/cmd.json @@ -0,0 +1,52 @@ +{ + "axes": { + "fix": "stats", + "mode": "live", + "trigger": "tc qdisc add dev d0 root handle 1: htb && tc filter add dev d0 parent 1: pref 1 handle 1 protocol all basic classid 1:1", + "until": "added filter", + "words": "-s monitor" + }, + "cmd": "xtcp2-nl-tcmon '-s monitor' 'tc qdisc add dev d0 root handle 1: htb && tc filter add dev d0 parent 1: pref 1 handle 1 protocol all basic classid 1:1' 'added filter'", + "desc": "positive: cmd=stats:live:-s_monitor", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-006", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-006/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-006/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-006/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-006/ip.out new file mode 100644 index 000000000..dce71fb86 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-006/ip.out @@ -0,0 +1,8 @@ +deleted qdisc noqueue 0: dev d0 root refcnt 2 + Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) + backlog 0b 0p requeues 0 +qdisc htb 1: dev d0 root r2q 10 default 0 direct_packets_stat 0 direct_qlen 1000 + Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) + backlog 0b 0p requeues 0 +added chain dev d0 parent 1: chain 0 +added filter dev d0 parent 1: protocol all pref 1 basic chain 0 handle 0x1 flowid 1:1 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-006/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-006/ip.pcap new file mode 100644 index 000000000..c0b47c392 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-006/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-006/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-006/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-006/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-007/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-007/cmd.json new file mode 100644 index 000000000..e8a8be0c1 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-007/cmd.json @@ -0,0 +1,52 @@ +{ + "axes": { + "fix": "details", + "mode": "live", + "trigger": "tc qdisc add dev d0 root handle 1: htb && tc filter add dev d0 parent 1: pref 1 handle 1 protocol all basic classid 1:1", + "until": "added filter", + "words": "-d monitor" + }, + "cmd": "xtcp2-nl-tcmon '-d monitor' 'tc qdisc add dev d0 root handle 1: htb && tc filter add dev d0 parent 1: pref 1 handle 1 protocol all basic classid 1:1' 'added filter'", + "desc": "positive: cmd=details:live:-d_monitor", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-007", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-007/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-007/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-007/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-007/ip.out new file mode 100644 index 000000000..0e51045c6 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-007/ip.out @@ -0,0 +1,4 @@ +deleted qdisc noqueue 0: dev d0 root refcnt 2 +qdisc htb 1: dev d0 root r2q 10 default 0 direct_packets_stat 0 ver 3.17 direct_qlen 1000 +added chain dev d0 parent 1: chain 0 +added filter dev d0 parent 1: protocol all pref 1 basic chain 0 handle 0x1 flowid 1:1 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-007/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-007/ip.pcap new file mode 100644 index 000000000..a859dfbeb Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-007/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-007/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-007/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-007/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-008/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-008/cmd.json new file mode 100644 index 000000000..d9747a800 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-008/cmd.json @@ -0,0 +1,52 @@ +{ + "axes": { + "fix": "stamp", + "mode": "live", + "trigger": "tc qdisc add dev d0 root handle 1: htb", + "until": "qdisc htb 1:", + "words": "-t monitor" + }, + "cmd": "xtcp2-nl-tcmon '-t monitor' 'tc qdisc add dev d0 root handle 1: htb' 'qdisc htb 1:'", + "desc": "corner: cmd=stamp:live:-t_monitor", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-008", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-008/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-008/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-008/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-008/ip.out new file mode 100644 index 000000000..b37a11a9a --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-008/ip.out @@ -0,0 +1,4 @@ +Timestamp: Thu Nov 26 04:58:19 2026 638445 usec +deleted qdisc noqueue 0: dev d0 root refcnt 2 +Timestamp: Thu Nov 26 04:58:19 2026 638498 usec +qdisc htb 1: dev d0 root r2q 10 default 0 direct_packets_stat 0 direct_qlen 1000 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-008/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-008/ip.pcap new file mode 100644 index 000000000..050d1ce66 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-008/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-008/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-008/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-008/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-009/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-009/cmd.json new file mode 100644 index 000000000..f4b9f8d4b --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-009/cmd.json @@ -0,0 +1,52 @@ +{ + "axes": { + "fix": "stampshort", + "mode": "live", + "trigger": "tc qdisc add dev d0 root handle 1: htb", + "until": "qdisc htb 1:", + "words": "-tshort monitor" + }, + "cmd": "xtcp2-nl-tcmon '-tshort monitor' 'tc qdisc add dev d0 root handle 1: htb' 'qdisc htb 1:'", + "desc": "corner: cmd=stampshort:live:-tshort_monitor", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-009", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-009/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-009/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-009/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-009/ip.out new file mode 100644 index 000000000..fc3e140e5 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-009/ip.out @@ -0,0 +1,2 @@ +[2026-11-26T04:58:20.057730] deleted qdisc noqueue 0: dev d0 root refcnt 2 +[2026-11-26T04:58:20.057801] qdisc htb 1: dev d0 root r2q 10 default 0 direct_packets_stat 0 direct_qlen 1000 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-009/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-009/ip.pcap new file mode 100644 index 000000000..455f01cd7 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-009/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-009/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-009/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-009/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-010/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-010/cmd.json new file mode 100644 index 000000000..f4e332625 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-010/cmd.json @@ -0,0 +1,52 @@ +{ + "axes": { + "fix": "json", + "mode": "live", + "trigger": "tc qdisc add dev d0 root handle 1: htb", + "until": "qdisc htb 1:", + "words": "-j monitor" + }, + "cmd": "xtcp2-nl-tcmon '-j monitor' 'tc qdisc add dev d0 root handle 1: htb' 'qdisc htb 1:'", + "desc": "corner: cmd=json:live:-j_monitor", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-010", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-010/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-010/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-010/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-010/ip.out new file mode 100644 index 000000000..9ca51e822 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-010/ip.out @@ -0,0 +1,2 @@ +deleted qdisc noqueue 0: dev d0 root refcnt 2 +qdisc htb 1: dev d0 root r2q 10 default 0 direct_packets_stat 0 direct_qlen 1000 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-010/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-010/ip.pcap new file mode 100644 index 000000000..c97d42479 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-010/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-010/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-010/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-010/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-011/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-011/cmd.json new file mode 100644 index 000000000..e1035ad52 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-011/cmd.json @@ -0,0 +1,52 @@ +{ + "axes": { + "fix": "rename", + "mode": "live", + "trigger": "tc qdisc add dev d0 root handle 1: htb && ip link set d0 down && ip link set d0 name d1 && tc qdisc del dev d1 root", + "until": "deleted qdisc htb", + "words": "monitor" + }, + "cmd": "xtcp2-nl-tcmon 'monitor' 'tc qdisc add dev d0 root handle 1: htb && ip link set d0 down && ip link set d0 name d1 && tc qdisc del dev d1 root' 'deleted qdisc htb'", + "desc": "corner: cmd=rename:live:monitor", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-011", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-011/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-011/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-011/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-011/ip.out new file mode 100644 index 000000000..8b6f779aa --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-011/ip.out @@ -0,0 +1,3 @@ +deleted qdisc noqueue 0: dev d0 root refcnt 2 +qdisc htb 1: dev d0 root r2q 10 default 0 direct_packets_stat 0 direct_qlen 1000 +deleted qdisc htb 1: dev d0 root r2q 10 default 0 direct_packets_stat 0 direct_qlen 1000 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-011/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-011/ip.pcap new file mode 100644 index 000000000..0de609ba5 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-011/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-011/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-011/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-011/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-012/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-012/cmd.json new file mode 100644 index 000000000..cb3ee539b --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-012/cmd.json @@ -0,0 +1,62 @@ +{ + "axes": { + "fix": "under", + "mode": "live", + "trigger": "tc filter add dev d0 ingress pref 1 handle 1 protocol all bpf bytecode-file ops.txt", + "until": "bytecode", + "words": "monitor" + }, + "cmd": "xtcp2-nl-tcmon 'monitor' 'tc filter add dev d0 ingress pref 1 handle 1 protocol all bpf bytecode-file ops.txt' 'bytecode'", + "desc": "boundary: cmd=under:live:monitor", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-012", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up", + "tc qdisc add dev d0 clsact", + "{ printf '2038'; i=0; while [ $i -lt 2038 ]; do printf ',6 0 0 0'; i=$((i+1)); done; echo; } > ops.txt" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up", + "rc": 0 + }, + { + "cmd": "tc qdisc add dev d0 clsact", + "rc": 0 + }, + { + "cmd": "{ printf '2038'; i=0; while [ $i -lt 2038 ]; do printf ',6 0 0 0'; i=$((i+1)); done; echo; } > ops.txt", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-012/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-012/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-012/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-012/ip.out new file mode 100644 index 000000000..f432ae323 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-012/ip.out @@ -0,0 +1,2 @@ +added chain dev d0 parent ffff: chain 0 +added filter dev d0 ingress protocol all pref 1 bpf chain 0 handle 0x1 not_in_hw bytecode '2038,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6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 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0' diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-012/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-012/ip.pcap new file mode 100644 index 000000000..fc2bebdcf Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-012/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-012/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-012/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-012/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-012/ops.txt b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-012/ops.txt new file mode 100644 index 000000000..4afc2648d --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-012/ops.txt @@ -0,0 +1 @@ +2038,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 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0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0,6 0 0 0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-013/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-013/cmd.json new file mode 100644 index 000000000..d7fb6a0c5 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-013/cmd.json @@ -0,0 +1,55 @@ +{ + "axes": { + "fix": "file", + "mode": "file", + "words": "monitor file m.bin" + }, + "cmd": "tc monitor file m.bin", + "desc": "positive: cmd=file:monitor_file_m.bin", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-013", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7AAAACgAAAAAAAAAAAAAAAAAAAACAAAAEAABAAEAAQAAAAAACAABAGh0YgA0AAIAMAABAAABAAAAAAAASOgBAAABAAAAAAAAkNADAABMHQCghgEAAF7QsgAAAAACAAAASAAHABQAAQAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAEAAAAAAAAAAAAAAAAAABMHQCghgEALAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAQAAAAAAAAAAAAAAAAAAEwdAKCGAQBAAAAALAAABgAAAAAAAAAAAAAAAAMAAAAFAAAAAAABAAgACgAHAAEAZncAAAgACwAAAAAADAACAAgAAQABAAEAtAAAADAAAAYAAAAAAAAAAAAAAACgAAEAnAABAAkAAQBnYWN0AAAAAEQABAAUAAEAAAAAAAAAAAAAAAAAAAAAABQABwAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAKAAAAAABAAAIAGAACACEAAAAAAAAAAgAAAAEAAAAAAAAAJAABABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACQAAAAAAAAAAAAAAAAAAAADAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACUAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | base64 -d > m.bin" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "rc": 0 + }, + { + "cmd": "echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7AAAACgAAAAAAAAAAAAAAAAAAAACAAAAEAABAAEAAQAAAAAACAABAGh0YgA0AAIAMAABAAABAAAAAAAASOgBAAABAAAAAAAAkNADAABMHQCghgEAAF7QsgAAAAACAAAASAAHABQAAQAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAEAAAAAAAAAAAAAAAAAABMHQCghgEALAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAQAAAAAAAAAAAAAAAAAAEwdAKCGAQBAAAAALAAABgAAAAAAAAAAAAAAAAMAAAAFAAAAAAABAAgACgAHAAEAZncAAAgACwAAAAAADAACAAgAAQABAAEAtAAAADAAAAYAAAAAAAAAAAAAAACgAAEAnAABAAkAAQBnYWN0AAAAAEQABAAUAAEAAAAAAAAAAAAAAAAAAAAAABQABwAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAKAAAAAABAAAIAGAACACEAAAAAAAAAAgAAAAEAAAAAAAAAJAABABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACQAAAAAAAAAAAAAAAAAAAADAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACUAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | base64 -d > m.bin", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-013/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-013/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-013/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-013/ip.out new file mode 100644 index 000000000..24b694f36 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-013/ip.out @@ -0,0 +1,11 @@ +qdisc htb 1: dev nlmon0 root refcnt 2 r2q 5 default 0x10 direct_packets_stat 0 direct_qlen 1000 +class htb 1:10 dev nlmon0 parent 1:1 prio 2 rate 1Mbit ceil 2Mbit burst 15Kb cburst 1600b +added filter dev d0 parent 1: protocol ip pref 10 fw chain 0 handle 0x5 classid 1:1 +total acts 0 +Added action + action order 1: gact action drop + random type none pass val 0 + index 33 ref 1 bind 0 + not_in_hw +qdisc htb 1: dev d0 root refcnt 2 r2q 5 default 0x10 direct_packets_stat 0 direct_qlen 1000 +deleted qdisc htb 1: dev nlmon0 root refcnt 2 r2q 5 default 0x10 direct_packets_stat 0 direct_qlen 1000 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-013/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-013/ip.pcap new file mode 100644 index 000000000..c51d7b606 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-013/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-013/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-013/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-013/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-013/m.bin b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-013/m.bin new file mode 100644 index 000000000..50abaad2b Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-013/m.bin differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-014/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-014/cmd.json new file mode 100644 index 000000000..fbd952071 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-014/cmd.json @@ -0,0 +1,55 @@ +{ + "axes": { + "fix": "file", + "mode": "file", + "words": "-t monitor file m.bin" + }, + "cmd": "tc -t monitor file m.bin", + "desc": "corner: cmd=file:-t_monitor_file_m.bin", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-014", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7AAAACgAAAAAAAAAAAAAAAA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AA | base64 -d > m.bin" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "rc": 0 + }, + { + "cmd": "echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7AAAACgAAAAAAAAAAAAAAAAAAAACAAAAEAABAAEAAQAAAAAACAABAGh0YgA0AAIAMAABAAABAAAAAAAASOgBAAABAAAAAAAAkNADAABMHQCghgEAAF7QsgAAAAACAAAASAAHABQAAQAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAEAAAAAAAAAAAAAAAAAABMHQCghgEALAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAQAAAAAAAAAAAAAAAAAAEwdAKCGAQBAAAAALAAABgAAAAAAAAAAAAAAAAMAAAAFAAAAAAABAAgACgAHAAEAZncAAAgACwAAAAAADAACAAgAAQABAAEAtAAAADAAAAYAAAAAAAAAAAAAAACgAAEAnAABAAkAAQBnYWN0AAAAAEQABAAUAAEAAAAAAAAAAAAAAAAAAAAAABQABwAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAKAAAAAABAAAIAGAACACEAAAAAAAAAAgAAAAEAAAAAAAAAJAABABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACQAAAAAAAAAAAAAAAAAAAADAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACUAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | base64 -d > m.bin", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-014/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-014/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-014/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-014/ip.out new file mode 100644 index 000000000..741729c23 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-014/ip.out @@ -0,0 +1,17 @@ +Timestamp: Thu Nov 26 04:58:20 2026 99173 usec +qdisc htb 1: dev nlmon0 root refcnt 2 r2q 5 default 0x10 direct_packets_stat 0 direct_qlen 1000 +Timestamp: Thu Nov 26 04:58:20 2026 99258 usec +class htb 1:10 dev nlmon0 parent 1:1 prio 2 rate 1Mbit ceil 2Mbit burst 15Kb cburst 1600b +Timestamp: Thu Nov 26 04:58:20 2026 99269 usec +added filter dev d0 parent 1: protocol ip pref 10 fw chain 0 handle 0x5 classid 1:1 +Timestamp: Thu Nov 26 04:58:20 2026 99307 usec +total acts 0 +Added action + action order 1: gact action drop + random type none pass val 0 + index 33 ref 1 bind 0 + not_in_hw +Timestamp: Thu Nov 26 04:58:20 2026 99316 usec +qdisc htb 1: dev d0 root refcnt 2 r2q 5 default 0x10 direct_packets_stat 0 direct_qlen 1000 +Timestamp: Thu Nov 26 04:58:20 2026 99319 usec +deleted qdisc htb 1: dev nlmon0 root refcnt 2 r2q 5 default 0x10 direct_packets_stat 0 direct_qlen 1000 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-014/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-014/ip.pcap new file mode 100644 index 000000000..6f418ccd8 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-014/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-014/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-014/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-014/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-014/m.bin b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-014/m.bin new file mode 100644 index 000000000..50abaad2b Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-014/m.bin differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-015/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-015/cmd.json new file mode 100644 index 000000000..cac188390 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-015/cmd.json @@ -0,0 +1,55 @@ +{ + "axes": { + "fix": "file", + "mode": "file", + "words": "-tshort monitor file m.bin" + }, + "cmd": "tc -tshort monitor file m.bin", + "desc": "corner: cmd=file:-tshort_monitor_file_m.bin", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-015", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7AAAACgAAAAAAAAAAAAAAAAAAAACAAAAEAABAAEAAQAAAAAACAABAGh0YgA0AAIAMAABAAABAAAAAAAASOgBAAABAAAAAAAAkNADAABMHQCghgEAAF7QsgAAAAACAAAASAAHABQAAQAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAEAAAAAAAAAAAAAAAAAABMHQCghgEALAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAQAAAAAAAAAAAAAAAAAAEwdAKCGAQBAAAAALAAABgAAAAAAAAAAAAAAAAMAAAAFAAAAAAABAAgACgAHAAEAZncAAAgACwAAAAAADAACAAgAAQABAAEAtAAAADAAAAYAAAAAAAAAAAAAAACgAAEAnAABAAkAAQBnYWN0AAAAAEQABAAUAAEAAAAAAAAAAAAAAAAAAAAAABQABwAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAKAAAAAABAAAIAGAACACEAAAAAAAAAAgAAAAEAAAAAAAAAJAABABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACQAAAAAAAAAAAAAAAAAAAADAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACUAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | base64 -d > m.bin" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "rc": 0 + }, + { + "cmd": "echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | base64 -d > m.bin", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-015/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-015/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-015/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-015/ip.out new file mode 100644 index 000000000..5388db3da --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-015/ip.out @@ -0,0 +1,11 @@ +[2026-11-26T04:58:20.105150] qdisc htb 1: dev nlmon0 root refcnt 2 r2q 5 default 0x10 direct_packets_stat 0 direct_qlen 1000 +[2026-11-26T04:58:20.105212] class htb 1:10 dev nlmon0 parent 1:1 prio 2 rate 1Mbit ceil 2Mbit burst 15Kb cburst 1600b +[2026-11-26T04:58:20.105220] added filter dev d0 parent 1: protocol ip pref 10 fw chain 0 handle 0x5 classid 1:1 +[2026-11-26T04:58:20.105248] total acts 0 +Added action + action order 1: gact action drop + random type none pass val 0 + index 33 ref 1 bind 0 + not_in_hw +[2026-11-26T04:58:20.105256] qdisc htb 1: dev d0 root refcnt 2 r2q 5 default 0x10 direct_packets_stat 0 direct_qlen 1000 +[2026-11-26T04:58:20.105259] deleted qdisc htb 1: dev nlmon0 root refcnt 2 r2q 5 default 0x10 direct_packets_stat 0 direct_qlen 1000 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-015/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-015/ip.pcap new file mode 100644 index 000000000..a07745ee1 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-015/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-015/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-015/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-015/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-015/m.bin b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-015/m.bin new file mode 100644 index 000000000..50abaad2b Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-015/m.bin differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-016/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-016/cmd.json new file mode 100644 index 000000000..27ac82a6f --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-016/cmd.json @@ -0,0 +1,55 @@ +{ + "axes": { + "fix": "file", + "mode": "file", + "words": "-j monitor file m.bin" + }, + "cmd": "tc -j monitor file m.bin", + "desc": "corner: cmd=file:-j_monitor_file_m.bin", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-016", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7AAAACgAAAAAAAAAAAAAAAAAAAACAAAAEAABAAEAAQAAAAAACAABAGh0YgA0AAIAMAABAAABAAAAAAAASOgBAAABAAAAAAAAkNADAABMHQCghgEAAF7QsgAAAAACAAAASAAHABQAAQAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAEAAAAAAAAAAAAAAAAAABMHQCghgEALAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAQAAAAAAAAAAAAAAAAAAEwdAKCGAQBAAAAALAAABgAAAAAAAAAAAAAAAAMAAAAFAAAAAAABAAgACgAHAAEAZncAAAgACwAAAAAADAACAAgAAQABAAEAtAAAADAAAAYAAAAAAAAAAAAAAACgAAEAnAABAAkAAQBnYWN0AAAAAEQABAAUAAEAAAAAAAAAAAAAAAAAAAAAABQABwAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAKAAAAAABAAAIAGAACACEAAAAAAAAAAgAAAAEAAAAAAAAAJAABABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACQAAAAAAAAAAAAAAAAAAAADAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACUAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | base64 -d > m.bin" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "rc": 0 + }, + { + "cmd": "echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7AAAACgAAAAAAAAAAAAAAAAAAAACAAAAEAABAAEAAQAAAAAACAABAGh0YgA0AAIAMAABAAABAAAAAAAASOgBAAABAAAAAAAAkNADAABMHQCghgEAAF7QsgAAAAACAAAASAAHABQAAQAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAEAAAAAAAAAAAAAAAAAABMHQCghgEALAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAQAAAAAAAAAAAAAAAAAAEwdAKCGAQBAAAAALAAABgAAAAAAAAAAAAAAAAMAAAAFAAAAAAABAAgACgAHAAEAZncAAAgACwAAAAAADAACAAgAAQABAAEAtAAAADAAAAYAAAAAAAAAAAAAAACgAAEAnAABAAkAAQBnYWN0AAAAAEQABAAUAAEAAAAAAAAAAAAAAAAAAAAAABQABwAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAKAAAAAABAAAIAGAACACEAAAAAAAAAAgAAAAEAAAAAAAAAJAABABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACQAAAAAAAAAAAAAAAAAAAADAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACUAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | base64 -d > m.bin", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-016/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-016/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-016/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-016/ip.out new file mode 100644 index 000000000..24b694f36 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-016/ip.out @@ -0,0 +1,11 @@ +qdisc htb 1: dev nlmon0 root refcnt 2 r2q 5 default 0x10 direct_packets_stat 0 direct_qlen 1000 +class htb 1:10 dev nlmon0 parent 1:1 prio 2 rate 1Mbit ceil 2Mbit burst 15Kb cburst 1600b +added filter dev d0 parent 1: protocol ip pref 10 fw chain 0 handle 0x5 classid 1:1 +total acts 0 +Added action + action order 1: gact action drop + random type none pass val 0 + index 33 ref 1 bind 0 + not_in_hw +qdisc htb 1: dev d0 root refcnt 2 r2q 5 default 0x10 direct_packets_stat 0 direct_qlen 1000 +deleted qdisc htb 1: dev nlmon0 root refcnt 2 r2q 5 default 0x10 direct_packets_stat 0 direct_qlen 1000 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-016/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-016/ip.pcap new file mode 100644 index 000000000..03958773c Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-016/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-016/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-016/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-016/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-016/m.bin b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-016/m.bin new file mode 100644 index 000000000..50abaad2b Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-016/m.bin differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-017/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-017/cmd.json new file mode 100644 index 000000000..8d1b6a98d --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-017/cmd.json @@ -0,0 +1,55 @@ +{ + "axes": { + "fix": "file", + "mode": "file", + "words": "-s -d monitor file m.bin" + }, + "cmd": "tc -s -d monitor file m.bin", + "desc": "corner: cmd=file:-s_-d_monitor_file_m.bin", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-017", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7AAAACgAAAAAAAAAAAAAAAAAAAACAAAAEAABAAEAAQAAAAAACAABAGh0YgA0AAIAMAABAAABAAAAAAAASOgBAAABAAAAAAAAkNADAABMHQCghgEAAF7QsgAAAAACAAAASAAHABQAAQAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAEAAAAAAAAAAAAAAAAAABMHQCghgEALAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAQAAAAAAAAAAAAAAAAAAEwdAKCGAQBAAAAALAAABgAAAAAAAAAAAAAAAAMAAAAFAAAAAAABAAgACgAHAAEAZncAAAgACwAAAAAADAACAAgAAQABAAEAtAAAADAAAAYAAAAAAAAAAAAAAACgAAEAnAABAAkAAQBnYWN0AAAAAEQABAAUAAEAAAAAAAAAAAAAAAAAAAAAABQABwAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAKAAAAAABAAAIAGAACACEAAAAAAAAAAgAAAAEAAAAAAAAAJAABABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACQAAAAAAAAAAAAAAAAAAAADAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACUAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | base64 -d > m.bin" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "rc": 0 + }, + { + "cmd": "echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEA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YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | base64 -d > m.bin", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-017/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-017/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-017/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-017/ip.out new file mode 100644 index 000000000..79c52c38f --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-017/ip.out @@ -0,0 +1,25 @@ +qdisc htb 1: dev nlmon0 root refcnt 2 r2q 5 default 0x10 direct_packets_stat 0 ver 3.17 direct_qlen 1000 + Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) + backlog 0b 0p requeues 0 +class htb 1:10 dev nlmon0 parent 1:1 prio 2 quantum -1294967296 rate 1Mbit ceil 2Mbit linklayer ethernet burst 15Kb/1mpu 0b cburst 1600b/1mpu 0b level 0 + Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) + backlog 0b 0p requeues 0 + lended: 0 borrowed: 0 giants: 0 + tokens: 1920000 ctokens: 100000 + +added filter dev d0 parent 1: protocol ip pref 10 fw chain 0 handle 0x5 classid 1:1 +total acts 0 +Added action + action order 1: gact action drop + random type none pass val 0 + index 33 ref 1 bind 0 installed 0 sec used 0 sec + Action statistics: + Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) + backlog 0b 0p requeues 0 + not_in_hw +qdisc htb 1: dev d0 root refcnt 2 r2q 5 default 0x10 direct_packets_stat 0 ver 3.17 direct_qlen 1000 + Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) + backlog 0b 0p requeues 0 +deleted qdisc htb 1: dev nlmon0 root refcnt 2 r2q 5 default 0x10 direct_packets_stat 0 ver 3.17 direct_qlen 1000 + Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) + backlog 0b 0p requeues 0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-017/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-017/ip.pcap new file mode 100644 index 000000000..562aeb85f Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-017/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-017/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-017/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-017/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-017/m.bin b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-017/m.bin new file mode 100644 index 000000000..50abaad2b Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-017/m.bin differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-018/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-018/cmd.json new file mode 100644 index 000000000..8095d2fe5 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-018/cmd.json @@ -0,0 +1,55 @@ +{ + "axes": { + "fix": "nonevents", + "mode": "file", + "words": "-t monitor file m.bin" + }, + "cmd": "tc -t monitor file m.bin", + "desc": "corner: cmd=nonevents:-t_monitor_file_m.bin", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-018", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "echo FAAAAAMAAgAAAAAAAAAAAAAAAAAkAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAAAAAAAIAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= | base64 -d > m.bin" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "rc": 0 + }, + { + "cmd": "echo FAAAAAMAAgAAAAAAAAAAAAAAAAAkAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAQAAAAAAAAAAAAAAIAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= | base64 -d > m.bin", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-018/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-018/ip.err new file mode 100644 index 000000000..9f2e44b7a --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-018/ip.err @@ -0,0 +1 @@ +Unknown message: length 00000032 type 00000010 flags 00000000 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-018/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-018/ip.out new file mode 100644 index 000000000..2cf0875fc --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-018/ip.out @@ -0,0 +1,4 @@ +Timestamp: Thu Nov 26 04:58:20 2026 486664 usec +Timestamp: Thu Nov 26 04:58:20 2026 486676 usec +Timestamp: Thu Nov 26 04:58:20 2026 486678 usec +Timestamp: Thu Nov 26 04:58:20 2026 486680 usec diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-018/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-018/ip.pcap new file mode 100644 index 000000000..dcb4ca923 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-018/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-018/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-018/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-018/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-018/m.bin b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-018/m.bin new file mode 100644 index 000000000..a3f0dafcd Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-018/m.bin differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-019/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-019/cmd.json new file mode 100644 index 000000000..020efa805 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-019/cmd.json @@ -0,0 +1,55 @@ +{ + "axes": { + "fix": "empty", + "mode": "file", + "words": "monitor file m.bin" + }, + "cmd": "tc monitor file m.bin", + "desc": "boundary: cmd=empty:monitor_file_m.bin", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-019", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + ": > m.bin" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "rc": 0 + }, + { + "cmd": ": > m.bin", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-019/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-019/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-019/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-019/ip.out new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-019/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-019/ip.pcap new file mode 100644 index 000000000..dcb4ca923 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-019/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-019/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-019/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-019/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-019/m.bin b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-019/m.bin new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/b.txt b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/b.txt new file mode 100644 index 000000000..92f5a903f --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/b.txt @@ -0,0 +1,2 @@ +qdisc show dev d0 +monitor file m.bin diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/cmd.json new file mode 100644 index 000000000..4da58a9ee --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/cmd.json @@ -0,0 +1,61 @@ +{ + "axes": { + "batch": "show-then-file", + "fix": "file", + "mode": "file", + "words": "-batch b.txt" + }, + "cmd": "tc -batch b.txt", + "desc": "corner: cmd=file:batch:show-then-file", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 0, + "refused_by": "none" + }, + "id": "tcmonitor/ec-020", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7AAAACgAAAAAAAAAAAAAAAAAAAACAAAAEAABAAEAAQAAAAAACAABAGh0YgA0AAIAMAABAAABAAAAAAAASOgBAAABAAAAAAAAkNADAABMHQCghgEAAF7QsgAAAAACAAAASAAHABQAAQAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAAEAAAAAAAAAAAAAAAAAABMHQCghgEALAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAQAAAAAAAAAAAAAAAAAAEwdAKCGAQBAAAAALAAABgAAAAAAAAAAAAAAAAMAAAAFAAAAAAABAAgACgAHAAEAZncAAAgACwAAAAAADAACAAgAAQABAAEAtAAAADAAAAYAAAAAAAAAAAAAAACgAAEAnAABAAkAAQBnYWN0AAAAAEQABAAUAAEAAAAAAAAAAAAAAAAAAAAAABQABwAAAAAAAAAAAAAAAAAAAAAAGAADAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAKAAAAAABAAAIAGAACACEAAAAAAAAAAgAAAAEAAAAAAAAAJAABABAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACQAAAAAAAAAAAAAAAAAAAADAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtAAAACUAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | base64 -d > m.bin", + "printf '%s\\n' 'qdisc show dev d0' 'monitor file m.bin' > b.txt" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "rc": 0 + }, + { + "cmd": "echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA7AAAACgAAAAAAAAAAAAAAAAAAAACAAAAEAABAAEAAQAAAAA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+ }, + { + "cmd": "printf '%s\\n' 'qdisc show dev d0' 'monitor file m.bin' > b.txt", + "rc": 0 + } + ], + "rc": 0, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/ip.err new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/ip.out new file mode 100644 index 000000000..f5947de82 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/ip.out @@ -0,0 +1,10 @@ +qdisc noqueue 0: root refcnt 2 +class htb 1:10 dev nlmon0 parent 1:1 prio 2 rate 1Mbit ceil 2Mbit burst 15Kb cburst 1600b +added filter dev d0 parent 1: protocol ip pref 10 fw chain 0 handle 0x5 classid 1:1 +total acts 0 +Added action + action order 1: gact action drop + random type none pass val 0 + index 33 ref 1 bind 0 + not_in_hw +qdisc htb 1: root refcnt 2 r2q 5 default 0x10 direct_packets_stat 0 direct_qlen 1000 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/ip.pcap new file mode 100644 index 000000000..8822ba72d Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/ip.rc new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/ip.rc @@ -0,0 +1 @@ +0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/m.bin b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/m.bin new file mode 100644 index 000000000..50abaad2b Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ec-020/m.bin differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-001/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-001/cmd.json new file mode 100644 index 000000000..d926e4267 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-001/cmd.json @@ -0,0 +1,62 @@ +{ + "axes": { + "fix": "big", + "mode": "live", + "trigger": "tc filter add dev d0 ingress pref 1 handle 1 protocol all bpf bytecode-file ops.txt", + "until": "", + "words": "monitor" + }, + "cmd": "xtcp2-nl-tcmon 'monitor' 'tc filter add dev d0 ingress pref 1 handle 1 protocol all bpf bytecode-file ops.txt'", + "desc": "negative: cmd=big:live:monitor: a 2040-op filter's event is past rtnl_listen's 16 KiB though its request fit tc's: Truncated message, exit 2 (MO5)", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 2, + "refused_by": "ack-then-fail" + }, + "id": "tcmonitor/ng-001", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up", + "tc qdisc add dev d0 clsact", + "{ printf '2040'; i=0; while [ $i -lt 2040 ]; do printf ',6 0 0 0'; i=$((i+1)); done; echo; } > ops.txt" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up", + "rc": 0 + }, + { + "cmd": "tc qdisc add dev d0 clsact", + "rc": 0 + }, + { + "cmd": "{ printf '2040'; i=0; while [ $i -lt 2040 ]; do printf ',6 0 0 0'; i=$((i+1)); done; echo; } > ops.txt", + "rc": 0 + } + ], + "rc": 2, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-001/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-001/ip.err new file mode 100644 index 000000000..8324dbbf4 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-001/ip.err @@ -0,0 +1 @@ +Truncated message diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-001/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-001/ip.out new file mode 100644 index 000000000..ad4cb4ab2 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-001/ip.out @@ -0,0 +1 @@ +added chain dev d0 parent ffff: chain 0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-001/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-001/ip.pcap new file mode 100644 index 000000000..2a0be41c4 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-001/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-001/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-001/ip.rc new file mode 100644 index 000000000..0cfbf0888 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-001/ip.rc @@ -0,0 +1 @@ +2 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-001/ops.txt b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-001/ops.txt new file mode 100644 index 000000000..e14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0 0 0,6 0 0 0 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-002/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-002/cmd.json new file mode 100644 index 000000000..097cd3c75 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-002/cmd.json @@ -0,0 +1,41 @@ +{ + "axes": { + "fix": "bare", + "mode": "file", + "words": "monitor help" + }, + "cmd": "tc monitor help", + "desc": "negative: cmd=ng:bare:monitor_help: help prints the usage and exits 255 (MO1)", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 255, + "refused_by": "iproute2" + }, + "id": "tcmonitor/ng-002", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "proto": "route", + "result": { + "rc": 255, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-002/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-002/ip.err new file mode 100644 index 000000000..3f67a27c0 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-002/ip.err @@ -0,0 +1 @@ +Usage: tc [-timestamp [-tshort] monitor diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-002/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-002/ip.out new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-002/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-002/ip.pcap new file mode 100644 index 000000000..dcb4ca923 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-002/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-002/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-002/ip.rc new file mode 100644 index 000000000..ace9d0362 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-002/ip.rc @@ -0,0 +1 @@ +255 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-003/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-003/cmd.json new file mode 100644 index 000000000..de85af267 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-003/cmd.json @@ -0,0 +1,41 @@ +{ + "axes": { + "fix": "bare", + "mode": "file", + "words": "monitor bogus" + }, + "cmd": "tc monitor bogus", + "desc": "negative: cmd=ng:bare:monitor_bogus: an unknown word (MO14)", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 255, + "refused_by": "iproute2" + }, + "id": "tcmonitor/ng-003", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "proto": "route", + "result": { + "rc": 255, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-003/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-003/ip.err new file mode 100644 index 000000000..4ec50b3ac --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-003/ip.err @@ -0,0 +1 @@ +Argument "bogus" is unknown, try "tc monitor help". diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-003/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-003/ip.out new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-003/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-003/ip.pcap new file mode 100644 index 000000000..dcb4ca923 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-003/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-003/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-003/ip.rc new file mode 100644 index 000000000..ace9d0362 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-003/ip.rc @@ -0,0 +1 @@ +255 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-004/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-004/cmd.json new file mode 100644 index 000000000..0b41c67c7 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-004/cmd.json @@ -0,0 +1,41 @@ +{ + "axes": { + "fix": "bare", + "mode": "file", + "words": "monitor file" + }, + "cmd": "tc monitor file", + "desc": "negative: cmd=ng:bare:monitor_file: file with no value (MO14)", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 255, + "refused_by": "iproute2" + }, + "id": "tcmonitor/ng-004", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "proto": "route", + "result": { + "rc": 255, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-004/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-004/ip.err new file mode 100644 index 000000000..f7d546177 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-004/ip.err @@ -0,0 +1 @@ +Command line is not complete. Try option "help" diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-004/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-004/ip.out new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-004/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-004/ip.pcap new file mode 100644 index 000000000..dcb4ca923 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-004/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-004/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-004/ip.rc new file mode 100644 index 000000000..ace9d0362 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-004/ip.rc @@ -0,0 +1 @@ +255 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-005/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-005/cmd.json new file mode 100644 index 000000000..7173845af --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-005/cmd.json @@ -0,0 +1,41 @@ +{ + "axes": { + "fix": "bare", + "mode": "file", + "words": "monitor file /nonexistent" + }, + "cmd": "tc monitor file /nonexistent", + "desc": "negative: cmd=ng:bare:monitor_file_/nonexistent: Cannot fopen (MO13)", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 255, + "refused_by": "iproute2" + }, + "id": "tcmonitor/ng-005", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "proto": "route", + "result": { + "rc": 255, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-005/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-005/ip.err new file mode 100644 index 000000000..8523a69c2 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-005/ip.err @@ -0,0 +1 @@ +Cannot fopen: No such file or directory diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-005/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-005/ip.out new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-005/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-005/ip.pcap new file mode 100644 index 000000000..dcb4ca923 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-005/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-005/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-005/ip.rc new file mode 100644 index 000000000..ace9d0362 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-005/ip.rc @@ -0,0 +1 @@ +255 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-006/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-006/cmd.json new file mode 100644 index 000000000..868369f74 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-006/cmd.json @@ -0,0 +1,55 @@ +{ + "axes": { + "fix": "trunc", + "mode": "file", + "words": "monitor file m.bin" + }, + "cmd": "tc monitor file m.bin", + "desc": "negative: cmd=ng:trunc:monitor_file_m.bin: a record cut inside its body (MO13)", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 255, + "refused_by": "iproute2" + }, + "id": "tcmonitor/ng-006", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== | base64 -d > m.bin" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "rc": 0 + }, + { + "cmd": "echo tAAAACQAAAAAAAAAAAAAAAAAAAACAAAAAAABAP////8CAAAACAABAGh0YgAkAAIAGAACABEAAwAFAAAAEAAAAAAAAAAAAAAACAAFAOgDAAAFAAwAAAAAADAABwAUAAEAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA== | base64 -d > m.bin", + "rc": 0 + } + ], + "rc": 255, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-006/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-006/ip.err new file mode 100644 index 000000000..5b5f42cf7 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-006/ip.err @@ -0,0 +1 @@ +rtnl-from_file: truncated message diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-006/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-006/ip.out new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-006/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-006/ip.pcap new file mode 100644 index 000000000..dcb4ca923 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-006/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-006/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-006/ip.rc new file mode 100644 index 000000000..ace9d0362 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-006/ip.rc @@ -0,0 +1 @@ +255 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-006/m.bin b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-006/m.bin new file mode 100644 index 000000000..73d92b648 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-006/m.bin differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-007/cmd.json b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-007/cmd.json new file mode 100644 index 000000000..d23285d70 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-007/cmd.json @@ -0,0 +1,55 @@ +{ + "axes": { + "fix": "malformed", + "mode": "file", + "words": "monitor file m.bin" + }, + "cmd": "tc monitor file m.bin", + "desc": "negative: cmd=ng:malformed:monitor_file_m.bin: a record whose length is under the header's (MO13)", + "env": { + "iproute2": "ip utility, iproute2-7.2.0, libbpf 1.8.0", + "kconfig": [ + "CONFIG_IPV6_IOAM6_LWTUNNEL=y", + "CONFIG_IPV6_RPL_LWTUNNEL=y", + "CONFIG_IPV6_SEG6_LWTUNNEL=y", + "CONFIG_LWTUNNEL=y", + "CONFIG_LWTUNNEL_BPF=y" + ], + "kernel": "7.3.1" + }, + "expect": { + "rc": 255, + "refused_by": "iproute2" + }, + "id": "tcmonitor/ng-007", + "modules": [ + "sch_htb", + "sch_ingress", + "sch_fq_codel", + "cls_basic", + "cls_matchall", + "cls_bpf", + "cls_fw", + "act_gact", + "act_mirred" + ], + "pre": [ + "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "echo CAAAACQAAAAAAAAAAAAAAA== | base64 -d > m.bin" + ], + "proto": "route", + "result": { + "pre": [ + { + "cmd": "ip link add d0 address 02:00:00:00:02:00 type dummy && ip link set d0 addrgenmode none && ip link set d0 up && ip link add d1 address 02:00:00:00:02:01 type dummy && ip link set d1 addrgenmode none && ip link set d1 up", + "rc": 0 + }, + { + "cmd": "echo CAAAACQAAAAAAAAAAAAAAA== | base64 -d > m.bin", + "rc": 0 + } + ], + "rc": 255, + "status": "OK" + } +} diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-007/ip.err b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-007/ip.err new file mode 100644 index 000000000..65e1d87ce --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-007/ip.err @@ -0,0 +1 @@ +!!!malformed message: len=8 @16 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-007/ip.out b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-007/ip.out new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-007/ip.pcap b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-007/ip.pcap new file mode 100644 index 000000000..dcb4ca923 Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-007/ip.pcap differ diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-007/ip.rc b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-007/ip.rc new file mode 100644 index 000000000..ace9d0362 --- /dev/null +++ b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-007/ip.rc @@ -0,0 +1 @@ +255 diff --git a/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-007/m.bin b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-007/m.bin new file mode 100644 index 000000000..bdf5c30ca Binary files /dev/null and b/pkg/xtcpnl/testdata/7_3_1/ws/tcmonitor/ng-007/m.bin differ diff --git a/pkg/xtcpnl/xtcpnl_tc_event.go b/pkg/xtcpnl/xtcpnl_tc_event.go new file mode 100644 index 000000000..4a2fb17b6 --- /dev/null +++ b/pkg/xtcpnl/xtcpnl_tc_event.go @@ -0,0 +1,65 @@ +package xtcpnl + +import "golang.org/x/sys/unix" + +// This file names the tc object a `tc monitor` event is about, as +// accept_tcmsg (iproute2 tc/tc_monitor.c) dispatches it to print_filter, +// print_class, print_qdisc or print_action. + +// TcObj is the tc object an rtnetlink message is about. +type TcObj uint8 + +const ( + // TcObjNone is not a tc event: tc's monitor prints `Unknown message` + // for it, or nothing for NLMSG_ERROR, NLMSG_NOOP and NLMSG_DONE. + TcObjNone TcObj = iota + TcObjQdisc + TcObjClass + TcObjFilter + TcObjChain + TcObjAction +) + +var tcObjNames = [...]string{"not tc", "qdisc", "class", "filter", "chain", "action"} + +func (o TcObj) String() string { + if int(o) < len(tcObjNames) { + return tcObjNames[o] + } + return "TcObj(?)" +} + +// TcEventKind is the tc object of a monitor event of type typ, and whether +// the event is a delete. It follows accept_tcmsg, not the uapi families of +// four: of the GET types only RTM_GETACTION is an event there (it reaches +// print_action), while RTM_GETQDISC, RTM_GETTCLASS, RTM_GETTFILTER and +// RTM_GETCHAIN fall through to `Unknown message`. A chain goes to +// print_filter in tc; it is kept apart here so a caller can tell. +// +// Values: RTM_NEWQDISC 36 .. RTM_GETACTION 50, RTM_NEWCHAIN 100, +// RTM_DELCHAIN 101 (linux/include/uapi/linux/rtnetlink.h). +func TcEventKind(typ uint16) (TcObj, bool) { + switch typ { + case unix.RTM_NEWQDISC: + return TcObjQdisc, false + case unix.RTM_DELQDISC: + return TcObjQdisc, true + case unix.RTM_NEWTCLASS: + return TcObjClass, false + case unix.RTM_DELTCLASS: + return TcObjClass, true + case unix.RTM_NEWTFILTER: + return TcObjFilter, false + case unix.RTM_DELTFILTER: + return TcObjFilter, true + case unix.RTM_NEWCHAIN: + return TcObjChain, false + case unix.RTM_DELCHAIN: + return TcObjChain, true + case unix.RTM_NEWACTION, unix.RTM_GETACTION: + return TcObjAction, false + case unix.RTM_DELACTION: + return TcObjAction, true + } + return TcObjNone, false +} diff --git a/pkg/xtcpnl/xtcpnl_tc_event_test.go b/pkg/xtcpnl/xtcpnl_tc_event_test.go new file mode 100644 index 000000000..71f09c016 --- /dev/null +++ b/pkg/xtcpnl/xtcpnl_tc_event_test.go @@ -0,0 +1,391 @@ +package xtcpnl + +import ( + "errors" + "fmt" + "os" + "path/filepath" + "testing" + + "golang.org/x/sys/unix" +) + +// TestTcEventKind holds TcEventKind to accept_tcmsg (tc/tc_monitor.c). +// +// go test ./pkg/xtcpnl/ -run TestTcEventKind +func TestTcEventKind(t *testing.T) { + tests := []struct { + description string + typ uint16 + expected string // object ("not tc" for none), then "del" for a delete + }{ + {"positive: RTM_NEWQDISC", unix.RTM_NEWQDISC, "qdisc"}, + {"positive: RTM_DELQDISC", unix.RTM_DELQDISC, "qdisc del"}, + {"positive: RTM_NEWTCLASS", unix.RTM_NEWTCLASS, "class"}, + {"positive: RTM_DELTCLASS", unix.RTM_DELTCLASS, "class del"}, + {"positive: RTM_NEWTFILTER", unix.RTM_NEWTFILTER, "filter"}, + {"positive: RTM_DELTFILTER", unix.RTM_DELTFILTER, "filter del"}, + {"positive: RTM_NEWCHAIN", unix.RTM_NEWCHAIN, "chain"}, + {"positive: RTM_DELCHAIN", unix.RTM_DELCHAIN, "chain del"}, + {"positive: RTM_NEWACTION", unix.RTM_NEWACTION, "action"}, + {"positive: RTM_DELACTION", unix.RTM_DELACTION, "action del"}, + {"negative: RTM_NEWLINK", unix.RTM_NEWLINK, "not tc"}, + {"negative: NLMSG_DONE", unix.NLMSG_DONE, "not tc"}, + {"negative: NLMSG_ERROR", unix.NLMSG_ERROR, "not tc"}, + {"negative: RTM_GETQDISC is Unknown message in tc", unix.RTM_GETQDISC, "not tc"}, + {"negative: RTM_GETTCLASS", unix.RTM_GETTCLASS, "not tc"}, + {"negative: RTM_GETTFILTER", unix.RTM_GETTFILTER, "not tc"}, + {"boundary: RTM_GETCHAIN (102), the highest tc type, is not an event", unix.RTM_GETCHAIN, "not tc"}, + {"boundary: RTM_NEWQDISC - 1 (RTM_SETROUTE slot 35)", unix.RTM_NEWQDISC - 1, "not tc"}, + {"boundary: RTM_GETACTION + 1 (51)", unix.RTM_GETACTION + 1, "not tc"}, + {"boundary: the largest type", 0xffff, "not tc"}, + {"corner: RTM_GETACTION reaches print_action", unix.RTM_GETACTION, "action"}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + obj, del := TcEventKind(tc.typ) + got := obj.String() + if del { + got += " del" + } + if got != tc.expected { + t.Errorf("TcEventKind(%d) = %q, want %q", tc.typ, got, tc.expected) + } + }) + } + if s := TcObj(200).String(); s != "TcObj(?)" { + t.Errorf("TcObj(200) = %q", s) + } +} + +// tcEvent is one notification a tc monitor was sent. +type tcEvent struct { + h NlMsgHdr + body []byte +} + +// tcMonEvents is what of a monitor row's capture its subscriber was sent: +// tc events, less the trigger's requests (NLM_F_REQUEST with pid 0; the +// kernel's filter and action events carry NLM_F_REQUEST too, with the +// requester's pid, K22), the startup link dump and the acks. It is +// internal/nlmon.Notifications without the get and echo cases, which no +// tcmonitor row has (that package imports this one). +func tcMonEvents(msgs []capturedNlMsg) []tcEvent { + var out []tcEvent + for _, m := range msgs { + h := m.h + obj, _ := TcEventKind(h.Type) + if m.proto != unix.NETLINK_ROUTE || obj == TcObjNone || h.Flags&unix.NLM_F_MULTI != 0 || + (h.Flags&unix.NLM_F_REQUEST != 0 && h.Pid == 0) { + continue + } + out = append(out, tcEvent{h, m.body}) + } + return out +} + +// tcEventDecode decodes an event as far as gotc's printers read it: the +// header and top-level attributes (O6), then the kind's options, a +// matchall's or bpf's actions, and each action's options. +func tcEventDecode(typ uint16, body []byte) error { + obj, _ := TcEventKind(typ) + errs := []error{wsTcMsgProblem(typ, body)} + switch obj { + case TcObjNone: + return nil + case TcObjQdisc, TcObjClass, TcObjFilter, TcObjChain: + case TcObjAction: + ai, err := ParseTcAction(body) + if err != nil { + return err + } + for _, a := range ai.Actions { + errs = append(errs, tcActOptDecode(a.Kind, a.Options)) + } + return errors.Join(errs...) + } + ti, err := ParseTcMsg(body) + if err != nil { + return err + } + if ti.HasStats2 { + _, err := ParseTcStats2(ti.Stats2) + errs = append(errs, err) + } + if !ti.HasOptions { + return errors.Join(errs...) + } + switch obj { + case TcObjNone, TcObjChain, TcObjAction: + case TcObjQdisc, TcObjClass: + _, err := ParseTcQopt(ti.Kind, ti.Options) + errs = append(errs, err) + case TcObjFilter: + f, err := ParseTcFopt(ti.Kind, ti.Options) + if err != nil { + return errors.Join(append(errs, err)...) + } + act := map[string]uint16{TcFKindMatchall: TcaMatchallAct, TcFKindBpf: TcaBpfAct, TcFKindFw: TcaFwAct}[ti.Kind] + if b := f.Tb.Bytes(act); act != 0 && b != nil { + tab, err := ParseTcActTab(b) + if err != nil { + return errors.Join(append(errs, err)...) + } + for o := uint16(0); int(o) < tab.Len(); o++ { + nest := tab.Bytes(o) + if nest == nil { + continue + } + one, err := ParseTcActOne(nest) + if err != nil { + errs = append(errs, err) + continue + } + kind, _ := one.Str(TcaActKind) + errs = append(errs, tcActOptDecode(kind, one.Bytes(TcaActOptions))) + } + } + } + return errors.Join(errs...) +} + +// tcActOptDecode decodes the options of the tcmonitor space's two action +// kinds. +func tcActOptDecode(kind string, opt []byte) error { + if opt == nil { + return nil + } + var err error + switch kind { + case TcActKindGact: + _, err = ParseTcGact(opt) + case TcActKindMirred: + _, err = ParseTcMirred(opt) + } + return err +} + +// tcMonFileRecs walks an rtnl_from_file record file. +func tcMonFileRecs(t testing.TB, path string) []tcEvent { + t.Helper() + b, err := os.ReadFile(path) + if err != nil { + t.Fatal(err) + } + var out []tcEvent + for len(b) >= NlMsgHdrSizeCst { + var h NlMsgHdr + if _, err := DeserializeNlMsgHdr(b, &h); err != nil { + t.Fatal(err) + } + l := int(h.Len) + if l < NlMsgHdrSizeCst || l > len(b) { + t.Fatalf("%s: record of %d bytes in %d", path, l, len(b)) + } + out = append(out, tcEvent{h, b[NlMsgHdrSizeCst:l]}) + b = b[min((l+3)&^3, len(b)):] + } + return out +} + +// TestWsTcMonitor decodes every event in the tcmonitor captures (gotc +// 14P), live and in the record files, and pins what they show of the +// kernel: K20, K22, K23 and MO5's sizes. +// +// go test ./pkg/xtcpnl/ -run TestWsTcMonitor +func TestWsTcMonitor(t *testing.T) { + dir := filepath.Join("testdata", "7_3_1", "ws", "tcmonitor") + rows, err := filepath.Glob(filepath.Join(dir, "*", "cmd.json")) + if err != nil { + t.Fatal(err) + } + if len(rows) != 27 { + t.Fatalf("%d tcmonitor rows, want 27", len(rows)) + } + seen := map[string]int{} + events := map[string][]tcEvent{} + datagrams := map[string][][]capturedNlMsg{} + for _, cj := range rows { + rd := filepath.Dir(cj) + id := filepath.Base(rd) + datagrams[id] = pcapNlDatagrams(t, filepath.Join(rd, "ip.pcap")) + evs := tcMonEvents(pcapNlMsgs(t, filepath.Join(rd, "ip.pcap"))) + if _, err := os.Stat(filepath.Join(rd, "m.bin")); err == nil && id[:2] == "ec" { + evs = append(evs, tcMonFileRecs(t, filepath.Join(rd, "m.bin"))...) + } + events[id] = evs + for i, e := range evs { + obj, del := TcEventKind(e.h.Type) + if obj == TcObjNone { + continue + } + if err := tcEventDecode(e.h.Type, e.body); err != nil { + t.Errorf("%s event %d (type %d): %v", id, i, e.h.Type, err) + } + seen[fmt.Sprintf("%s del=%t", obj, del)]++ + } + } + + evOf := func(id string, typ uint16) []tcEvent { + var out []tcEvent + for _, e := range events[id] { + if e.h.Type == typ { + out = append(out, e) + } + } + return out + } + tests := []struct { + description string + check func() error + expected string // "" for no problem + }{ + {"positive: NEW and DEL of all five objects decode", func() error { + var errs []error + for _, o := range []TcObj{TcObjQdisc, TcObjClass, TcObjFilter, TcObjChain, TcObjAction} { + for _, del := range []bool{false, true} { + if seen[fmt.Sprintf("%s del=%t", o, del)] == 0 { + errs = append(errs, fmt.Errorf("no %s event with del=%t", o, del)) + } + } + } + return errors.Join(errs...) + }, ""}, + {"positive: K22, a filter event carries NLM_F_REQUEST and the requester's pid (ec-003)", func() error { + f := evOf("ec-003", unix.RTM_NEWTFILTER) + if len(f) == 0 { + return errors.New("no filter event") + } + if h := f[0].h; h.Flags != 0x605 || h.Pid == 0 { + return fmt.Errorf("flags %#x pid %d, want 0x605 and nonzero", h.Flags, h.Pid) + } + return nil + }, ""}, + {"positive: K20, a qdisc on the noqueue root comes as DELQDISC then NEWQDISC in one datagram (ec-001)", func() error { + for _, d := range datagrams["ec-001"] { + for i := 1; i < len(d); i++ { + if d[i-1].h.Type == unix.RTM_DELQDISC && d[i].h.Type == unix.RTM_NEWQDISC { + return nil + } + } + } + return errors.New("no datagram holds DELQDISC then NEWQDISC") + }, ""}, + {"negative: K23, a matchall add's event has handle 0 and no options (ec-004)", func() error { + for _, e := range evOf("ec-004", unix.RTM_NEWTFILTER) { + ti, err := ParseTcMsg(e.body) + if err != nil { + return err + } + if ti.Kind == TcFKindMatchall { + if ti.Hdr.Handle != 0 || ti.HasOptions { + return fmt.Errorf("handle %#x options %t: K23 fixed?", ti.Hdr.Handle, ti.HasOptions) + } + return nil + } + } + return errors.New("no matchall add event") + }, ""}, + {"boundary: MO5, a 2038-op bpf filter's event is 16380 bytes (ec-012)", func() error { + return tcBpfEventLen(evOf("ec-012", unix.RTM_NEWTFILTER), 16380) + }, ""}, + {"boundary: MO5, a 2040-op bpf filter's event is 16396 bytes, past 16384 (ng-001)", func() error { + return tcBpfEventLen(evOf("ng-001", unix.RTM_NEWTFILTER), 16396) + }, ""}, + {"corner: the record files' six events decode (ec-013)", func() error { + if n := len(events["ec-013"]); n != 6 { + return fmt.Errorf("%d events, want 6", n) + } + return nil + }, ""}, + {"corner: the non-event file holds no tc event (ec-018)", func() error { + for _, e := range events["ec-018"] { + if obj, _ := TcEventKind(e.h.Type); obj != TcObjNone { + return fmt.Errorf("type %d is a %s event", e.h.Type, obj) + } + } + if len(events["ec-018"]) != 4 { + return fmt.Errorf("%d records, want 4", len(events["ec-018"])) + } + return nil + }, ""}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + err := tc.check() + got := "" + if err != nil { + got = err.Error() + } + if got != tc.expected { + t.Errorf("got %q, want %q", got, tc.expected) + } + }) + } + t.Logf("events %v", seen) +} + +// tcBpfEventLen wants a bpf filter add event of n bytes among evs. +func tcBpfEventLen(evs []tcEvent, n uint32) error { + for _, e := range evs { + ti, err := ParseTcMsg(e.body) + if err != nil { + return err + } + if ti.Kind == TcFKindBpf { + if e.h.Len != n { + return fmt.Errorf("bpf event of %d bytes, want %d", e.h.Len, n) + } + return nil + } + } + return errors.New("no bpf filter event") +} + +// BenchmarkWsTcMonitor decodes every event of the tcmonitor corpus per +// iteration. +// +// go test ./pkg/xtcpnl/ -run '^$' -bench WsTcMonitor -benchmem +func BenchmarkWsTcMonitor(b *testing.B) { + m, err := filepath.Glob(filepath.Join("testdata", "7_3_1", "ws", "tcmonitor", "*", "ip.pcap")) + if err != nil { + b.Fatal(err) + } + evs := make([]tcEvent, 0, 128) + for _, p := range m { + evs = append(evs, tcMonEvents(pcapNlMsgs(b, p))...) + } + if len(evs) == 0 { + b.Fatal("no events") + } + var bytes int + for _, e := range evs { + bytes += len(e.body) + } + b.ReportAllocs() + b.SetBytes(int64(bytes)) + for b.Loop() { + for _, e := range evs { + if err := tcEventDecode(e.h.Type, e.body); err != nil { + b.Fatal(err) + } + } + } + b.ReportMetric(float64(b.Elapsed().Nanoseconds())/float64(b.N)/float64(len(evs)), "ns/msg") +} + +// BenchmarkTcEventKind is the dispatch alone. +func BenchmarkTcEventKind(b *testing.B) { + types := []uint16{unix.RTM_NEWQDISC, unix.RTM_DELTFILTER, unix.RTM_NEWCHAIN, unix.RTM_GETACTION, unix.RTM_NEWLINK} + var n int + for b.Loop() { + for _, typ := range types { + if o, _ := TcEventKind(typ); o != TcObjNone { + n++ + } + } + } + if n == 0 { + b.Fatal("no events") + } +} diff --git a/tools/nlcapgen/main.go b/tools/nlcapgen/main.go index eba54af01..bb930c0ff 100644 --- a/tools/nlcapgen/main.go +++ b/tools/nlcapgen/main.go @@ -156,6 +156,7 @@ var families = map[string]func() []*space{ "tcflower": func() []*space { return []*space{tcflowerSpace()} }, "tcaction": func() []*space { return []*space{tcactionSpace()} }, "tcaction2": func() []*space { return []*space{tcaction2Space()} }, + "tcmonitor": func() []*space { return []*space{tcmonitorSpace()} }, } // namedFamilies are families of named rows, written out as they are @@ -169,7 +170,7 @@ var namedFamilies = map[string]func() []row{ func runMatrix(args []string, stdout, stderr io.Writer) int { fs := flag.NewFlagSet("matrix", flag.ContinueOnError) fs.SetOutput(stderr) - family := fs.String("family", "", "the family to generate: route, rule, nexthop, addr, neigh, link, linkattr, routeget, fdb, mdb, ss, mpls, ethtool, devlink, vdpa, fou, mptcp, tipc, bridge, bridgex, bridgefdb, bridgemdb, tunnel, tuntap, tcqdisc, tcclass, tcfilter, tcflower, tcaction, tcaction2, kwlive, lwt, lwtx, lwtenc, nhstats, v730, v730ip720, stats") + family := fs.String("family", "", "the family to generate: route, rule, nexthop, addr, neigh, link, linkattr, routeget, fdb, mdb, ss, mpls, ethtool, devlink, vdpa, fou, mptcp, tipc, bridge, bridgex, bridgefdb, bridgemdb, tunnel, tuntap, tcqdisc, tcclass, tcfilter, tcflower, tcaction, tcaction2, tcmonitor, kwlive, lwt, lwtx, lwtenc, nhstats, v730, v730ip720, stats") seed := fs.Uint64("seed", 1, "the random rows' seed, recorded in their ids") random := fs.Int("random", 0, "random rows per space") out := fs.String("out", "", "rows file to write") @@ -181,7 +182,7 @@ func runMatrix(args []string, stdout, stderr io.Writer) int { ok = true } if !ok || *out == "" || *random < 0 { - fmt.Fprintln(stderr, "nlcapgen matrix: -family (route, rule, nexthop, addr, neigh, link, linkattr, routeget, fdb, mdb, ss, mpls, ethtool, devlink, vdpa, fou, mptcp, tipc, bridge, bridgex, bridgefdb, bridgemdb, tunnel, tuntap, tcqdisc, tcclass, tcfilter, tcflower, tcaction, tcaction2, kwlive, lwt, lwtx, lwtenc, nhstats, v730, v730ip720, stats) and -out are required, -random must be >= 0") + fmt.Fprintln(stderr, "nlcapgen matrix: -family (route, rule, nexthop, addr, neigh, link, linkattr, routeget, fdb, mdb, ss, mpls, ethtool, devlink, vdpa, fou, mptcp, tipc, bridge, bridgex, bridgefdb, bridgemdb, tunnel, tuntap, tcqdisc, tcclass, tcfilter, tcflower, tcaction, tcaction2, tcmonitor, kwlive, lwt, lwtx, lwtenc, nhstats, v730, v730ip720, stats) and -out are required, -random must be >= 0") return 2 } var rows []row diff --git a/tools/nlcapgen/matrix_tcmonitor.go b/tools/nlcapgen/matrix_tcmonitor.go new file mode 100644 index 000000000..7aece9699 --- /dev/null +++ b/tools/nlcapgen/matrix_tcmonitor.go @@ -0,0 +1,272 @@ +package main + +import ( + "encoding/base64" + "encoding/binary" + "encoding/hex" + "strconv" + "strings" + + "golang.org/x/sys/unix" +) + +// The tc monitor space (gotc 14C): `tc monitor` live, under the +// xtcp2-nl-tcmon helper (nix/microvms/netlink-capture.nix), which starts it +// in the background, waits for its RTNLGRP_TC subscription, runs a trigger +// and stops it with SIGTERM once its output matches; and `tc monitor file` +// over records nlcapgen writes, in one corpus directory, ws/tcmonitor. +// +// tc's side is tc/tc_monitor.c (accept_tcmsg, do_tcmonitor), lib/libnetlink.c +// (rtnl_listen, rtnl_from_file), lib/utils.c (print_timestamp), and the +// printers print_qdisc, print_class, print_filter and print_action, whose +// event branches print deleted, added, replaced, "Added action" and the like. +// The kernel's side is each object's notify: qdisc_notify, tclass_notify, +// tfilter_notify, tc_chain_notify and tcf_add_notify/tcf_del_notify. +// +// The rows pin the plan's leads (docs/netlink/upstream/iproute2-tc-monitor.md): +// help's usage (MO1), the stamp ahead of a non-event (MO2), %08d (MO3), -j +// ignored (MO4), the 16 KiB receive (MO5), qdisc added/replaced never +// printed (MO6, K19, K20), the three replaced rules (MO7), the action +// events' "total acts 0" (MO9), the stale link cache (MO10), a batch's +// filter statics (MO11), file mode's gets (MO12), the file errors (MO13) +// and the argument refusals (MO14). +// +// Determinism: explicit handles and indexes, fixed MACs, no packets; a +// live row's events are waited for by ERE before SIGTERM. The -t stamps are +// the wall clock, masked by the corpus tests. Writes happen only in +// triggers and pre steps. + +// tcMonitorModules are the qdiscs, classifiers and actions the triggers use. +var tcMonitorModules = []string{ + "sch_htb", "sch_ingress", "sch_fq_codel", "cls_basic", "cls_matchall", "cls_bpf", "cls_fw", + "act_gact", "act_mirred", +} + +// tcMonFixD0 is one dummy, d0. +var tcMonFixD0 = []string{tcDummies("d0")} + +// tcMonFixHtb is d0 with an htb root, for the class triggers. +var tcMonFixHtb = []string{tcDummies("d0"), "tc qdisc add dev d0 root handle 1: htb"} + +// tcMonFixClsact is d0 with clsact, for the filter triggers. +var tcMonFixClsact = []string{tcDummies("d0"), "tc qdisc add dev d0 clsact"} + +// tcMonFixFile is d0 and d1, ifindex 2 and 3 in the row's fresh namespace, +// which the file records name. +var tcMonFixFile = []string{tcDummies("d0", "d1")} + +// Bodies of real messages, from the 7.3.1 corpus, for the file records: +// an htb qdisc (tcqdisc/ec-035), an htb class (tcclass/ec-013), an fw +// filter with a classid (tcfilter/ec-024) and a gact action's tab +// (tcaction/ec-057). Each tcmsg's ifindex is rewritten to the row's device. +const ( + monQdiscHtbHex = "000000000300000000000100ffffffff0200000008000100687462002400020018000200110003000500000010000000000000000000000008000500e803000005000c00000000003000070014000100000000000000000000000000000000001800030000000000000000000000000000000000000000002c00030000000000000000000000000000000000000000000000000000000000000000000000000000000000" + monClassHtbHex = "000000000300000010000100010001000000000008000100687462003400020030000100000100000000000048e80100000100000000000090d00300004c1d00a0860100005ed0b2000000000200000048000700140001000000000000000000000000000000000018000300000000000000000000000000000000000000000018000400000000000000000000000000004c1d00a08601002c0003000000000000000000000000000000000000000000000000000000000000000000000000000000000018000400000000000000000000000000004c1d00a0860100" + monFilterFwHex = "0000000004000000050000000000010008000a00070001006677000008000b00000000000c0002000800010001000100" + monActGactHex = "00000000a00001009c000100090001006761637400000000440004001400010000000000000000000000000000000000140007000000000000000000000000000000000018000300000000000000000000000000000000000000000008000a000000000040000200180002002100000000000000020000000100000000000000240001001000000000000000100000000000000000000000000000000000000000000000" +) + +// monBody is a hex body with its tcmsg ifindex set; ifindex 0 leaves it. +func monBody(hexBody string, ifindex uint32) []byte { + b, err := hex.DecodeString(hexBody) + if err != nil { + panic(err) + } + if ifindex != 0 { + binary.LittleEndian.PutUint32(b[4:8], ifindex) + } + return b +} + +// monRec is one rtnl_from_file record: a header whose length is lenField +// (0: the true length), then the body padded to 4 bytes. +func monRec(typ, flags uint16, body []byte, lenField uint32) []byte { + l := uint32(16 + len(body)) + if lenField != 0 { + l = lenField + } + b := binary.LittleEndian.AppendUint32(nil, l) + b = binary.LittleEndian.AppendUint16(b, typ) + b = binary.LittleEndian.AppendUint16(b, flags) + b = binary.LittleEndian.AppendUint32(b, 0) + b = binary.LittleEndian.AppendUint32(b, 0) + b = append(b, body...) + for len(b)%4 != 0 { + b = append(b, 0) + } + return b +} + +// monEvents is a file of one event of each object, and the qdisc deleted: +// htb on d0, its class, an fw filter on d1, a gact added, htb deleted. +func monEvents() []byte { + b := make([]byte, 0, 1600) + b = append(b, monRec(unix.RTM_NEWQDISC, 0, monBody(monQdiscHtbHex, 2), 0)...) + b = append(b, monRec(unix.RTM_NEWTCLASS, 0, monBody(monClassHtbHex, 2), 0)...) + b = append(b, monRec(unix.RTM_NEWTFILTER, unix.NLM_F_CREATE|unix.NLM_F_EXCL, monBody(monFilterFwHex, 3), 0)...) + b = append(b, monRec(unix.RTM_NEWACTION, unix.NLM_F_CREATE|unix.NLM_F_EXCL, monBody(monActGactHex, 0), 0)...) + b = append(b, monRec(unix.RTM_NEWQDISC, 0, monBody(monQdiscHtbHex, 3), 0)...) + b = append(b, monRec(unix.RTM_DELQDISC, 0, monBody(monQdiscHtbHex, 2), 0)...) + return b +} + +// monNonEvents is a DONE, an ERROR and a NOOP, which accept_tcmsg stamps +// but does not print (MO2), then a NEWLINK, which it calls unknown (MO3). +func monNonEvents() []byte { + b := make([]byte, 0, 128) + b = append(b, monRec(unix.NLMSG_DONE, unix.NLM_F_MULTI, make([]byte, 4), 0)...) + b = append(b, monRec(unix.NLMSG_ERROR, 0, make([]byte, 20), 0)...) + b = append(b, monRec(unix.NLMSG_NOOP, 0, nil, 0)...) + b = append(b, monRec(unix.RTM_NEWLINK, 0, make([]byte, 16), 0)...) + return b +} + +// monFile is a pre step writing data to m.bin. +func monFile(data []byte) string { + return "echo " + base64.StdEncoding.EncodeToString(data) + " | base64 -d > m.bin" +} + +// monBigOps is a pre step writing a cBPF program of n "ret 0" instructions +// to ops.txt, for bytecode-file. +func monBigOps(n int) string { + return "{ printf '" + strconv.Itoa(n) + "'; i=0; while [ $i -lt " + strconv.Itoa(n) + + " ]; do printf ',6 0 0 0'; i=$((i+1)); done; echo; } > ops.txt" +} + +// monLive is a live row: tc's args, the fixture, the trigger and the EREs +// the monitor's output must match before SIGTERM. +func monLive(kind brKind, name, args string, pre []string, trigger string, until ...string) value { + val := bc(kind, name, args, pre) + val.Name = name + ":live:" + strings.ReplaceAll(args, " ", "_") + val.Facts["mode"] = "live" + val.Facts["trigger"] = trigger + val.Facts["until"] = strings.Join(until, "\n") + return val +} + +// monOffline is a `tc ...` row: a file or argument row. +func monOffline(kind brKind, name, args string, pre []string) value { + val := bc(kind, name, args, pre) + val.Facts["mode"] = "file" + return val +} + +// tcMonBuild makes a tcmonitor row: a live value runs tc under the helper, +// any other as itself. +func tcMonBuild(vals []value) row { + val := vals[0] + r := row{ + Proto: "route", + Modules: tcMonitorModules, + Expect: expect{RC: intp(0), RefusedBy: refNone}, + Axes: mergeFacts(vals), + } + for _, p := range val.Pre { + r.Pre = append(r.Pre, preStep{Cmd: p}) + } + if val.Facts["mode"] != "live" { + r.Cmd = "tc " + val.Arg + return r + } + words := []string{"xtcp2-nl-tcmon", shq(val.Arg), shq(val.Facts["trigger"])} + if u := val.Facts["until"]; u != "" { + for _, re := range strings.Split(u, "\n") { + words = append(words, shq(re)) + } + } + r.Cmd = strings.Join(words, " ") + return r +} + +// tcmonitorSpace: `tc monitor` live over four fixtures and `tc monitor +// file` over generated records. +func tcmonitorSpace() *space { + const ( + qdiscLife = "tc qdisc add dev d0 root handle 1: fq_codel && tc qdisc change dev d0 root handle 1: fq_codel limit 500" + + " && tc qdisc replace dev d0 root handle 2: htb && tc qdisc del dev d0 root" + classLife = "tc class add dev d0 parent 1: classid 1:10 htb rate 1mbit" + + " && tc class change dev d0 parent 1: classid 1:10 htb rate 2mbit && tc class del dev d0 classid 1:10" + filterLife = "tc filter add dev d0 ingress pref 1 handle 1 protocol all basic action gact pass" + + " && tc filter replace dev d0 ingress pref 1 handle 1 protocol all basic action gact drop" + + " && tc filter change dev d0 ingress pref 1 handle 1 protocol all basic action gact pipe" + + " && tc filter del dev d0 ingress pref 1 handle 1 protocol all basic" + + " && tc chain add dev d0 ingress chain 3 && tc chain del dev d0 ingress chain 3" + filterActs = "tc filter add dev d0 ingress pref 2 handle 2 protocol all matchall action gact pass" + + " action mirred egress redirect dev d0 && tc filter del dev d0 ingress pref 2" + actLife = "tc actions add action gact pass index 7 && tc actions replace action gact drop index 7" + + " && tc actions del action gact index 7 && tc actions add action gact pass index 8" + + " && tc actions flush action gact" + qdiscAdd = "tc qdisc add dev d0 root handle 1: htb" + qdiscFilt = "tc qdisc add dev d0 root handle 1: htb && tc filter add dev d0 parent 1: pref 1 handle 1 protocol all basic classid 1:1" + rename = "tc qdisc add dev d0 root handle 1: htb && ip link set d0 down && ip link set d0 name d1" + + " && tc qdisc del dev d1 root" + bigOps = "tc filter add dev d0 ingress pref 1 handle 1 protocol all bpf bytecode-file ops.txt" + ) + // tc's request for an n-op bpf filter is 60 + 8n bytes and the + // kernel's event 76 + 8n: at 2040 the request still fits tc's 16384-byte + // send buffer and the event no longer fits its 16384-byte receive + // (MO5); at 2038 the event is 16380 and fits. + big := append(clonePre(tcMonFixClsact), monBigOps(2040)) + under := append(clonePre(tcMonFixClsact), monBigOps(2038)) + events := append(clonePre(tcMonFixFile), monFile(monEvents())) + nonEvents := append(clonePre(tcMonFixFile), monFile(monNonEvents())) + cmds := make([]value, 0, 20) + cmds = append(cmds, + monLive(brPos, "qdisc", "monitor", tcMonFixD0, qdiscLife, "deleted qdisc htb 2:"), // MO6, K19, K20 + monLive(brPos, "class", "monitor", tcMonFixHtb, classLife, "deleted class htb 1:10"), // MO8 + monLive(brPos, "filter", "monitor", tcMonFixClsact, filterLife, "deleted chain"), // MO7, K22 + monLive(brPos, "filteracts", "monitor", tcMonFixClsact, filterActs, "deleted filter"), // bind 1 + monLive(brPos, "actions", "monitor", tcMonFixD0, actLife, "Flushed table"), // MO9 + monLive(brPos, "stats", "-s monitor", tcMonFixD0, qdiscFilt, "added filter"), // -s + monLive(brPos, "details", "-d monitor", tcMonFixD0, qdiscFilt, "added filter"), // -d + monLive(brCorner, "stamp", "-t monitor", tcMonFixD0, qdiscAdd, "qdisc htb 1:"), + monLive(brCorner, "stampshort", "-tshort monitor", tcMonFixD0, qdiscAdd, "qdisc htb 1:"), + monLive(brCorner, "json", "-j monitor", tcMonFixD0, qdiscAdd, "qdisc htb 1:"), // MO4 + monLive(brCorner, "rename", "monitor", tcMonFixD0, rename, "deleted qdisc htb"), // MO10 + monLive(brBoundary, "under", "monitor", under, bigOps, "bytecode"), // MO5's edge + // Offline: file mode and the batch. + monOffline(brPos, "file", "monitor file m.bin", events), // MO12 + monOffline(brCorner, "file", "-t monitor file m.bin", events), + monOffline(brCorner, "file", "-tshort monitor file m.bin", events), + monOffline(brCorner, "file", "-j monitor file m.bin", events), // MO4 + monOffline(brCorner, "file", "-s -d monitor file m.bin", events), + monOffline(brCorner, "nonevents", "-t monitor file m.bin", nonEvents), // MO2, MO3 + monOffline(brBoundary, "empty", "monitor file m.bin", append(clonePre(tcMonFixFile), ": > m.bin")), + ) + batch := bb(brCorner, "file", "show-then-file", "", false, batchFile( + "qdisc show dev d0", + "monitor file m.bin"), events) // MO11 + batch.Facts["mode"] = "file" + cmds = append(cmds, batch) + + tool := expect{RC: intp(255), RefusedBy: refIproute2} + bigVal := monLive(brPos, "big", "monitor", big, bigOps) + short := monRec(unix.RTM_NEWQDISC, 0, monBody(monQdiscHtbHex, 2), 0) + bad := []badValue{ + {Axis: "cmd", Value: bigVal, Expect: expect{RC: intp(2), RefusedBy: refAckThenFail}, + Why: "a 2040-op filter's event is past rtnl_listen's 16 KiB though its request fit tc's: Truncated message, exit 2 (MO5)"}, + monBad("bare", "monitor help", nil, tool, "help prints the usage and exits 255 (MO1)"), + monBad("bare", "monitor bogus", nil, tool, "an unknown word (MO14)"), + monBad("bare", "monitor file", nil, tool, "file with no value (MO14)"), + monBad("bare", "monitor file /nonexistent", nil, tool, "Cannot fopen (MO13)"), + monBad("trunc", "monitor file m.bin", append(clonePre(tcMonFixFile), monFile(short[:len(short)-8])), tool, + "a record cut inside its body (MO13)"), + monBad("malformed", "monitor file m.bin", + append(clonePre(tcMonFixFile), monFile(monRec(unix.RTM_NEWQDISC, 0, nil, 8))), tool, + "a record whose length is under the header's (MO13)"), + } + return &space{ + Name: "tcmonitor", + Axes: []axis{{Name: "cmd", Values: cmds}}, + Bad: bad, + Build: tcMonBuild, + NegBase: func([]value) bool { return true }, + } +} + +// monBad is a refused `tc ...` row. +func monBad(fix, words string, pre []string, exp expect, why string) badValue { + b := brBad(fix, words, pre, exp, why) + b.Value.Facts["mode"] = "file" + return b +} diff --git a/tools/nlcapgen/matrix_tcmonitor_test.go b/tools/nlcapgen/matrix_tcmonitor_test.go new file mode 100644 index 000000000..6ae0e1a7f --- /dev/null +++ b/tools/nlcapgen/matrix_tcmonitor_test.go @@ -0,0 +1,185 @@ +package main + +import ( + "bytes" + "encoding/base64" + "fmt" + "regexp" + "strings" + "testing" +) + +// TestTcMonitorSpace pins the tc monitor rows (gotc 14C): `tc monitor` live +// under xtcp2-nl-tcmon over four fixtures, `tc monitor file` over generated +// records, a batch, and the refusals. Rows are keyed by their cmd value's +// name. +// +// go test ./tools/nlcapgen/ -run TestTcMonitorSpace +func TestTcMonitorSpace(t *testing.T) { + rows, err := matrixRows(families["tcmonitor"](), matrixOpts{Seed: 1}) + if err != nil { + t.Fatal(err) + } + if err := checkRows(rows); err != nil { + t.Fatal(err) + } + if len(rows) != 27 { + t.Errorf("%d rows, want 27 (12 live, 8 offline, 7 negatives)", len(rows)) + } + byDesc := map[string]row{} + for _, r := range rows { + if !strings.HasPrefix(r.ID, "tcmonitor/") { + t.Errorf("%s: not in tcmonitor/", r.ID) + } + if r.InitNS || r.Serial || r.Proto != "route" || strings.Join(r.Modules, ",") != strings.Join(tcMonitorModules, ",") { + t.Errorf("%s: initns %t serial %t proto %q modules %v", r.ID, r.InitNS, r.Serial, r.Proto, r.Modules) + } + for _, m := range r.Modules { + if !tdcGuestModules[m] { + t.Errorf("%s: module %s is not one the guest has", r.ID, m) + } + } + _, name, _ := strings.Cut(r.Desc, "cmd=") + name, _, _ = strings.Cut(name, ": ") + byDesc[name] = r + } + + tests := []struct { + description string + name string // the cmd value + expected string // kind rc refused-by | live | until count + }{ + // Positive. + {"positive: the qdisc lifecycle (MO6, K19, K20)", "qdisc:live:monitor", "positive 0 none | live | 1"}, + {"positive: the class lifecycle (MO8)", "class:live:monitor", "positive 0 none | live | 1"}, + {"positive: the filter and chain lifecycle (MO7, K22)", "filter:live:monitor", "positive 0 none | live | 1"}, + {"positive: a filter with two actions (bind 1)", "filteracts:live:monitor", "positive 0 none | live | 1"}, + {"positive: the action lifecycle (MO9)", "actions:live:monitor", "positive 0 none | live | 1"}, + {"positive: -s", "stats:live:-s_monitor", "positive 0 none | live | 1"}, + {"positive: -d", "details:live:-d_monitor", "positive 0 none | live | 1"}, + {"positive: a file of every object's event (MO12)", "file:monitor_file_m.bin", "positive 0 none | file | 0"}, + // Negative. + {"negative: a 2040-op filter's event is truncated (MO5)", "big:live:monitor", "negative 2 ack-then-fail | live | 0"}, + {"negative: help (MO1)", "ng:bare:monitor_help", "negative 255 iproute2 | file | 0"}, + {"negative: an unknown word (MO14)", "ng:bare:monitor_bogus", "negative 255 iproute2 | file | 0"}, + {"negative: file with no value (MO14)", "ng:bare:monitor_file", "negative 255 iproute2 | file | 0"}, + {"negative: no such file (MO13)", "ng:bare:monitor_file_/nonexistent", "negative 255 iproute2 | file | 0"}, + {"negative: a truncated file (MO13)", "ng:trunc:monitor_file_m.bin", "negative 255 iproute2 | file | 0"}, + {"negative: a malformed file (MO13)", "ng:malformed:monitor_file_m.bin", "negative 255 iproute2 | file | 0"}, + // Boundary. + {"boundary: a 2038-op filter's event fits in 16 KiB", "under:live:monitor", "boundary 0 none | live | 1"}, + {"boundary: an empty file", "empty:monitor_file_m.bin", "boundary 0 none | file | 0"}, + // Corner. + {"corner: -t", "stamp:live:-t_monitor", "corner 0 none | live | 1"}, + {"corner: -tshort", "stampshort:live:-tshort_monitor", "corner 0 none | live | 1"}, + {"corner: -j is text (MO4)", "json:live:-j_monitor", "corner 0 none | live | 1"}, + {"corner: a renamed device keeps its old name (MO10)", "rename:live:monitor", "corner 0 none | live | 1"}, + {"corner: -j over a file (MO4)", "file:-j_monitor_file_m.bin", "corner 0 none | file | 0"}, + {"corner: stamps on non-events, and an unknown type (MO2, MO3)", "nonevents:-t_monitor_file_m.bin", "corner 0 none | file | 0"}, + {"corner: a batch's statics carry into the file (MO11)", "file:batch:show-then-file", "corner 0 none | file | 0"}, + } + for _, tc := range tests { + t.Run(tc.description, func(t *testing.T) { + r, ok := byDesc[tc.name] + if !ok { + t.Fatalf("no row %q", tc.name) + } + kind, _, _ := strings.Cut(r.Desc, ":") + until := 0 + if u := r.Axes["until"]; u != "" { + until = len(strings.Split(u, "\n")) + } + got := fmt.Sprintf("%s %d %s | %s | %d", kind, *r.Expect.RC, r.Expect.RefusedBy, r.Axes["mode"], until) + if got != tc.expected { + t.Errorf("got %q, want %q", got, tc.expected) + } + }) + } + + objs := map[string]bool{} + all := new(strings.Builder) + for _, r := range rows { + live := r.Axes["mode"] == "live" + // A live monitor runs only under the helper, which stops it with + // SIGTERM; nothing else starts one. + if live != strings.HasPrefix(r.Cmd, "xtcp2-nl-tcmon ") { + t.Errorf("%s: mode %q but cmd %q", r.ID, r.Axes["mode"], r.Cmd) + } + if !live && !strings.HasPrefix(r.Cmd, "tc ") { + t.Errorf("%s: an offline row's cmd is not tc: %q", r.ID, r.Cmd) + } + if live && r.Axes["trigger"] == "" { + t.Errorf("%s: a live row with no trigger", r.ID) + } + for _, fam := range []string{"qdisc", "class", "filter", "chain", "actions"} { + if strings.Contains(r.Axes["trigger"], "tc "+fam+" ") { + objs[fam] = true + } + } + all.WriteString(r.Cmd + "\n" + r.Axes["trigger"] + "\n") + for _, p := range r.Pre { + all.WriteString(p.Cmd + "\n") + } + } + for _, fam := range []string{"qdisc", "class", "filter", "chain", "actions"} { + if !objs[fam] { + t.Errorf("no trigger makes a %s event", fam) + } + } + // Each event type: NEW and DEL of qdisc, class, filter, chain and action. + for _, s := range []string{"tc qdisc add", "tc qdisc del", "tc class add", "tc class del", "tc filter add", + "tc filter del", "tc chain add", "tc chain del", "tc actions add", "tc actions del", "tc actions flush", + "tc qdisc replace", "tc filter replace", "tc filter change", "tc actions replace", "ip link set d0 name d1", + "printf '2040'", "printf '2038'"} { + if !strings.Contains(all.String(), s) { + t.Errorf("no row, trigger or fixture has %q", s) + } + } + // cBPF only. + if ebpf := regexp.MustCompile(`\b(obj|object-file|object-pinned)\b`); ebpf.MatchString(all.String()) { + t.Errorf("a row loads eBPF: %q", ebpf.FindString(all.String())) + } + // The event file holds six records of four objects; the non-event file + // four records. + for _, f := range []struct { + data []byte + n int + }{{monEvents(), 6}, {monNonEvents(), 4}} { + if got := countRecs(f.data); got != f.n { + t.Errorf("%d records, want %d", got, f.n) + } + if !strings.Contains(all.String(), base64.StdEncoding.EncodeToString(f.data)) { + t.Error("a record file no row writes") + } + } + + // Determinism: the same seed writes the same bytes, record files and all. + var a, b bytes.Buffer + for _, buf := range []*bytes.Buffer{&a, &b} { + rows, err := matrixRows(families["tcmonitor"](), matrixOpts{Seed: 1}) + if err != nil { + t.Fatal(err) + } + if err := writeRows(buf, nil, rows); err != nil { + t.Fatal(err) + } + } + if !bytes.Equal(a.Bytes(), b.Bytes()) { + t.Error("two runs with seed 1 differ") + } +} + +// countRecs walks rtnl_from_file records by their length fields. +func countRecs(b []byte) int { + n := 0 + for len(b) >= 16 { + l := int(uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24) + l = (l + 3) &^ 3 + if l < 16 || l > len(b) { + return -1 + } + b = b[l:] + n++ + } + return n +}