Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: tmenninger@everpuredata.com
Cc: leon@kernel.org, jgg@ziepe.ca, bharat@chelsio.com,
	dsahern@kernel.org, idosch@nvidia.com, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org, shuah@kernel.org, slingappa@everpuredata.com,
	rpatil@everpuredata.com, linux-rdma@vger.kernel.org,
	netdev@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/3] RDMA/core: Use the CM source port in IP route lookups
Date: Sat, 05 Dec 2026 00:37:31 +0000	[thread overview]
Message-ID: <179643105116.3146.11951961371618442363@kernel.org> (raw)
In-Reply-To: <20261203234720.2428689-4-tmenninger@everpuredata.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] This patch makes rdma_cm's nexthop choice depend on the
  connection.

--

RDMA/core: Use the CM source port in IP route lookups

This patch fills in fl4_sport and fl6_sport in addr4_resolve() and
addr6_resolve() from the source port that rdma_cm assigned. With an
L4-aware fib_multipath_hash_policy, rdma_cm connections to the same
destination then spread across the ECMP nexthops.

> diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
> index bdaa3eb83bccd..6b80cc2c84c88 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);

[Severity: Medium]
Can this lead the iWARP drivers to resolve the destination MAC of a
different nexthop than the one rdma_cm picked?

With this change, the nexthop chosen in addr4_resolve() and addr6_resolve()
depends on the CM port. That choice decides the egress netdev, the
src_dev_addr, the ib_device the cm_id binds to and the resolved source
address.

irdma and qedr then do their own route and neighbour lookup for the same
connection. They key it only on (saddr, daddr), with no ports and no oif:

drivers/infiniband/hw/irdma/cm.c:irdma_addr_resolve_neigh() {
    ...
	rt = ip_route_output(&init_net, dst_ipaddr, src_ipaddr, 0, 0,
			     RT_SCOPE_UNIVERSE);
    ...
}

drivers/infiniband/hw/irdma/cm.c:irdma_get_dst_ipv6() {
    ...
		dst = ip6_route_output(&init_net, NULL, &fl6);
    ...
}

qedr_addr4_resolve() and qedr_addr6_resolve() in qedr_iw_cm.c do the
same thing.

The neigh->ha from that second lookup is then written into the context of
the device that rdma_cm selected:

  - irdma_add_arp() stores it, and irdma_make_cm_node() copies it into
    cm_node->rem_mac.
  - qedr_iw_connect() resolves it into in_params.remote_mac_addr.

The CM now hashes on (saddr, daddr, sport), while the drivers hash on
(saddr, daddr, 0).

For IPv4 legacy multipath, fib_select_multipath() prefers the nexthop
whose nh_saddr matches fl4->saddr. So the driver lookup should still end
up on the CM's nexthop.

IPv4 nexthop-object groups skip that preference and select on the hash
alone:

net/ipv4/fib_semantics.c:fib_select_multipath() {
	...
	if (unlikely(res->fi->nh)) {
		nexthop_path_fib_result(res, hash);
		return;
	}
	...
}

IPv6 has no such preference either. fib6_select_path() selects only on
the value from rt6_multipath_hash().

In those cases, with hash policy 1 (or 3 with the source port field
selected), could the driver pick up the other path's gateway MAC? Or a
neighbour that hasn't been resolved, so irdma returns an error and qedr
programs a zero MAC? The QP would still transmit on the CM-selected port.

Before this patch both lookups were fixed per destination, so a
destination either always worked or always failed. Now a destination
that used to work might fail intermittently, depending on the CM port.

cxgb4 doesn't seem to be affected. cxgb_find_route() already hashes on
sport, dport and IPPROTO_TCP, and it checks cxgb_our_interface().

The commit message says:

    The normal RoCE CM route setup retains the selected interface and
    destination MAC.

Should it also cover the iWARP drivers that do their own L2 resolution?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203234720.2428689-1-tmenninger%40everpuredata.com

      reply	other threads:[~2026-12-05  0:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 23:47 [PATCH v2 0/3] Spread rdma_cm connections across ECMP paths Tim Menninger
2026-12-03 23:47 ` [PATCH v2 1/3] ipv6: Use the selected nexthop for source address selection Tim Menninger
2026-12-05  0:37   ` netdev-bot+sashiko
2026-12-03 23:47 ` [PATCH v2 2/3] selftests: fib_nexthops: Check the IPv6 multipath source address Tim Menninger
2026-12-05  0:37   ` netdev-bot+sashiko
2026-12-03 23:47 ` [PATCH v2 3/3] RDMA/core: Use the CM source port in IP route lookups Tim Menninger
2026-12-05  0:37   ` netdev-bot+sashiko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179643105116.3146.11951961371618442363@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=bharat@chelsio.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=jgg@ziepe.ca \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rpatil@everpuredata.com \
    --cc=shuah@kernel.org \
    --cc=slingappa@everpuredata.com \
    --cc=tmenninger@everpuredata.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox