[PATCH rdma-next v1 2/2] RDMA/cma: accept cross-NIC same-host local dst in validate_ipv6_net_dev

From: Alex Timofeyev

Date: Mon Jun 15 2026 - 13:48:38 EST


validate_ipv6_net_dev() confirms an incoming CM REQ was delivered on the
correct net_dev with an rt6_lookup() that requires
rt->rt6i_idev->dev == net_dev. For an IPv6 destination that is local to a
different netdev of the same host, the FIB resolves the lookup onto the
loopback netdev, so rt6i_idev->dev is lo regardless of which physical
netdev owns the listener address. The strict comparison then rejects the
REQ with -EHOSTUNREACH even though it was correctly delivered on net_dev.

Accept the request when the resolved route is RTF_LOCAL and net_dev itself
owns the address the listener was bound to (src_addr). This is the
receive-side counterpart to the cross-NIC same-host send-side fix in
addr_resolve_neigh().

Fixes: f887f2ac87c2 ("IB/cma: Validate routing of incoming requests")
Cc: stable@xxxxxxxxxxxxxxx
Cc: Parav Pandit <parav@xxxxxxxxxx>
Signed-off-by: Alex Timofeyev <sashka@xxxxxxxxx>
---
drivers/infiniband/core/cma.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 9480d1a51c11..872c57943362 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1635,7 +1635,20 @@ static bool validate_ipv6_net_dev(struct net_device *net_dev,
if (!rt)
return false;

- ret = rt->rt6i_idev->dev == net_dev;
+ if (rt->rt6i_idev->dev == net_dev) {
+ ret = true;
+ } else if (rt->rt6i_flags & RTF_LOCAL) {
+ /* For a destination that is local to another netdev of the same
+ * host, the FIB collapses the lookup onto the loopback netdev,
+ * so rt6i_idev->dev is not net_dev even though the request was
+ * correctly delivered on net_dev. Accept it when net_dev itself
+ * owns the address we were listening on.
+ */
+ ret = ipv6_chk_addr(dev_net(net_dev), &src_addr->sin6_addr,
+ net_dev, 1);
+ } else {
+ ret = false;
+ }
ip6_rt_put(rt);

return ret;
--
2.40.4