Skip to content

net: multipath routes, RTA_MULTIPATH for IPv4 and IPv6 (#538) - #826

Merged
tamnd merged 1 commit into
mainfrom
nwd-mp
Nov 23, 2026
Merged

tamnd merged 1 commit into
mainfrom
nwd-mp

Conversation

@tamnd

@tamnd tamnd commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Multipath routes, as Linux, for #538. systemd-networkd sends MultiPathRoute= as RTM_NEWROUTE with RTA_MULTIPATH, also for IPv4 routes with IPv6 gateways (RTA_VIA in each rtnexthop). Before, the kernel did not use RTA_MULTIPATH, so the route had no device, and networkd failed dummy98 in NetworkdNetworkTests.test_route_static with "Could not set static route: No such device".

The change, as Linux:

  • IPv4: RTM_NEWROUTE with RTA_MULTIPATH makes one route with a path for each rtnexthop, with the checks of fib_count_nexthops, fib_get_nhs and fib_check_nh for the device and the gateway of each path. The weight is rtnh_hops and one. A request with one path makes a route with one path.
  • The dump and RTM_GETROUTE give RTA_MULTIPATH with the weights. RTM_DELROUTE with paths matches them in order, as fib_nh_match.
  • A device that goes down marks its paths dead linkdown. The route goes away when all of its paths are dead.
  • IPv6: a route with RTA_MULTIPATH makes a route for each path, and these routes are siblings, as ip6_route_multipath_add. The dump and the notifications show the siblings in one RTA_MULTIPATH with their weights. A delete without a gateway removes the siblings too. An IPv6 path whose device goes down stays, marked dead linkdown, while another path is alive, as fib6_ifdown.
  • A flow takes a path from a hash of its addresses and the weights, so its packets stay in order.
  • tools/systemd/networkd.md: test_route_static moves from "Exceptions" to "The kernel fixes". It does not use gre devices in systemd 257.13, so that note goes.

BusyBox ip of the boot tests cannot send RTA_MULTIPATH, so the netcfg boot test cannot add a multipath route. The tests of this change are the unit tests and systemd-networkd-tests.py, where networkd sends RTA_MULTIPATH and iproute2 shows the result.

Tests:

  • Unit tests of rk-net-inet on server2 (load average 6.0): 129 passed, 0 failed. New: multipath_has_the_checks_of_linux, a_multipath_route, ipv6_multipath_routes_are_siblings. clippy of rk-net-inet gives no new warning. rustfmt is clean.
  • NetworkdNetworkTests of systemd-networkd-tests.py on x86_64, on server1 (load average 0.2 at the start, about 1.1 during the run): 32 of 42 pass. test_route_static now passes, for both manage_foreign_routes=True and False. Before, with the kernel of net: an IPv4 route through an IPv6 gateway, RTA_VIA (#538) #816 (run via1), 31 of 42 passed. No other test of the class changed. The journal has no "Could not set static route" (12 before). ip route show 192.168.10.1, ip route show 192.168.10.2 and ip -6 route show 2001:1234:5:bfff:ff:ff:ff:ff give the same paths, weights and order as Linux 6.8 in the same VM, for example:
2001:1234:5:bfff:ff:ff:ff:ff proto static metric 1024 pref medium
	nexthop via 2001:1234:5:6fff:ff:ff:ff:ff dev test1 weight 20
	nexthop via 2001:1234:5:7fff:ff:ff:ff:ff dev test1 weight 30
	nexthop via 2001:1234:5:9fff:ff:ff:ff:ff dev dummy98 weight 5
	nexthop via 2001:1234:5:8fff:ff:ff:ff:ff dev dummy98 weight 10
  • The 10 tests of the class that do not pass are the same as before, and are in tools/systemd/networkd.md. test_ip_route_ipv6_src_route needs a bond device and has no multipath route: networkd says "bond199: Failed to create netdev: Operation not supported", and its journal has no route error.
  • The 5 route tests of NetworkdNetworkTests on arm64, on server2 (QEMU TCG, 1 CPU, 2 GB, Debian trixie tree; load average 2.8 at the start, 8.2 at the end): test_route_static, test_route_via_ipv6, test_nexthop and test_route_static_issue_35047 pass. test_ip_route_ipv6_src_route gives an error because bond199 does not come up, the same cause as on x86_64. The journal has no "Could not set static route", and ip route show gives the same paths and weights as on x86_64.
  • Linux reference (run lx-x86-c3, Linux 6.8 in the same QEMU VM on server1, load average 3.0 at the start, about 1.4 during the run): 84 of 85 tests of NetworkctlTests, NetworkdBondTests, NetworkdBridgeTests, NetworkdDHCPPDTests, NetworkdDHCPServerRelayAgentTests, NetworkdDHCPServerTests, NetworkdIPv6PrefixTests, NetworkdLLDPTests, NetworkdMTUTests, NetworkdMatchTests, NetworkdStateFileTests, NetworkdTCTests and WaitOnlineTests pass, and TEST-75-RESOLVED passes. NetworkdDHCPPDTests.test_dhcp4_6rd gave an error once on Linux. It passed in the earlier Linux run of the table in networkd.md.

The full gate did not run.

An IPv4 route takes the paths of RTA_MULTIPATH with the checks of fib_get_nhs and fib_check_nh, and a weight for each path. The dump shows them, and RTM_DELROUTE matches them as fib_nh_match. A device that goes down marks its paths dead. An IPv6 route with RTA_MULTIPATH makes a route for each path, and these routes are siblings, as ip6_route_multipath_add. The dump and the notifications show the siblings in one RTA_MULTIPATH. An IPv6 path whose device goes down stays, dead, while another path is alive, as fib6_ifdown. A flow takes a path by a hash and the weights.
@tamnd tamnd added kind/feature New behavior or a new part. area/net Networking: sockets, TCP, netlink and netfilter. labels Nov 23, 2026
@tamnd
tamnd merged commit a2fd0a3 into main Nov 23, 2026
6 of 7 checks passed
@tamnd
tamnd deleted the nwd-mp branch November 23, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/net Networking: sockets, TCP, netlink and netfilter. kind/feature New behavior or a new part.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant