From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2C533A9870; Thu, 8 Oct 2026 03:14:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791429269; cv=none; b=JPGmTs9oGHalRp/9bAfV+0u+kRiW+v1SHr+poidJ+Toa58hw7f+Shkc0c2ovakRWBF1pZzY7MS8DqnJy7nsFtspd5DiKR2nNG3yFAO+MxGAYxanjHc6KFbaUST8Q/HWIYo0G1lzGfyrT8axwtHlKUFW2qKFClMEs8zcKZ0omx04= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791429269; c=relaxed/simple; bh=V4g5JWra+C0sHiheecK+EUE34GgDq/3cizLddLUGlls=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OKnsC8y4Agw0+FGIlyUeoTN4Rkp3rzCClzGy20Ld32Pv/TbTCmVB1BpJuQjex1/d+tTNyq4Piw1k0hcgY/TNErzjRYFPMapo7LaCkucf1jZJCjYNoeAume5R29mkGlcTEWPVENJUxcIota14+pGDOXLiM9gL4QX+w4NI/AuAfhA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IA3aGvZ4; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IA3aGvZ4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F9531F00898; Thu, 8 Oct 2026 03:14:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1791429268; bh=+d9E3uD8bYJdhV0ovkNhfQN4UmktMMHdbPG90A1E9xA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IA3aGvZ4iw+BHUUNVHCLwp2Gi0gCLpWi/2Y0Yy5M/vd4zUr8gGXuXx7/c0OaER+sV ErKc8RjOmd/h3CHpcEj1LQ3ee2s7tJP58kBfOr+bVgT83hbG2vMArtV4nBSd1R8Xvq tEoxrnnzM7BS8R79TGfo+SavVwXvy0NY9Kz+RiUOYhSQOxai/KgxlvAmbgFxfgtLTB iLg08iKw+9gEgWdcIrdoxB04E13Ns2JK+aab2e2S1Uut0dRZWHrfJKo8lVMAzTLG2M Se7YCjqzt2ovXWOcSLK/0kko9RMvr7gskyeh23ik/2kosqAIGTN1xGke6JUbTdCnPQ fwhngIF+vdguw== From: Allison Henderson To: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, pabeni@redhat.com, edumazet@google.com, kuba@kernel.org, horms@kernel.org Cc: achender@kernel.org Subject: [PATCH net v4 2/2] net/rds: include the scope id in the sendmsg connection cache check Date: Wed, 7 Oct 2026 20:14:26 -0700 Message-Id: <20261008031426.1142344-3-achender@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261008031426.1142344-1-achender@kernel.org> References: <20261008031426.1142344-1-achender@kernel.org> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit rds_sendmsg() reuses the connection cached in rs->rs_conn when its peer address and ToS match the request. The interface index is part of a connection's identity as well: rds_conn_create_outgoing() passes the request's scope_id down as dev_if, and rds_conn_lookup() compares c_dev_if, so sends to the same link-local address through two interfaces are two different connections. The cache-hit test never looked at it. A socket bound to a non-link-local address has rs_bound_scope_id 0, and the scope check at the top of rds_sendmsg() accepts any non-zero destination scope for such a socket. So after a send to fe80::x%ifA, a send to fe80::x%ifB hits the cached ifA connection and the datagram leaves through ifA, to whichever peer answers to that address there. Compare c_dev_if with the request's scope_id in the cache test, so that such a send takes the lookup path and finds, or creates, the ifB connection - the same key the lookup uses. With the previous patch a send without a destination carries the connected peer's scope, or the bound scope for a non-link-local peer, which is what an explicit send to that peer computes, so the comparison is exact for it too. Found by inspection while reworking this cache for the connection lifetime series on net-next; not observed in the field. Fixes: 1e2b44e78eea ("rds: Enable RDS IPv6 support") Assisted-by: Claude-Code:claude-fable-5 Signed-off-by: Allison Henderson --- net/rds/send.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/rds/send.c b/net/rds/send.c index 7b525a6f7eac..f38967f65af1 100644 --- a/net/rds/send.c +++ b/net/rds/send.c @@ -1346,7 +1346,8 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len) /* rds_conn_create has a spinlock that runs with IRQ off. * Caching the conn in the socket helps a lot. */ if (rs->rs_conn && ipv6_addr_equal(&rs->rs_conn->c_faddr, &daddr) && - rs->rs_tos == rs->rs_conn->c_tos) { + rs->rs_tos == rs->rs_conn->c_tos && + rs->rs_conn->c_dev_if == scope_id) { conn = rs->rs_conn; } else { conn = rds_conn_create_outgoing(sock_net(sock->sk), -- 2.25.1