diff --git a/deploy/containerlab/README.md b/deploy/containerlab/README.md index cdd1db93..0931bc7f 100644 --- a/deploy/containerlab/README.md +++ b/deploy/containerlab/README.md @@ -696,10 +696,11 @@ its addresses. The script works for any Kind node of the topology. The [VLAN transport contract](../../docs/designs/vlan-transport/contract.md) needs each side of an edge node to run tagged (802.1Q) or untagged. The topology above builds untagged bonds only. `scripts/vlan-transport.sh` re-plumbs sjc at run time, without changing a manifest. It changes the public side (sjc-worker2 `bond0` to tr2 `bond1`) and the fabric side (sjc-worker2 `bond1` to sjc-worker `bond0`). -- `resources/vlan-transport/cells.env` defines cells C1 to C6 of the [acceptance matrix](../../docs/designs/vlan-transport/acceptance.md) except C5, which point-to-point links cannot build. `PUB_VID` and `FAB_VID` override a cell's IDs. +- `resources/vlan-transport/cells.env` defines cells C1 to C6 of the [acceptance matrix](../../docs/designs/vlan-transport/acceptance.md), plus C1AB and C4AB on active-backup bonds. `PUB_VID` and `FAB_VID` override a cell's IDs, `PUB_PARENT` and `FAB_PARENT` its parent per side (`bond`, `nic` or `shared`), and `BOND_MODE` its bond mode. A later `apply` changes only the side whose ID or parent differs. +- C5 needs one parent that reaches both tr2 and sjc-worker, which point-to-point links cannot give. `scripts/vlan-transport-switch.sh` adds a bridge node, `clab-gvpc-vtsw`, with four new veths. The edge's new bond `bondsw` trunks both VLANs to the bridge, which passes the public VLAN to tr2 and the fabric VLAN to sjc-worker. `apply C5` builds it and `revert` removes it. Creating the veths needs passwordless `sudo` for `containerlab tools veth create`, as `restart-node.sh` does. - `apply` creates the VLAN netdevices on both ends of each tagged side and moves the link's addresses onto them: with `ip` on the Kind nodes and in vtysh's running configuration on tr2. It then points `galactic-gateway`, `galactic-nat` and `galactic-cni` at the new interfaces with `kubectl set env`. `SELECT=logical` names the VLAN netdevice, as the contract requires. `SELECT=parent` names the parent instead. -- sjc's single `galactic-cni` DaemonSet needs a different interface on each node once a side is tagged. `apply` gives sjc-worker2 its own copy, `galactic-cni-vt-edge`, and excludes that node from the original. -- `apply` saves the deployed settings on sjc-worker2 in `/galactic/vlan-transport.state`. `revert` uses it to restore C1. `offload on|off` toggles VLAN offloads on every transport member. +- sjc's single `galactic-cni` DaemonSet needs a different interface on each node once a side is tagged. By default `apply` gives sjc-worker2 its own copy, `galactic-cni-vt-edge`, and excludes that node from the original. `CNI_SELECT=by-node` instead sets `GALACTIC_CNI_EBPF_INTERFACES_BY_NODE` on the one DaemonSet, which needs a `galactic-cni` that reads it ([#1539](https://github.com/datum-cloud/galactic/pull/1539), for [#1404](https://github.com/datum-cloud/galactic/issues/1404)). +- `apply` saves the deployed settings on sjc-worker2 in `/galactic/vlan-transport.state`. `revert` uses it to restore C1. `offload on|off` toggles VLAN offloads on every transport member. `csum on|off` toggles their transmit checksum offload: a veth sender with it on hands a natively redirected frame on with a partial checksum, which the far end counts as a checksum error. - `VT_SITE=dfw-worker3` re-plumbs only dfw-worker3's public side. It exists for the same-node delivery row, which `verify:edge-listener` runs on dfw. Set `EDGE_CONFORMANCE_UPLINK_DEV=dfw-worker3=bond2.101` so the test pins its VIP through the VLAN. ```bash @@ -713,6 +714,26 @@ task variant:vlan-transport:revert `verify-gateway-ingress*.sh` take `UPLINK_DEV="sjc-worker2=bond1.101"` to pin through a tagged transit-side device. +#### Acceptance run + +`task verify:vlan-transport` runs the matrix's lab rows, V01 to V28, over the cells, the host XDP modes (`lab:xdp-mode`) and both VLAN offload states, and writes a row-by-row report: + +```bash +task verify:vlan-transport DRY_RUN=1 CELL=C4 # print every step; no lab needed +task verify:vlan-transport CELL="C1 C4" ROWS="V01-V08 V11" OUT=/tmp/vt +task verify:vlan-transport # every cell, row, mode and offload state +task report:vlan-transport OUT=/tmp/vt # re-render the report +``` + +- `CELL` takes cell names, or `all`: C1 to C6, C4ALT (C4 with the IDs in `ALT_PUB_VID` and `ALT_FAB_VID`, default 1234 and 3456), C1AB and C4AB. Untagged cells run first, since each tagged cell's throughput, latency and recovery are compared with C1 (C1AB for C4AB) in the same XDP mode and offload state. +- `ROWS` takes row IDs, ranges such as `V01-V08`, or `all`. `XM` checks every XDP hook's mode, `NAA` reproduces the `verify:nat-active-active` finding from #1401 once, and `POST` runs sjc's untagged checks after the final revert. +- `XDP_MODES` (default `native generic`), `OFFLOADS` (default `on off`), `SELECT`, `CSUM` (default `off`) and `CNI_SELECT` set the run's configuration. `BASELINE` names a pre-change run's output for V20. +- V17 to V28 test configuration and lifecycle, so they run once per cell and XDP mode, in the first offload state. + +`OUT` holds `report.md` (pinned revisions, configuration, expected against observed for every check, skips, captures and counters, commands), `results.tsv`, and a directory per cell, mode and offload state with each step's output and captures. A check is PASS, FAIL, SKIP (did not run, with the reason), BASELINE (an untagged measurement), N/A (excluded by the contract for that cell) or PLANNED (dry run). A skip is never a pass: the task exits 1 when a check failed and 3 when none failed but some were skipped. An interrupted live run still reverts sjc to C1, restores the XDP mode and writes the report. + +The rows reuse the variant's scripts: `vlan-transport.sh` for cells, offloads and captures (with the tenant attachment's own capture), `vlan-transport-inject.sh` for V11 to V13, `vlan-transport-interrupt.sh` for V21 to V28 with a public, a fabric and an end-to-end probe every 20 ms, and `vlan-transport-perf.sh` for V09 (iperf3 and ping between tenants and through NAT66). Rows that call the `verify-*` scripts and tasks run them unchanged. + Hold a containerlab-manager reservation for everything except `plan`, and end with `revert` and the sjc checks: `verify-gateway-ingress*.sh --node sjc-worker2`, `verify:nat-datapath SENDER_SITE=sjc SHARD_NODE=sjc-worker2 SHARD_SITE=sjc`, `verify-ns20.sh` and `verify:bonds`. The [baseline report](../../docs/archive/benchmarks/vlan-transport-baseline-2026-11-30.md) lists which rows have run. ## Notes diff --git a/deploy/containerlab/Taskfile.yaml b/deploy/containerlab/Taskfile.yaml index 9f7c1a5c..827b575d 100644 --- a/deploy/containerlab/Taskfile.yaml +++ b/deploy/containerlab/Taskfile.yaml @@ -1429,6 +1429,13 @@ tasks: cmds: - LAB={{.LAB}} ./scripts/vlan-transport.sh offload {{.STATE}} + "variant:vlan-transport:csum": + desc: Turn transmit checksum offload on or off on every sjc transport member (STATE=on|off) + requires: + vars: [STATE] + cmds: + - LAB={{.LAB}} ./scripts/vlan-transport.sh csum {{.STATE}} + "variant:vlan-transport:status": desc: Show the applied transport cell and sjc's transport interfaces cmds: @@ -1443,6 +1450,31 @@ tasks: LAB={{.LAB}} {{if .PUB_VID}}PUB_VID={{.PUB_VID}} {{end}}{{if .FAB_VID}}FAB_VID={{.FAB_VID}} {{end}} ./scripts/vlan-transport-baseline.sh {{.CELL}} {{.SELECT | default "logical"}} {{.OUT}} {{.ROWS | default "V06 V01 V03 V05 V07"}} + # The acceptance matrix's lab rows (docs/designs/vlan-transport/ + # acceptance.md, #1405), over the cells in resources/vlan-transport/ + # cells.env, with a row-by-row report in OUT. DRY_RUN=1 prints every step + # and writes the report skeleton without the lab. Anything else needs the + # containerlab-manager reservation and ends with sjc back at C1. + "verify:vlan-transport": + desc: Run the VLAN transport acceptance rows with a row-by-row report (CELL=, ROWS=, XDP_MODES=, OFFLOADS=, OUT=, DRY_RUN=1) + cmds: + - >- + LAB={{.LAB}} ./scripts/verify-vlan-transport.sh + {{if .DRY_RUN}}--dry-run{{end}} + --cells "{{.CELL | default "all"}}" --rows "{{.ROWS | default "all"}}" + --xdp-modes "{{.XDP_MODES | default "native generic"}}" --offloads "{{.OFFLOADS | default "on off"}}" + --select {{.SELECT | default "logical"}} --csum {{.CSUM | default "off"}} + --cni-select {{.CNI_SELECT | default "copy"}} + {{if .BASELINE}}--baseline {{.BASELINE}}{{end}} + {{if .OUT}}--out {{.OUT}}{{end}} + + "report:vlan-transport": + desc: Re-render OUT/report.md from a verify:vlan-transport run's results (OUT=) + requires: + vars: [OUT] + cmds: + - ./scripts/vlan-transport-report.sh {{.OUT}} + clean: desc: Destroy the lab and delete artifacts cmds: diff --git a/deploy/containerlab/resources/vlan-transport/cells.env b/deploy/containerlab/resources/vlan-transport/cells.env index 8eb56cf7..c85a3433 100644 --- a/deploy/containerlab/resources/vlan-transport/cells.env +++ b/deploy/containerlab/resources/vlan-transport/cells.env @@ -8,15 +8,20 @@ # The variant runs on the sjc site. Contract name to lab interface: # bondpub sjc-worker2 bond0 (peer tr2 bond1) public side # bondfab sjc-worker2 bond1 (peer sjc-worker bond0) fabric side -# PARENT=nic takes each side's first bond member out of its bond on both ends -# and uses that veth as a plain NIC. # -# C5 (two VLANs on one parent) is not a lab cell: the lab's links are -# point-to-point, so one parent cannot reach both the external router and the -# compute node. Its kernel behaviour is measured by the vlanprobe root test -# (internal/plumbing/ebpf/vlanprobe). +# PARENT is the kind of parent for both sides; PUB_PARENT and FAB_PARENT +# override it per side, as do the same names in the environment at apply time. +# bond the side's existing bond +# nic each side's first bond member, taken out of its bond on both ends +# and used as a plain NIC +# shared C5 only: both sides on one new bond, bondsw, behind a VLAN-aware +# bridge node (scripts/vlan-transport-switch.sh) that trunks the +# public VLAN to tr2 and the fabric VLAN to sjc-worker +# +# BOND_MODE is the mode of every bond on the variant's links: 802.3ad (the +# lab's default) or active-backup. -# cell public-VID fabric-VID parent +# cell public-VID fabric-VID parent bond mode C1_PUB_VID= C1_FAB_VID= C1_PARENT=bond @@ -33,6 +38,21 @@ C4_PUB_VID=101 C4_FAB_VID=202 C4_PARENT=bond +C5_PUB_VID=101 +C5_FAB_VID=202 +C5_PARENT=shared + C6_PUB_VID=101 C6_FAB_VID=202 C6_PARENT=nic + +# Active-backup bonds: C1AB is the untagged baseline for C4AB. +C1AB_PUB_VID= +C1AB_FAB_VID= +C1AB_PARENT=bond +C1AB_BOND_MODE=active-backup + +C4AB_PUB_VID=101 +C4AB_FAB_VID=202 +C4AB_PARENT=bond +C4AB_BOND_MODE=active-backup diff --git a/deploy/containerlab/scripts/verify-vlan-transport.sh b/deploy/containerlab/scripts/verify-vlan-transport.sh new file mode 100755 index 00000000..c536eaab --- /dev/null +++ b/deploy/containerlab/scripts/verify-vlan-transport.sh @@ -0,0 +1,292 @@ +#!/bin/bash +# verify-vlan-transport.sh: the containerlab (L) rows of the tagged and +# untagged transport acceptance matrix, docs/designs/vlan-transport/ +# acceptance.md, over its configuration cells, with a row-by-row report +# (issue #1405). `task verify:vlan-transport` runs it. +# +# Usage: verify-vlan-transport.sh [--dry-run] [--cells "C1 C4 ..."] +# [--rows "V01-V08 V11 ..."] [--xdp-modes "native generic"] +# [--offloads "on off"] [--select logical|parent] [--csum on|off] +# [--cni-select copy|by-node] [--baseline DIR] [--out DIR] +# +# --cells all (default) is C1 C2 C3 C4 C4ALT C5 C6 C1AB C4AB. C4ALT is +# C4 with the alternate IDs ALT_PUB_VID/ALT_FAB_VID (default +# 1234/3456); C1AB and C4AB run on active-backup bonds; C5 +# adds the bridge node (vlan-transport-switch.sh). Untagged +# cells run first: C1 is the baseline every other cell's +# performance and recovery is compared with, C1AB for C4AB. +# --rows all (default) is XM NAA V01-V28 POST. XM checks the XDP +# attach mode, NAA reproduces the verify:nat-active-active +# finding once, POST runs sjc's untagged checks after revert. +# V17 to V28 run once per cell and XDP mode, in the first +# offload state: they test configuration and lifecycle. +# --xdp-modes host XDP modes, set with `task lab:xdp-mode` (generic, +# native or auto); default "native generic". +# --offloads VLAN receive and transmit offload states; default "on off". +# --csum transmit checksum offload on the veth senders; default off, +# so native redirects do not produce false checksum errors. +# --cni-select how galactic-cni gets per-node interfaces (vlan-transport.sh +# CNI_SELECT); by-node needs GALACTIC_CNI_EBPF_INTERFACES_BY_NODE. +# --baseline a pre-change run's output directory, for V20. +# --out output directory; default /tmp/vlan-transport-. +# +# --dry-run prints every step and writes the report skeleton without touching +# the lab: no docker, kubectl or task call runs. Everything else needs the +# containerlab-manager reservation, and ends with the lab back at C1 in the +# XDP mode RESTORE_XDP_MODE (default empty: the drivers' choice). +# +# Output: OUT/results.tsv (one line per check), OUT/report.md (from +# vlan-transport-report.sh), OUT// per cell, XDP mode and offload +# state with commands.log, captures, counters and each step's output. +# Exit status: 0 when every check passed, is a baseline or is excluded by +# the contract (N/A); 1 when any check failed; 3 when none failed but some +# were skipped, since a skip is not a pass. A dry run exits 0. An interrupted +# or aborted live run still reverts sjc to C1, restores the XDP mode and +# writes the report. +set -uo pipefail + +SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) +CLAB=$(cd "${SCRIPT_DIR}/.." && pwd) +cd "${CLAB}" || exit 2 +VT="${SCRIPT_DIR}/vlan-transport.sh" +LAB=${LAB:-gvpc} +ALL_CELLS="C1 C2 C3 C4 C4ALT C5 C6 C1AB C4AB" +ALT_PUB_VID=${ALT_PUB_VID:-1234} +ALT_FAB_VID=${ALT_FAB_VID:-3456} + +DRY_RUN=0 CELLS=all ROWS=all XMODES="native generic" OFFLOADS="on off" SELECT=logical CSUM=off +CNI_SELECT=${CNI_SELECT:-copy} PRE_CHANGE="" TOP="" +while [ "$#" -gt 0 ]; do + case "$1" in + --dry-run) DRY_RUN=1 ;; + --cells) CELLS="$2"; shift ;; + --rows) ROWS="$2"; shift ;; + --xdp-modes) XMODES="$2"; shift ;; + --offloads) OFFLOADS="$2"; shift ;; + --select) SELECT="$2"; shift ;; + --csum) CSUM="$2"; shift ;; + --cni-select) CNI_SELECT="$2"; shift ;; + --baseline) PRE_CHANGE="$2"; shift ;; + --out) TOP="$2"; shift ;; + -h | --help) sed -n '2,46p' "$0"; exit 0 ;; + *) echo "verify-vlan-transport: unknown argument $1" >&2; exit 2 ;; + esac + shift +done +[ -n "${CELLS}" ] || CELLS=all +[ -n "${ROWS}" ] || ROWS=all + +die() { echo "verify-vlan-transport: $*" >&2; exit 2; } +case "${SELECT}" in logical | parent) ;; *) die "--select must be logical or parent" ;; esac +case "${CSUM}" in on | off) ;; *) die "--csum must be on or off" ;; esac +case "${CNI_SELECT}" in copy | by-node) ;; *) die "--cni-select must be copy or by-node" ;; esac +for m in ${XMODES}; do case "${m}" in native | generic | auto) ;; *) die "unknown XDP mode ${m}" ;; esac; done +for o in ${OFFLOADS}; do case "${o}" in on | off) ;; *) die "unknown offload state ${o}" ;; esac; done + +# Cells in run order: each untagged baseline before the cells compared with it. +[ "${CELLS}" = all ] && CELLS=${ALL_CELLS} +ordered="" +for c in ${ALL_CELLS}; do + [[ " ${CELLS} " == *" ${c} "* ]] && ordered="${ordered} ${c}" +done +for c in ${CELLS}; do + [[ " ${ALL_CELLS} " == *" ${c} "* ]] || die "unknown cell ${c} (cells: ${ALL_CELLS})" +done +CELLS=${ordered# } + +# Rows: "all", IDs, or ranges such as V01-V08. +expand_rows() { + local r a b i + for r in $1; do + case "${r}" in + all) echo XM NAA; for i in $(seq 1 28); do printf 'V%02d\n' "${i}"; done; echo POST ;; + V[0-9][0-9]-V[0-9][0-9]) + a=${r:1:2} b=${r:5:2} + for i in $(seq "$((10#${a}))" "$((10#${b}))"); do printf 'V%02d\n' "${i}"; done ;; + XM | NAA | POST | V[0-2][0-9]) echo "${r}" ;; + *) die "unknown row ${r}" ;; + esac + done +} +WANT=" $(expand_rows "${ROWS}" | tr '\n' ' ') " +row_wanted() { [[ "${WANT}" == *" $1 "* ]]; } +any_wanted() { local r; for r in "$@"; do row_wanted "${r}" && return 0; done; return 1; } + +TOP=${TOP:-/tmp/vlan-transport-$(date -u +%Y%m%dT%H%M%SZ)} +mkdir -p "${TOP}" +TOP=$(cd "${TOP}" && pwd) +RESULTS="${TOP}/results.tsv" +printf 'run\tcell\txdp\toffload\trow\tcase\tstatus\texpected\tobserved\tevidence\tcommands\n' >"${RESULTS}" +exec > >(tee -a "${TOP}/$([ "${DRY_RUN}" = 1 ] && echo plan || echo run).log") 2>&1 + +# shellcheck source=vlan-transport-rows.sh +source "${SCRIPT_DIR}/vlan-transport-rows.sh" + +# --- pinned revisions and configuration ---------------------------------------- + +meta() { printf '%s=%q\n' "$1" "$2" >>"${TOP}/meta.env"; } +: >"${TOP}/meta.env" +meta date "$(date -u +%FT%TZ)" +meta mode "$([ "${DRY_RUN}" = 1 ] && echo dry-run || echo live)" +meta commit "$(git -C "${CLAB}" rev-parse HEAD 2>/dev/null || echo unknown)" +meta describe "$(git -C "${CLAB}" describe --always --dirty 2>/dev/null || echo unknown)" +meta branch "$(git -C "${CLAB}" rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)" +meta worktree "$(git -C "${CLAB}" status --porcelain 2>/dev/null | wc -l | tr -d ' ') uncommitted paths" +meta cells "${CELLS}" +meta rows "$(echo "${WANT}" | xargs)" +meta xdp_modes "${XMODES}" +meta offloads "${OFFLOADS}" +meta select "${SELECT}" +meta csum "${CSUM}" +meta cni_select "${CNI_SELECT}" +meta alt_ids "${ALT_PUB_VID}/${ALT_FAB_VID}" +meta third_vid "${THIRD_VID}" +meta lab "${LAB}" +meta pre_change "${PRE_CHANGE:-none}" +meta host_kernel "$(uname -r)" +if [ "${DRY_RUN}" = 1 ]; then + meta images "not collected (dry run)" +else + meta containerlab "$(containerlab version 2>/dev/null | awk '/version:/ {print $2; exit}')" + meta docker "$(docker version -f '{{.Server.Version}}' 2>/dev/null)" + for cp in dfw-control-plane sjc-control-plane iad-control-plane; do + docker exec "${cp}" kubectl get pods -A -o jsonpath='{range .items[*]}{range .status.containerStatuses[*]}{.image}{"\t"}{.imageID}{"\n"}{end}{end}' 2>/dev/null \ + | grep -E 'galactic|fabric' | sed "s/^/${cp%-control-plane}\t/" + done | sort -u >"${TOP}/images.tsv" + meta images "images.tsv ($(wc -l <"${TOP}/images.tsv") image digests)" +fi + +echo "== verify:vlan-transport $([ "${DRY_RUN}" = 1 ] && echo '(dry run: nothing runs)') -> ${TOP}" +echo " cells: ${CELLS}; XDP modes: ${XMODES}; offloads: ${OFFLOADS}; select ${SELECT}; csum ${CSUM}; cni ${CNI_SELECT}" + +# --- per cell ------------------------------------------------------------------- + +# cell_setup CELL sets the cell's names and comparisons from vlan-transport.sh +# plan, which needs no lab. +cell_setup() { + local cell="$1" plan + BASE_CELL=${cell} VT_ENV=() VT_VARS="" + if [ "${cell}" = C4ALT ]; then + BASE_CELL=C4 + VT_ENV=(PUB_VID="${ALT_PUB_VID}" FAB_VID="${ALT_FAB_VID}") + VT_VARS="PUB_VID=${ALT_PUB_VID},FAB_VID=${ALT_FAB_VID}," + fi + BASE_REF=C1 + [[ "${cell}" == *AB ]] && BASE_REF=C1AB + IS_BASE=0 + [ "${cell}" = "${BASE_REF}" ] && IS_BASE=1 + plan=$(env "${VT_ENV[@]}" CNI_SELECT="${CNI_SELECT}" "${VT}" plan "${BASE_CELL}" "${SELECT}") || return 1 + printf ' %s\n' "${plan//$'\n'/$'\n' }" + # " END: node logical L, parent P, addresses A B" + read -r TR_DEV TR_PAR <<<"$(awk '$1 == "PUB_PEER:" {gsub(",", ""); print $4, $6}' <<<"${plan}")" + read -r PUB_L PUB_P <<<"$(awk '$1 == "PUB_EDGE:" {gsub(",", ""); print $4, $6}' <<<"${plan}")" + read -r FAB_L FAB_P <<<"$(awk '$1 == "FAB_EDGE:" {gsub(",", ""); print $4, $6}' <<<"${plan}")" + read -r CPT_L CPT_P <<<"$(awk '$1 == "FAB_PEER:" {gsub(",", ""); print $4, $6}' <<<"${plan}")" + PUB_VID=$(sed -n "1s/.*public VID '\([^']*\)'.*/\1/p" <<<"${plan}") + FAB_VID=$(sed -n "1s/.*fabric VID '\([^']*\)'.*/\1/p" <<<"${plan}") + [ "${PUB_VID}" = none ] && PUB_VID="" + [ "${FAB_VID}" = none ] && FAB_VID="" + PUB_KIND=$(sed -n '1s/.*public VID [^ ]* parent \([a-z]*\).*/\1/p' <<<"${plan}") + FAB_KIND=$(sed -n '1s/.*fabric VID [^ ]* parent \([a-z]*\).*/\1/p' <<<"${plan}") + CELL_BOND_MODE=$(sed -n '1s/.*bonds \([^,]*\),.*/\1/p' <<<"${plan}") +} + +run_rows() { + local first="$1" + row_wanted XM && row_XM + row_wanted V06 && row_V06 + any_wanted V01 V02 && row_V01 + any_wanted V03 V04 && row_V03 + row_wanted V05 && row_V05 + row_wanted V07 && row_V07 + row_wanted V08 && row_V08 + any_wanted V11 V12 V13 && row_V11 + row_wanted V15 && row_V15 + row_wanted V09 && row_V09 + row_wanted V10 && row_V10 + row_wanted V14 && row_V14 + row_wanted V16 && row_V16 + [ "${first}" = 1 ] || return 0 + row_wanted V17 && row_V17 + row_wanted V18 && row_V18 + row_wanted V19 && row_V19 + row_wanted V20 && row_V20 + any_wanted V21 V22 V23 V24 V25 V26 V27 V28 && row_V21 + return 0 +} + +# finish reverts the lab and writes the report, once: at the normal end, or +# from the EXIT trap when a live run is interrupted or aborts. +FINISHED=0 +finish() { + [ "${FINISHED}" = 1 ] && return 0 + FINISHED=1 + echo "== cleanup" + CELL=- XMODE=- OFFLOAD=- RUN_ID=post OUT="${TOP}/post" + mkdir -p "${OUT}" + row_start REVERT "back to C1" + x env LAB="${LAB}" "${VT}" revert || record REVERT "" FAIL "vlan-transport.sh revert failed; check sjc by hand" + x task -d "${CLAB}" lab:xdp-mode XDP_MODE="${RESTORE_XDP_MODE:-}" \ + || record REVERT xdp-mode FAIL "restoring the XDP mode failed" + [ "${1:-}" = aborted ] && record ABORT "" FAIL "run interrupted or aborted before every row ran" + [ "${1:-}" = aborted ] || { row_wanted POST && row_POST; } + "${SCRIPT_DIR}/vlan-transport-report.sh" "${TOP}" + echo "== report: ${TOP}/report.md" +} +if [ "${DRY_RUN}" != 1 ]; then + trap 'finish aborted' EXIT + trap 'exit 130' INT TERM +fi + +naa_done=0 +for XMODE in ${XMODES}; do + CELL=- OFFLOAD=- RUN_ID="setup-${XMODE}" OUT="${TOP}/${RUN_ID}" + mkdir -p "${OUT}" + echo "== XDP mode ${XMODE}" + row_start XDP "set the host XDP mode" + x task -d "${CLAB}" lab:xdp-mode XDP_MODE="$([ "${XMODE}" = auto ] || echo "${XMODE}")" + if row_wanted NAA && [ "${naa_done}" = 0 ]; then + row_NAA + naa_done=1 + fi + for CELL in ${CELLS}; do + echo "== ${CELL} in ${XMODE} mode" + if ! cell_setup "${CELL}"; then + OFFLOAD=- RUN_ID="${CELL}-${XMODE}" + skip CELL "" "vlan-transport.sh plan refused ${BASE_CELL}" + continue + fi + OUT="${TOP}/${CELL}-${XMODE}" + mkdir -p "${OUT}" + RUN_ID="${CELL}-${XMODE}" + row_start APPLY "apply ${CELL}" + if ! x env LAB="${LAB}" "${VT_ENV[@]}" CNI_SELECT="${CNI_SELECT}" EXTRA_VIDS="${THIRD_VID}" "${VT}" apply "${BASE_CELL}" "${SELECT}"; then + record APPLY "" FAIL "vlan-transport.sh apply ${BASE_CELL} failed; no row ran in this cell" + continue + fi + first=1 + for OFFLOAD in ${OFFLOADS}; do + RUN_ID="${CELL}-${XMODE}-offload-${OFFLOAD}" + OUT="${TOP}/${RUN_ID}" + BASE_DIR="${TOP}/${BASE_REF}-${XMODE}-offload-${OFFLOAD}" + mkdir -p "${OUT}" + echo "== ${RUN_ID}" + row_start SETUP "offloads and snapshot" + if ! x env LAB="${LAB}" "${VT}" offload "${OFFLOAD}" || ! x env LAB="${LAB}" "${VT}" csum "${CSUM}"; then + record SETUP "" FAIL "setting VLAN offload ${OFFLOAD} or checksum offload ${CSUM} failed; no row ran in this state" + continue + fi + x env LAB="${LAB}" "${VT}" snapshot "${OUT}" + xo "${OUT}/components.txt" docker exec sjc-control-plane kubectl -n galactic-system get pods -o wide + run_rows "${first}" + first=0 + done + done +done + +finish completed +trap - EXIT +[ "${DRY_RUN}" = 1 ] && exit 0 +awk -F'\t' 'NR > 1 {n[$7]++} + END {printf "== %d passed, %d failed, %d skipped, %d baseline, %d N/A\n", n["PASS"], n["FAIL"], n["SKIP"], n["BASELINE"], n["N/A"] + exit n["FAIL"] ? 1 : (n["SKIP"] || n["PLANNED"]) ? 3 : 0}' "${RESULTS}" diff --git a/deploy/containerlab/scripts/verify-xdp-mode.sh b/deploy/containerlab/scripts/verify-xdp-mode.sh index 04335bfc..3d4f3ae8 100755 --- a/deploy/containerlab/scripts/verify-xdp-mode.sh +++ b/deploy/containerlab/scripts/verify-xdp-mode.sh @@ -4,7 +4,10 @@ # dispatcher (xdp_dispatch) and any program galactic-gateway or galactic-nat # attached directly (edge_lb, edge_return, nat_ingress). It reads the mode # from the kernel, as `ip -d link show` reports it (xdp or xdpgeneric), and -# fails on any attachment in the other mode or a node with none at all. It +# fails on any attachment in the other mode or a node with none at all. A +# VLAN netdevice, a tagged transport side's logical interface, is expected +# in generic mode whatever EXPECT says: the kernel offers it no native XDP +# (docs/designs/vlan-transport/contract.md section 5). It # then checks that every galactic-gateway and galactic-nat pod logged the # same mode, and prints the source each logged (driver or forced). # @@ -52,7 +55,8 @@ for link in json.load(sys.stdin): continue seen += 1 mode = modes.get(xdp.get("mode"), str(xdp.get("mode"))) - ok = mode == expect + want = "generic" if link.get("linkinfo", {}).get("info_kind") == "vlan" else expect + ok = mode == want bad += not ok verdict = "ok" if ok else "WRONG MODE" print(" %s %s: %s %s %s" % (node, link["ifname"], mode, ",".join(sorted(names)), verdict)) diff --git a/deploy/containerlab/scripts/vlan-transport-baseline.sh b/deploy/containerlab/scripts/vlan-transport-baseline.sh index 136985c5..2f4022ce 100755 --- a/deploy/containerlab/scripts/vlan-transport-baseline.sh +++ b/deploy/containerlab/scripts/vlan-transport-baseline.sh @@ -23,39 +23,16 @@ EDGE=sjc-worker2 COMPUTE=sjc-worker TR=clab-${LAB}-tr2 VT="${SCRIPT_DIR}/vlan-transport.sh" -GW_METRICS=8081 -NAT_METRICS=9182 mkdir -p "${OUT}" exec > >(tee -a "${OUT}/run.log") 2>&1 q() { docker exec "$@"; } result() { echo "RESULT ${CELL}/${SELECT} $1: $2" | tee -a "${OUT}/results.txt"; } -metrics() { # NODE PORT FILE - q "$1" curl -s --max-time 4 "http://localhost:$2/metrics" | grep -E '^galactic_' >"$3" || true -} - -# metric_delta BEFORE AFTER PATTERN: per-series increases for matching series. -metric_delta() { - join -a2 -e 0 -o '0,1.2,2.2' <(grep -E "$3" "$1" | awk '{print $1, $2}' | sort) \ - <(grep -E "$3" "$2" | awk '{print $1, $2}' | sort) | awk '$3 != $2 {printf " %s %s -> %s\n", $1, $2, $3}' -} - -counters_before() { - metrics "${EDGE}" "${GW_METRICS}" "${OUT}/$1-gw.before" - metrics "${EDGE}" "${NAT_METRICS}" "${OUT}/$1-nat.before" -} - -counters_after() { - metrics "${EDGE}" "${GW_METRICS}" "${OUT}/$1-gw.after" - metrics "${EDGE}" "${NAT_METRICS}" "${OUT}/$1-nat.after" - { - echo "gateway counters that moved:" - metric_delta "${OUT}/$1-gw.before" "${OUT}/$1-gw.after" '^galactic_(edge|xdp|gateway)' - echo "nat counters that moved:" - metric_delta "${OUT}/$1-nat.before" "${OUT}/$1-nat.after" '^galactic_(nat|xdp)' - } | tee "${OUT}/$1-counters.txt" -} +# metrics, metric_delta and the counter snapshots are shared with +# verify-vlan-transport.sh, which runs these rows as part of the full matrix. +# shellcheck source=vlan-transport-rows.sh +source "${SCRIPT_DIR}/vlan-transport-rows.sh" field() { q "${EDGE}" sh -c "grep '^$1=' /galactic/vlan-transport.state | cut -d= -f2-"; } diff --git a/deploy/containerlab/scripts/vlan-transport-inject.sh b/deploy/containerlab/scripts/vlan-transport-inject.sh index 5710497f..d2d26e85 100755 --- a/deploy/containerlab/scripts/vlan-transport-inject.sh +++ b/deploy/containerlab/scripts/vlan-transport-inject.sh @@ -11,8 +11,13 @@ # bond, so the tag crosses the veth as skb metadata, as receive # VLAN offload presents it to XDP. # -# Called by vlan-transport-baseline.sh inside the lab reservation; every -# change on tr2 is echoed with "change:" and removed before returning. +# INJECT_NODE, INJECT_DEV and INJECT_BOND move the sender: by default tr2's +# bond1 and its member eth1. Cell C5 sends from the switch node's edge-facing +# bond (vtsw, bondsw, e1), so the fabric VLAN reaches the shared parent too. +# FAB_VID is the other side's ID (default 202), used as a wrong ID. +# +# Called inside the lab reservation; every change on the sender is echoed +# with "change:" and removed before returning. set -uo pipefail SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) @@ -21,7 +26,10 @@ OUT=${1:?out} PUB_L=${2:?public logical interface} PUB_VID=${3:-} EDGE=sjc-worker2 -TR=clab-${LAB}-tr2 +TR=${INJECT_NODE:-clab-${LAB}-tr2} +DEV=${INJECT_DEV:-eth1} +BOND=${INJECT_BOND:-bond1} +FAB=${FAB_VID:-202} VIP=2001:db8:6060:2::1 SRC=2001:db8:1:40::2 COUNT=20 @@ -40,21 +48,21 @@ other=$(( ${PUB_VID:-0} == 999 ? 998 : 999 )) pub=${PUB_VID:-101} echo "edge public ${PUB_L} (VID ${PUB_VID:-none}); edge MAC ${edge_mac}" -for c in untagged "q:${pub}" "q:${other}" q:202 prio "qq:${pub}:5" "ad:300:${pub}" "trunc:${pub}"; do +for c in untagged "q:${pub}" "q:${other}" "q:${FAB}" prio "qq:${pub}:5" "ad:300:${pub}" "trunc:${pub}"; do before=$(rule_packets) - q "${TR}" python3 /tmp/vlan-inject.py eth1 "${edge_mac}" "${SRC}" "${VIP}" 80 "${c}" "${COUNT}" >/dev/null + q "${TR}" python3 /tmp/vlan-inject.py "${DEV}" "${edge_mac}" "${SRC}" "${VIP}" 80 "${c}" "${COUNT}" >/dev/null sleep 2 after=$(rule_packets) echo "case in-frame ${c}: sent ${COUNT}, gateway rule packets +$((after - before))" done # Kernel-tagged: the same VIP reached through a temporary VLAN on tr2's bond. -for vid in "${pub}" "${other}" 202; do - dev="bond1.${vid}" +for vid in "${pub}" "${other}" "${FAB}"; do + dev="${BOND}.${vid}" created=0 if ! q "${TR}" ip link show dev "${dev}" >/dev/null 2>&1; then - echo "change: ${TR}: ip link add link bond1 name ${dev} type vlan id ${vid}" - q "${TR}" ip link add link bond1 name "${dev}" type vlan id "${vid}" + echo "change: ${TR}: ip link add link ${BOND} name ${dev} type vlan id ${vid}" + q "${TR}" ip link add link "${BOND}" name "${dev}" type vlan id "${vid}" q "${TR}" ip link set dev "${dev}" up created=1 fi diff --git a/deploy/containerlab/scripts/vlan-transport-interrupt.sh b/deploy/containerlab/scripts/vlan-transport-interrupt.sh index 2b8d0ad3..fd875f83 100755 --- a/deploy/containerlab/scripts/vlan-transport-interrupt.sh +++ b/deploy/containerlab/scripts/vlan-transport-interrupt.sh @@ -1,75 +1,231 @@ #!/bin/bash -# vlan-transport-interrupt.sh OUT: interruption baselines for the tagged -# transport variant (acceptance rows V23, V24, V27, V28). A tenant pod on -# sjc's compute node pings the off-fabric host every 20 ms through sjc's NAT -# shard, crossing both of sjc's transport sides, while one event happens. The -# interruption is the longest run of missing replies times 20 ms. +# vlan-transport-interrupt.sh OUT [EVENT...]: interruption timing for the +# tagged transport variant (acceptance rows V21 to V28, and their untagged +# baselines in C1). Three probes send every 20 ms while one event happens: # -# Events, each with its own prober: -# restart-C1 galactic-nat restarted on untagged sides (V27 baseline) -# transition-C1-C2 C1 to C2 with parent selection (V23) -# restart-C2 galactic-nat restarted with the public side tagged (V27) -# recreate-C2 the edge's public VLAN netdevice deleted and recreated (V24) -# rollback-C2-C1 C2 back to C1 (V28) +# public tr2 pings sjc-worker2's public address: the public side alone +# fabric sjc-worker pings sjc-worker2's fabric address: the fabric side alone +# tenant sjc's ns20 pod pings the off-fabric host through sjc's NAT shard, +# crossing both sides # -# Runs inside the lab reservation; leaves sjc at C1. +# Each probe's interruption is its longest run of missing replies times +# 20 ms. Results go to OUT/interrupt.tsv as "name probe replies sent gap_ms +# event", where name is the event's position and spelling (01-restart_all), +# and the old netdevice check to OUT/.stale. +# +# Events: +# restart:COMPONENT roll galactic-nat, galactic-gateway (the edge's own +# DaemonSet) or galactic-cni; restart:all rolls the three, +# the contract's reconfiguration step 4 +# apply:CELL[:SELECT[:VAR=VAL,...]] +# vlan-transport.sh apply, with PUB_VID, FAB_VID, +# PUB_PARENT or FAB_PARENT set for that apply only +# revert vlan-transport.sh revert +# recreate:SIDE delete the edge's VLAN netdevice on SIDE (public or +# fabric) and recreate it with its ID and addresses +# member:SIDE take the peer end's first bond member on SIDE down +# for MEMBER_HOLD seconds (default 10), then up +# neigh:SIDE flush the edge's neighbours on SIDE's logical interface +# route:SIDE hard-reset the BGP sessions on SIDE: tr2's toward +# the edge (public), the edge's toward sjc-worker (fabric) +# +# With no EVENT, runs #1401's sequence: restart:galactic-nat in C1, +# apply:C2:parent, restart:galactic-nat, recreate:public, revert. +# +# Runs inside the lab reservation. Events change the variant's state as the +# named command does; the caller reverts at the end. set -uo pipefail SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) source "${SCRIPT_DIR}/lib.sh" OUT=${1:?out} +shift +LAB=${LAB:-gvpc} VT="${SCRIPT_DIR}/vlan-transport.sh" CP=sjc-control-plane EDGE=sjc-worker2 +COMPUTE=sjc-worker +TR=clab-${LAB}-tr2 +NS=galactic-system TARGET=2001:db8:1:40::2 +PUB_ADDR=2001:db8:1:21::2 +FAB_ADDR=2001:db8:1:20::1 INTERVAL=0.02 -COUNT=9000 # 180 s, enough for an apply or revert to finish +COUNT=${PROBE_COUNT:-9000} # 180 s at 20 ms, enough for an apply or revert to finish +DELAY=${EVENT_DELAY:-10} +MEMBER_HOLD=${MEMBER_HOLD:-10} mkdir -p "${OUT}" -POD=$(pod_name "${CP}" ns20) +kc() { docker exec "${CP}" kubectl -n "${NS}" "$@"; } +field() { docker exec "${EDGE}" sh -c "grep '^$1=' /galactic/vlan-transport.state 2>/dev/null | cut -d= -f2-"; } -# probe NAME EVENT_DELAY COMMAND...: start the prober, run COMMAND after -# EVENT_DELAY seconds, wait for the prober, and report the longest gap. -probe() { - local name="$1" delay="$2" - shift 2 - docker exec "${CP}" kubectl -n ns20 exec "${POD}" -- \ - ping -6 -n -i "${INTERVAL}" -c "${COUNT}" -W 1 "${TARGET}" >"${OUT}/${name}.ping" 2>&1 & - local pinger=$! - sleep "${delay}" - echo "event ${name} at $(date -u +%T.%N | cut -c1-12): $*" - "$@" >"${OUT}/${name}.event" 2>&1 - wait "${pinger}" - python3 - "${OUT}/${name}.ping" "${COUNT}" <<'EOF' | tee -a "${OUT}/results.txt" +# side_dev SIDE prints the edge's logical interface on SIDE now. +side_dev() { + local d + d=$(field "$1" | cut -d/ -f1) + if [ -n "${d}" ]; then echo "${d}"; elif [ "$1" = public ]; then echo bond0; else echo bond1; fi +} + +restart() { + local ds="$1" + if [ "${ds}" = galactic-gateway ]; then + ds=$(kc get ds -o name | grep -E "galactic-gateway.*${EDGE}" | head -1 | cut -d/ -f2) + fi + echo "change: rollout restart ds/${ds}" + kc rollout restart "ds/${ds}" + kc rollout status "ds/${ds}" --timeout=180s +} + +recreate() { + local dev vid addrs + dev=$(side_dev "$1") + vid=${dev##*.} + [ "${dev}" != "${vid}" ] || { echo "recreate: ${1} side ${dev} is not a VLAN netdevice"; return 1; } + addrs=$(docker exec "${EDGE}" sh -c "ip -o addr show dev ${dev} scope global | awk '{print \$4}'") + echo "change: ${EDGE}: ip link del ${dev}; recreate it with VID ${vid} and ${addrs//$'\n'/ }" + docker exec "${EDGE}" ip link del "${dev}" + docker exec "${EDGE}" ip link add link "${dev%.*}" name "${dev}" type vlan id "${vid}" + docker exec "${EDGE}" ip link set "${dev}" up + local a + for a in ${addrs}; do docker exec "${EDGE}" ip addr add "${a}" dev "${dev}"; done +} + +# member SIDE: the peer end's first member, as vlan-transport.sh names it. +# On C5's shared parent both sides ride bondsw, whose far end is the bridge +# node's e1 and e2. +member() { + local node dev + if [[ "$(field pub_spec)" == shared/* ]]; then + node=clab-${LAB}-vtsw dev=e1 + elif [ "$1" = public ]; then + node=${TR} dev=eth1 + else + node=${COMPUTE} dev=eth1 + fi + echo "change: ${node}: ip link set ${dev} down; ${MEMBER_HOLD}s; up" + docker exec "${node}" ip link set dev "${dev}" down + sleep "${MEMBER_HOLD}" + docker exec "${node}" ip link set dev "${dev}" up +} + +neigh() { + local dev + dev=$(side_dev "$1") + echo "change: ${EDGE}: ip neigh flush dev ${dev}" + docker exec "${EDGE}" ip neigh flush dev "${dev}" +} + +route() { + if [ "$1" = public ]; then + echo "change: tr2: clear bgp 2001:db8:1:21::2 and 10.1.21.2" + docker exec "${TR}" vtysh -c "clear bgp 2001:db8:1:21::2" -c "clear bgp 10.1.21.2" + else + local pod + pod=$(kc get pods -l app.kubernetes.io/name=fabric-router --field-selector "spec.nodeName=${EDGE}" -o name) + echo "change: ${EDGE} FRR: clear bgp 2001:db8:1:20::2 and 10.1.20.2" + kc exec "${pod}" -c frr -- vtysh -c "clear bgp 2001:db8:1:20::2" -c "clear bgp 10.1.20.2" + fi +} + +apply_event() { # CELL[:SELECT[:VAR=VAL,...]] + local cell select vars kv + IFS=: read -r cell select vars <<<"$1" + local -a set_vars=() kvs=() + IFS=, read -ra kvs <<<"${vars}" + for kv in "${kvs[@]}"; do + case "${kv%%=*}" in PUB_VID | FAB_VID | PUB_PARENT | FAB_PARENT) set_vars+=("${kv}") ;; '') ;; *) echo "apply: ignoring ${kv}" ;; esac + done + env "${set_vars[@]}" LAB="${LAB}" "${VT}" apply "${cell}" "${select:-logical}" +} + +run_event() { + case "$1" in + restart:all) restart galactic-cni && restart galactic-gateway && restart galactic-nat ;; + restart:*) restart "${1#restart:}" ;; + apply:*) apply_event "${1#apply:}" ;; + revert) LAB=${LAB} "${VT}" revert ;; + recreate:*) recreate "${1#recreate:}" ;; + member:*) member "${1#member:}" ;; + neigh:*) neigh "${1#neigh:}" ;; + route:*) route "${1#route:}" ;; + *) echo "unknown event $1"; return 2 ;; + esac +} + +# links_now prints "ifindex name" for every link on the edge. +links_now() { docker exec "${EDGE}" ip -o link show | awk -F': ' '{split($2, n, "@"); print $1, n[1]}'; } + +# stale NAME BEFORE: after an event, look for anything still naming a +# netdevice that went away or came back with a new ifindex. +stale() { + local name="$1" before="$2" idx dev now + now=$(links_now) + { + while read -r idx dev; do + grep -qx "${idx} ${dev}" <<<"${now}" && continue + echo "gone or recreated: ${dev} (old ifindex ${idx})" + # A recreated device rightly has routes under its old name again. + if ! awk '{print $2}' <<<"${now}" | grep -qx "${dev}"; then + docker exec "${EDGE}" sh -c "ip route show table all; ip -6 route show table all" | grep -qw "dev ${dev}" \ + && echo "stale: a route still names ${dev}" + fi + docker exec "${EDGE}" sh -c "ip -d link show" | grep -E "^${idx}: " | grep -q xdp && echo "stale: XDP still on ifindex ${idx}" + if docker exec "${EDGE}" sh -c 'command -v bpftool' >/dev/null 2>&1; then + docker exec "${EDGE}" bpftool map dump name vlan_egress 2>/dev/null \ + | grep -Eq "\"key\": ${idx}(,|\$)" && echo "stale: vlan_egress row for ifindex ${idx}" + else + echo "map check: bpftool not on ${EDGE} (not checked)" + fi + done <<<"${before}" + } | tee "${OUT}/${name}.stale" + grep -q '^stale:' "${OUT}/${name}.stale" || echo "stale: none" | tee -a "${OUT}/${name}.stale" +} + +gap() { # FILE PROBE NAME EVENT + python3 -I - "$1" "${COUNT}" "$2" "$3" "$4" <<'EOF' import re, sys -path, count = sys.argv[1], int(sys.argv[2]) +path, count, probe, name, event = sys.argv[1], int(sys.argv[2]), sys.argv[3], sys.argv[4], sys.argv[5] seen = set(int(m.group(1)) for m in re.finditer(r"icmp_seq=(\d+)", open(path).read())) gap = run = 0 for s in range(1, count + 1): run = 0 if s in seen else run + 1 gap = max(gap, run) -name = path.rsplit("/", 1)[1][:-5] -print("%s: %d/%d replies, longest gap %d probes = %d ms" % (name, len(seen), count, gap, gap * 20)) +print("%s\t%s\t%d\t%d\t%d\t%s" % (name, probe, len(seen), count, gap * 20, event)) EOF } -restart_nat() { - docker exec "${CP}" kubectl -n galactic-system rollout restart ds/galactic-nat - docker exec "${CP}" kubectl -n galactic-system rollout status ds/galactic-nat --timeout=120s -} - -recreate_vlan() { - local dev vid - dev=$(docker exec "${EDGE}" sh -c "grep '^public=' /galactic/vlan-transport.state | cut -d= -f2 | cut -d/ -f1") - vid=${dev##*.} - echo "change: ${EDGE}: ip link del ${dev}; recreate it with VID ${vid} and its addresses" - docker exec "${EDGE}" sh -c "ip link del ${dev} && ip link add link ${dev%.*} name ${dev} type vlan id ${vid} \ - && ip link set ${dev} up && ip -6 addr add 2001:db8:1:21::2/64 dev ${dev} && ip -4 addr add 10.1.21.2/24 dev ${dev}" +# probe NAME EVENT: start the probes, run EVENT after DELAY seconds, wait for +# the probes, and report each one's longest gap. +probe() { + local name="$1" event="$2" pod before + pod=$(pod_name "${CP}" ns20) + local -a pids=() + docker exec "${TR}" ping -6 -n -i "${INTERVAL}" -c "${COUNT}" -W 1 "${PUB_ADDR}" >"${OUT}/${name}.public.ping" 2>&1 & + pids+=($!) + docker exec "${COMPUTE}" ping -6 -n -i "${INTERVAL}" -c "${COUNT}" -W 1 "${FAB_ADDR}" >"${OUT}/${name}.fabric.ping" 2>&1 & + pids+=($!) + docker exec "${CP}" kubectl -n ns20 exec "${pod}" -- \ + ping -6 -n -i "${INTERVAL}" -c "${COUNT}" -W 1 "${TARGET}" >"${OUT}/${name}.tenant.ping" 2>&1 & + pids+=($!) + sleep "${DELAY}" + before=$(links_now) + echo "event ${name} at $(date -u +%T.%N | cut -c1-12): ${event}" + run_event "${event}" >"${OUT}/${name}.event" 2>&1 + echo "event ${name} exit $?" >>"${OUT}/${name}.event" + wait "${pids[@]}" + local p + for p in public fabric tenant; do + gap "${OUT}/${name}.${p}.ping" "${p}" "${name}" "${event}" | tee -a "${OUT}/interrupt.tsv" + done + stale "${name}" "${before}" >/dev/null } -probe restart-C1 10 restart_nat -probe transition-C1-C2 10 "${VT}" apply C2 parent -probe restart-C2 10 restart_nat -probe recreate-C2 10 recreate_vlan -probe rollback-C2-C1 10 "${VT}" revert -cat "${OUT}/results.txt" +if [ "$#" -eq 0 ]; then + set -- restart:galactic-nat apply:C2:parent restart:galactic-nat recreate:public revert +fi +i=0 +for event in "$@"; do + i=$((i + 1)) + probe "$(printf '%02d-%s' "${i}" "$(tr ':=,' '___' <<<"${event}")")" "${event}" +done +cat "${OUT}/interrupt.tsv" diff --git a/deploy/containerlab/scripts/vlan-transport-perf.sh b/deploy/containerlab/scripts/vlan-transport-perf.sh new file mode 100755 index 00000000..253221d5 --- /dev/null +++ b/deploy/containerlab/scripts/vlan-transport-perf.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# vlan-transport-perf.sh OUT: throughput and latency for acceptance row V09 +# on sjc's transport sides, written to OUT/perf.tsv as +# "path direction metric value". The untagged run (C1) of the same XDP mode +# and offload settings is the baseline every tagged run is compared with +# (contract section 8); this script only measures. +# +# Paths (docs/designs/vlan-transport/packet-paths.md): +# tenant sjc's ns20 pod to dfw's, P6/P7: tenant SRv6 across sjc's fabric +# and public sides +# nat sjc's ns20 pod to the off-fabric host, P4/P5: NAT66 through +# sjc's shard. The host has no iperf3, so a PERF_IMAGE container +# joins its network namespace for the server. +# +# Throughput is iperf3 TCP for PERF_SECONDS (default 10) each way; latency is +# the 99th percentile of PING_COUNT (default 1000) pings 10 ms apart. The +# gateway path (P1/P3) has no iperf3 backend behind a VIP and is not +# measured here; the harness reports it as a skip. +set -uo pipefail + +SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) +source "${SCRIPT_DIR}/lib.sh" +OUT=${1:?out} +LAB=${LAB:-gvpc} +HOST=clab-${LAB}-remote-host +TARGET=2001:db8:1:40::2 +SECONDS_=${PERF_SECONDS:-10} +PINGS=${PING_COUNT:-1000} +# The netshoot release galactic-debug builds on, which carries iperf3. +PERF_IMAGE=${PERF_IMAGE:-nicolaka/netshoot:v0.16@sha256:b09d9b21381f47a79b3cbcb30da25266dc17186ea00ae65e99fdc51396f48e70} +mkdir -p "${OUT}" + +SRC_CP=sjc-control-plane +DST_CP=dfw-control-plane +SRC=$(pod_name "${SRC_CP}" ns20) +DST=$(pod_name "${DST_CP}" ns20) +DST_IP=$(pod_ip6 "${DST_CP}" ns20 "${DST}") +in_src() { docker exec "${SRC_CP}" kubectl -n ns20 exec "${SRC}" -- "$@"; } +in_dst() { docker exec "${DST_CP}" kubectl -n ns20 exec "${DST}" -- "$@"; } + +emit() { printf '%s\t%s\t%s\t%s\n' "$@" | tee -a "${OUT}/perf.tsv"; } + +# iperf PATH SERVER: TCP each way, from the sjc pod to SERVER. +iperf() { + local path="$1" server="$2" dir flag bps + for dir in out in; do + flag=() + [ "${dir}" = in ] && flag=(-R) + in_src iperf3 -6 -J -t "${SECONDS_}" -c "${server}" "${flag[@]}" >"${OUT}/perf-${path}-${dir}.json" 2>&1 + bps=$(python3 -I -c 'import json,sys; print(round(json.load(open(sys.argv[1]))["end"]["sum_received"]["bits_per_second"] / 1e6, 1))' \ + "${OUT}/perf-${path}-${dir}.json" 2>/dev/null || echo error) + emit "${path}" "${dir}" throughput_mbps "${bps}" + done +} + +# latency PATH DEST: p99 round trip, which covers both directions at once. +latency() { + local path="$1" dest="$2" p99 + in_src ping -6 -n -i 0.01 -c "${PINGS}" "${dest}" >"${OUT}/perf-${path}-ping.txt" 2>&1 + p99=$(python3 -I -c ' +import re, sys +r = sorted(float(m) for m in re.findall(r"time=([0-9.]+)", open(sys.argv[1]).read())) +print("%.3f" % r[min(len(r) - 1, int(len(r) * 0.99))] if r else "error")' "${OUT}/perf-${path}-ping.txt") + emit "${path}" both p99_ms "${p99}" +} + +echo "tenant: ${SRC} (sjc) -> ${DST} (dfw, ${DST_IP})" +in_dst sh -c "pkill iperf3; iperf3 -s -D" >/dev/null 2>&1 +iperf tenant "${DST_IP}" +latency tenant "${DST_IP}" +in_dst pkill iperf3 >/dev/null 2>&1 + +echo "nat: ${SRC} (sjc) -> ${TARGET} (${HOST}, server from ${PERF_IMAGE%@*})" +docker rm -f vt-perf-server >/dev/null 2>&1 +docker run -d --rm --name vt-perf-server --network "container:${HOST}" "${PERF_IMAGE}" iperf3 -s >/dev/null +sleep 2 +iperf nat "${TARGET}" +latency nat "${TARGET}" +docker rm -f vt-perf-server >/dev/null 2>&1 +exit 0 diff --git a/deploy/containerlab/scripts/vlan-transport-report.sh b/deploy/containerlab/scripts/vlan-transport-report.sh new file mode 100755 index 00000000..0ed7dee9 --- /dev/null +++ b/deploy/containerlab/scripts/vlan-transport-report.sh @@ -0,0 +1,160 @@ +#!/bin/bash +# vlan-transport-report.sh OUT: write OUT/report.md, the row-by-row report of +# a verify-vlan-transport.sh run (issue #1405), from OUT/meta.env and +# OUT/results.tsv. verify-vlan-transport.sh calls it at the end; run it again +# to re-render after editing nothing but the inputs. +# +# Sections: pinned revisions, configuration, summary, results per run +# (expected against observed, with evidence), skips, captures and counters, +# commands. A row counts as passed only with status PASS; SKIP, FAIL and +# PLANNED rows are gaps, BASELINE rows are measurements, not acceptance, and +# N/A rows are cases the contract excludes for that cell. +set -euo pipefail + +OUT=${1:?output directory of a verify-vlan-transport.sh run} +[ -s "${OUT}/results.tsv" ] || { echo "vlan-transport-report: no ${OUT}/results.tsv" >&2; exit 1; } + +python3 -I - "${OUT}" <<'PY' +import csv, glob, os, shlex, sys +from collections import Counter, OrderedDict + +top = sys.argv[1] +meta = OrderedDict() +with open(os.path.join(top, "meta.env")) as f: + for line in f: + k, _, v = line.rstrip("\n").partition("=") + meta[k] = " ".join(shlex.split(v)) if v else "" +with open(os.path.join(top, "results.tsv")) as f: + rows = list(csv.DictReader(f, delimiter="\t", quoting=csv.QUOTE_NONE)) + +dry = meta.get("mode") == "dry-run" +cell = lambda s: (s or "").replace("|", "\\|") +out = [] +w = out.append + +w("# VLAN transport acceptance run, %s" % meta.get("date", "?")) +w("") +if dry: + w("> [!NOTE]") + w("> Dry run. Every step below was printed, not executed. Nothing was observed, so no row has passed.") + w("") +w("Rows and pass conditions: `docs/designs/vlan-transport/acceptance.md`. A row passes only with status PASS and its evidence. SKIP, FAIL and PLANNED are gaps; a skip is never a pass. BASELINE rows are the untagged measurements other cells are compared with, not acceptance. N/A rows are cases the contract excludes for that cell.") +w("") +w("## Pinned revisions") +w("") +w("| Item | Value |") +w("| --- | --- |") +for k, label in [("commit", "Code commit"), ("describe", "git describe"), ("branch", "Branch"), + ("worktree", "Worktree"), ("images", "Image digests"), ("host_kernel", "Host kernel"), + ("containerlab", "containerlab"), ("docker", "Docker")]: + if k in meta: + w("| %s | `%s` |" % (label, cell(meta[k]))) +w("") +w("Per-node kernels, NIC drivers, offloads and bond modes are in each run's `snapshot.txt`.") +w("") +w("## Configuration") +w("") +w("| Setting | Value |") +w("| --- | --- |") +for k, label in [("mode", "Mode"), ("lab", "Lab"), ("cells", "Cells"), ("rows", "Rows"), + ("xdp_modes", "Host XDP modes"), ("offloads", "VLAN offloads"), + ("csum", "Sender checksum offload"), ("select", "Interface selection"), + ("cni_select", "galactic-cni per-node selection"), ("alt_ids", "C4ALT VLAN IDs"), + ("third_vid", "V15 third VLAN"), ("pre_change", "V20 pre-change run")]: + if k in meta: + w("| %s | `%s` |" % (label, cell(meta[k]))) +w("") + +counts = Counter(r["status"] for r in rows) +w("## Summary") +w("") +w("| Status | Checks |") +w("| --- | --- |") +for s in ["PASS", "FAIL", "SKIP", "BASELINE", "N/A", "PLANNED"]: + w("| %s | %d |" % (s, counts.get(s, 0))) +w("") +gaps = sum(counts.get(s, 0) for s in ("FAIL", "SKIP", "PLANNED")) +if dry: + w("**Verdict:** not run.") +elif gaps: + w("**Verdict:** not qualified: %d checks failed, %d were skipped." % (counts.get("FAIL", 0), counts.get("SKIP", 0))) +else: + w("**Verdict:** every check passed.") +w("") + +w("## Results") +runs = OrderedDict() +for r in rows: + runs.setdefault(r["run"], []).append(r) +for run, rs in runs.items(): + w("") + w("### %s" % run) + w("") + w("Cell `%s`, XDP `%s`, VLAN offload `%s`." % (rs[0]["cell"], rs[0]["xdp"], rs[0]["offload"])) + w("") + w("| Row | Case | Status | Expected | Observed | Evidence |") + w("| --- | --- | --- | --- | --- | --- |") + for r in rs: + w("| %s | %s | %s | %s | %s | %s |" % (r["row"], cell(r["case"]), r["status"], cell(r["expected"]), + cell(r["observed"]), cell(r["evidence"]))) + +skips = [r for r in rows if r["status"] == "SKIP"] +w("") +w("## Skips") +w("") +if skips: + w("Each skip is a gap in the acceptance evidence until it runs or the epic agrees a disposition.") + w("") + w("| Run | Row | Case | Reason |") + w("| --- | --- | --- | --- |") + for r in skips: + w("| %s | %s | %s | %s |" % (r["run"], r["row"], cell(r["case"]), cell(r["observed"]))) +else: + w("None.") + +w("") +w("## Captures and counters") +w("") +tags = sorted(glob.glob(os.path.join(top, "*", "*-tags.txt"))) +if not tags: + w("None recorded%s." % (" (dry run)" if dry else "")) +for t in tags: + w("`%s`:" % os.path.relpath(t, top)) + w("") + w("```text") + with open(t) as f: + w(f.read().rstrip()) + tenant = t.replace("-tags.txt", "-tenant.txt") + if os.path.exists(tenant): + with open(tenant) as f: + w(f.read().rstrip()) + w("```") + w("") +counters = sorted(glob.glob(os.path.join(top, "*", "*-counters.txt"))) +if counters: + w("Counter deltas: %s." % ", ".join("`%s`" % os.path.relpath(c, top) for c in counters)) + +w("") +w("## Commands") +w("") +if dry: + w("The dry run's full plan is `plan.log`; each `plan:` line is one step.") +else: + w("Every step, in order, is in `run.log` and per run in `/commands.log`; each row's own steps are in `/.cmds`.") + for run in runs: + log = os.path.join(top, run, "commands.log") + if os.path.exists(log): + w("") + w("
%s" % run) + w("") + w("```sh") + with open(log) as f: + w(f.read().rstrip()) + w("```") + w("") + w("
") + +with open(os.path.join(top, "report.md"), "w") as f: + f.write("\n".join(out) + "\n") +print("report: %s (%s)" % (os.path.join(top, "report.md"), ", ".join("%s %d" % kv for kv in sorted(counts.items())))) +PY diff --git a/deploy/containerlab/scripts/vlan-transport-rows.sh b/deploy/containerlab/scripts/vlan-transport-rows.sh new file mode 100755 index 00000000..bdfed668 --- /dev/null +++ b/deploy/containerlab/scripts/vlan-transport-rows.sh @@ -0,0 +1,761 @@ +#!/bin/bash +# vlan-transport-rows.sh: the acceptance rows of +# docs/designs/vlan-transport/acceptance.md as functions, sourced by +# verify-vlan-transport.sh (every row) and vlan-transport-baseline.sh (its +# counters). Not run on its own. +# +# Every step that touches the lab goes through x or xo, which log it to the +# run's commands.log and the row's .cmds file, or with DRY_RUN=1 only print +# it. Every row ends in record, which appends one line per check to the +# results file the report writer (vlan-transport-report.sh) reads: +# +# PASS the pass condition held, with the evidence named +# FAIL it did not; the observed column says what was seen +# SKIP the check did not run; the observed column says why. A skip is +# never a pass +# BASELINE an untagged measurement other cells are compared with; not +# acceptance +# N/A the contract excludes the case for this cell (such as a VLAN on +# an untagged side's parent, contract Q8) +# PLANNED dry run: the steps were printed, nothing ran +# +# The caller sets LAB, VT, OUT (the run directory), RESULTS, RUN_ID, CELL, +# XMODE, OFFLOAD, SELECT, DRY_RUN and the side names (side_names). +# shellcheck disable=SC2034 # globals shared with the sourcing scripts + +GW_METRICS=8081 +NAT_METRICS=9182 +CNI_METRICS=9180 +EDGE=${EDGE:-sjc-worker2} +COMPUTE=${COMPUTE:-sjc-worker} +CP=${CP:-sjc-control-plane} +TR=clab-${LAB:-gvpc}-tr2 +SW=clab-${LAB:-gvpc}-vtsw +THIRD_VID=${THIRD_VID:-303} +DRY_RUN=${DRY_RUN:-0} + +# What each row passes on, condensed from the acceptance matrix. +declare -A EXPECTED=( + [XM]="Every Galactic XDP hook runs in the host's mode, except on a VLAN netdevice, which runs generic" + [NAA]="verify:nat-active-active passes (reproduces the #1405 finding if it recurs)" + [V01]="Every TCP and UDP probe to the IPv6 and IPv4 VIP reaches the backend; wire observation rule holds" + [V02]="The backend's replies reach the client through the public side; wire observation rule holds" + [V03]="NAT66 TCP and UDP flows deliver both ways; wire observation rule holds" + [V04]="NAT64 TCP and UDP flows deliver both ways; wire observation rule holds" + [V05]="Tenant traffic between sites delivers both ways; no tag at the tenant" + [V06]="BGP on each side Established; ND and ARP resolve on each logical interface; the node is Ready" + [V07]="After a neighbour flush V01 and V03 still pass and neigh_fallbacks rises" + [V08]="Full-size packets deliver; one byte over draws PTB or Fragmentation Needed where sent today" + [V09]="Per direction: throughput >= 90% and p99 latency <= 110% of the untagged baseline" + [V10]="With the backend on the gateway's node, V01 and V02 deliver and local_deliveries rises" + [V11]="Traffic with the other side's or an unknown VLAN ID is claimed by no Galactic program" + [V12]="Priority-tagged, double-tagged, 802.1ad and truncated frames are claimed by no Galactic program" + [V13]="Untagged on a tagged side and tagged on an untagged side are not claimed; valid traffic is" + [V14]="C5: V01 to V05 and V11 pass with both VLANs on one parent" + [V15]="A third VLAN on a side's parent carries host traffic both ways with its own tag, unclaimed" + [V16]="Zero frames with the other side's tag, zero tagged frames at the tenant, zero cross-VPC packets" + [V17]="Each component reports per side: mode, VLAN ID, parent and logical interface" + [V18]="Each invalid configuration fails with an error naming side, component, interface and rule" + [V19]="C1 unset matches C1 named; tagged cells need explicit edge selection; compute auto-detects" + [V20]="C1 passes V01 to V08 with the same results as the pre-change baseline" + [V21]="VLAN ID change: changed side recovers within baseline + 1 s; other side loses nothing; nothing stale" + [V22]="Parent change: as V21" + [V23]="Untagged to tagged and back: as V21" + [V24]="VLAN netdevice recreated: as V21" + [V25]="Bond member failure and return: as V21" + [V26]="Route and neighbour changes on each side: as V21" + [V27]="Restart of each component: as V21" + [V28]="Rollback of V21 to V23: as V21" + [POST]="sjc passes its untagged checks after revert" +) + +# --- execution and recording ------------------------------------------------- + +ROW_CMDS=/dev/null + +row_start() { # ROW TITLE + ROW_CMDS="${OUT}/$1.cmds" + [ "${DRY_RUN}" = 1 ] || : >"${ROW_CMDS}" + echo "-- ${RUN_ID} $1: $2" +} + +log_cmd() { + local line + line=$(printf '%q ' "$@") + # Paths relative to deploy/containerlab, where every command is run from. + [ -n "${CLAB:-}" ] && line=${line//"${CLAB}/"/./} && line=${line//" ${CLAB} "/ . } + if [ "${DRY_RUN}" = 1 ]; then + echo " plan: ${line% }" + else + echo " run: ${line% }" + echo "${line% }" >>"${ROW_CMDS}" + echo "$(date -u +%FT%TZ) ${RUN_ID} ${line% }" >>"${OUT}/commands.log" + fi +} + +# x CMD...: run a lab step, or print it in a dry run. Returns its status. +x() { + log_cmd "$@" + [ "${DRY_RUN}" = 1 ] && return 0 + "$@" +} + +# xo FILE CMD...: as x, with the step's output in FILE. +xo() { + local f="$1" + shift + log_cmd "$@" + [ "${DRY_RUN}" = 1 ] && { echo " > ${f#"${TOP:-}"/}"; return 0; } + echo " > ${f#"${TOP:-}"/}" >>"${ROW_CMDS}" + "$@" >"${f}" 2>&1 +} + +# record ROW CASE STATUS OBSERVED [EVIDENCE]: one result line. In a dry run +# every status but SKIP becomes PLANNED, since nothing was observed. +record() { + local row="$1" case="$2" status="$3" obs="$4" ev="${5:-}" + if [ "${DRY_RUN}" = 1 ] && [ "${status}" != SKIP ] && [ "${status}" != N/A ]; then + status=PLANNED obs="not run (dry run)" + fi + obs=${obs//$'\t'/ } + obs=${obs//$'\n'/; } + printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "${RUN_ID}" "${CELL}" "${XMODE}" "${OFFLOAD}" \ + "${row}" "${case:--}" "${status}" "${EXPECTED[${row}]:-}" "${obs}" "${ev:--}" "${ROW_CMDS#"${TOP:-}"/}" >>"${RESULTS}" + echo " ${status} ${row}${case:+ (${case})}: ${obs}" +} + +skip() { record "$1" "$2" SKIP "$3"; } + +# --- lab reads ---------------------------------------------------------------- + +kc() { docker exec "${CP}" kubectl -n galactic-system "$@"; } + +# edge_gateway_ds names the edge node's own galactic-gateway DaemonSet. +edge_gateway_ds() { + if [ "${DRY_RUN}" = 1 ]; then + echo "galactic-gateway-${EDGE}" + else + kc get ds -o name | grep -E "galactic-gateway.*${EDGE}" | head -1 | cut -d/ -f2 + fi +} + +metrics() { # NODE PORT FILE + docker exec "$1" curl -s --max-time 4 "http://localhost:$2/metrics" | grep -E '^galactic_' >"$3" || true +} + +# metric_delta BEFORE AFTER PATTERN: per-series increases for matching series. +metric_delta() { + join -a2 -e 0 -o '0,1.2,2.2' <(grep -E "$3" "$1" | awk '{print $1, $2}' | sort) \ + <(grep -E "$3" "$2" | awk '{print $1, $2}' | sort) | awk '$3 != $2 {printf " %s %s -> %s\n", $1, $2, $3}' +} + +counters_before() { + [ "${DRY_RUN}" = 1 ] && return 0 + metrics "${EDGE}" "${GW_METRICS}" "${OUT}/$1-gw.before" + metrics "${EDGE}" "${NAT_METRICS}" "${OUT}/$1-nat.before" +} + +counters_after() { + [ "${DRY_RUN}" = 1 ] && return 0 + metrics "${EDGE}" "${GW_METRICS}" "${OUT}/$1-gw.after" + metrics "${EDGE}" "${NAT_METRICS}" "${OUT}/$1-nat.after" + { + echo "gateway counters that moved:" + metric_delta "${OUT}/$1-gw.before" "${OUT}/$1-gw.after" '^galactic_(edge|xdp|gateway)' + echo "nat counters that moved:" + metric_delta "${OUT}/$1-nat.before" "${OUT}/$1-nat.after" '^galactic_(nat|xdp)' + } | tee "${OUT}/$1-counters.txt" +} + +# --- captures and the wire observation rule ------------------------------------ + +cap_start() { # NAME + x env LAB="${LAB}" "${VT}" capture-start "${OUT}" "$1" + x env LAB="${LAB}" "${VT}" tenant-capture-start "${OUT}" "$1" +} + +cap_stop() { # NAME + x env LAB="${LAB}" TAG_A="${PUB_VID:-101}" TAG_B="${FAB_VID:-202}" "${VT}" capture-stop "${OUT}" "$1" + x env LAB="${LAB}" "${VT}" tenant-capture-stop "${OUT}" "$1" +} + +# wire NAME: check NAME's capture summaries against the wire observation +# rule and set WIRE to what was seen. Fails on any breach, on a side that +# carried no frames at all (no positive control), or on a missing summary. +wire() { + WIRE="not run (dry run)" + [ "${DRY_RUN}" = 1 ] && return 0 + local f="${OUT}/$1-tags.txt" t="${OUT}/$1-tenant.txt" + if [ ! -s "${f}" ]; then + WIRE="no capture summary" + return 1 + fi + WIRE=$(awk -v pt="${PUB_VID:+1}" -v ft="${FAB_VID:+1}" ' + { for (i = 4; i <= NF; i++) { split($i, kv, "="); v[i] = kv[2] } + role = $1; tot = v[4]; a = v[5]; b = v[6]; un = v[7]; oth = v[8] + cls = role; sub(/-.*/, "", cls); seen[cls] += tot + bad = "" + if (oth > 0) bad = bad " other-tag=" oth + if (cls == "public") { if (b > 0) bad = bad " fabric-tag=" b; if (pt && un > 0) bad = bad " untagged=" un; if (!pt && a > 0) bad = bad " public-tag-on-untagged=" a } + if (cls == "fabric") { if (a > 0) bad = bad " public-tag=" a; if (ft && un > 0) bad = bad " untagged=" un; if (!ft && b > 0) bad = bad " fabric-tag-on-untagged=" b } + if (cls == "trunk") { if (un > 0) bad = bad " untagged=" un } + if (bad != "") { printf "%s %s %s:%s; ", role, $2, $3, bad; breach = 1 } } + END { for (c in seen) if (seen[c] == 0) { printf "no frames on %s links; ", c; breach = 1 } + if (!breach) printf "rule holds"; exit breach }' "${f}") + local rc=$? + if [ -s "${t}" ]; then + local tagged + tagged=$(grep -Eo 'tagged=[0-9]+' "${t}" | cut -d= -f2) + if [ "${tagged:-1}" != 0 ]; then + WIRE="${WIRE}; tenant saw ${tagged:-unknown} tagged frames" + rc=1 + else + WIRE="${WIRE}; tenant untagged" + fi + else + WIRE="${WIRE}; no tenant capture" + rc=1 + fi + return "${rc}" +} + +# verdict OK...: PASS when every argument is 0. +verdict() { + local a + for a in "$@"; do [ "${a}" = 0 ] || { echo FAIL; return; }; done + echo PASS +} + +# --- rows ---------------------------------------------------------------------- + +row_XM() { + row_start XM "XDP attach mode" + local want=${XMODE} + [ "${want}" = auto ] && want=native + xo "${OUT}/XM.txt" "${SCRIPT_DIR}/verify-xdp-mode.sh" "${want}" + local rc=$? + record XM "" "$(verdict "${rc}")" "verify-xdp-mode ${want}: exit ${rc}" "XM.txt" +} + +row_NAA() { + row_start NAA "verify:nat-active-active" + xo "${OUT}/NAA.txt" task -d "${CLAB}" verify:nat-active-active + local rc=$? + local why="exit ${rc}" + [ "${DRY_RUN}" = 1 ] || why="${why}; $(grep -m1 -E 'want [0-9]+' "${OUT}/NAA.txt" || echo 'no route-count mismatch logged')" + record NAA "" "$(verdict "${rc}")" "${why}" "NAA.txt" +} + +row_V01() { # also V02 + row_start V01 "gateway ingress and DSR return" + counters_before V01 + cap_start V01 + xo "${OUT}/V01-ipv6.txt" env UPLINK_DEV="${EDGE}=${TR_DEV}" LAB="${LAB}" "${SCRIPT_DIR}/verify-gateway-ingress.sh" --node "${EDGE}" + local r6=$? + xo "${OUT}/V01-ipv4.txt" env UPLINK_DEV="${EDGE}=${TR_DEV}" LAB="${LAB}" "${SCRIPT_DIR}/verify-gateway-ingress-ipv4.sh" --node "${EDGE}" + local r4=$? + cap_stop V01 + counters_after V01 + wire V01 + local w=$? + record V01 "" "$(verdict "${r6}" "${r4}" "${w}")" "IPv6 VIP exit ${r6}, IPv4 VIP exit ${r4}; ${WIRE}" "V01-ipv6.txt V01-ipv4.txt V01-tags.txt V01-counters.txt" + record V02 "" "$(verdict "${r6}" "${r4}" "${w}")" "replies in V01's probes (exit ${r6}/${r4}); ${WIRE}" "V01-tags.txt" +} + +row_V03() { # also V04 + row_start V03 "NAT66 and NAT64 outbound and return" + counters_before V03 + cap_start V03 + xo "${OUT}/V03.txt" task -d "${CLAB}" verify:nat-datapath SENDER_SITE=sjc SHARD_NODE="${EDGE}" SHARD_SITE=sjc + local r=$? + cap_stop V03 + counters_after V03 + wire V03 + local w=$? + local n66="exit ${r}" n64="exit ${r}" + if [ "${DRY_RUN}" != 1 ]; then + n66="${n66}, $(grep -ciE 'nat66.*ok|ok.*nat66' "${OUT}/V03.txt") NAT66 ok lines" + n64="${n64}, $(grep -ciE 'nat64.*ok|ok.*nat64' "${OUT}/V03.txt") NAT64 ok lines" + fi + record V03 "" "$(verdict "${r}" "${w}")" "verify:nat-datapath ${n66}; ${WIRE}" "V03.txt V03-tags.txt V03-counters.txt" + record V04 "" "$(verdict "${r}" "${w}")" "verify:nat-datapath ${n64}; ${WIRE}" "V03.txt V03-tags.txt" +} + +row_V05() { + row_start V05 "tenant SRv6 between nodes" + cap_start V05 + xo "${OUT}/V05.txt" "${SCRIPT_DIR}/verify-ns20.sh" + local r=$? + cap_stop V05 + wire V05 + local w=$? + record V05 "" "$(verdict "${r}" "${w}")" "ns20 full mesh exit ${r}; ${WIRE}" "V05.txt V05-tags.txt V05-tenant.txt" +} + +row_V06() { + row_start V06 "control plane" + xo "${OUT}/V06-public-bgp.txt" docker exec "${TR}" vtysh -c 'show bgp summary json' + xo "${OUT}/V06-fabric-bgp.txt" docker exec "${CP}" sh -c \ + "kubectl -n galactic-system exec \$(kubectl -n galactic-system get pods -l app.kubernetes.io/name=fabric-router --field-selector spec.nodeName=${EDGE} -o name) -c frr -- vtysh -c 'show bgp summary json'" + xo "${OUT}/V06-neigh.txt" docker exec "${EDGE}" sh -c "ip neigh show dev ${PUB_L}; echo ---; ip neigh show dev ${FAB_L}" + xo "${OUT}/V06-node.txt" docker exec "${CP}" kubectl get node "${EDGE}" --no-headers + [ "${DRY_RUN}" = 1 ] && { record V06 "" PLANNED ""; return; } + est() { # FILE PEER + python3 -I -c 'import json,sys; d=json.load(open(sys.argv[1])); p=sys.argv[2] +print(any(af.get("peers",{}).get(p,{}).get("state")=="Established" for af in d.values() if isinstance(af,dict)))' "$1" "$2" 2>/dev/null + } + local pub=1 fab=1 nd node + if [ "$(est "${OUT}/V06-public-bgp.txt" 2001:db8:1:21::2)" = True ] && [ "$(est "${OUT}/V06-public-bgp.txt" 10.1.21.2)" = True ]; then pub=0; fi + if [ "$(est "${OUT}/V06-fabric-bgp.txt" 2001:db8:1:20::2)" = True ] && [ "$(est "${OUT}/V06-fabric-bgp.txt" 10.1.20.2)" = True ]; then fab=0; fi + nd=$(awk '/^---/{s=1; next} /REACHABLE|STALE|DELAY|PERMANENT/{ok[s]=1} END{exit !(ok[0] && ok[1])}' "${OUT}/V06-neigh.txt"; echo $?) + node=$(grep -qw Ready "${OUT}/V06-node.txt"; echo $?) + record V06 "" "$(verdict "${pub}" "${fab}" "${nd}" "${node}")" \ + "public BGP $([ "${pub}" = 0 ] && echo up || echo down), fabric BGP $([ "${fab}" = 0 ] && echo up || echo down), neighbours on ${PUB_L} and ${FAB_L} $([ "${nd}" = 0 ] && echo resolved || echo missing), node $([ "${node}" = 0 ] && echo Ready || echo 'not Ready')" \ + "V06-public-bgp.txt V06-fabric-bgp.txt V06-neigh.txt" +} + +row_V07() { + row_start V07 "cold and warm neighbours" + counters_before V07 + x docker exec "${EDGE}" ip neigh flush dev "${PUB_L}" + x docker exec "${EDGE}" ip neigh flush dev "${FAB_L}" + xo "${OUT}/V07-gw.txt" env UPLINK_DEV="${EDGE}=${TR_DEV}" LAB="${LAB}" "${SCRIPT_DIR}/verify-gateway-ingress.sh" --node "${EDGE}" + local rg=$? + x docker exec "${EDGE}" ip neigh flush dev "${PUB_L}" + x docker exec "${EDGE}" ip neigh flush dev "${FAB_L}" + xo "${OUT}/V07-nat.txt" task -d "${CLAB}" verify:nat-datapath SENDER_SITE=sjc SHARD_NODE="${EDGE}" SHARD_SITE=sjc + local rn=$? + counters_after V07 + local fb=1 fbs="not read" + if [ "${DRY_RUN}" != 1 ]; then + fbs=$(grep -E 'neigh_fallbacks' "${OUT}/V07-counters.txt" | tr -s ' ' | tr '\n' ';') + [ -n "${fbs}" ] && fb=0 + fi + record V07 "" "$(verdict "${rg}" "${rn}" "${fb}")" "gateway exit ${rg}, NAT exit ${rn}; neigh_fallbacks: ${fbs:-did not rise}" "V07-gw.txt V07-nat.txt V07-counters.txt" +} + +row_V08() { + row_start V08 "MTU, TCP, UDP and ICMP errors" + cap_start V08 + xo "${OUT}/V08-pmtu.txt" "${SCRIPT_DIR}/verify-pmtu.sh" + local rp=$? + xo "${OUT}/V08-mss.txt" "${SCRIPT_DIR}/verify-mss-clamp.sh" + local rm=$? + cap_stop V08 + wire V08 + local w=$? + record V08 tenant-and-nat "$(verdict "${rp}" "${rm}" "${w}")" "verify-pmtu exit ${rp}, verify-mss-clamp exit ${rm}; ${WIRE}" "V08-pmtu.txt V08-mss.txt V08-tags.txt" + skip V08 gateway "full-size and one-byte-over probes through a VIP are not automated; verify-pmtu covers the CNI and NAT paths only" +} + +# perf_of FILE PATH DIR METRIC prints one value from a perf.tsv. +perf_of() { awk -F'\t' -v p="$2" -v d="$3" -v m="$4" '$1 == p && $2 == d && $3 == m {print $4}' "$1" 2>/dev/null; } + +row_V09() { + row_start V09 "throughput and latency" + xo "${OUT}/V09.txt" env LAB="${LAB}" "${SCRIPT_DIR}/vlan-transport-perf.sh" "${OUT}" + skip V09 gateway "no iperf3 backend behind a VIP; P1/P3 throughput is not measured" + [ "${DRY_RUN}" = 1 ] && { record V09 tenant-and-nat PLANNED ""; return; } + local base="${BASE_DIR}/perf.tsv" + if [ "${IS_BASE}" = 1 ]; then + record V09 tenant-and-nat BASELINE "$(tr '\t\n' ' ;' <"${OUT}/perf.tsv")" "perf.tsv" + return + fi + if [ ! -s "${base}" ]; then + skip V09 tenant-and-nat "no untagged baseline for ${XMODE}/offload ${OFFLOAD} (run ${BASE_CELL} first)" + return + fi + local path dir v b obs="" bad=0 + for path in tenant nat; do + for dir in out in; do + v=$(perf_of "${OUT}/perf.tsv" "${path}" "${dir}" throughput_mbps) + b=$(perf_of "${base}" "${path}" "${dir}" throughput_mbps) + obs="${obs}${path} ${dir} ${v:-?}/${b:-?} Mb/s; " + awk -v v="${v}" -v b="${b}" 'BEGIN{exit !(v+0 > 0 && b+0 > 0 && v >= 0.9 * b)}' || bad=1 + done + v=$(perf_of "${OUT}/perf.tsv" "${path}" both p99_ms) + b=$(perf_of "${base}" "${path}" both p99_ms) + obs="${obs}${path} p99 ${v:-?}/${b:-?} ms; " + awk -v v="${v}" -v b="${b}" 'BEGIN{exit !(v+0 > 0 && b+0 > 0 && v <= 1.1 * b)}' || bad=1 + done + record V09 tenant-and-nat "$(verdict "${bad}")" "this/baseline: ${obs}" "perf.tsv ${base#"${TOP}"/}" +} + +row_V10() { + row_start V10 "same-node gateway delivery (dfw-worker3)" + if [ "${PUB_KIND}" = shared ] || [ "${CELL_BOND_MODE}" != 802.3ad ]; then + skip V10 "" "the dfw-worker3 variant builds neither the shared parent nor active-backup bonds; ${BASE_CELL} has parent ${PUB_KIND}, bonds ${CELL_BOND_MODE}" + return + fi + local plan dev + plan=$(env VT_SITE=dfw-worker3 "${VT_ENV[@]}" "${VT}" plan "${BASE_CELL}" "${SELECT}") + dev=$(awk '/PUB_PEER:/ {print $4; exit}' <<<"${plan}" | tr -d ,) + x env VT_SITE=dfw-worker3 LAB="${LAB}" "${VT_ENV[@]}" "${VT}" apply "${BASE_CELL}" "${SELECT}" + xo "${OUT}/V10.txt" env EDGE_CONFORMANCE_UPLINK_DEV="dfw-worker3=${dev}" task -d "${CLAB}" verify:edge-listener + local r=$? + x env VT_SITE=dfw-worker3 LAB="${LAB}" "${VT}" revert + record V10 "" "$(verdict "${r}")" "verify:edge-listener through tr1 ${dev}: exit ${r}" "V10.txt" +} + +row_V11() { # also V12, V13 + row_start V11 "isolation by injection on the public side" + local -a inj=() + [ "${PUB_KIND}" = shared ] && inj=(INJECT_NODE="${SW}" INJECT_DEV=e1 INJECT_BOND=bondsw) + xo "${OUT}/V11.txt" env LAB="${LAB}" FAB_VID="${FAB_VID:-202}" "${inj[@]}" "${SCRIPT_DIR}/vlan-transport-inject.sh" "${OUT}" "${PUB_L}" "${PUB_VID}" + skip V11 fabric-sid-and-shard "injection drives the public VIP only; wrong-ID shard and SID traffic is not sent" + if [ "${DRY_RUN}" = 1 ]; then + record V11 public-vip PLANNED "" + record V12 public-vip PLANNED "" + record V13 public-vip PLANNED "" + return + fi + # claimed CASE prints the gateway's claim count for one injection case. + claimed() { awk -v c="case $1:" 'index($0, c) == 1 {sub(/.*\+/, ""); print; exit}' "${OUT}/V11.txt"; } + local pv=${PUB_VID:-101} fv=${FAB_VID:-202} other + other=$((${PUB_VID:-0} == 999 ? 998 : 999)) + local valid wrong=() malformed=(in-frame\ prio "in-frame qq:${pv}:5" "in-frame ad:300:${pv}" "in-frame trunc:${pv}") cross=() + if [ -n "${PUB_VID}" ]; then + valid=("in-frame q:${pv}" "kernel q:${pv}") + cross=("in-frame untagged") + else + valid=("in-frame untagged") + cross=("in-frame q:${pv}" "kernel q:${pv}") + fi + wrong=("in-frame q:${other}" "in-frame q:${fv}" "kernel q:${other}" "kernel q:${fv}") + # none LABEL CASE...: 0 when every case was claimed zero times. + local c n obs bad + check() { # ROW WANT CASE... + local row="$1" want="$2" + shift 2 + obs="" bad=0 + for c in "$@"; do + n=$(claimed "${c}") + obs="${obs}${c} +${n:-?}; " + if [ "${want}" = none ]; then [ "${n:-x}" = 0 ] || bad=1; else [ "${n:-0}" -gt 0 ] 2>/dev/null || bad=1; fi + done + } + check V11 some "${valid[@]}" + local ctl_bad=${bad} ctl_obs=${obs} + check V11 none "${wrong[@]}" + record V11 public-vip "$(verdict "${bad}" "${ctl_bad}")" "positive control ${ctl_obs}wrong IDs ${obs}" "V11.txt inject.txt" + check V12 none "${malformed[@]}" + record V12 public-vip "$(verdict "${bad}" "${ctl_bad}")" "${obs}" "V11.txt" + check V13 none "${cross[@]}" + record V13 public-vip "$(verdict "${bad}" "${ctl_bad}")" "${obs}valid: ${ctl_obs}" "V11.txt" +} + +row_V14() { + row_start V14 "two VLANs on one parent" + if [ "${PUB_KIND}" != shared ]; then + return 0 + fi + [ "${DRY_RUN}" = 1 ] && { record V14 "" PLANNED ""; return; } + local s st bad=0 obs="" + for s in V01 V02 V03 V04 V05 V11; do + st=$(awk -F'\t' -v r="${RUN_ID}" -v w="${s}" '$1 == r && $5 == w && $6 != "fabric-sid-and-shard" {print $7}' "${RESULTS}" | sort -u | tr '\n' ' ') + obs="${obs}${s} ${st:-not run}; " + [ "${st}" = "PASS " ] || bad=1 + done + record V14 "" "$(verdict "${bad}")" "${obs}" "results of ${RUN_ID}" +} + +# third_vlan SIDE: V15 on one side's parent. +third_vlan() { + local side="$1" a_node a_par b_node b_par a_addr=2001:db8:ffff:15::1 b_addr=2001:db8:ffff:15::2 + if [ "${side}" = public ]; then + a_node=${TR} a_par=${TR_PAR} b_node=${EDGE} b_par=${PUB_P} + else + a_node=${COMPUTE} a_par=${CPT_P} b_node=${EDGE} b_par=${FAB_P} + fi + local dev_a="${a_par}.${THIRD_VID}" dev_b="${b_par}.${THIRD_VID}" + counters_before "V15-${side}" + x docker exec "${a_node}" ip link add link "${a_par}" name "${dev_a}" type vlan id "${THIRD_VID}" + x docker exec "${b_node}" ip link add link "${b_par}" name "${dev_b}" type vlan id "${THIRD_VID}" + x docker exec "${a_node}" sh -c "ip link set ${dev_a} up && ip -6 addr add ${a_addr}/64 dev ${dev_a} nodad" + x docker exec "${b_node}" sh -c "ip link set ${dev_b} up && ip -6 addr add ${b_addr}/64 dev ${dev_b} nodad" + x env LAB="${LAB}" "${VT}" capture-start "${OUT}" "V15-${side}" + xo "${OUT}/V15-${side}-a.txt" docker exec "${a_node}" ping -6 -c 20 -i 0.2 -W 1 "${b_addr}" + local ra=$? + xo "${OUT}/V15-${side}-b.txt" docker exec "${b_node}" ping -6 -c 20 -i 0.2 -W 1 "${a_addr}" + local rb=$? + x env LAB="${LAB}" TAG_A="${THIRD_VID}" TAG_B="${PUB_VID:-${FAB_VID}}" "${VT}" capture-stop "${OUT}" "V15-${side}" + counters_after "V15-${side}" + x docker exec "${a_node}" ip link del "${dev_a}" + x docker exec "${b_node}" ip link del "${dev_b}" + local tag=1 tagobs="not read" + if [ "${DRY_RUN}" != 1 ]; then + tagobs=$(awk -v s="${side}" -v t="vlan${THIRD_VID}=" 'index($1, s) == 1 {for (i = 1; i <= NF; i++) if (index($i, t) == 1) {split($i, kv, "="); n += kv[2]}} END {print n + 0}' "${OUT}/V15-${side}-tags.txt") + [ "${tagobs}" -gt 0 ] 2>/dev/null && tag=0 + fi + record V15 "${side}" "$(verdict "${ra}" "${rb}" "${tag}")" \ + "pings ${a_node#clab-"${LAB}"-}->${b_node} exit ${ra}, back exit ${rb}; ${tagobs} frames tagged ${THIRD_VID}; Galactic counters in V15-${side}-counters.txt" \ + "V15-${side}-a.txt V15-${side}-b.txt V15-${side}-tags.txt V15-${side}-counters.txt" +} + +row_V15() { + row_start V15 "unrelated trunk traffic" + if [ -n "${PUB_VID}" ]; then third_vlan public; else record V15 public N/A "untagged side: a VLAN on its parent is contract Q8, not supported"; fi + if [ -z "${FAB_VID}" ]; then + record V15 fabric N/A "untagged side: a VLAN on its parent is contract Q8, not supported" + elif [ "${FAB_KIND}" = shared ]; then + skip V15 fabric "C5's switch trunks the extra VLAN toward tr2 only" + else + third_vlan fabric + fi +} + +row_V16() { + row_start V16 "no leakage, no cross-tenant delivery" + skip V16 cross-vpc "the lab has no two VPCs with identical prefixes on sjc; not automated" + [ "${DRY_RUN}" = 1 ] && { record V16 wire PLANNED ""; return; } + local f bad=0 obs="" n=0 + for f in "${OUT}"/V*-tags.txt; do + [ -e "${f}" ] || continue + case "${f}" in *V15-*) continue ;; esac + n=$((n + 1)) + if ! wire "$(basename "${f}" -tags.txt)"; then + bad=1 + obs="${obs}$(basename "${f}" -tags.txt): ${WIRE}; " + fi + done + [ "${n}" -gt 0 ] || { skip V16 wire "no captures in this run"; return; } + record V16 wire "$(verdict "${bad}")" "${n} captures; ${obs:-no breach}" "*-tags.txt *-tenant.txt" +} + +# side_info NODE PORT: the galactic_transport_side_info series a component +# exports, one "side interface mode vlan parent" line each. +side_info() { + docker exec "$1" curl -s --max-time 4 "http://localhost:$2/metrics" \ + | sed -n 's/^galactic_transport_side_info{\(.*\)} 1$/\1/p' \ + | awk -F, '{for (i = 1; i <= NF; i++) {split($i, kv, "="); gsub(/"/, "", kv[2]); v[kv[1]] = kv[2]} + print v["side"], v["interface"], v["mode"], (v["vlan_id"] == "" ? "-" : v["vlan_id"]), v["parent"]}' +} + +row_V17() { + row_start V17 "derived mode is visible" + local comp node port want_pub want_fab + want_pub="public ${PUB_L} $([ -n "${PUB_VID}" ] && echo tagged || echo untagged) ${PUB_VID:--} ${PUB_P}" + want_fab="fabric ${FAB_L} $([ -n "${FAB_VID}" ] && echo tagged || echo untagged) ${FAB_VID:--} ${FAB_P}" + for comp in "galactic-gateway ${EDGE} ${GW_METRICS}" "galactic-nat ${EDGE} ${NAT_METRICS}" "galactic-cni ${EDGE} ${CNI_METRICS}" "galactic-cni ${COMPUTE} ${CNI_METRICS}"; do + read -r comp node port <<<"${comp}" + log_cmd docker exec "${node}" curl -s "http://localhost:${port}/metrics" + [ "${DRY_RUN}" = 1 ] && { record V17 "${comp}@${node}" PLANNED ""; continue; } + local got + got=$(side_info "${node}" "${port}") + echo "${got}" >"${OUT}/V17-${comp}-${node}.txt" + local want=("${want_pub}" "${want_fab}") w bad=0 miss="" + if [ "${node}" = "${COMPUTE}" ]; then + want=("fabric ${CPT_L} $([ -n "${FAB_VID}" ] && echo tagged || echo untagged) ${FAB_VID:--} ${CPT_P}") + fi + for w in "${want[@]}"; do + grep -qxF "${w}" <<<"${got}" || { bad=1; miss="${miss}missing '${w}'; "; } + done + record V17 "${comp}@${node}" "$(verdict "${bad}")" "${miss:-reports} ${got//$'\n'/ | }" "V17-${comp}-${node}.txt" + done +} + +# invalid CASE RULE PUBLIC INTERNAL SETUP TEARDOWN: point the edge's gateway +# and NAT at an invalid configuration, expect both to refuse it with RULE, +# then restore the cell. +invalid() { + local case="$1" rule="$2" pub="$3" int="$4" setup="$5" teardown="$6" gw + [ -n "${setup}" ] && x docker exec "${EDGE}" sh -c "${setup}" + gw=$(edge_gateway_ds) + x docker exec "${CP}" kubectl -n galactic-system set env "ds/${gw}" -c galactic-gateway \ + "GALACTIC_GATEWAY_PUBLIC_INTERFACE=${pub}" "GALACTIC_GATEWAY_INTERNAL_INTERFACES=${int}" + x docker exec "${CP}" kubectl -n galactic-system set env ds/galactic-nat -c galactic-nat "GALACTIC_NAT_UPLINK_INTERFACES=${pub},${int}" + x sleep "${V18_WAIT:-60}" + xo "${OUT}/V18-${case}.txt" docker exec "${CP}" sh -c \ + "for l in app.kubernetes.io/name=galactic-gateway app.kubernetes.io/name=galactic-nat; do + for p in \$(kubectl -n galactic-system get pods -l \$l --field-selector spec.nodeName=${EDGE} -o name); do + echo \"=== \$p\"; kubectl -n galactic-system get \$p -o jsonpath='{range .status.containerStatuses[*]}{.name} ready={.ready} restarts={.restartCount}{\"\\n\"}{end}'; + kubectl -n galactic-system logs \$p --all-containers --tail=200 2>&1 | grep -iE 'transport|${rule}' | tail -5; + kubectl -n galactic-system logs \$p --all-containers --previous --tail=200 2>/dev/null | grep -iE 'transport|${rule}' | tail -5; + done; done" + [ -n "${teardown}" ] && x docker exec "${EDGE}" sh -c "${teardown}" + x env LAB="${LAB}" "${VT_ENV[@]}" "${VT}" apply "${BASE_CELL}" "${SELECT}" + [ "${DRY_RUN}" = 1 ] && { record V18 "${case}" PLANNED ""; return; } + local pods refused named + pods=$(grep -c '^=== ' "${OUT}/V18-${case}.txt") + refused=$(grep -c 'ready=false' "${OUT}/V18-${case}.txt") + named=$(grep -ciE "${rule}" "${OUT}/V18-${case}.txt") + local ok=1 + [ "${pods}" -ge 2 ] && [ "${refused}" -ge 2 ] && [ "${named}" -ge 2 ] && ok=0 + record V18 "${case}" "$(verdict "${ok}")" "${refused} of ${pods} gateway/NAT pods not ready; ${named} log lines name ${rule}" "V18-${case}.txt" +} + +row_V18() { + row_start V18 "invalid configuration is rejected" + local pp=${PUB_P} + invalid not-found interface_not_found vtnone0 "${FAB_L}" "" "" + invalid vlan-id-0 vlan_id_out_of_range "${pp}.0" "${FAB_L}" \ + "ip link add link ${pp} name ${pp}.0 type vlan id 0 && ip link set ${pp}.0 up" "ip link del ${pp}.0" + invalid 802.1ad vlan_protocol_unsupported vtad.101 "${FAB_L}" \ + "ip link add link ${pp} name vtad.101 type vlan protocol 802.1ad id 101 && ip link set vtad.101 up" "ip link del vtad.101" + invalid stacked stacked_vlan vtst.5 "${FAB_L}" \ + "ip link add link ${pp} name vtst type vlan id 3001 && ip link add link vtst name vtst.5 type vlan id 5 && ip link set vtst up && ip link set vtst.5 up" \ + "ip link del vtst.5; ip link del vtst" + invalid parent-type parent_type_unsupported vtdum0.7 "${FAB_L}" \ + "ip link add vtdum0 type dummy && ip link add link vtdum0 name vtdum0.7 type vlan id 7 && ip link set vtdum0 up && ip link set vtdum0.7 up" \ + "ip link del vtdum0.7; ip link del vtdum0" + invalid sides-overlap sides_overlap "${PUB_L}" "${PUB_L}" "" "" + skip V18 parent-missing "the kernel cannot hold a VLAN netdevice without its parent; covered by unit tests" + skip V18 components-disagree "no rule name to match; the harness does not drive a disagreement between components" + skip V18 galactic-cni "the invalid cases are driven on the gateway and NAT only" +} + +row_V19() { + row_start V19 "auto-detection and explicit selection" + local gw + gw=$(edge_gateway_ds) + if [ "${DRY_RUN}" != 1 ]; then + side_info "${EDGE}" "${GW_METRICS}" >"${OUT}/V19-named.txt" + fi + log_cmd docker exec "${EDGE}" curl -s "http://localhost:${GW_METRICS}/metrics" + x docker exec "${CP}" kubectl -n galactic-system set env "ds/${gw}" -c galactic-gateway \ + GALACTIC_GATEWAY_PUBLIC_INTERFACE- GALACTIC_GATEWAY_INTERNAL_INTERFACES- + x docker exec "${CP}" kubectl -n galactic-system rollout status "ds/${gw}" --timeout=120s + x sleep 20 + xo "${OUT}/V19-unset.txt" docker exec "${CP}" sh -c \ + "kubectl -n galactic-system get pods -l app.kubernetes.io/name=galactic-gateway --field-selector spec.nodeName=${EDGE} -o wide; + kubectl -n galactic-system logs -l app.kubernetes.io/name=galactic-gateway --all-containers --tail=100 2>&1 | grep -iE 'transport|interface' | tail -10" + [ "${DRY_RUN}" = 1 ] || side_info "${EDGE}" "${GW_METRICS}" >"${OUT}/V19-auto.txt" + x env LAB="${LAB}" "${VT_ENV[@]}" "${VT}" apply "${BASE_CELL}" "${SELECT}" + [ "${DRY_RUN}" = 1 ] && { record V19 edge PLANNED ""; return; } + if [ -z "${PUB_VID}${FAB_VID}" ]; then + local same=1 + [ -s "${OUT}/V19-named.txt" ] && cmp -s "${OUT}/V19-named.txt" "${OUT}/V19-auto.txt" && same=0 + record V19 edge-untagged "$(verdict "${same}")" "named: $(tr '\n' '|' <"${OUT}/V19-named.txt"); unset: $(tr '\n' '|' <"${OUT}/V19-auto.txt")" "V19-named.txt V19-auto.txt" + else + # Refused: the edge's gateway pod is not fully ready, or not Running. + local refused + refused=$(awk '$1 ~ /^galactic-gateway/ {split($2, r, "/"); if (r[1] != r[2] || $3 != "Running") f = 1} END {print f ? 0 : 1}' "${OUT}/V19-unset.txt") + record V19 edge-tagged "$(verdict "${refused}")" "gateway with no selection on a tagged edge: $(grep -m1 galactic-gateway "${OUT}/V19-unset.txt" | tr -s ' ')" "V19-unset.txt" + fi + skip V19 compute-auto "auto-detection of the compute node's fabric side needs galactic-cni's side report on the compute node (V17 galactic-cni@${COMPUTE}); not driven separately" +} + +row_V20() { + row_start V20 "existing configuration preserved" + if [ "${CELL}" != C1 ]; then + return 0 + fi + if [ -z "${PRE_CHANGE}" ]; then + skip V20 "" "no pre-change baseline: pass --baseline with a run of this harness against the pre-epic revision" + return + fi + [ "${DRY_RUN}" = 1 ] && { record V20 "" PLANNED ""; return; } + local pre="${PRE_CHANGE}/results.tsv" diffs + diffs=$(join -t$'\t' -a1 -a2 -e missing -o '0,1.2,2.2' \ + <(awk -F'\t' -v r="${RUN_ID}" '$1 == r && $5 ~ /^V0[1-8]$/ {print $5 "/" $6 "\t" $7}' "${RESULTS}" | sort) \ + <(awk -F'\t' -v r="${RUN_ID}" '$1 == r && $5 ~ /^V0[1-8]$/ {print $5 "/" $6 "\t" $7}' "${pre}" | sort) \ + | awk -F'\t' '$2 != $3 {printf "%s now %s, before %s; ", $1, $2, $3}') + record V20 "" "$(verdict "$([ -z "${diffs}" ]; echo $?)")" "${diffs:-V01 to V08 match the pre-change run}" "${pre}" +} + +# --- reconfiguration and recovery (V21 to V28) --------------------------------- + +# events prints "ROW SIDE BASELINE-EVENT EVENT" for this cell: what to run +# and which untagged event it is compared with. +events() { + local s v alt kind other + for s in public fabric; do + if [ "${s}" = public ]; then v=${PUB_VID} kind=${PUB_KIND} alt=PUB; else v=${FAB_VID} kind=${FAB_KIND} alt=FAB; fi + if [ "${IS_BASE}" = 1 ]; then + [ "${kind}" = bond ] && echo "V22 ${s} - apply:${BASE_CELL}:${SELECT}:${alt}_PARENT=nic" + [ "${kind}" = bond ] && echo "V22 ${s} - apply:${BASE_CELL}:${SELECT}:${alt}_PARENT=bond" + elif [ -n "${v}" ]; then + other=$((v == 3999 ? 3998 : 3999)) + echo "V21 ${s} restart:all apply:${BASE_CELL}:${SELECT}:${VT_VARS}${alt}_VID=${other}" + echo "V28 ${s} restart:all apply:${BASE_CELL}:${SELECT}:${VT_VARS}" + if [ "${kind}" = bond ]; then + echo "V22 ${s} apply:${BASE_REF}:${SELECT}:${alt}_PARENT=nic apply:${BASE_CELL}:${SELECT}:${VT_VARS}${alt}_PARENT=nic" + echo "V28 ${s} apply:${BASE_REF}:${SELECT}:${alt}_PARENT=bond apply:${BASE_CELL}:${SELECT}:${VT_VARS}" + elif [ "${kind}" = nic ]; then + echo "V22 ${s} apply:${BASE_REF}:${SELECT}:${alt}_PARENT=nic apply:${BASE_CELL}:${SELECT}:${VT_VARS}${alt}_PARENT=bond" + echo "V28 ${s} apply:${BASE_REF}:${SELECT}:${alt}_PARENT=bond apply:${BASE_CELL}:${SELECT}:${VT_VARS}" + fi + echo "V23 ${s} restart:all apply:${BASE_CELL}:${SELECT}:${VT_VARS}${alt}_VID=" + echo "V28 ${s} restart:all apply:${BASE_CELL}:${SELECT}:${VT_VARS}" + echo "V24 ${s} restart:all recreate:${s}" + fi + # A plain NIC parent has no bond member to lose. + [ "${kind}" != nic ] && echo "V25 ${s} member:${s} member:${s}" + echo "V26 ${s} neigh:${s} neigh:${s}" + echo "V26 ${s} route:${s} route:${s}" + done + [ "${IS_BASE}" = 1 ] && echo "V23 - - restart:all" + local c + for c in galactic-cni galactic-gateway galactic-nat; do + echo "V27 - restart:${c} restart:${c}" + done +} + +# gap_of FILE NAME PROBE prints a probe's longest gap for one event by its +# name; base_gap FILE EVENT PROBE, for the first event spelled EVENT. +gap_of() { awk -F'\t' -v e="$2" -v p="$3" '$1 == e && $2 == p {print $5; exit}' "$1" 2>/dev/null; } +base_gap() { awk -F'\t' -v e="$2" -v p="$3" '$6 == e && $2 == p {print $5; exit}' "$1" 2>/dev/null; } + +row_V21() { # V21 to V28 + row_start V21 "reconfiguration and recovery" + local row side base event n=0 + local -a evs=() + while read -r row side base event; do + row_wanted "${row}" || continue + evs+=("${event}") + done < <(events) + [ "${#evs[@]}" -gt 0 ] || return 0 + xo "${OUT}/V21.txt" env LAB="${LAB}" "${SCRIPT_DIR}/vlan-transport-interrupt.sh" "${OUT}/recovery" "${evs[@]}" + # Back to the cell as applied, whatever the last event left. + x env LAB="${LAB}" "${VT_ENV[@]}" "${VT}" apply "${BASE_CELL}" "${SELECT}" + local tsv="${OUT}/recovery/interrupt.tsv" btsv="${BASE_DIR}/recovery/interrupt.tsv" + while read -r row side base event; do + row_wanted "${row}" || continue + n=$((n + 1)) + local name case + name=$(printf '%02d-%s' "${n}" "$(tr ':=,' '___' <<<"${event}")") + case="${event}" + if [ "${DRY_RUN}" = 1 ]; then + record "${row}" "${case}" PLANNED "" + continue + fi + local pub fab ten stale_txt + pub=$(gap_of "${tsv}" "${name}" public) + fab=$(gap_of "${tsv}" "${name}" fabric) + ten=$(gap_of "${tsv}" "${name}" tenant) + stale_txt=$(grep -h '^stale:' "${OUT}/recovery/${name}.stale" 2>/dev/null | tr '\n' ' ') + local obs="gaps: public ${pub:-?} ms, fabric ${fab:-?} ms, tenant ${ten:-?} ms; ${stale_txt:-stale: not checked}" + if [ "${IS_BASE}" = 1 ]; then + record "${row}" "${case}" BASELINE "${obs}" "recovery/interrupt.tsv recovery/${name}.*" + continue + fi + local bad=0 changed other b + if [ ! -s "${btsv}" ] || [ -z "$(base_gap "${btsv}" "${base}" tenant)" ]; then + record "${row}" "${case}" SKIP "no untagged baseline for ${base} in ${BASE_CELL} (${XMODE}, offload ${OFFLOAD}); ${obs}" + continue + fi + case "${side}" in public) changed=${pub} other=${fab} ;; fabric) changed=${fab} other=${pub} ;; *) changed=${ten} other=0 ;; esac + b=$(base_gap "${btsv}" "${base}" "$([ "${side}" = - ] && echo tenant || echo "${side}")") + [ "${changed:-x}" -le $((b + 1000)) ] 2>/dev/null || bad=1 + [ "${other:-x}" = 0 ] || bad=1 + [ "${stale_txt}" = "stale: none " ] || bad=1 + record "${row}" "${case}" "$(verdict "${bad}")" "${obs}; baseline ${base} ${b} ms" "recovery/interrupt.tsv recovery/${name}.*" + done < <(events) +} + +row_POST() { + row_start POST "sjc back to untagged after revert" + local r1 r2 r3 r4 r5 + xo "${OUT}/POST-gw6.txt" env LAB="${LAB}" "${SCRIPT_DIR}/verify-gateway-ingress.sh" --node "${EDGE}" + r1=$? + xo "${OUT}/POST-gw4.txt" env LAB="${LAB}" "${SCRIPT_DIR}/verify-gateway-ingress-ipv4.sh" --node "${EDGE}" + r2=$? + xo "${OUT}/POST-nat.txt" task -d "${CLAB}" verify:nat-datapath SENDER_SITE=sjc SHARD_NODE="${EDGE}" SHARD_SITE=sjc + r3=$? + xo "${OUT}/POST-ns20.txt" "${SCRIPT_DIR}/verify-ns20.sh" + r4=$? + xo "${OUT}/POST-bonds.txt" task -d "${CLAB}" verify:bonds + r5=$? + record POST "" "$(verdict "${r1}" "${r2}" "${r3}" "${r4}" "${r5}")" \ + "gateway IPv6 ${r1}, IPv4 ${r2}, NAT ${r3}, ns20 ${r4}, bonds ${r5} (exit codes)" "POST-*.txt" +} diff --git a/deploy/containerlab/scripts/vlan-transport-switch.sh b/deploy/containerlab/scripts/vlan-transport-switch.sh new file mode 100755 index 00000000..6ccdbda0 --- /dev/null +++ b/deploy/containerlab/scripts/vlan-transport-switch.sh @@ -0,0 +1,143 @@ +#!/bin/bash +# vlan-transport-switch.sh: the bridge node behind cell C5 (two VLANs on one +# parent) of the tagged transport variant (scripts/vlan-transport.sh). +# +# The lab's links are point-to-point, so no one parent reaches both tr2 and +# sjc-worker. `up` adds a node, clab--vtsw, holding a VLAN-aware Linux +# bridge, and four new veths: +# +# sjc-worker2 vtsw1, vtsw2 <-> vtsw e1, e2 one bond, bondsw, on each end: +# the edge's shared parent, +# a trunk of PUB_VID and FAB_VID +# tr2 vtsw0 <-> vtsw tr PUB_VID only +# sjc-worker vtsw0 <-> vtsw cpt FAB_VID only +# +# EXTRA_VIDS (space-separated) are also trunked between the edge and tr2, for +# the unrelated-trunk row V15. The switch's edge-facing members carry the +# lab's pass-through XDP program, as every veth peer of a Galactic XDP +# transmit must (Taskfile deploy:lab-xdp-passthrough). Nothing outside the new +# node and its veths changes; vlan-transport.sh moves the addresses. +# +# Usage: +# vlan-transport-switch.sh plan PUB_VID FAB_VID print what up would build +# vlan-transport-switch.sh up PUB_VID FAB_VID build it (idempotent) +# vlan-transport-switch.sh down remove the node and its veths +# +# BOND_MODE (802.3ad by default, or active-backup) sets both bondsw ends. +# Creating veths uses `containerlab tools veth create`, which needs +# passwordless sudo, as scripts/restart-node.sh does. +set -euo pipefail + +SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) +LAB=${LAB:-gvpc} +SW=clab-${LAB}-vtsw +TR=clab-${LAB}-tr2 +EDGE=sjc-worker2 +COMPUTE=sjc-worker +IMAGE=${VT_SWITCH_IMAGE:-kindest/node:galactic} +XDP_OBJ="${SCRIPT_DIR}/../node_files/common/xdp-passthrough.o" +BOND_MODE=${BOND_MODE:-802.3ad} + +# node interface switch-port +LINKS=( + "${EDGE} vtsw1 e1" + "${EDGE} vtsw2 e2" + "${TR} vtsw0 tr" + "${COMPUTE} vtsw0 cpt" +) + +on() { local n="$1"; shift; echo "change: ${n#clab-"${LAB}"-}: $*"; docker exec "${n}" "$@"; } +q() { docker exec "$@"; } + +vid_ok() { + if ! [[ "$1" =~ ^[0-9]+$ ]] || [ "$1" -lt 1 ] || [ "$1" -gt 4094 ]; then + echo "vlan-transport-switch: VLAN ID '$1' is outside 1 to 4094" >&2 + exit 1 + fi +} + +# mkbond NODE: build bondsw from MEMBERS in BOND_MODE with the lab's bond +# helper, baked into the Kind node image the switch also runs. +mkbond() { + local n="$1" a="$2" b="$3" + if ! q "${n}" ip link show dev bondsw >/dev/null 2>&1 && [ "${BOND_MODE}" != 802.3ad ]; then + on "${n}" ip link add bondsw type bond mode "${BOND_MODE}" miimon 100 + fi + on "${n}" /galactic/scripts/mkbond.sh bondsw "${a}" "${b}" +} + +cmd_plan() { + local pv="${1:?public VID}" fv="${2:?fabric VID}" l n i p + vid_ok "${pv}" + vid_ok "${fv}" + echo " switch ${SW#clab-"${LAB}"-} (${IMAGE}): bridge br0, vlan_filtering 1, no default PVID" + for l in "${LINKS[@]}"; do + read -r n i p <<<"${l}" + echo " veth ${n#clab-"${LAB}"-}:${i} <-> vtsw:${p}" + done + echo " bondsw (${BOND_MODE}) on ${EDGE} (vtsw1 vtsw2) and vtsw (e1 e2): trunk VIDs ${pv} ${fv}${EXTRA_VIDS:+ ${EXTRA_VIDS}}" + echo " vtsw tr: VID ${pv}${EXTRA_VIDS:+ ${EXTRA_VIDS}}; vtsw cpt: VID ${fv}" + echo " pass-through XDP on vtsw e1 e2" +} + +cmd_up() { + local pv="${1:?public VID}" fv="${2:?fabric VID}" l n i p v + vid_ok "${pv}" + vid_ok "${fv}" + for v in ${EXTRA_VIDS:-}; do vid_ok "${v}"; done + if [ "$(docker inspect -f '{{.State.Running}}' "${SW}" 2>/dev/null)" != true ]; then + docker rm -f "${SW}" >/dev/null 2>&1 || true + echo "change: docker run ${SW} (${IMAGE}, network none)" + docker run -d --name "${SW}" --hostname vtsw --network none --privileged \ + --entrypoint sleep "${IMAGE}" infinity >/dev/null + fi + for l in "${LINKS[@]}"; do + read -r n i p <<<"${l}" + if ! q "${SW}" ip link show dev "${p}" >/dev/null 2>&1; then + echo "change: veth ${n}:${i} <-> ${SW}:${p}" + sudo -n containerlab tools veth create -a "${n}:${i}" -b "${SW}:${p}" -m 1500 >/dev/null + fi + on "${n}" ip link set dev "${i}" up + done + mkbond "${EDGE}" vtsw1 vtsw2 + mkbond "${SW}" e1 e2 + + docker cp "${XDP_OBJ}" "${SW}:/xdp-passthrough.o" >/dev/null + for i in e1 e2; do + on "${SW}" ip -force link set dev "${i}" xdp obj /xdp-passthrough.o sec xdp + done + + q "${SW}" ip link show dev br0 >/dev/null 2>&1 \ + || on "${SW}" ip link add br0 type bridge vlan_filtering 1 vlan_default_pvid 0 + for i in bondsw tr cpt; do + on "${SW}" ip link set dev "${i}" master br0 + done + for v in "${pv}" "${fv}" ${EXTRA_VIDS:-}; do + on "${SW}" bridge vlan add dev bondsw vid "${v}" + done + for v in "${pv}" ${EXTRA_VIDS:-}; do + on "${SW}" bridge vlan add dev tr vid "${v}" + done + on "${SW}" bridge vlan add dev cpt vid "${fv}" + for i in tr cpt bondsw br0; do + on "${SW}" ip link set dev "${i}" up + done +} + +cmd_down() { + if docker inspect "${SW}" >/dev/null 2>&1; then + # Removing the node's network namespace deletes every veth pair it ends. + echo "change: docker rm -f ${SW}" + docker rm -f "${SW}" >/dev/null + fi + if q "${EDGE}" ip link show dev bondsw >/dev/null 2>&1; then + on "${EDGE}" ip link del dev bondsw + fi +} + +case "${1:-}" in + plan) shift; cmd_plan "$@" ;; + up) shift; cmd_up "$@" ;; + down) cmd_down ;; + *) sed -n '2,28p' "$0"; exit 2 ;; +esac diff --git a/deploy/containerlab/scripts/vlan-transport.sh b/deploy/containerlab/scripts/vlan-transport.sh index 82175eab..7d817216 100755 --- a/deploy/containerlab/scripts/vlan-transport.sh +++ b/deploy/containerlab/scripts/vlan-transport.sh @@ -17,15 +17,27 @@ # vlan-transport.sh revert back to C1 with the saved Galactic settings # vlan-transport.sh status what is applied now # vlan-transport.sh offload on|off VLAN offloads on every transport member +# vlan-transport.sh csum on|off transmit checksum offload on every transport member # vlan-transport.sh snapshot DIR interfaces, offloads, XDP, versions # vlan-transport.sh capture-start DIR NAME tcpdump every transport link # vlan-transport.sh capture-stop DIR NAME stop and summarize tags per link +# vlan-transport.sh tenant-capture-start DIR NAME tcpdump sjc's ns20 tenant attachment +# vlan-transport.sh tenant-capture-stop DIR NAME stop and count tagged frames there # # SELECT=logical (default) names each side's logical interface, as the # contract requires: the VLAN netdevice on a tagged side. SELECT=parent names # the parent instead, the misconfiguration the contract's section 4 accepts, # which lets the unchanged XDP programs show how they treat tagged traffic. -# PUB_VID and FAB_VID override the cell's IDs. +# PUB_VID and FAB_VID override the cell's IDs, PUB_PARENT and FAB_PARENT its +# parent kind per side (bond, nic or shared), and BOND_MODE its bond mode +# (802.3ad or active-backup). A later apply changes only the sides whose +# parent or ID differs, so one side can change while the other forwards; a +# bond mode change, or entering or leaving the shared parent, rebuilds both. +# +# CNI_SELECT picks how galactic-cni gets a different interface list on the +# edge and compute nodes: "copy" (default) gives the edge node its own copy +# of the DaemonSet; "by-node" sets GALACTIC_CNI_EBPF_INTERFACES_BY_NODE on +# the one DaemonSet, which needs a galactic-cni that reads it (#1404). # # The caller holds the containerlab-manager reservation. Every change here is # echoed with a "change:" prefix so the run's log records it exactly. @@ -46,26 +58,28 @@ CNI_COPY=galactic-cni-vt-edge # the edge conformance suite runs on dfw; dfw's NAT DaemonSet also serves # dfw-worker2, so its settings stay as deployed there. # -# Per side: " " for -# both ends. Keep in step with resources/node-addresses/ and node_files/tr*. +# Per side: " " for both ends. The shared parent is the interface +# vlan-transport-switch.sh gives that end for cell C5. Keep in step with +# resources/node-addresses/ and node_files/tr*. # The side arrays are read through namerefs (side_apply, side_revert). # shellcheck disable=SC2034 case "${VT_SITE:-sjc}" in sjc) EDGE=sjc-worker2 COMPUTE=sjc-worker CP=sjc-control-plane TR=clab-${LAB}-tr2 - PUB_EDGE=("${EDGE}" bond0 eth1 2001:db8:1:21::2/64 10.1.21.2/24) - PUB_PEER=("${TR}" bond1 eth1 2001:db8:1:21::1/64 10.1.21.1/24) - FAB_EDGE=("${EDGE}" bond1 eth2 2001:db8:1:20::1/64 10.1.20.1/24) - FAB_PEER=("${COMPUTE}" bond0 eth1 2001:db8:1:20::2/64 10.1.20.2/24) + PUB_EDGE=("${EDGE}" bond0 eth1 2001:db8:1:21::2/64 10.1.21.2/24 eth3 bondsw) + PUB_PEER=("${TR}" bond1 eth1 2001:db8:1:21::1/64 10.1.21.1/24 eth5 vtsw0) + FAB_EDGE=("${EDGE}" bond1 eth2 2001:db8:1:20::1/64 10.1.20.1/24 eth4 bondsw) + FAB_PEER=("${COMPUTE}" bond0 eth1 2001:db8:1:20::2/64 10.1.20.2/24 eth2 vtsw0) MEMBERS=("${TR} eth1 eth5" "${EDGE} eth1 eth3 eth2 eth4" "${COMPUTE} eth1 eth2") SET_NAT=1 ;; dfw-worker3) EDGE=dfw-worker3 COMPUTE=dfw-worker CP=dfw-control-plane TR=clab-${LAB}-tr1 - PUB_EDGE=("${EDGE}" bond0 eth1 2001:db8:1:12::2/64 10.1.12.2/24) - PUB_PEER=("${TR}" bond2 eth5 2001:db8:1:12::1/64 10.1.12.1/24) - FAB_EDGE=("${EDGE}" bond1 eth2 2001:db8:1:13::1/64 10.1.13.1/24) - FAB_PEER=("${COMPUTE}" bond1 eth2 2001:db8:1:13::2/64 10.1.13.2/24) + PUB_EDGE=("${EDGE}" bond0 eth1 2001:db8:1:12::2/64 10.1.12.2/24 eth3 -) + PUB_PEER=("${TR}" bond2 eth5 2001:db8:1:12::1/64 10.1.12.1/24 eth7 -) + FAB_EDGE=("${EDGE}" bond1 eth2 2001:db8:1:13::1/64 10.1.13.1/24 eth4 -) + FAB_PEER=("${COMPUTE}" bond1 eth2 2001:db8:1:13::2/64 10.1.13.2/24 eth4 -) MEMBERS=("${TR} eth5 eth7" "${EDGE} eth1 eth3") SET_NAT=0 ;; @@ -112,6 +126,7 @@ save_original() { state_put gw_internal "$(ds_env "${gw}" galactic-gateway GALACTIC_GATEWAY_INTERNAL_INTERFACES)" state_put nat_uplinks "$(ds_env galactic-nat galactic-nat GALACTIC_NAT_UPLINK_INTERFACES)" state_put cni_ifaces "$(ds_env galactic-cni credential-refresh GALACTIC_CNI_EBPF_INTERFACES)" + state_put cni_by_node "$(ds_env galactic-cni credential-refresh GALACTIC_CNI_EBPF_INTERFACES_BY_NODE)" q "${EDGE}" cat "${STATE}" | sed 's/^/saved: /' } @@ -139,6 +154,7 @@ side_apply() { local -n e="$1" local kind="$2" vid="$3" n="${e[0]}" bond="${e[1]}" member="${e[2]}" v6="${e[3]}" v4="${e[4]}" local parent="${bond}" + [ "${kind}" = shared ] && parent="${e[6]}" if [ "${kind}" = nic ]; then parent="${member}" if q "${n}" ip -o link show dev "${member}" | grep -q " master ${bond} "; then @@ -162,10 +178,10 @@ side_apply() { # side_revert END: remove any VLAN and re-bond, moving the addresses home. side_revert() { local -n e="$1" - local n="${e[0]}" bond="${e[1]}" member="${e[2]}" v6="${e[3]}" v4="${e[4]}" dev + local n="${e[0]}" bond="${e[1]}" member="${e[2]}" v6="${e[3]}" v4="${e[4]}" shared="${e[6]}" dev for dev in $(q "${n}" sh -c "ip -o link show type vlan | awk -F': ' '{print \$2}' | cut -d@ -f1"); do case "${dev}" in - "${bond}".* | "${member}".*) + "${bond}".* | "${member}".* | "${shared}".*) addr_move "${n}" "${dev}" "${bond}" "${v6}" "${v4}" on "${n}" ip link del dev "${dev}" ;; @@ -200,14 +216,28 @@ set_nat() { # set_cni COMPUTE_VALUE EDGE_VALUE. One cluster-wide DaemonSet serves both # sjc nodes, and bond0 is the public side on the edge but the fabric side on -# the compute node, so a tagged side needs different names per node. When the -# values differ, the edge gets its own copy of the DaemonSet and the original -# excludes it. +# the compute node, so a tagged side needs different names per node. With +# CNI_SELECT=copy, when the values differ, the edge gets its own copy of the +# DaemonSet and the original excludes it. With CNI_SELECT=by-node, the one +# DaemonSet names each node in GALACTIC_CNI_EBPF_INTERFACES_BY_NODE. set_cni() { local compute="$1" edge="$2" if kc get ds "${CNI_COPY}" >/dev/null 2>&1; then cni_unsplit fi + if [ "${CNI_SELECT:-copy}" = by-node ]; then + local by_node="${EDGE}=${edge}" + [ "${SET_NAT}" = 1 ] && by_node="${by_node};${COMPUTE}=${compute}" + if [ "${edge}" = "${compute}" ] && [ -z "$(state_get cni_by_node)" ]; then + echo "change: ds/galactic-cni: unset GALACTIC_CNI_EBPF_INTERFACES_BY_NODE (all containers)" + kc set env ds/galactic-cni --containers='*' GALACTIC_CNI_EBPF_INTERFACES_BY_NODE- + else + echo "change: ds/galactic-cni: GALACTIC_CNI_EBPF_INTERFACES_BY_NODE=${by_node} (all containers)" + kc set env ds/galactic-cni --containers='*' "GALACTIC_CNI_EBPF_INTERFACES_BY_NODE=${by_node}" + fi + kc rollout status ds/galactic-cni --timeout=300s || echo "set_cni: galactic-cni not ready (recorded, not fatal)" + return 0 + fi if [ "${edge}" != "${compute}" ]; then echo "change: ds/galactic-cni: exclude ${EDGE}; ds/${CNI_COPY} on ${EDGE} with GALACTIC_CNI_EBPF_INTERFACES=${edge}" kc patch ds galactic-cni --type=json -p "[{\"op\":\"add\",\"path\":\"/spec/template/spec/affinity/nodeAffinity/requiredDuringSchedulingIgnoredDuringExecution/nodeSelectorTerms/0/matchExpressions/-\",\"value\":{\"key\":\"kubernetes.io/hostname\",\"operator\":\"NotIn\",\"values\":[\"${EDGE}\"]}}]" @@ -239,6 +269,25 @@ cni_unsplit() { fi } +# cni_restore puts galactic-cni back as deployed, whichever CNI_SELECT ran. +cni_restore() { + if kc get ds "${CNI_COPY}" >/dev/null 2>&1; then + cni_unsplit + fi + local orig + orig=$(state_get cni_by_node) + if [ -n "${orig}" ]; then + echo "change: ds/galactic-cni: GALACTIC_CNI_EBPF_INTERFACES_BY_NODE=${orig} (all containers)" + kc set env ds/galactic-cni --containers='*' "GALACTIC_CNI_EBPF_INTERFACES_BY_NODE=${orig}" + elif [ -n "$(ds_env galactic-cni credential-refresh GALACTIC_CNI_EBPF_INTERFACES_BY_NODE)" ]; then + echo "change: ds/galactic-cni: unset GALACTIC_CNI_EBPF_INTERFACES_BY_NODE (all containers)" + kc set env ds/galactic-cni --containers='*' GALACTIC_CNI_EBPF_INTERFACES_BY_NODE- + fi + echo "change: ds/galactic-cni: GALACTIC_CNI_EBPF_INTERFACES=$(state_get cni_ifaces) (all containers)" + kc set env ds/galactic-cni --containers='*' "GALACTIC_CNI_EBPF_INTERFACES=$(state_get cni_ifaces)" + kc rollout status ds/galactic-cni --timeout=300s || echo "cni_restore: galactic-cni not ready (recorded, not fatal)" +} + wait_galactic() { local gw rc=0 gw=$(state_get gw_ds) @@ -249,26 +298,72 @@ wait_galactic() { return "${rc}" } +# --- bonds ------------------------------------------------------------------ + +# bond_mode END MODE rebuilds one end's bond in MODE: a bond's mode changes +# only while it is down and has no members. Taking it down drops its IPv6 +# addresses, so the Kind nodes get theirs back here; zebra restores tr2's. +bond_mode() { + local -n e="$1" + local mode="$2" n="${e[0]}" bond="${e[1]}" cur m + cur=$(q "${n}" cat "/sys/class/net/${bond}/bonding/mode" | cut -d' ' -f1) + [ "${cur}" = "${mode}" ] && return 0 + for m in "${e[2]}" "${e[5]}"; do + on "${n}" ip link set dev "${m}" nomaster || true + done + on "${n}" ip link set dev "${bond}" down + if [ "${mode}" = 802.3ad ]; then + on "${n}" ip link set dev "${bond}" type bond mode 802.3ad miimon 100 lacp_rate fast xmit_hash_policy layer3+4 + else + on "${n}" ip link set dev "${bond}" type bond mode "${mode}" miimon 100 + fi + for m in "${e[2]}" "${e[5]}"; do + on "${n}" ip link set dev "${m}" down + on "${n}" ip link set dev "${m}" master "${bond}" + on "${n}" ip link set dev "${m}" up + done + on "${n}" ip link set dev "${bond}" up + if [ "${n}" != "${TR}" ]; then + on "${n}" ip -6 addr replace "${e[3]}" dev "${bond}" + on "${n}" ip -4 addr replace "${e[4]}" dev "${bond}" + fi +} + # --- commands --------------------------------------------------------------- -# cell_values CELL SELECT sets pv, fv and kind from cells.env, applying the -# PUB_VID and FAB_VID overrides, and rejects values no transport may use. +# cell_values CELL SELECT sets pv, fv, pk, fk (parent kind per side) and bm +# (bond mode) from cells.env, applying the PUB_VID, FAB_VID, PUB_PARENT, +# FAB_PARENT and BOND_MODE overrides, and rejects values no transport may use. cell_values() { - local cell="$1" select="$2" v - case "${cell}" in C[0-9]) ;; *) die "unknown cell ${cell}" ;; esac + local cell="$1" select="$2" v kind + [[ "${cell}" =~ ^C[0-9][A-Z0-9]*$ ]] || die "unknown cell ${cell}" case "${select}" in logical | parent) ;; *) die "select must be logical or parent, not ${select}" ;; esac # shellcheck disable=SC1090 source "${CELLS}" eval "pv=\${${cell}_PUB_VID-unset} fv=\${${cell}_FAB_VID-unset} kind=\${${cell}_PARENT-unset}" [ "${kind}" != unset ] || die "unknown cell ${cell}" + eval "pk=\${${cell}_PUB_PARENT:-${kind}} fk=\${${cell}_FAB_PARENT:-${kind}} bm=\${${cell}_BOND_MODE:-802.3ad}" pv=${PUB_VID-${pv}} fv=${FAB_VID-${fv}} + pk=${PUB_PARENT:-${pk}} + fk=${FAB_PARENT:-${fk}} + bm=${BOND_MODE:-${bm}} for v in "${pv}" "${fv}"; do [ -z "${v}" ] && continue if ! [[ "${v}" =~ ^[0-9]+$ ]] || [ "${v}" -lt 1 ] || [ "${v}" -gt 4094 ]; then die "VLAN ID ${v} is outside 1 to 4094" fi done + for v in "${pk}" "${fk}"; do + case "${v}" in bond | nic | shared) ;; *) die "parent must be bond, nic or shared, not ${v}" ;; esac + done + case "${bm}" in 802.3ad | active-backup) ;; *) die "bond mode must be 802.3ad or active-backup, not ${bm}" ;; esac + if [ "${pk}" = shared ] || [ "${fk}" = shared ]; then + if [ "${pk}" != shared ] || [ "${fk}" != shared ]; then die "shared parent is for both sides at once"; fi + if [ -z "${pv}" ] || [ -z "${fv}" ]; then die "shared parent needs both sides tagged"; fi + [ "${pv}" != "${fv}" ] || die "shared parent needs two different VLAN IDs" + [ "${PUB_EDGE[6]}" != - ] || die "shared parent is not built on ${VT_SITE}" + fi } # name_of END KIND VID prints an end's logical interface and parent, as @@ -277,18 +372,19 @@ name_of() { local -n e="$1" local parent="${e[1]}" [ "$2" = nic ] && parent="${e[2]}" + [ "$2" = shared ] && parent="${e[6]}" if [ -n "$3" ]; then echo "${parent}.$3 ${parent}"; else echo "${parent} ${parent}"; fi } # cmd_plan CELL [SELECT] prints what apply would change, touching nothing. cmd_plan() { - local cell="${1:?cell}" select="${2:-logical}" pv fv kind end l p + local cell="${1:?cell}" select="${2:-logical}" pv fv pk fk bm end l p cell_values "${cell}" "${select}" - echo "plan ${cell} on ${VT_SITE:-sjc}: public VID '${pv:-none}', fabric VID '${fv:-none}', parent ${kind}, select ${select}" + echo "plan ${cell} on ${VT_SITE:-sjc}: public VID '${pv:-none}' parent ${pk}, fabric VID '${fv:-none}' parent ${fk}, bonds ${bm}, select ${select}, cni ${CNI_SELECT:-copy}" declare -A pick for end in PUB_PEER PUB_EDGE FAB_EDGE FAB_PEER; do - local vid=${pv} - [[ "${end}" == FAB_* ]] && vid=${fv} + local vid=${pv} kind=${pk} + [[ "${end}" == FAB_* ]] && vid=${fv} kind=${fk} read -r l p <<<"$(name_of "${end}" "${kind}" "${vid}")" local -n arr="${end}" echo " ${end}: ${arr[0]#clab-"${LAB}"-} logical ${l}, parent ${p}, addresses ${arr[3]} ${arr[4]}" @@ -296,6 +392,9 @@ cmd_plan() { [ "${select}" = parent ] && pick[${end}]=${p} unset -n arr done + if [ "${pk}" = shared ]; then + "${SCRIPT_DIR}/vlan-transport-switch.sh" plan "${pv}" "${fv}" + fi echo " galactic-gateway on ${EDGE}: PUBLIC=${pick[PUB_EDGE]} INTERNAL=${pick[FAB_EDGE]}" if [ "${SET_NAT}" = 1 ]; then echo " galactic-nat: UPLINK_INTERFACES=${pick[PUB_EDGE]},${pick[FAB_EDGE]}" @@ -305,19 +404,58 @@ cmd_plan() { fi } +# side_keep END KIND VID reports an unchanged end's names as side_apply would. +side_keep() { name_of "$1" "$2" "$3" >&3; } + cmd_apply() { - local cell="${1:?cell}" select="${2:-logical}" pv fv kind + local cell="${1:?cell}" select="${2:-logical}" pv fv pk fk bm cell_values "${cell}" "${select}" save_original - [ -z "$(state_get cell)" ] || [ "$(state_get cell)" = C1 ] || cmd_revert_interfaces - echo "apply ${cell}: public VID '${pv:-none}', fabric VID '${fv:-none}', parent ${kind}, select ${select}" + local old_pub old_fab old_bm full=0 pub_changed=1 fab_changed=1 + old_pub=$(state_get pub_spec) + old_fab=$(state_get fab_spec) + old_bm=$(state_get bond_mode) + old_pub=${old_pub:-bond/} old_fab=${old_fab:-bond/} old_bm=${old_bm:-802.3ad} + [ "${old_pub}" = "${pk}/${pv}" ] && pub_changed=0 + [ "${old_fab}" = "${fk}/${fv}" ] && fab_changed=0 + if [ "${old_bm}" != "${bm}" ] || [[ "${old_pub}${pk}" == *shared* ]]; then + if [ "${pub_changed}${fab_changed}" != 00 ] || [ "${old_bm}" != "${bm}" ]; then + full=1 pub_changed=1 fab_changed=1 + fi + fi + echo "apply ${cell}: public VID '${pv:-none}' parent ${pk}, fabric VID '${fv:-none}' parent ${fk}, bonds ${bm}, select ${select}; changing public=${pub_changed} fabric=${fab_changed} rebuild=${full}" + + if [ "${full}" = 1 ]; then + cmd_revert_interfaces + local end + for end in PUB_PEER PUB_EDGE FAB_EDGE FAB_PEER; do + bond_mode "${end}" "${bm}" + done + state_put bond_mode "${bm}" + if [ "${pk}" = shared ]; then + BOND_MODE=${bm} "${SCRIPT_DIR}/vlan-transport-switch.sh" up "${pv}" "${fv}" + fi + else + if [ "${pub_changed}" = 1 ]; then side_revert PUB_PEER; side_revert PUB_EDGE; fi + if [ "${fab_changed}" = 1 ]; then side_revert FAB_EDGE; side_revert FAB_PEER; fi + fi local pub fab cpt exec 3>/tmp/vlan-transport.$$ - side_apply PUB_PEER "${kind}" "${pv}" - side_apply PUB_EDGE "${kind}" "${pv}" - side_apply FAB_EDGE "${kind}" "${fv}" - side_apply FAB_PEER "${kind}" "${fv}" + if [ "${pub_changed}" = 1 ]; then + side_apply PUB_PEER "${pk}" "${pv}" + side_apply PUB_EDGE "${pk}" "${pv}" + else + side_keep PUB_PEER "${pk}" "${pv}" + side_keep PUB_EDGE "${pk}" "${pv}" + fi + if [ "${fab_changed}" = 1 ]; then + side_apply FAB_EDGE "${fk}" "${fv}" + side_apply FAB_PEER "${fk}" "${fv}" + else + side_keep FAB_EDGE "${fk}" "${fv}" + side_keep FAB_PEER "${fk}" "${fv}" + fi exec 3>&- mapfile -t lines /dev/null 2>&1; then + "$@" "${EDGE}" vtsw1 + "$@" "${EDGE}" vtsw2 + "$@" "${TR}" vtsw0 + "$@" "${COMPUTE}" vtsw0 + fi } # cmd_offload on|off sets rx-vlan-offload and tx-vlan-offload on every # transport member at once. With them off a veth carries the tag in packet # data, as a NIC without VLAN offload presents it to XDP. +offload_one() { + echo "change: $1: ethtool -K $2 rxvlan ${OFFLOAD_STATE} txvlan ${OFFLOAD_STATE}" + eth "$1" -K "$2" rxvlan "${OFFLOAD_STATE}" txvlan "${OFFLOAD_STATE}" || echo "offload: $1 $2 refused (recorded)" +} cmd_offload() { - local v="${1:?on or off}" m n i + OFFLOAD_STATE="${1:?on or off}" save_original - for m in "${MEMBERS[@]}"; do - read -r n i <<<"${m%% *} ${m#* }" - for i in ${m#* }; do - echo "change: ${n}: ethtool -K ${i} rxvlan ${v} txvlan ${v}" - eth "${n}" -K "${i}" rxvlan "${v}" txvlan "${v}" || echo "offload: ${n} ${i} refused (recorded)" - done - done - state_put offload "${v}" + for_members offload_one + state_put offload "${OFFLOAD_STATE}" +} + +# cmd_csum on|off sets transmit checksum offload on every transport member. +# A veth sender with it on hands its peer a frame whose checksum is still +# partial, and a native XDP redirect forwards those bytes as they are, so the +# far end counts a false checksum error (baseline report, probe-rig artifact). +csum_one() { + echo "change: $1: ethtool -K $2 tx ${CSUM_STATE}" + eth "$1" -K "$2" tx "${CSUM_STATE}" || echo "csum: $1 $2 refused (recorded)" +} +cmd_csum() { + CSUM_STATE="${1:?on or off}" + save_original + for_members csum_one + state_put csum "${CSUM_STATE}" } cmd_status() { @@ -392,7 +578,7 @@ cmd_status() { local n for n in "${TR}" "${EDGE}" "${COMPUTE}"; do echo "--- ${n}" - q "${n}" sh -c "ip -br addr show | grep -E '^(bond|eth[1-5])' || true" + q "${n}" sh -c "ip -br addr show | grep -E '^(bond|eth[1-5]|vtsw)' || true" done kc get pods -o wide 2>/dev/null | grep -E "galactic-(gateway|nat|cni).*(${EDGE}|${COMPUTE})" || true } @@ -406,10 +592,11 @@ cmd_snapshot() { for n in "${TR}" "${EDGE}" "${COMPUTE}"; do echo "=== ${n}" q "${n}" uname -r - q "${n}" ip -d link show 2>/dev/null | grep -A3 -E '^[0-9]+: (bond|eth[1-5])' || true - for i in $(q "${n}" sh -c "ls /sys/class/net | grep -E '^(bond|eth[1-5])'"); do + q "${n}" ip -d link show 2>/dev/null | grep -A3 -E '^[0-9]+: (bond|eth[1-5]|vtsw)' || true + for i in $(q "${n}" sh -c "ls /sys/class/net | grep -E '^(bond|eth[1-5]|vtsw)'"); do echo "--- ${n} ${i} ethtool" - { eth "${n}" -i "${i}" 2>/dev/null | head -2; eth "${n}" -k "${i}" 2>/dev/null | grep -E 'vlan|generic-receive'; } || true + { eth "${n}" -i "${i}" 2>/dev/null | head -2; eth "${n}" -k "${i}" 2>/dev/null | grep -E 'vlan|generic-receive|tx-checksumming'; } || true + q "${n}" sh -c "cat /sys/class/net/${i}/bonding/mode 2>/dev/null | sed 's/^/bond mode: /'" || true done done echo "=== galactic images" @@ -423,22 +610,27 @@ cmd_snapshot() { # sender transmits from XDP (invisible to its own tcpdump) are still seen. # Captures run on bond members or plain NICs, never on VLAN netdevices, so # libpcap reports the tag whether it is in the frame or in skb metadata. -if [ "${VT_SITE:-sjc}" = sjc ]; then - CAPS=( - "${TR} eth1 public-at-router" "${TR} eth5 public-at-router" - "${EDGE} eth1 public-at-edge" "${EDGE} eth3 public-at-edge" - "${EDGE} eth2 fabric-at-edge" "${EDGE} eth4 fabric-at-edge" - "${COMPUTE} eth1 fabric-at-compute" "${COMPUTE} eth2 fabric-at-compute" - ) -else - CAPS=( - "${TR} eth5 public-at-router" "${TR} eth7 public-at-router" - "${EDGE} eth1 public-at-edge" "${EDGE} eth3 public-at-edge" - ) -fi +# A role starting "trunk-" carries both sides' VLANs (C5's shared parent). +caps() { + if [ "${VT_SITE:-sjc}" != sjc ]; then + printf '%s\n' "${TR} eth5 public-at-router" "${TR} eth7 public-at-router" \ + "${EDGE} eth1 public-at-edge" "${EDGE} eth3 public-at-edge" + elif [[ "$(state_get pub_spec)" == shared/* ]]; then + printf '%s\n' "${TR} vtsw0 public-at-router" \ + "${EDGE} vtsw1 trunk-at-edge" "${EDGE} vtsw2 trunk-at-edge" \ + "clab-${LAB}-vtsw e1 trunk-at-switch" "clab-${LAB}-vtsw e2 trunk-at-switch" \ + "${COMPUTE} vtsw0 fabric-at-compute" + else + printf '%s\n' "${TR} eth1 public-at-router" "${TR} eth5 public-at-router" \ + "${EDGE} eth1 public-at-edge" "${EDGE} eth3 public-at-edge" \ + "${EDGE} eth2 fabric-at-edge" "${EDGE} eth4 fabric-at-edge" \ + "${COMPUTE} eth1 fabric-at-compute" "${COMPUTE} eth2 fabric-at-compute" + fi +} cmd_capture_start() { local dir="${1:?dir}" name="${2:?name}" c n i role + mapfile -t CAPS < <(caps) for c in "${CAPS[@]}"; do read -r n i role <<<"${c}" q "${n}" sh -c "rm -f /tmp/vt-${name}-${i}.pcap; (timeout 300 tcpdump -i ${i} -nn -e -s 128 -w /tmp/vt-${name}-${i}.pcap >/dev/null 2>/tmp/vt-${name}-${i}.err &)" @@ -446,9 +638,14 @@ cmd_capture_start() { sleep 2 } +# LACP, LLDP and STP frames are link-local and never tagged; they are left +# out of every count so a tagged link's "untagged" means data frames only. +L2CTL='(ether proto 0x8809 or ether proto 0x88cc or stp)' + cmd_capture_stop() { local dir="${1:?dir}" name="${2:?name}" c n i role f mkdir -p "${dir}" + mapfile -t CAPS < <(caps) sleep 1 for c in "${CAPS[@]}"; do read -r n i role <<<"${c}" @@ -459,24 +656,51 @@ cmd_capture_stop() { read -r n i role <<<"${c}" f="${dir}/${name}-${n#clab-"${LAB}"-}-${i}.pcap" docker cp "${n}:/tmp/vt-${name}-${i}.pcap" "${f}" >/dev/null 2>&1 || continue - local tot v1 v2 un - tot=$(tcpdump -r "${f}" -nn 2>/dev/null | wc -l) + local tot v1 v2 un drop + tot=$(tcpdump -r "${f}" -nn "not ${L2CTL}" 2>/dev/null | wc -l) v1=$(tcpdump -r "${f}" -nn "vlan ${TAG_A:-101}" 2>/dev/null | wc -l) v2=$(tcpdump -r "${f}" -nn "vlan ${TAG_B:-202}" 2>/dev/null | wc -l) - un=$(tcpdump -r "${f}" -nn 'not vlan' 2>/dev/null | wc -l) - printf '%-18s %-12s %-5s total=%-6s vlan%s=%-6s vlan%s=%-6s untagged=%-6s other-tag=%s\n' "${role}" "${n#clab-"${LAB}"-}" "${i}" \ - "${tot}" "${TAG_A:-101}" "${v1}" "${TAG_B:-202}" "${v2}" "${un}" "$((tot - v1 - v2 - un))" + un=$(tcpdump -r "${f}" -nn "not vlan and not ${L2CTL}" 2>/dev/null | wc -l) + drop=$(q "${n}" sh -c "grep -Eo '[0-9]+ packets dropped by kernel' /tmp/vt-${name}-${i}.err | cut -d' ' -f1" 2>/dev/null) + printf '%-18s %-12s %-5s total=%-6s vlan%s=%-6s vlan%s=%-6s untagged=%-6s other-tag=%-4s capture-drops=%s\n' "${role}" "${n#clab-"${LAB}"-}" "${i}" \ + "${tot}" "${TAG_A:-101}" "${v1}" "${TAG_B:-202}" "${v2}" "${un}" "$((tot - v1 - v2 - un))" "${drop:-unknown}" done | tee "${dir}/${name}-tags.txt" } +# The tenant attachment: sjc's ns20 pod, which V05 and the NAT rows reach. +# Its own eth0 must never see a tag (wire observation rule). +tenant_pod() { pod_name "${CP}" ns20; } + +cmd_tenant_capture_start() { + local name="${2:?name}" pod + pod=$(tenant_pod) + docker exec "${CP}" kubectl -n ns20 exec "${pod}" -- sh -c \ + "rm -f /tmp/vt-${name}.pcap; (timeout 300 tcpdump -i eth0 -nn -e -s 128 -w /tmp/vt-${name}.pcap >/dev/null 2>&1 &)" + sleep 2 +} + +cmd_tenant_capture_stop() { + local dir="${1:?dir}" name="${2:?name}" pod tot tagged + pod=$(tenant_pod) + mkdir -p "${dir}" + docker exec "${CP}" kubectl -n ns20 exec "${pod}" -- sh -c "pkill -INT tcpdump || true" + sleep 1 + tot=$(docker exec "${CP}" kubectl -n ns20 exec "${pod}" -- sh -c "tcpdump -r /tmp/vt-${name}.pcap -nn 2>/dev/null | wc -l") + tagged=$(docker exec "${CP}" kubectl -n ns20 exec "${pod}" -- sh -c "tcpdump -r /tmp/vt-${name}.pcap -nn vlan 2>/dev/null | wc -l") + printf '%-18s %-12s %-5s total=%-6s tagged=%s\n' tenant "${pod}" eth0 "${tot}" "${tagged}" | tee "${dir}/${name}-tenant.txt" +} + case "${1:-}" in plan) shift; cmd_plan "$@" ;; apply) shift; cmd_apply "$@" ;; revert) cmd_revert ;; status) cmd_status ;; offload) shift; cmd_offload "$@" ;; + csum) shift; cmd_csum "$@" ;; snapshot) shift; cmd_snapshot "$@" ;; capture-start) shift; cmd_capture_start "$@" ;; capture-stop) shift; cmd_capture_stop "$@" ;; - *) sed -n '2,30p' "$0"; exit 2 ;; + tenant-capture-start) shift; cmd_tenant_capture_start "$@" ;; + tenant-capture-stop) shift; cmd_tenant_capture_stop "$@" ;; + *) sed -n '2,44p' "$0"; exit 2 ;; esac diff --git a/docs/designs/vlan-transport/acceptance.md b/docs/designs/vlan-transport/acceptance.md index 1222db41..be9bd6e5 100644 --- a/docs/designs/vlan-transport/acceptance.md +++ b/docs/designs/vlan-transport/acceptance.md @@ -18,7 +18,7 @@ Performance and recovery targets are relative to the untagged baseline that [#14 | L | Containerlab with a tagged variant, run from `deploy/containerlab`, generic and native XDP on veth-backed bonds | Variant: [#1401](https://github.com/datum-cloud/galactic/issues/1401). Automation: [#1405](https://github.com/datum-cloud/galactic/issues/1405) | | H | Hardware with the target NICs and bonds; named by the epic's open hardware decision | [#1406](https://github.com/datum-cloud/galactic/issues/1406) | -[#1405](https://github.com/datum-cloud/galactic/issues/1405) adds one task target for the L rows, `task verify:vlan-transport`, taking a cell and row filter. Until it exists, [#1401](https://github.com/datum-cloud/galactic/issues/1401) records its commands with its evidence. The [baseline report](../../archive/benchmarks/vlan-transport-baseline-2026-11-30.md#lab-rows) lists those commands. They use the lab variant in `deploy/containerlab/scripts/vlan-transport.sh`, and no L row has run yet. +`task verify:vlan-transport` in `deploy/containerlab` runs the L rows, taking a cell and row filter, and writes a row-by-row report ([README](../../../deploy/containerlab/README.md#acceptance-run)). It drives the lab variant in `deploy/containerlab/scripts/vlan-transport.sh`. No L row has run yet; [#1405](https://github.com/datum-cloud/galactic/issues/1405) runs them. ## Configuration cells