Skip to content

feat: Netlink ARP/NDP monitor — proper MAC resolution for provider/ECMP deployments #30

Description

@redlemonbe

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

  1. On startup: open NETLINK_ROUTE socket in monitoring mode (RTMGRP_NEIGH)
  2. Background thread receives kernel events on every ARP/NDP create/update/delete
  3. Updates HashMap<IpAddr, MacAddr> via ArcSwap — zero contention with fast path
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestenterpriseEnterprise / commercial featurenetworkingNetwork / DNS featurev1.2Enterprise features

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions