Netdev List
 help / color / mirror / Atom feed
* [PATCH] RDMA/core: Use the CM source port in IP route lookups
@ 2026-11-30 19:36 Tim Menninger
  2026-12-02 11:18 ` Leon Romanovsky
  0 siblings, 1 reply; 6+ messages in thread
From: Tim Menninger @ 2026-11-30 19:36 UTC (permalink / raw)
  To: Jason Gunthorpe, Leon Romanovsky
  Cc: linux-rdma, netdev, David Ahern, Ido Schimmel, Shiva Lingappa,
	Rohit Patil

From: Shiva Lingappa <slingappa@everpuredata.com>

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 address resolution was checked by resolving 64 rdma_cm IDs to one
destination over a two-way IPv6 ECMP route with hash policy 1. Device
selection changed from 64/0 IDs before this change to 31/33 after.

Reported-by: Rohit Patil <rpatil@everpuredata.com>
Signed-off-by: Shiva Lingappa <slingappa@everpuredata.com>
Co-developed-by: Tim Menninger <tmenninger@everpuredata.com>
Signed-off-by: Tim Menninger <tmenninger@everpuredata.com>
---
NOTE: Rohit's report was internal, so no public report URL is available.

 drivers/infiniband/core/addr.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index bdaa3eb83bcc..6b80cc2c84c8 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -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);
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] RDMA/core: Use the CM source port in IP route lookups
  2026-11-30 19:36 [PATCH] RDMA/core: Use the CM source port in IP route lookups Tim Menninger
@ 2026-12-02 11:18 ` Leon Romanovsky
  2026-12-02 14:43   ` tmenninger
  0 siblings, 1 reply; 6+ messages in thread
From: Leon Romanovsky @ 2026-12-02 11:18 UTC (permalink / raw)
  To: Tim Menninger
  Cc: Jason Gunthorpe, linux-rdma, netdev, David Ahern, Ido Schimmel,
	Shiva Lingappa, Rohit Patil

On Mon, Nov 30, 2026 at 07:36:48PM +0000, Tim Menninger wrote:
> From: Shiva Lingappa <slingappa@everpuredata.com>
> 
> 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 address resolution was checked by resolving 64 rdma_cm IDs to one
> destination over a two-way IPv6 ECMP route with hash policy 1. Device
> selection changed from 64/0 IDs before this change to 31/33 after.
> 
> Reported-by: Rohit Patil <rpatil@everpuredata.com>
> Signed-off-by: Shiva Lingappa <slingappa@everpuredata.com>
> Co-developed-by: Tim Menninger <tmenninger@everpuredata.com>
> Signed-off-by: Tim Menninger <tmenninger@everpuredata.com>
> ---
> NOTE: Rohit's report was internal, so no public report URL is available.
> 
>  drivers/infiniband/core/addr.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
> index bdaa3eb83bcc..6b80cc2c84c8 100644
> --- a/drivers/infiniband/core/addr.c
> +++ b/drivers/infiniband/core/addr.c
> @@ -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);

I asked AI to see if it breaks something and it claims that the commit broke
IPv6 RoCE address resolution on ECMP nexthop groups by selecting an outgoing
interface while using another interface’s source address. Chelsio is also 
broken with this change.

Thanks

> -- 
> 2.53.0
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] RDMA/core: Use the CM source port in IP route lookups
  2026-12-02 11:18 ` Leon Romanovsky
@ 2026-12-02 14:43   ` tmenninger
  2026-12-03 12:19     ` Leon Romanovsky
  0 siblings, 1 reply; 6+ messages in thread
From: tmenninger @ 2026-12-02 14:43 UTC (permalink / raw)
  To: leon
  Cc: dsahern, idosch, jgg, linux-rdma, netdev, rpatil, slingappa,
	tmenninger

> I asked AI to see if it breaks something and it claims that the commit broke
> IPv6 RoCE address resolution on ECMP nexthop groups by selecting an outgoing
> interface while using another interface’s source address. Chelsio is also 
> broken with this change.
> 
> Thanks

