From 281f12f8c0dac3707dc4ff8dee7f70e1bdc0ccda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dav=C3=AD=C3=B0=20Steinn=20Geirsson?= Date: Fri, 13 Feb 2026 18:24:06 +0000 Subject: [PATCH] docs: update CLAUDE.md for per-flow metrics Co-Authored-By: Claude Opus 4.6 --- CLAUDE.md | 2 +- vm-switch/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 8050750..8e17e66 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -242,7 +242,7 @@ Messages serialized with `postcard`. FDs passed via ancillary data. - On child exit (child sends `MetricsReport` before exiting) - On shutdown (final collection from all children) -Per-peer metrics: packets, bytes, dropped_packets, dropped_bytes, codel_drops, tail_drops, fq_sojourn_us (Stats), queue_depth_bytes (Stats), flow_count (Stats), sojourn_us (Stats), arp_requests. +Per-peer metrics: packets, bytes, dropped_packets, dropped_bytes, codel_drops, tail_drops, fq_sojourn_us (Stats), queue_depth_bytes (Stats), flow_count (Stats), sojourn_us (Stats), arp_requests. Per-peer flow snapshots: top 50 active flows by packet count, each with identities (Vec of 5-tuples for hash collision grouping), packets, bytes, codel_drops, sojourn_us (Stats). `metrics.json` is written atomically to the config directory every 15 seconds for live inspection. **L3 IP-based forwarding**: The forwarder routes packets by destination IP rather than MAC address. Each worker maintains an `ip_to_peer` map (Ipv4Addr -> peer name) for egress routing. TX processing: ARP requests are answered locally with the target peer's MAC (proxy ARP, returns `ForwardResult::ArpReply`); IPv4 unicast is classified by flow, enqueued into FQ-CoDel, dequeued, and pushed to the ring; IPv4 broadcast (255.255.255.255) goes directly to all broadcast-enabled peers (bypasses FQ-CoDel); other ethertypes are dropped. Ingress validation: source MAC must match expected peer, and IPv4 source IP must match peer's configured IP (anti-spoofing). `forward_tx()` returns `ForwardResult` enum (Forwarded, Dropped, ArpReply). diff --git a/vm-switch/src/lib.rs b/vm-switch/src/lib.rs index 7745c9b..f0708f1 100644 --- a/vm-switch/src/lib.rs +++ b/vm-switch/src/lib.rs @@ -45,7 +45,7 @@ pub use args::{init_logging, Args, LogLevel}; pub use config::{ConfigEvent, VmConfig, VmRole}; pub use control::{ChildToMain, ControlChannel, ControlError, MainToChild, MAX_FDS, MAX_MESSAGE_SIZE}; pub use fq_codel::FqCodelConfig; -pub use metrics::{ChildMetrics, PeerMetrics, Stats, SwitchMetrics}; +pub use metrics::{ChildMetrics, FlowIdentity, FlowMetrics, PeerMetrics, Stats, SwitchMetrics}; pub use metrics_store::MetricsStore; pub use mac::Mac; pub use manager::{BackendManager, ChildMessage};