Context
Current XDP TX path uses naive MAC inversion (swap src/dst from incoming frame). This works for 95% of use cases (direct LAN, single-hop deployments) but fails in provider environments with:
- Intermediate routers / load balancers between client and server
- ECMP (Equal-Cost Multi-Path) routing — response path ≠ request path
- Asymmetric routing — packet arrives via Router A, should leave via Router B
Problem
Naive MAC inversion in an ECMP/provider setup sends responses to a black hole.
Solution — Netlink RTMGRP_NEIGH monitor + ArcSwap
Architecture
Kernel ARP/NDP table
│
│ NETLINK_ROUTE (RTMGRP_NEIGH)
▼
Background Netlink monitor thread
│
│ ArcSwap atomic update
▼
MAC lookup table (HashMap<IpAddr, MacAddr>)
│
│ lock-free read
▼
XDP TX fast path — no syscall, no ARP request
How it works
- On startup: open
NETLINK_ROUTE socket in monitoring mode (RTMGRP_NEIGH)
- Background thread receives kernel events on every ARP/NDP create/update/delete
- Updates
HashMap<IpAddr, MacAddr> via ArcSwap — zero contention with fast path
- XDP TX path does
mac_table.get(next_hop_ip) — single lock-free lookup, no syscall
Next-hop resolution for ECMP
For provider deployments with asymmetric routing:
- Query kernel via
ip route get <client_ip> (Netlink RTM_GETROUTE) to find next-hop
- Store next-hop MAC in response cache at ArcSwap insert time
- On route change (Netlink RTM_NEWROUTE/RTM_DELROUTE) → invalidate affected entries
Passive MAC learning (complementary)
Extract (src_ip, src_mac) from every incoming XDP frame to pre-populate the table before the kernel ARP entry exists. Zero overhead — data is already in the UMEM buffer.
Fallback
If MAC not found in table → XDP_PASS to kernel for normal UDP response path. Silent, no packet drop.
Current behaviour
Naive src/dst MAC swap — works on direct L2 segments, fails with intermediate routing equipment.
Target deployments unlocked
Related
Context
Current XDP TX path uses naive MAC inversion (swap src/dst from incoming frame). This works for 95% of use cases (direct LAN, single-hop deployments) but fails in provider environments with:
Problem
Naive MAC inversion in an ECMP/provider setup sends responses to a black hole.
Solution — Netlink RTMGRP_NEIGH monitor + ArcSwap
Architecture
How it works
NETLINK_ROUTEsocket in monitoring mode (RTMGRP_NEIGH)HashMap<IpAddr, MacAddr>via ArcSwap — zero contention with fast pathmac_table.get(next_hop_ip)— single lock-free lookup, no syscallNext-hop resolution for ECMP
For provider deployments with asymmetric routing:
ip route get <client_ip>(Netlink RTM_GETROUTE) to find next-hopPassive MAC learning (complementary)
Extract
(src_ip, src_mac)from every incoming XDP frame to pre-populate the table before the kernel ARP entry exists. Zero overhead — data is already in the UMEM buffer.Fallback
If MAC not found in table →
XDP_PASSto kernel for normal UDP response path. Silent, no packet drop.Current behaviour
Naive src/dst MAC swap — works on direct L2 segments, fails with intermediate routing equipment.
Target deployments unlocked
Related