🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #4260

[PATCH net-next v5 2/2] net/rds: include the scope id in the sendmsg connection cache check

#4260
From: Allison Henderson
Date: Sat, 17 Oct 2026 03:23
48 lines
7369 bytes
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 <achender@kernel.org>
---
 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.50.1
Technical Details
Message-ID: <20261017032358.2563121-3-achender@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347677-linux-kernel-netdev=dewy.ru
References: <20261017032358.2563121-1-achender@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347677-linux-kernel-netdev=dewy.ru
From: achender@kernel.org (Allison Henderson)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v5 2/2] net/rds: include the scope id in the sendmsg connection cache check
Date: Fri, 16 Oct 2026 20:23:58 -0700
Organization: Usenet Network
Message-ID: <20261017032358.2563121-3-achender@kernel.org>
References: <20261017032358.2563121-1-achender@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2955380"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:6VNEJzAdfO9zCGRq/3/xLcgO05E= sha256:9Hxo8vZma4THe9/89q9/5xMT8xYfYQFS+Aobey2g6CM=
	sha1:ujprRQA6F0EGWKneUqLpJ9o17zY= sha256:U6+InYsNs5Z0MVR8owC5P5VKyrDksymA52I6Jz6MeI4=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 4475A110688; Sat, 17 Oct 2026 06:24:35 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.64
X-Spam-Status: No, score=-3.64 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 8AXb-O9yrKI6;
	Sat, 17 Oct 2026 06:24:33 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-347677-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id D127E110685; Sat, 17 Oct 2026 06:24:24 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by tor.lore.kernel.org (Postfix) with ESMTP id 69A6541C27; Sat, 17 Oct 2026 03:24:09 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 910923D171C;
	Sat, 17 Oct 2026 03:24:01 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="E+vYH/EP"
X-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 83AB83B3886;
	Sat, 17 Oct 2026 03:24:00 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1792207441; cv=none; b=qYpJwsT8E/xQhx9ydy3J+WvIhihT1t0OL2ZO6DQIZc6hmJQX6ojX/Alp+dnvP+YpFX4yWpDN7Lxlhv3pCdYfaNW4ZI022mN6nEaEnTqaHHEhWnML1968IlZBmnt3qW8sDhJrNRR3PzSN98xQjgNqUhW5PklVixCgqZ5Xh9BZdJo=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1792207441; c=relaxed/simple;
	bh=gUW6HFeSz4UjD7n74KkpqChg08y1FHM0uQ49Jh7frlE=;
	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
	 MIME-Version; b=iMBuBQDNXnZWeusbqRHCTy9/tyqRup1aRP1wb7zCBrnB0I43KXNIXjyfsHqYVzzLnyZy0+0zFtAl1wT50LS1RwxEzkX5uH9tBr/1IWXLFqQOIQDiJzAfiiGEfCEPq1MOCYjRBVR0Aq//yTDWPtL4yjLQJHqs6iPq7hH6CWbzsh0=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=E+vYH/EP; arc=none smtp.client-ip=100.103.45.18
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B60571F000C7;
	Sat, 17 Oct 2026 03:23:59 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1792207440;
	bh=7wzQDZoqB11PrDEQ6TOh55IhA7crK6UbEChKQrk+cZM=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=E+vYH/EPodWvsLex3y7HfbY5NNHtlKgELpuhPvCWOfn9GwHb/yvVsQZKS79D6mI/i
	 JNz86+hXmr678vl1e+I4ajp9WbJwqu8OAtv+BCTlTE3hWBTCTJ7mkeKPOetd9H87hP
	 NbyStUdmVwQKS56IBf6TjNPVs1zCKFcaYTloFUDhIxCRU0AKMIiFyqPuCjED9nhtHN
	 DSb6n7xguTsTGSsPiNdmPq00z8XwXxprjYRDkceIICQpkJzlXobdWiETP/4ZUGOQTd
	 7QR9l9FKeZuELnwvJ0pG8R9gZsa4oLb4Fe4kFPdsfY17gbLtMzrLpjgZDiWJKz/dMS
	 rzuwkZkF1GgUA==
X-Cc: achender@kernel.org
X-Mailer: git-send-email 2.50.1
X-In-Reply-To: <20261017032358.2563121-1-achender@kernel.org>
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>