Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
199 lines (192 loc) · 9.83 KB
/
Copy pathflake.nix
File metadata and controls
199 lines (192 loc) · 9.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#
# flake.nix — xtcp2
#
# Thin orchestrator. Every concern lives under ./nix/ and is wired up here.
# See ./nix/default.nix for the per-system aggregator.
# Monitor "run all": nix build path:.#test-linkmonitor -L
# Runs core tests, race, vet, lint, formatting, replay, fuzzing and doc checks,
# plus RDMA tests/lint, the RDMA test tooling, library and executable checks; all
# CGO_ENABLED=0 since R4-T02 (RDMA events from netlink, umad in Go).
# Go-native RDMA guards: test-linkmonitor-rdma-abi (kernel uapi layouts) and
# test-linkmonitor-parse-guards (bounds checks, escape report, zero allocations),
# test-linkmonitor-rdma-capture (redaction, manifests, capture dry run).
# Performance correctness is included. Repeatable measurement targets are
# nix run path:.#bench-linkmonitor-smoke (short),
# nix run path:.#bench-linkmonitor (microbenchmarks), and
# nix run path:.#bench-linkmonitor-soak (fresh ten-minute profiles).
# Go-native RDMA benchmarks: nix run path:.#bench-linkmonitor-rdma-native -- --output DIR
# Monitor start-up, build against build: nix run path:.#bench-linkmonitor-startup -- --output DIR LABEL=BINARY...
# (-count=10, pprof and benchstat, --baseline DIR against committed cgo output; gated by
# nix build path:.#test-linkmonitor-rdma-native-bench).
# External HTTP load and profiling use an operator-owned endpoint:
# nix run path:.#siege-linkmonitor -- --url http://127.0.0.1:9088 --output /tmp/siege
# nix run path:.#profile-linkmonitor -- --url http://127.0.0.1:9088 --output /tmp/pprof
# PGO build/compare: nix run path:.#pgo-linkmonitor -- --profile CPU.pprof --output ./go-link-monitor-pgo
# Privileged performance/live-netlink VM: nix run path:.#test-linkmonitor-performance-vm -- [DIR]
# (also checks.vm-linkmonitor-performance, in checks.vm-all).
# It boots a root guest, captures an nlmon pcap around live tests, and returns
# benchmark/pprof evidence without requiring host netlink privileges.
# Includes embedding checks/artifacts; execute the disposable integration with
# nix run path:.#test-linkmonitor-embedding-vm -- --accel=auto (KVM or TCG).
# Standalone: nix build path:.#go-link-monitor (#go-link-monitor-core is an alias).
# Software RDMA guest: checks.vm-linkmonitor-rdma, or nix run path:.#test-linkmonitor-rdma-vm (needs KVM).
# See ./nix/README.md for individual targets, logs and Nix policy checks.
#
# Quick references:
# nix run path:.#test-tcp-controller-vm -- --accel=auto
# nix run path:.#test-tcp-controller-soak-vm -- --cycles=3 --interval=3m
# nix build path:.#test-tcp-controller-unit path:.#test-tcp-controller-race
# nix build path:.#bench-tcp-controller
# Repeated RTT changes, automatic discovery, test-operator approval,
# automatic rollback and cooldown checks (~30 minutes by default).
# Seven guests: TCP load, netem RTT bands, ClickHouse/PostgreSQL, reviewed
# canary, withdrawal and independent expiry. Also checks.vm-tcp-controller,
# checks.vm-all, and integration-all (nix/tests/tcp-controller).
# nix develop # dev shell
# nix build .#xtcp2 # main binary
# nix build .#xtcp2-all # every cmd/* binary
# nix build .#oci-xtcp2 # OCI image (load via `./result | docker load`)
# nix run .#regen-protos # `buf generate` (needs network)
# nix flake check # all registered checks, including monitor suite
# nix build path:.#test-linkmonitor -L # focused monitor gates; includes untracked files
# nix run .#microvm-x86_64-lifecycle # boot xtcp2 in a VM, run 3-check self-test
# nix run .#microvm-x86_64-discovery-bench # ns-discovery A/B (dir vs /proc scan)
# nix run .#microvm-x86_64-socket-scale # socket-count gate, SYN + netns floods
# nix run .#microvm-x86_64-goip-parity # ip vs goip netlink comparison (needs /dev/kvm)
#
# Capturing netlink fixtures — use the microVM, not the host:
# (RETIRED, V401: microvm-x86_64-nlmon-capture, the rtnetlink EVENT capture
# oneshot — its product, the 7_1_4 event corpus, stays committed at
# pkg/xtcpnl/testdata/7_1_4/netlink_route_events*.pcap; the driven
# goip-parity rows are the event path now. See
# docs/netlink/goip-parity-events.md, EG2-T02.)
# nix run .#microvm-x86_64-netlink-dump-capture
# THE SANCTIONED CAPTURE PATH. Boots a root guest, drives it over serial
# with tcl/expect, captures in a clean namespace with no side traffic,
# and writes pkg/xtcpnl/testdata/. Needs /dev/kvm; does NOT need host
# root, so it is runnable unattended. Pass --out DIR to write somewhere
# else, which is worth doing first: it rewrites EVERY fixture it
# captures, not only a newly added one, and committed line-number
# citations point into those files.
# nix run .#microvm-x86_64-link-write-capture
# Bond / LACP readback fixtures from a bond with a real LACP partner
# (two namespaces, two veth pairs), in three negotiation states. Writes
# pkg/xtcpnl/testdata/<kernel>/link-write/. Needs /dev/kvm, not root.
# The full set takes hours; --only <sections> runs some of them.
# nix run .#microvm-x86_64-link-write-capture-<section>
# One section of the above (lacp, addr, write, rtnl, genl, xfrm, kinds,
# brmpls; nix/microvms/scripts/link-write-sections.exp), writing only
# that section's directories.
# nix run .#microvm-x86_64-lacp-pair-capture
# The same readback on virtio-net ports, with the LACP partner in a
# second microVM across two point-to-point dgram links (Tier 2).
# Writes pkg/xtcpnl/testdata/<kernel>/link-write/lacp-pair/.
# nix run .#capture-netlink-fixtures
# The same corpus on the HOST. Needs host root (sudo, interactively) and
# captures in the host's namespace, where other processes' netlink
# traffic is mixed in. Diagnostic fallback only — prefer the microVM.
#
# Capturing go-native RDMA testdata (pkg/linkmonitor/internal/rdmanative/testdata):
# nix run .#microvm-x86_64-rdma-capture[-<kernel>] # vm-rxe, with the nldev rows
# nix build .#test-linkmonitor-ionic-vm && ./result/bin/test-linkmonitor-ionic-vm --capture --promote
# nix run .#capture-rdma-testdata # a real host (sudo); read-only unless
# # --gid-trigger IFACE or --umad
# Each takes --dry-run (the VM runners with --native-out DIR) to write
# placeholder contents and a manifest without a device.
#
{
description = "xtcp2 — TCP socket introspection via netlink";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
microvm = {
url = "github:astro/microvm.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# xdp2 provides `proto-audit`, the netlink layout oracle. It normalises the
# kernel UAPI headers and 15 other sources to one IR indexed by wire bit
# offset, which is what lets it find a field xtcp2's Go structs are
# *missing* rather than merely mis-reading one they have. Consumed by
# nix/checks/proto-audit-netlink.nix; see docs/netlink/coverage-status.md.
#
# Deliberately NOT `inputs.nixpkgs.follows = "nixpkgs"`. proto-audit is a
# Rust build over a large pinned source set (a kernel tarball, DPDK, nDPI,
# suricata, tshark, a scapy python) and is built against the nixpkgs it was
# tested with. Following xtcp2's nixpkgs would trade one duplicated nixpkgs
# evaluation for a build that may simply not work.
#
# Override to a local checkout when iterating on the oracle itself:
# nix build .#proto-audit-netlink --override-input xdp2 path:/home/das/Downloads/xdp2
xdp2.url = "github:randomizedcoder/xdp2/16aa76764c8ab18897de6af13cac37c2fa89bb37";
# rocm-ernic emulates an AMD Pensando ionic NIC over vfio-user, so the
# in-tree ionic/ionic_rdma drivers give the VM checks real driver
# netlink, ethtool and verbs replies without hardware. Consumed through
# nix/ernic (nixosModules.ernic-guest, packages.ernic-run and the
# server); see docs/design-rocm-ernic-nics.md.
#
# Pinned to upstream develop by rev AND narHash, so the fetched content
# is part of the declaration. checks.ernic-pin keeps this, flake.lock and
# nix/upstream-pins.json in step; `nix run .#check-upstream-pins` reports
# how far develop has moved. To bump: change rev, set narHash from
# `nix flake prefetch github:ROCm/rocm-ernic/<rev>`, then
# `nix flake lock --update-input rocm-ernic` and the manifest entry.
# Iterate on the emulator with:
# nix run .#test-linkmonitor-ionic-vm --override-input rocm-ernic path:/home/das/Downloads/rocm-ernic
rocm-ernic = {
type = "github";
owner = "ROCm";
repo = "rocm-ernic";
rev = "bd902345b0f8f3863f535a0a09da9f21ce744737";
narHash = "sha256-vwIFQjGK7rorBfCNwyq4kepVz68A4BJHag2X3y/T+xU=";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
inputs.microvm.follows = "microvm";
};
};
nixConfig = {
extra-substituters = [ "https://microvm.cachix.org" ];
extra-trusted-public-keys = [
"microvm.cachix.org-1:oXnBc6hRE3eX5rSYdRyMYXnfzcCxC7yKPTbZXALsqys="
];
};
outputs =
{
self,
nixpkgs,
flake-utils,
microvm,
xdp2,
rocm-ernic,
}:
flake-utils.lib.eachSystem [ "x86_64-linux" ] (
system:
let
pkgs = import nixpkgs {
inherit system;
};
inherit (nixpkgs) lib;
aggregator = import ./nix {
inherit
pkgs
lib
microvm
nixpkgs
xdp2
;
rocmErnic = rocm-ernic;
src = ./.;
};
in
{
inherit (aggregator)
packages
devShells
checks
apps
;
}
)
// {
overlays.default = import ./nix/overlays.nix { inherit self; };
};
}