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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/cni/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ The [ADD and DEL sequences](cni-cmd-sequence.md) describe attachment; the [GC se
- **A packet too big for the fabric gets an ICMP error from the datapath, not a silent drop at the uplink.** `usid_egress` calls `send_too_big` after the MSS clamp and before it encapsulates. A packet longer than `encap_mtu_table`'s limit (the uplink MTU less 40, so 1460 at a 1500-byte fabric) is rewritten in place into an ICMPv6 Packet Too Big, or an ICMPv4 Fragmentation Needed for an IPv4 tenant with DF set, and redirected back out the interface it arrived on. The error carries the limit, comes from the attachment's own IPAM gateway (`tenant_gw_table`, keyed by host-side ifindex and written by `galactic-bgp` at ADD, removed by `galactic-veth`/`galactic-tap` at DEL), and quotes the packet's first 68 bytes with NPTv6 undone, so the tenant's path MTU discovery matches it to the socket that sent it. A GSO packet is judged by its segment length. No error is sent for an IPv4 packet without DF, for an ICMP error, past a per-CPU token bucket of 1,000 a second with a burst of 100 (`pmtu_icmp_bucket`), or for an attachment with no gateway in that family; those are dropped and counted as `fib_frag_needed`. Each outcome is counted in `pmtu_stats`, exported as `galactic_usid_pmtu_packets_total{result}`, and the limit as `galactic_usid_pmtu_limit_bytes`. The same `mssclamp.Reconciler` writes `encap_mtu_table` and `mss_clamp_table` from one `GALACTIC_CNI_TCP_MSS_CLAMP` setting, so the two cannot disagree. A pod's or guest's TCP and UDP packets usually arrive `CHECKSUM_PARTIAL`, which no BPF helper can clear, and a device without checksum offload (a tap whose guest did not negotiate it) would finish that checksum into the middle of the error. So the error is laid out with room pushed at the front until the kernel's checksum spot (the original transport header plus 16 for TCP, 6 otherwise) lands on a trailing slot word, with a pad word chosen so the sum the kernel writes there equals what is already there. `usid_pmtu_tap_test.go` checks this against the kernel through a `virtio_net_hdr` tap, with offload on and off.
- **Per-VRF traffic is counted in each direction in its own per-CPU map, not in `vrf_value`.** `vrf_traffic_counters` is a `BPF_MAP_TYPE_PERCPU_HASH` keyed like `vrf_table` (Block<<12|Argument, so one VPC per node) holding packets, tenant bytes and claimed drops for `ingress` and `egress`. Per CPU, because the hot path then increments its own copy with no atomic and no shared cache line; a new map, because changing `vrf_value`'s layout would make `attach.Load` recreate `vrf_table` empty. The datapath only looks rows up: `VRFTable.Register` creates a VRF's row with `BPF_NOEXIST`, so registering again never resets it, `Unregister` removes it, and `Reconcile` ends with `SyncTraffic`, which creates rows for VRFs that predate the map and removes orphans, re-checking `vrf_table` before each delete and again after it, so a VRF registered while it runs keeps its row. `galactic-cni run` also calls `SyncTraffic` once the datapath loads, so an upgraded node counts from its first packet rather than its first 5-minute GC sweep. Every writer of `vrf_table` rows (CNI ADD, the datapath repair, the GC sweep, the ingress sidecar) goes through `VRFTable`, so none needs code of its own. Inbound counts at `usid_ingress`'s two redirects (warm FIB and `bpf_redirect_neigh`). Outbound counts at `usid_egress`'s encapsulating redirect, which covers egress shards, and its VIP reply redirect, and at the service path's redirects, remote ones inside `service_remote_encap` because its caller cannot tell a forwarded packet from a Packet Too Big. Same-node traffic between two attachments never reaches `usid_ingress`: the sender's `usid_egress` matches the receiver's local pass-through entry and hands the packet to the kernel, so that hit counts once in each direction on the shared VPC row, except a destination equal to the sender's own `tenant_gw_table` gateway. Bytes are the tenant packet's own length in both directions, unlike `vrf_value.bytes`, which counts the whole frame at step 6 and stays for `galactic_usid_vrf_bytes_total` and make-before-break checks. Exported as `galactic_usid_vrf_{forwarded_packets,forwarded_bytes,dropped_packets}_total{direction}`; see [docs/metrics.md](../observability/vpc-dataplane.md#traffic). The gateway check reads the destination from `service_fib_scratch` itself rather than taking a pointer to it: passed a map-value pointer as a subprogram argument, `usid_egress`'s verifier cost went past the kernel's 1M-instruction limit.
- **An uplink that drops out of auto-detection keeps `usid_ingress` for 60 seconds.** `attach.Watch` re-resolves the uplink set on every netlink link or route event, and an uplink found only through BGP-learned routes leaves that set whenever FRR withdraws them, which it does for every restart (#778). Detaching on the first miss dropped SRv6 traffic still arriving on that uplink until FRR re-learned the routes. An attached interface whose link still exists now keeps its hook, and its place in the published uplink list, until it has been missing for `detachHoldDown`. Watch re-evaluates on its own when the hold-down ends, so an uplink that really stops carrying fabric routes is still detached. A deleted link is dropped at once.
- **`usid_ingress` claims only its side's transport VLAN.** For a VLAN on a bond, `usid_ingress` also runs on the bond's members, and there the kernel has already moved any single 802.1Q tag into `skb->vlan_tci`, so the hook sees every VLAN of the bond. After the locator match, it looks up the receiving ifindex in `transport_vlan_table`, a 4096-bit set of accepted VLAN IDs with bit 0 for untagged, and leaves any other tag, an 802.1ad tag or a priority tag to the kernel, counting it in the row's `unclaimed_packets`. A missing row accepts untagged frames only. `attach.SyncTransport` derives the rows from the selected interfaces' netlink state, with no setting of its own: a selected VLAN netdevice accepts untagged frames, because the kernel removed its tag; its parent and the parent's bond members accept its ID; any other selected interface and its members accept untagged frames. Two VLANs on one parent give the union. `attach.Start` writes the rows before it attaches and fails readiness if it cannot, and `attach.Watch` rewrites them before every re-attach, keeping each row's counter and leaving a held interface's row alone. A selected VLAN that fails validation (802.1ad, an ID outside 1 to 4094, or stacked on another VLAN) loses its rows, so its parent and members fall back to untagged only. The map is new and holds nothing worth keeping, so a layout change only recreates it. The tag is still popped after decapsulation, so no transit tag reaches a tenant. See the [transport contract](../designs/vlan-transport/contract.md).
- **CRD-driven config, no sidecar gRPC.** `galactic-bgp` writes `BGPVRFInstance`/`BGPAdvertisement` CRDs directly via a bare controller-runtime client; `galactic-router`'s reconciler picks them up. No in-node gRPC calls between any of the CNI-chain binaries and `galactic-router`.
- **DEL is intentionally minimal everywhere in the CNI chain; GC reclaims shared state asynchronously.** Every binary's own `cmdDel` only cleans up what it itself created *and* is safe to release immediately per-container: IPAM deallocation via `galactic-ipam`'s own on-disk marker file; guest-netns flush/host-device DEL in `galactic-veth`; and, in both `galactic-veth`/`galactic-tap`, deleting this attachment's own host/guest veth pair or tap device outright, since that interface is private to one attachment and no sibling pod/VM can ever depend on it. `galactic-bgp` removes its container's entries from this node's `BGPAdvertisement` and deletes it once no container it records is alive, so a replacement whose ADD ran first keeps it. None of them delete the VRF, routes, the eBPF `vrf_table` entry, or the `BGPVRFInstance` — those are keyed by `(vpc, node)` and shared by every attachment on the VPC and node. `galactic-router`'s GC controller (see [ARCHITECTURE-ROUTER.md](../router/architecture.md)) reclaims orphaned CRDs and stale kernel VRFs once no live container still references them; the installer separately sweeps stale eBPF VRF entries — see [docs/cni/gc-cmd-sequence.md](../cni/gc-cmd-sequence.md) for why the host veth/tap interface is reclaimed only with a dead attachment's `BGPAdvertisement`, when its DEL never removed it.
- **A DSR backend's node translates the VIP, and its replies leave out the fabric uplink unencapsulated.** `galactic-gateway` carries a client's packet unmodified inside the outer IPv6 header, with Next Header 41 for an IPv6 client and 4 for an IPv4 one, to the backend node's End.DT46 uSID with the backend's slot in bits 81–96. Workloads are IPv6 only, so every backend is IPv6. For an IPv6 client, `usid_ingress` decapsulates the packet and, before the VRF FIB lookup, looks up `vip_xlat_table`'s ingress row by (Block, Argument, slot, protocol, destination address, destination port) and rewrites the destination to the backend's address and port, leaving the client's source alone. On the way back, `usid_egress` (TC ingress of the backend's host-side veth or tap, the same code for both kinds) looks up the egress row by the reply's source address and port, rewrites the source to the VIP, clamps a SYN-ACK's MSS to the IPv6 limit, and redirects the frame unencapsulated to the node's fabric uplink neighbor from `public_uplink_table`, skipping NPTv6 and `egress_route_table` entirely: that table's `::/0` and IPv4 entries would encapsulate the reply toward a NAT shard, which would translate an already correctly addressed reply. The reply is then ordinary routed traffic with the VIP as its source; where the compute node's uplink neighbor is an edge node, as in the containerlab topology, that node's `edge_return` forwards it because its source is in `vip_addr_table` (see [ARCHITECTURE-GATEWAY.md](../gateway/packet-paths.md#return-path-edgedsrc-program-edge_return)). Where the first public uplink's neighbor is the hosting provider's ToR/VRRP gateway, the reply goes straight to the provider and no edge forwards it; `edge_return` applies there only if that uplink loses its neighbor and the row falls back to an interface whose neighbor is an edge. An egress shard never claims it: `nat_ingress` takes only its own SID and masquerade addresses as destinations. Until `public_uplink_table` is written the reply falls through to the ordinary egress path. A packet to a multicast or link-local destination never takes this path: `usid_egress` hands it to the kernel before the VIP lookup and NPTv6, as well as `egress_route_table`, since a VIP's client is never link-local. A host-side TCP probe of the backend's bound port, sourced from the host interface's link-local address, gets its reply that way (see [the backend health design](../gateway/backend-health.md#reply-path)). The row holds one next hop, used for IPv4 frames too: the first resolved IPv6 neighbor of the first eBPF interface, in `attach.ResolveInterfaces` order, that has carrier (`srv6.ResolvePublicUplink`). Every reply from the node takes that uplink, whichever gateway node took the request, so on a compute node dual-homed to two edge nodes the row must follow the uplinks. `galactic-cni run` re-resolves it on every link change and IPv6 neighbor change (`installer.watchPublicUplink`, debounced 250 ms) and on every datapath repair pass (`attachreg.FillNode`), and rewrites it when it differs. A pass that resolves nothing keeps the row it has. `task verify:gateway-node-loss` in `deploy/containerlab/` takes one of `dfw-worker`'s two edge nodes off the fabric and checks the VIP still serves through the other.
Expand Down
3 changes: 2 additions & 1 deletion docs/designs/vlan-transport/contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ The Worker branch adds no setting that selects a VLAN or an interface, so [§4](
Source facts used by this contract:

- `edge_lb`, `edge_return` and `nat_ingress` classify only Ethernet type IPv4 or IPv6 (`internal/plumbing/ebpf/edgeprog/edgedsr.c:1306`, `:1472`; `internal/plumbing/ebpf/natprog/nat.c:3068`). A frame whose tag is in packet data is not claimed.
- `usid_ingress` pops a metadata tag after decapsulation and documents that an in-frame tag reaches its ethertype check unparsed (`usid.c:4479`, `DROP_REASON_TRACE_ING_ENTRY` comment).
- `usid_ingress` pops a metadata tag after decapsulation (`bpf_skb_vlan_pop` in `usid.c`). A single 802.1Q tag never reaches it in packet data: the kernel moves it into `skb->vlan_tci` before tc ingress whatever the offload settings ([baseline](../../archive/benchmarks/vlan-transport-baseline-2026-11-30.md#finding-a-single-8021q-tag-never-reaches-tc-ingress-in-the-frame)). Only a second tag, or the tag under an 802.1ad outer tag, stays in the frame; it fails the ethertype check and is not claimed, as [§6](#frame-handling-per-mode) requires.
- `usid_ingress` claims a frame only when its tag, or its lack of one, is in the receiving interface's `transport_vlan_table` row, derived from the selected interfaces by `attach.SyncTransport` ([#1402](https://github.com/datum-cloud/galactic/issues/1402)).
- Tenant egress redirects to the interface its route uses (`EgressRouteTable.Register`, `PublicUplink.Set`, `internal/plumbing/ebpf/egressroutemap/egressroute.go:349`, `:667`). A route through a VLAN netdevice names that netdevice.
- XDP attach in native mode refuses an interface the kernel reports without native support (`checkNativeXDPSupport`, `internal/plumbing/ebpf/xdpattach/gate.go:78`).
- `main` has no tagged lab topology; `deploy/containerlab` builds untagged bonds.
Expand Down
Loading
Loading