Hi Leon,

Thanks, I reproduced the IPv6 case. For a nexthop group, the source address
comes from the group's first member, not the selected path. That already
fails on v7.4-rc3 when the port-0 hash picks another member, and this patch
exposes it per connection. Would it be acceptable to fix that first in
addr6_resolve()? For a wildcard source only, when the chosen address isn't
on the egress device, it would pick one there with ipv6_dev_get_saddr().
That made every ID resolve in my testing.

I can also drop the fl6_sport change in v2, keeping this patch IPv4-only, and
send the IPv6 fix separately. IPv4 picks the source after the nexthop, so it
isn't affected.

For Chelsio, could you share a reproducer, including the address family
and whether the source address was bound? c4iw_connect() does its own
route lookup on the TCP 4-tuple, but rdma_cm's lookup still picks the
device, so I may be missing a case. I don't have Chelsio hardware to test.

Thanks,
Tim

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] RDMA/core: Use the CM source port in IP route lookups
  2026-12-02 14:43   ` tmenninger
@ 2026-12-03 12:19     ` Leon Romanovsky
  2026-12-03 15:17       ` Tim Menninger
  0 siblings, 1 reply; 6+ messages in thread
From: Leon Romanovsky @ 2026-12-03 12:19 UTC (permalink / raw)
  To: tmenninger; +Cc: dsahern, idosch, jgg, linux-rdma, netdev, rpatil, slingappa

On Wed, Dec 02, 2026 at 02:43:42PM +0000, tmenninger@everpuredata.com wrote:
> > I asked AI to see if it breaks something and it claims that the commit broke
> > IPv6 RoCE address resolution on ECMP nexthop groups by selecting an outgoing
> > interface while using another interface’s source address. Chelsio is also 
> > broken with this change.
> > 
> > Thanks
> 
> Hi Leon,
> 
> Thanks, I reproduced the IPv6 case. For a nexthop group, the source address
> comes from the group's first member, not the selected path. That already
> fails on v7.4-rc3 when the port-0 hash picks another member, and this patch
> exposes it per connection. Would it be acceptable to fix that first in
> addr6_resolve()? For a wildcard source only, when the chosen address isn't
> on the egress device, it would pick one there with ipv6_dev_get_saddr().
> That made every ID resolve in my testing.
> 
> I can also drop the fl6_sport change in v2, keeping this patch IPv4-only, and
> send the IPv6 fix separately. IPv4 picks the source after the nexthop, so it
> isn't affected.

It would be good for the IPv4 and IPv6 paths to behave consistently. Please
send all fixes together.

> 
> For Chelsio, could you share a reproducer, including the address family
> and whether the source address was bound? c4iw_connect() does its own
> route lookup on the TCP 4-tuple, but rdma_cm's lookup still picks the
> device, so I may be missing a case. I don't have Chelsio hardware to test.

I don't have either.
---- from AI :
Chelsio IPv6 iWARP has a separate connect-time failure path. With two separate adapters,
CM can select one adapter using the source port. cxgb_find_route6() repeats the lookup
with port zero and rejects an egress belonging to the other adapter. c4iw_connect()
then returns -EHOSTUNREACH. I reproduced the routing mismatch in a network namespace
and verified the error path in source. A hardware connect test remains outstanding
-----------

> 
> Thanks,
> Tim
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] RDMA/core: Use the CM source port in IP route lookups
  2026-12-03 12:19     ` Leon Romanovsky
@ 2026-12-03 15:17       ` Tim Menninger
  2026-12-03 20:10         ` Leon Romanovsky
  0 siblings, 1 reply; 6+ messages in thread
From: Tim Menninger @ 2026-12-03 15:17 UTC (permalink / raw)
  To: leon; +Cc: bharat, jgg, linux-rdma, netdev, dsahern, idosch, slingappa,
	rpatil

