Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- **Golden-record shapes.** `xtcp2-golden profile` reduces a capture to its shape (populated columns, enum values, families, kinds of namespace) with no identity in it, and `xtcp2-golden shape-diff` compares two, so a capture from a real host can be checked against the microVM fixture although the workloads differ. `pkg/xtcp/testdata/golden/coverage.json` lists the columns, values, families and kinds of namespace every fixture must exercise; `check` (and so `checks.golden-records`) fails a fixture that falls short ([Golden records](nix/README.md#golden-records)).
- **Socket options on the traffic tools.** `tcp_client` and `tcp_server` take `-cong`, `-tos`, `-priority`, `-rcvbuf`, `-freebind`, `-transparent` and `-bindNoPort`, and `tcp_client` takes `-bulk`, `-close` and `-halfclose` (`tcp_server -holdEOF` holds the other end), so a test workload can give the collector sockets with a chosen congestion algorithm, TOS, class_id, window scale, sockopt bits and TCP state. The OCI image passes `TCP_CLIENT_ARGS` / `TCP_SERVER_ARGS` through ([integration testing](docs/integration-testing.md#tcp_server--tcp_client--socket-population)).
- **Golden records cover the fleet's columns.** The capture workload adds four netns pairs: one connection per congestion algorithm the kernel offers (IPv4 and IPv6; every `tcp_*` module is loaded), bulk transfers over netem loss and reordering, TOS/traffic class, priority, the sockopt bits and three window scales, and TIME_WAIT, SYN_SENT, FIN_WAIT2 and CLOSE_WAIT sockets in exact numbers. Three MTUs give three pmtu/MSS pairs. `coverage.json` requires the per-algorithm info structs, the loss counters, the new states and values, and every algorithm in the capture's `cong_available`. `ROW` lines on the VM console check each pair ([Golden records](nix/README.md#golden-records)).
- **Golden records cover NICs, locality and ASN.** The capture VM gains a second uplink (an emulated e1000e) and a 10000 Mb/s virtio NIC, and the collector enriches locality and ASN against an artifact built from documentation prefixes. A netns trio gives one connection per locality (self, subnet, remote over IPv4 and IPv6). `coverage.json` requires the uplink 2 columns, the NIC speeds, localities 1–3, the ASN, owner and egress columns, and the bound interface name.
- **Vulnerability check.** `checks.govulncheck` runs govulncheck against a pinned snapshot of the Go vulnerability database, with no tags and with every flavor tag, and fails on a reachable finding not in its accepted list. One is accepted: GO-2026-6859 in `net/http`, fixed in go1.27.4, until the toolchain moves. `nix run .#govulncheck-fresh` checks against the live database and runs `go mod verify`; `nix build .#sbom-<binary>` writes a CycloneDX SBOM for any binary package.

### Fixes
Expand Down
3 changes: 3 additions & 0 deletions nix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,10 @@ direct `container_*` columns).
- `golden-bulk-a/b` (MTU 1500, netem delay 5 ms, loss 2 %, reorder 1 % both ways): a 4 MiB echo each for cubic, bbr, dctcp and vegas, done before xtcp2 starts, so the loss counters are settled.
- `golden-opts-a/b` (MTU 1450): TOS 0x08 and 0xb8 (traffic class on IPv6), priority 6 (`class_id`), freebind, transparent and bind-no-port (`sockopt`), receive buffers of 64 KiB, 1 MiB and 16 MiB (three window scales), and one client bound with `SO_BINDTODEVICE`.
- `golden-states-a/b` (MTU 1300): a FIN_WAIT2/CLOSE_WAIT pair. After poll 1 the capture adds exactly 3 TIME_WAIT sockets (they last 60 s; polls are 30 s apart) and 2 SYN_SENT ones (to 192.0.2.1, blackholed past `golden-states-b`; the SYN retries outlast poll 2).
- `golden-loc-a/b` and `golden-remote`: one connection per locality from `golden-loc-a` (its own address, `golden-loc-b`'s, and `golden-remote`'s 203.0.113.10 and 2001:db8:113::10 through `golden-loc-b` as a router).
- All in named netns, so root sets any algorithm or option without container capabilities, and no host TCP is opened before poll 2.
- The collector adds `-enrichLocality` and `-enrichAsn`. The ASN artifact is built with the VM from documentation prefixes only (203.0.113.0/24 → AS64500, 2001:db8:113::/48 → AS64501; `goldenAsnDb` in `mkVm.nix`), so no feed or internet is involved.
- Two uplinks: the virtio NIC reports 10000 Mb/s full duplex (`-global virtio-net-pci.speed`), and an emulated e1000e on its own restricted SLiRP net has a default route at a higher metric, so `DefaultUplinks` finds it as uplink 2 with a real PCI vendor/device, firmware version and bus address. A fleet NIC's driver and IDs (`bnxt_en` and so on) can't be reproduced in a VM; `shape-diff` against a fleet profile still shows them.
- netem loses and reorders at random, so `xtcp2-golden diff` doesn't compare the twelve columns seen to vary between captures (`goldenrec.lossyColumns`: dsack_dups, reord_seen, rwnd_limited, probes, delivery_rate_app_limited, idiag_retrans, dctcp alpha, reordering, and the RTO group: total_rto, its recoveries and time, rehash) in rows of `golden-bulk-a/b` (`goldenrec.DefaultLossyNetns`). Their other columns, such as total_retrans and bytes_received, are compared, and `coverage.json` still requires the loss counters populated.
- `ROW <name> <category> PASS|FAIL` lines on the console check the pairs: a row per algorithm and family, the info structs, the options, loss only where netem is, the state counts, and pmtu/snd_mss per pair.
- The runner keeps xtcp2's second poll, uploaded as its own object. The first poll is immediate and can miss a namespace whose netlink socket is still opening.
Expand Down
73 changes: 73 additions & 0 deletions nix/microvms/mkVm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2416,6 +2416,60 @@ let
"-enrichContainer"
"-enrichNic"
"-populateNsid"
]
# The golden flavor adds locality and ASN over goldenAsnDb; the families
# check keeps the base args.
++ lib.optionals isS3ParquetGolden [
"-enrichLocality"
"-enrichAsn"
"-asnDbPath"
"${goldenAsnDb}"
"-ipmetaBootstrapPath"
""
"-ipmetaCachePath"
"/run/xtcp2/golden-asn.lookup.parquet.zst"
];

# The golden capture's ASN artifact, built here from documentation
# prefixes only (the golden-remote netns in golden-workload.sh), so
# -enrichAsn resolves without a feed or the internet. The columns are the
# ones pkg/ipasn reads.
goldenAsnPrefixes = [
{
prefix = "203.0.113.0/24";
asn = 64500;
owner = "fixture-net";
}
{
prefix = "2001:db8:113::/48";
asn = 64501;
owner = "fixture-net6";
}
];
goldenAsnDb = pkgs.runCommand "xtcp2-golden-asn.parquet" { nativeBuildInputs = [ pkgs.duckdb ]; } ''
export HOME=$TMPDIR
duckdb -c "COPY (SELECT prefix, asn::UINTEGER AS asn, network_owner FROM (VALUES ${
lib.concatMapStringsSep ", " (
p: "('${p.prefix}', ${toString p.asn}, '${p.owner}')"
) goldenAsnPrefixes
}) t(prefix, asn, network_owner)) TO '$out' (FORMAT parquet)"
'';

# The golden flavor's NICs. virtio-net reports no speed unless told
# (drivers/net/virtio_net.c), so eth0 gets 10000. A second uplink, an
# emulated e1000e on its own restricted SLiRP net, gives a PCI vendor and
# device, a firmware version and a bus address; its default route (below)
# has the higher metric, so DefaultUplinks lists it second.
goldenUplink2Mac = "02:00:00:00:10:02";
goldenNicArgs = [
"-global"
"virtio-net-pci.speed=10000"
"-global"
"virtio-net-pci.duplex=full"
"-netdev"
"user,id=up2,restrict=on,net=10.0.3.0/24"
"-device"
"e1000e,netdev=up2,mac=${goldenUplink2Mac},romfile="
];

goldenWorkloadScript = pkgs.writeShellApplication {
Expand Down Expand Up @@ -3140,6 +3194,7 @@ in
]
# The lacp pair's two dgram links; empty for every other flavor.
++ lacpNicArgs
++ lib.optionals isS3ParquetGolden goldenNicArgs
# The workbench's ephemeral ssh key. A relative path, resolved in
# the directory the host CLI starts qemu from (its state dir), so
# the key is chosen at `up` time and never baked into the runner.
Expand Down Expand Up @@ -4560,6 +4615,24 @@ in
# bond_enslave refuses a port that is up. Measured on the first
# Tier 2 run: lb1 sent DHCP discovers from inside B's bond, and B's
# bond sent one LACPDU and then none.
# The golden flavor's second uplink (goldenNicArgs): static, with a
# default route behind the DHCP one on the virtio NIC.
systemd.network.networks."05-golden-uplink2" = lib.mkIf isS3ParquetGolden {
matchConfig.MACAddress = goldenUplink2Mac;
address = [ "10.0.3.15/24" ];
routes = [
{
Gateway = "10.0.3.2";
Metric = 2048;
}
];
networkConfig = {
DHCP = "no";
IPv6AcceptRA = false;
LinkLocalAddressing = "no";
};
};

systemd.network.networks."05-lacp-unmanaged" = lib.mkIf isLacpPair {
matchConfig.Name = "la* lb* bond*";
linkConfig.Unmanaged = true;
Expand Down
37 changes: 36 additions & 1 deletion nix/microvms/scripts/golden-capture.sh
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,40 @@ got=$(q "SELECT string_agg(DISTINCT netns || '=' || tcp_info_pmtu || '/' || tcp_
ok=0
[ "$got" = "golden-cc-a=1500/1448,golden-opts-a=1450/1398,golden-states-a=1300/1248" ] && ok=1
row mtu_paths corner "$ok" "IPv4 pmtu/snd_mss per pair: $got"

# The NICs, locality and ASN (goldenNicArgs, goldenAsnDb, golden-loc-*).
got=$(q "SELECT concat_ws(',', max(uplink2_nic_driver), max(uplink2_nic_pci_vendor), bool_or(uplink2_nic_fw_version <> ''), bool_or(uplink2_nic_bus_info <> '')) FROM $P")
ok=0
[ "$got" = "e1000e,32902,true,true" ] && ok=1
row uplink2 positive "$ok" "uplink2 driver, PCI vendor, firmware set, bus set: $got"
got=$(q "SELECT string_agg(DISTINCT enrich_socket_dest_locality::VARCHAR, ',' ORDER BY enrich_socket_dest_locality::VARCHAR) FROM $P WHERE netns = 'golden-loc-a' AND inet_diag_msg_state = 1")
ok=0
[ "$got" = "1,2,3" ] && ok=1
row locality_all positive "$ok" "localities of golden-loc-a's connections: $got"
n=$(q "SELECT count(*) FROM $P WHERE netns = 'golden-opts-a' AND enrich_socket_interface_name = 'veth0'")
ok=0
[ "$n" -eq 1 ] && ok=1
row bound_ifname positive "$ok" "$n rows bound to veth0 (SO_BINDTODEVICE) named"
got=$(q "SELECT concat_ws(',', count(*) FILTER (enrich_socket_dest_asn <> 0), count(*) FILTER (enrich_socket_dest_asn <> 0 AND (enrich_socket_dest_locality <> 3 OR enrich_socket_dest_network_owner = ''))) FROM $P")
ok=0
[ "$got" = "2,0" ] && ok=1
row asn_remote negative "$ok" "rows with an ASN, and of those not REMOTE or without an owner: $got, want 2,0"
n=$(q "SELECT count(*) FROM $P WHERE netns = 'golden-states-a' AND inet_diag_msg_state = 2 AND enrich_socket_dest_locality = 3 AND enrich_socket_dest_asn = 0")
ok=0
[ "$n" -eq "$K_SYN" ] && ok=1
row no_asn_unlisted negative "$ok" "$n REMOTE SYN_SENT rows to 192.0.2.1 (not in the artifact) without an ASN, want $K_SYN"
got=$(q "SELECT concat_ws(',', string_agg(DISTINCT uplink1_nic_speed_mbps::VARCHAR, '/'), string_agg(DISTINCT uplink2_nic_speed_mbps::VARCHAR, '/')) FROM $P")
ok=0
[ "$got" = "10000,1000" ] && ok=1
row nic_speed boundary "$ok" "uplink1, uplink2 speed: $got"
n=$(q "SELECT count(*) FROM $P WHERE netns = 'golden-loc-a' AND inet_diag_msg_family = 10 AND enrich_socket_dest_locality = 3 AND enrich_socket_dest_asn = 64501 AND enrich_socket_dest_network_owner = 'fixture-net6'")
ok=0
[ "$n" -eq 1 ] && ok=1
row v6_remote corner "$ok" "$n IPv6 rows to 2001:db8:113::10 with AS64501"
got=$(q "SELECT string_agg(DISTINCT enrich_socket_dest_egress_ifname, ',') FROM $P WHERE netns = 'golden-loc-a' AND enrich_socket_dest_locality = 3")
ok=0
[ "$got" = "veth0" ] && ok=1
row egress_named corner "$ok" "egress of golden-loc-a's REMOTE rows: $got"
[ "$row_failed" = 0 ] || fail "rows failed"

version=$(q "SELECT any_value(daemon_version) FROM $P")
Expand All @@ -193,7 +227,8 @@ jq -n \
capabilities: ($caps | split(" ")),
workload: {containers: $containers, sockets_per_container: $sockets,
named_netns: ["golden-ns", "golden-cc-a", "golden-cc-b", "golden-bulk-a", "golden-bulk-b",
"golden-opts-a", "golden-opts-b", "golden-states-a", "golden-states-b"]},
"golden-opts-a", "golden-opts-b", "golden-states-a", "golden-states-b",
"golden-loc-a", "golden-loc-b", "golden-remote"]},
cong_available: $cong,
rows: $rows, captured: $captured}' >"$OUT/manifest.json"
rm -f "$OUT"/ss-golden-* "$OUT"/nsid-golden-*
Expand Down
39 changes: 39 additions & 0 deletions nix/microvms/scripts/golden-workload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
# sockopt bits, three receive buffers, SO_BINDTODEVICE
# golden-states-a/b veth, MTU 1300: a FIN_WAIT2/CLOSE_WAIT pair; the
# capture adds TIME_WAIT and SYN_SENT after poll 1
# golden-loc-a/b veth, MTU 1500, and golden-remote behind golden-loc-b:
# golden-remote one connection per locality (self, subnet, remote
# over IPv4 and IPv6 to documentation addresses)
# the host as it is
#
# Every pair is a named netns, so root picks any algorithm and option
Expand Down Expand Up @@ -186,6 +189,40 @@ wait_listen golden-states-b 4000 2
wait_listen golden-states-b 4002
spawn states-half golden-states-a "$TCP_CLIENT" -count 1 -connect 10.3.0.2 -halfclose -pads 0

