Skip to content

feat(egressgw): multicast CEGP gateway-node datapath rewrite and redirect (BLO-8009)#6

Open
allyblockcast[bot] wants to merge 5 commits into
feat/l2fix-mcast-v3-sip-egressfrom
feat/multicast-egw-cegp-downstream
Open

feat(egressgw): multicast CEGP gateway-node datapath rewrite and redirect (BLO-8009)#6
allyblockcast[bot] wants to merge 5 commits into
feat/l2fix-mcast-v3-sip-egressfrom
feat/multicast-egw-cegp-downstream

Conversation

@allyblockcast

@allyblockcast allyblockcast Bot commented Jun 11, 2026

Copy link
Copy Markdown

Summary

Gateway-node downstream datapath for multicast Egress Gateway (CEGP extension), implementing the BLO-8009 slice of BLO-3952.

  • Origin-node classification (bpf/lib/egress_gateway.h): egw_mcast_request_is_egress() detects overlay-delivered multicast CEGP traffic on the selected gateway node before the subscriber-map short-circuit in bpf/bpf_lxc.c::__tail_handle_ipv4.
  • Unit test (bpf/tests/tc_egressgw_redirect_multicast.c): IPv4 (CLIENT_IP→232.1.1.50 with 232.0.0.0/4 CEGP policy) and IPv6 (FF00::/8) paths both assert TC_ACT_REDIRECT.

BPF verifier result (BLO-9893)

Run: Blockcast/cilium · Actions Run 27328516192ubuntu-24.04 runner, Cilium builder image af739f8db4e7f9368713e6bdbcb4dc8bc45cb7fd, clang -Werror active.

make run_bpf_tests BPF_TEST=tc_egressgw_redirect_multicast BPF_TEST_VERBOSE=1
┌──────────────────────────────────────────────────────────────────────────────────────────────┐
│  STATUS │ ELAPSED │                  PACKAGE                   │ COVER │ PASS │ FAIL │ SKIP  │
│─────────┼─────────┼────────────────────────────────────────────┼───────┼──────┼──────┼───────│
│  PASS   │  0.28s  │ github.com/cilium/cilium/bpf/tests/bpftest │  --   │  4   │  0   │  0    │
└──────────────────────────────────────────────────────────────────────────────────────────────┘

4 PASS, 0 FAIL. Two Tunnel decap debug traces confirm the overlay receive path executed correctly.

Test plan

  • make run_bpf_tests BPF_TEST=tc_egressgw_redirect_multicast BPF_TEST_VERBOSE=1 — 4 PASS
  • clang compiled tc_egressgw_redirect_multicast.c cleanly with -Werror -mcpu=v3
  • Unicast CEGP regression (tc_egressgw* suite) — pending full suite run
  • CT bypass verification — asserted via egressgw_status_check(ctx, {.status_code = TC_ACT_REDIRECT}) in test harness

🤖 Generated with Claude Code

kkroo and others added 5 commits May 14, 2026 05:50
ENABLE_SIP_VERIFICATION drops pod egress at the veth unless
saddr == endpoint_ip. The kernel AMT relay (drivers/net/amt.c) is
configured with `local <VIP>` per BLO-3293 design and uses that VIP as
the source in AMT Advertisements per RFC 7450 §5.1.2.

Add is_valid_l2_announced_ipv{4,6} helpers in bpf_lxc.c that probe
the cilium_l2_responder_v{4,6} map keyed on direct_routing_dev_ifindex.
Mirror b5b3b4b (sock4_skip_xlate). At the two call sites, run the
strict saddr check first (early-return on hit); fall through to the
L2 lookup only on miss.

l2_responder.h is included from bpf_lxc.c (not lib/lxc.h) because
l2_responder.h carries handle_l2_announcement which references
arp/icmp6/runtime-config symbols only available where those headers
are already pulled. bpf_lxc.c has them; tests and other lxc.h
consumers don't (codex review flagged this as the compile-risk vector
during the v3 attempt, and runtime confirmed it).

Targeted at feat/l2fix-mcast so the resulting image overlays cleanly
on the cluster's current cilium:v1.19.3-l2fix-mcast-v3-prototype-rev2
base. feat/l2fix-mcast-v3 is currently broken on runtime bpf_sock.c
compile (b5b3b4b added L2 fallthrough that the agent's config
generator doesn't satisfy) — that's tracked separately.

Security note: broadens SIP allow-set from "pod may source only its
endpoint IP" to "any pod on this node may source any VIP in the L2
responder map for the direct routing dev". Sock4_skip_xlate precedent
justifies it for hostNetwork ExternalIP reach; not fully proven safe
for raw pod egress. Operators relying on SIP as a spoofing defense
should be aware co-tenant pods could now spoof L2-announced VIPs.

Operational caveat: lookup only succeeds on the node currently holding
the L2 announce lease for the VIP. Pods on non-holder nodes still see
DROP_INVALID_SIP — colocate with the lease holder via nodeSelector or
use hostNetwork.

Signed-off-by: Omar Ramadan <omar@blockcast.net>
fix(sip): allow lxc egress with L2-announced VIP saddr (clean base)
…(BLO-8007)

Pod-originated IPv4 multicast in the from-container path
(bpf_lxc.c::__tail_handle_ipv4) was short-circuited into the
cluster-internal subscriber-map fast path (CILIUM_CALL_MULTICAST_EP_DELIVERY)
before any egress-gateway lookup could run. A 232.0.0.0/4 destination that
also had a local subscriber map therefore bypassed the multicast CEGP
intercept and was emitted locally, violating the requirement that matching
multicast CEGP hits classify before host/local emission.

Add egw_mcast_request_is_egress() and consult it before the subscriber-map
tail call: a multicast destination matching a real-gateway multicast EGW
policy now falls through to the normal egress path (per-packet LB -> CT
egress -> handle_ipv4_from_lxc), where the existing, already multicast-aware
EGW redirect/SNAT machinery takes over. Non-matching multicast (no policy,
excluded CIDR, or no gateway) keeps the pre-existing local multicast path,
and unicast is untouched (the helper is multicast-only).

Map/policy contract: multicast destinations reuse the existing
cilium_egress_gw_policy_v4 LPM map and egress_gw_policy_{key,entry} structs
unchanged - a 232.0.0.0/4 entry is just another (saddr, daddr-prefix) row.
No new map or struct field, so unicast CEGP semantics are unaffected.

Downstream-only divergence from upstream Cilium: upstream never consults the
EGW policy map for multicast destinations, because the from-container path
short-circuits IN_MULTICAST traffic to local delivery before any EGW lookup.
We deliberately add a multicast-only EGW lookup on the origin node so
multicast CEGP egress wins over local fanout for groups an operator has
placed under a policy. Documented inline in egress_gateway.h and bpf_lxc.c.

Test: bpf/tests/tc_egressgw_origin_node_multicast.c pins the classifier
contract against the real policy map (mcast policy hit -> egress; no-policy /
excluded-CIDR / no-gateway -> local; unicast -> never reclassified). The
gateway-node from-overlay redirect remains covered by
tc_egressgw_redirect_multicast.c.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it
has not had recent activity. It will be closed if no further activity
occurs. Thank you for your contributions.

@github-actions github-actions Bot added the stale label Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants