[PATCH net-next 0/3] net: nexthop: per-nexthop UDP dst port for fdb (VXLAN) nexthops

From: Jack Ma

Date: Sun Jul 12 2026 - 15:16:41 EST


FDB nexthops let a VXLAN fdb entry point at a group of remote VTEPs, with the
kernel flow-hashing across the group (commit 1274e1cc4226 ("vxlan: ecmp support
for mac fdb entries")). Each leg carries its own remote IP, but the UDP
destination port is always taken from the VXLAN device (vxlan->cfg.dst_port)
and cannot be set per leg.

Some deployments pack several receivers behind a single underlay IP and tell
them apart by UDP destination port. To spread flows across such receivers they
need a nexthop group whose legs share the remote IP but differ in UDP port,
which is not currently expressible.

This series adds an optional per-nexthop UDP destination port for fdb nexthops:

- Patch 1 adds a netlink attribute NHA_FDB_PORT (__be16, mirroring NDA_PORT),
stored in struct nh_info and echoed back on dump. It is
only accepted together with NHA_FDB and NHA_GATEWAY. Control-plane only;
datapath behaviour is unchanged.
- Patch 2 wires it into the VXLAN datapath: vxlan_fdb_nh_path_select() sets
rdst->remote_port to the selected leg's port. vxlan_xmit_one() already
prefers rdst->remote_port when non-zero and otherwise falls back to the
device port, so nexthops without a port are unaffected (backward
compatible).
- Patch 3 adds a selftest.

Example:

ip nexthop add id 1 via 192.0.2.10 fdb port 4789
ip nexthop add id 2 via 192.0.2.10 fdb port 5789
ip nexthop add id 10 group 1/2 fdb
bridge fdb add 00:11:22:33:44:55 dev vxlan0 nhid 10

Both legs share gateway 192.0.2.10 and differ only in UDP port; the kernel
hashes flows across them.

Testing: kernel and iproute2 built on net-next. The control-plane selftest
passes (6/6) and a datapath test (two netns, tcpdump on the underlay) confirms
outer traffic is hashed across both UDP ports. The series is bisectable:
patches 1 and 2 each build individually.

Note: remote_vni has the same per-leg limitation and could be exposed the same
way (e.g. NHA_FDB_VNI); left as a follow-up to keep this series focused.
Naming NHA_FDB_PORT vs a generic NHA_PORT is open to discussion -- VXLAN is the
only fdb-nexthop consumer today.

A matching iproute2 change (the `ip nexthop ... fdb port N` keyword) is posted
separately to the iproute2 list.

Jack Ma (3):
net: nexthop: add NHA_FDB_PORT for fdb nexthops
vxlan: honor per-nexthop fdb destination port
selftests: net: add coverage for fdb nexthop dst port

include/net/nexthop.h | 7 +-
include/net/vxlan.h | 5 +-
include/uapi/linux/nexthop.h | 3 +
net/ipv4/nexthop.c | 20 ++++-
tools/testing/selftests/net/Makefile | 1 +
.../selftests/net/fib_nexthops_fdb_port.sh | 78 +++++++++++++++++++
6 files changed, 111 insertions(+), 3 deletions(-)
create mode 100755 tools/testing/selftests/net/fib_nexthops_fdb_port.sh


base-commit: f6f3b36c15ed44de1fbb44e645e4fae8c4a4453e
--
2.43.0