# loc: one destination of each locality from golden-loc-a. Its own address
# (self), golden-loc-b's (subnet), and golden-remote's documentation
# addresses through golden-loc-b as a router (remote; goldenAsnDb in mkVm.nix
# maps them to ASNs).
pair loc 5 1500
ip netns del golden-remote 2>/dev/null || true
ip netns add golden-remote
ip -n golden-remote link set lo up
ip link add veth1 netns golden-loc-b type veth peer name veth0 netns golden-remote
ip -n golden-loc-b addr add 203.0.113.1/24 dev veth1
ip -n golden-loc-b addr add 2001:db8:113::1/64 dev veth1 nodad
ip -n golden-remote addr add 203.0.113.10/24 dev veth0
ip -n golden-remote addr add 2001:db8:113::10/64 dev veth0 nodad
ip -n golden-loc-b link set veth1 up
ip -n golden-remote link set veth0 up
ip netns exec golden-loc-b sysctl -qw net.ipv4.ip_forward=1 net.ipv6.conf.all.forwarding=1
ip -n golden-remote route add default via 203.0.113.1
ip -n golden-remote -6 route add default via 2001:db8:113::1
ip -n golden-loc-a route add 203.0.113.0/24 via 10.5.0.2
ip -n golden-loc-a -6 route add 2001:db8:113::/48 via fd00:5::2
spawn loc-self-server golden-loc-a "$TCP_SERVER" -count 1 -bind 10.5.0.1
spawn loc-subnet-server golden-loc-b "$TCP_SERVER" -count 1 -bind 10.5.0.2
spawn loc-remote-server-4 golden-remote "$TCP_SERVER" -count 1 -bind 203.0.113.10
spawn loc-remote-server-6 golden-remote "$TCP_SERVER" -count 1 -bind 2001:db8:113::10
wait_listen golden-loc-a 4000
wait_listen golden-loc-b 4000
wait_listen golden-remote 4000 2
spawn loc-self golden-loc-a "$TCP_CLIENT" -count 1 -connect 10.5.0.1 -sleep 1h -pads 0
spawn loc-subnet golden-loc-a "$TCP_CLIENT" -count 1 -connect 10.5.0.2 -sleep 1h -pads 0
spawn loc-remote-4 golden-loc-a "$TCP_CLIENT" -count 1 -connect 203.0.113.10 -sleep 1h -pads 0
spawn loc-remote-6 golden-loc-a "$TCP_CLIENT" -count 1 -connect 2001:db8:113::10 -sleep 1h -pads 0
# The self connection shows twice in golden-loc-a, once per end.
loc_established=5

# Each container's connections show twice, once per end.
need=$((2 * SOCKETS))
deadline=$((SECONDS + READY_SEC))
Expand All @@ -210,6 +247,8 @@ while :; do
if [ $((n + m)) -lt "$want" ]; then pending="$pending golden-bulk($((n + m))/$want)"; fi
n=$(count_state golden-opts-a established)
if [ "$n" -lt "$opts_clients" ]; then pending="$pending golden-opts-a($n/$opts_clients)"; fi
n=$(count_state golden-loc-a established)
if [ "$n" -lt "$loc_established" ]; then pending="$pending golden-loc-a($n/$loc_established)"; fi
n=$(count_state golden-states-a fin-wait-2)
m=$(count_state golden-states-b close-wait)
if [ "$n" -lt 1 ] || [ "$m" -lt 1 ]; then pending="$pending golden-states(fin-wait-2 $n, close-wait $m)"; fi
Expand Down
9 changes: 6 additions & 3 deletions pkg/xtcp/testdata/golden/7_3_1/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
"golden-opts-a",
"golden-opts-b",
"golden-states-a",
"golden-states-b"
"golden-states-b",
"golden-loc-a",
"golden-loc-b",
"golden-remote"
]
},
"cong_available": [
Expand All @@ -43,6 +46,6 @@
"westwood",
"yeah"
],
"rows": 158,
"captured": "2026-11-24"
"rows": 170,
"captured": "2026-11-25"
}
Loading