Hi Leon,

> I don't have either.
> ---- from AI :
> Chelsio IPv6 iWARP has a separate connect-time failure path. With two separate adapters,
> CM can select one adapter using the source port. cxgb_find_route6() repeats the lookup
> with port zero and rejects an egress belonging to the other adapter. c4iw_connect()
> then returns -EHOSTUNREACH. I reproduced the routing mismatch in a network namespace
> and verified the error path in source. A hardware connect test remains outstanding
> -----------

I looked into the Chelsio mismatch further, and it is a pre-existing
issue rather than something specific to the source-port change.
Replaying both lookups with "ip route get" over two-way ECMP, treating
each port as a separate adapter, the IPv4 lookups disagreed for 93 of
200 connections before the change and 97 of 200 after. The IPv6 lookups
were all or nothing per destination before, with some destinations
disagreeing for every connection, and the source port makes it per
connection. So I understand the regression concern for IPv6.

I have a candidate fix that retries the lookup restricted to the
adapter's own ports, but it raises questions around policy routing, VLAN
interfaces and the iSCSI target, which shares the libcxgb helpers. I
also don't have Chelsio hardware to test it.

Would you be open to handling the Chelsio lookup separately? If so, I'll
send v2 with the IPv6 source address fix, a selftest for it and the
source port change.

Adding Bharat for the Chelsio side.

Thanks,
Tim

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] RDMA/core: Use the CM source port in IP route lookups
  2026-12-03 15:17       ` Tim Menninger
@ 2026-12-03 20:10         ` Leon Romanovsky
  0 siblings, 0 replies; 6+ messages in thread
From: Leon Romanovsky @ 2026-12-03 20:10 UTC (permalink / raw)
  To: Tim Menninger
  Cc: bharat, jgg, linux-rdma, netdev, dsahern, idosch, slingappa,
	rpatil

On Thu, Dec 03, 2026 at 03:17:04PM +0000, Tim Menninger wrote:
> Hi Leon,
> 
> > I don't have either.
> > ---- from AI :
> > Chelsio IPv6 iWARP has a separate connect-time failure path. With two separate adapters,
> > CM can select one adapter using the source port. cxgb_find_route6() repeats the lookup
> > with port zero and rejects an egress belonging to the other adapter. c4iw_connect()
> > then returns -EHOSTUNREACH. I reproduced the routing mismatch in a network namespace
> > and verified the error path in source. A hardware connect test remains outstanding
> > -----------
> 
> I looked into the Chelsio mismatch further, and it is a pre-existing
> issue rather than something specific to the source-port change.
> Replaying both lookups with "ip route get" over two-way ECMP, treating
> each port as a separate adapter, the IPv4 lookups disagreed for 93 of
> 200 connections before the change and 97 of 200 after. The IPv6 lookups
> were all or nothing per destination before, with some destinations
> disagreeing for every connection, and the source port makes it per
> connection. So I understand the regression concern for IPv6.
> 
> I have a candidate fix that retries the lookup restricted to the
> adapter's own ports, but it raises questions around policy routing, VLAN
> interfaces and the iSCSI target, which shares the libcxgb helpers. I
> also don't have Chelsio hardware to test it.
> 
> Would you be open to handling the Chelsio lookup separately? If so, I'll
> send v2 with the IPv6 source address fix, a selftest for it and the
> source port change.

Yes, let's handle Chelsio separately, since none of us can test it.

Thanks

> 
> Adding Bharat for the Chelsio side.
> 
> Thanks,
> Tim
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-12-03 20:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 19:36 [PATCH] RDMA/core: Use the CM source port in IP route lookups Tim Menninger
2026-12-02 11:18 ` Leon Romanovsky
2026-12-02 14:43   ` tmenninger
2026-12-03 12:19     ` Leon Romanovsky
2026-12-03 15:17       ` Tim Menninger
2026-12-03 20:10         ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox