Spread rdma_cm connections across ECMP paths
Subsystems (5)
v2 cover Spread rdma_cm connections across ECMP paths
rdma_cm resolves routes with the flow's source port left zero, so every connection to one destination takes the same ECMP nexthop, even when the multipath hash includes L4 ports. On a client with two 400G ports and one NFS data server, that leaves one port idle and halves read throughput. Patch 3 fills in the CM source port for IPv4 and IPv6, as in v1.
Leon pointed out two problems with v1.
For a multipath nexthop group, IPv6 picks the source address for the group's first nexthop rather than the path the lookup selected, so RoCE address resolution can fail with -ENODEV. This already happens without the series whenever the hash picks another member, and v1 exposed it per connection. Patch 1 fixes it in IPv6 source address selection, matching IPv6 legacy multipath and IPv4 nexthop groups, and patch 2 adds a selftest for it.
Leon also reported that Chelsio iWARP can fail with -EHOSTUNREACH when its own route lookup picks a different adapter than rdma_cm. That already happens without this series, and as agreed on the v1 thread it will be handled separately, since none of us can test on Chelsio hardware.
Patches 1 and 2 also stand on their own.
Changes in v2:
- Add patches 1 and 2, the IPv6 source address fix and its selftest (Leon)
- Patch 3 commit message notes the dependency on patch 1 and adds the IPv6 results
v1: https://lore.kernel.org/all/[email protected]/
Shiva Lingappa (1):
RDMA/core: Use the CM source port in IP route lookups
Tim Menninger (2):
ipv6: Use the selected nexthop for source address selection
selftests: fib_nexthops: Check the IPv6 multipath source address
drivers/infiniband/core/addr.c | 2 ++ include/net/ip6_route.h | 9 ++++-- net/ipv6/ip6_output.c | 3 +- net/ipv6/route.c | 2 +- tools/testing/selftests/net/fib_nexthops.sh | 35 +++++++++++++++++++++ 5 files changed, 47 insertions(+), 4 deletions(-)
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
Signature · 1 line
2.53.0
PATCH v2 1/3 ipv6: Use the selected nexthop for source address selection
When a route uses a multipath nexthop group and has no preferred source, ip6_route_get_saddr() selects the source address for fib6_info_nh_dev(), which is the group's first nexthop. The lookup may have selected a different nexthop, so the source address can belong to another interface than the one the packet leaves through:
$ ip -6 route get fd00:ecb:eeee::1 ... via fe80::b2cf:eff:feaf:6eb6 dev ens6np0 src fd00:ecb::3 ...
where fd00:ecb::3 is assigned to ens3np0. IPv6 legacy multipath routes and IPv4 nexthop groups both select the source address for the chosen path. TCP and UDP can operate with a source address assigned to another interface, but RoCE address resolution requires a matching GID on the selected device, and rdma_cm address resolution fails with -ENODEV whenever the hash selects a nexthop other than the first.
Pass the dst to ip6_route_get_saddr() and, for a multipath nexthop group, select the source address for the device of the selected path. A configured preferred source still takes precedence, and routes without a multipath nexthop group are unchanged.
Tested on a host with two ConnectX-7 ports, an IPv6 route through a two-member nexthop group and hash policy 1, with rdma_cm resolving the address and route of 64 IDs per destination. Before this change, every ID failed for three destinations whose hash selected the second nexthop. After it, every ID resolved, with the source address on the egress port. A route with a preferred source on another interface kept that source, and local destinations resolved as before.
---
Changes in v2:
- New patch, replacing the addr6_resolve() fix proposed on v1
include/net/ip6_route.h | 9 +++++++-- net/ipv6/ip6_output.c | 3 ++- net/ipv6/route.c | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-)
include/net/ip6_route.h +7 -2
@@ -143,6 +143,7 @@ void rt6_age_exceptions(struct fib6_info *f6i, struct fib6_gc_args *gc_args, unsigned long now);static inline int ip6_route_get_saddr (struct net *net,struct fib6_info *f6i, +const struct dst_entry *dst,const struct in6_addr *daddr,unsigned int prefs,int l3mdev_index,struct in6_addr *saddr)
@@ -155,8 +156,12 @@ static inline int ip6_route_get_saddr(struct net *net, struct fib6_info *f6i,rcu_read_lock (); l3mdev =dev_get_by_index_rcu (net, l3mdev_index); -if (!f6i || !f6i->fib6_prefsrc.plen || l3mdev) - dev = f6i ?fib6_info_nh_dev (f6i) :NULL ; +if (!f6i || !f6i->fib6_prefsrc.plen || l3mdev) { +if (dst && f6i && f6i->nh &&nexthop_is_multipath (f6i->nh)) + dev =dst_dev_rcu (dst); +else + dev = f6i ?fib6_info_nh_dev (f6i) :NULL ; + } same_vrf = !l3mdev ||l3mdev_master_dev_rcu (dev) == l3mdev;if (f6i && f6i->fib6_prefsrc.plen && same_vrf) *saddr = f6i->fib6_prefsrc.addr;
net/ipv6/ip6_output.c +2 -1
@@ -1162,7 +1162,8 @@ static int ip6_dst_lookup_tail(struct net *net, const struct sock *sk,rcu_read_lock (); from = rt ?rcu_dereference (rt->from) :NULL ; - err =ip6_route_get_saddr (net, from, &fl6->daddr, + err =ip6_route_get_saddr (net, from, rt ? &rt->dst :NULL , + &fl6->daddr, sk ?READ_ONCE (inet6_sk (sk)->srcprefs) :0 , fl6->flowi6_l3mdev, &fl6->saddr);
net/ipv6/route.c +1 -1
@@ -5881,7 +5881,7 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb, goto nla_put_failure; }else if (dest) {struct in6_addr saddr_buf; -if (ip6_route_get_saddr (net, rt, dest,0 ,0 , &saddr_buf) ==0 && +if (ip6_route_get_saddr (net, rt, dst, dest,0 ,0 , &saddr_buf) ==0 &&nla_put_in6_addr (skb,RTA_PREFSRC , &saddr_buf)) goto nla_put_failure; }
Signature · 1 line
2.53.0
PATCH v2 2/3 selftests: fib_nexthops: Check the IPv6 multipath source address
In reply to Tim MenningerExtend ipv6_mpath_select to check that, for a destination hashed to each member of a multipath nexthop group, the reported source address belongs to the device of the selected nexthop. Without "ipv6: Use the selected nexthop for source address selection", the source address always comes from the first nexthop's device and the check fails for the other member.
---
Changes in v2:
- New patch
tools/testing/selftests/net/fib_nexthops.sh | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+)
tools/testing/selftests/net/fib_nexthops.sh +35 -0
@@ -387,6 +387,16 @@ get_route_dev() fi } +get_route_prefsrc() +{ + local pfx="$1" + local out + + if out=$($IP -j route get "$pfx" | jq -re ".[0].prefsrc"); then + echo "$out" + fi +} + check_route_dev() { local pfx="$1"
@@ -867,6 +877,31 @@ ipv6_mpath_select() done log_test $rc 0 "Use valid neighbor during multipath selection" + # The source address must belong to the selected nexthop's device, + # not the device of the group's first nexthop. + local -A srcs + srcs=([veth1]=2001:db8:91::1 [veth3]=2001:db8:92::1) + rc=0 + for dev in veth1 veth3; do + match=0 + for h in {1..65535}; do + addr=$(printf "2001:db8:101::%x" $h) + if [ "$(get_route_dev "$addr")" = "$dev" ]; then + match=1 + break + fi + done + if (( match == 0 )); then + echo "SKIP: Did not find a route using device $dev" + return $ksft_skip + fi + if ! check_output "$(get_route_prefsrc "$addr")" "${srcs[$dev]}"; then + rc=1 + break + fi + done + log_test $rc 0 "Source address of selected multipath nexthop" + run_cmd "$IP neigh add 2001:db8:91::2 dev veth1 nud incomplete" run_cmd "$IP neigh add 2001:db8:92::2 dev veth3 nud incomplete" run_cmd "$IP route get 2001:db8:101::1"
Signature · 1 line
2.53.0
PATCH v2 3/3 RDMA/core: Use the CM source port in IP route lookups
In reply to Tim MenningerFrom: Shiva Lingappa <[email protected]>
addr4_resolve() and addr6_resolve() leave the flow's source port zero. With wildcard source addresses and identical routing constraints, connections to the same destination therefore select the same ECMP nexthop, even when fib_multipath_hash_policy includes L4 ports, leaving the other paths idle.
Populate fl4_sport/fl6_sport from the source sockaddr, which already contains the CM-assigned port. This provides per-connection entropy with hash policy 1, or policy 3 with the source-port field selected. The normal RoCE CM route setup retains the selected interface and destination MAC.
This is the CM port-space port, not the RoCEv2 UDP source port, so it does not reproduce downstream switch hashing. It also changes matching of source-port FIB rules without an ipproto restriction, independently of the hash policy. Policies excluding the source port retain the same multipath hash.
Tested over IPv4 with an NFSv4.1 flexfiles client (nconnect=16), one data server, two-way ECMP over two 400G ConnectX-7 ports, hash policy 1 and default FIB rules. All 16 connections used one device without the change. With the change, connections used both devices on every tested mount. elbencho 1 MiB direct-read throughput increased from 46596 to 92726 MiB/s.
IPv6 relies on "ipv6: Use the selected nexthop for source address selection". Without it, IDs hashed to a nexthop group member other than the first fail address resolution. With both changes, address and route resolution of 64 rdma_cm IDs per destination over two-way IPv6 ECMP with hash policy 1 split between the devices on every run. A legacy multipath route went from 64/0 to between 30/34 and 33/31. Four destinations through a nexthop group, three of which failed for every ID before, split between 23/41 and 39/25 with no failures.
---
Changes in v2:
- Note the dependency on patch 1 for IPv6
- Add the IPv6 nexthop group results
v1: https://lore.kernel.org/all/[email protected]/
drivers/infiniband/core/addr.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/core/addr.c +2 -0
@@ -382,6 +382,7 @@ static int addr4_resolve(struct sockaddr *src_sock,memset (&fl4,0 ,sizeof (fl4)); fl4.daddr = dst_ip; fl4.saddr = src_ip; + fl4.fl4_sport = src_in->sin_port; fl4.flowi4_oif = addr->bound_dev_if; rt =ip_route_output_key (addr->net, &fl4); ret =PTR_ERR_OR_ZERO (rt);
@@ -411,6 +412,7 @@ static int addr6_resolve(struct sockaddr *src_sock,memset (&fl6,0 ,sizeof fl6); fl6.daddr = dst_in->sin6_addr; fl6.saddr = src_in->sin6_addr; + fl6.fl6_sport = src_in->sin6_port; fl6.flowi6_oif = addr->bound_dev_if; dst =ip6_dst_lookup_flow (addr->net,NULL , &fl6,NULL );
Signature · 1 line
2.53.0