🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25406

[PATCH net-next v3 01/13] ipv6: allocate the exception entry before removing the one it replaces

#25406
From: David Ahern
Date: Tue, 01 Dec 2026 17:40
67 lines
9801 bytes
From: David Ahern <dahern@nvidia.com>

rt6_insert_exception() unlinks the existing exception for a
destination before it allocates, with GFP_ATOMIC, the table entry for
its replacement. If that allocation fails, what was learned (a
reduced PMTU or a redirect gateway) is already gone and the caller gets
-ENOMEM, so traffic falls back to the route's own MTU and gateway.

Allocate the entry first. If that fails nothing has been touched and
the exception stays as it was.

Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache")
Signed-off-by: David Ahern <dahern@nvidia.com>
---
 net/ipv6/route.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index df843178e5ec..c41c5ca23fe1 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1721,8 +1721,8 @@ static int rt6_insert_exception(struct rt6_info *nrt,
 	struct net *net = dev_net(nrt->dst.dev);
 	struct rt6_exception_bucket *bucket;
 	struct fib6_info *f6i = res->f6i;
+	struct rt6_exception *rt6_ex, *new_ex;
 	struct in6_addr *src_key = NULL;
-	struct rt6_exception *rt6_ex;
 	struct fib6_nh *nh = res->nh;
 	int max_depth;
 	int err = 0;
@@ -1765,19 +1765,24 @@ static int rt6_insert_exception(struct rt6_info *nrt,
 		goto out;
 	}
 
+	/* Allocate the new entry before the one it replaces is touched, so
+	 * that running out of memory leaves what was learned in place.
+	 */
+	new_ex = kzalloc_obj(*new_ex, GFP_ATOMIC);
+	if (!new_ex) {
+		err = -ENOMEM;
+		goto out;
+	}
+
+	new_ex->rt6i = nrt;
+	new_ex->stamp = jiffies;
+
 	rt6_ex = __rt6_find_exception_spinlock(&bucket, &nrt->rt6i_dst.addr,
 					       src_key);
 	if (rt6_ex)
 		rt6_remove_exception(bucket, rt6_ex);
 
-	rt6_ex = kzalloc_obj(*rt6_ex, GFP_ATOMIC);
-	if (!rt6_ex) {
-		err = -ENOMEM;
-		goto out;
-	}
-	rt6_ex->rt6i = nrt;
-	rt6_ex->stamp = jiffies;
-	hlist_add_head_rcu(&rt6_ex->hlist, &bucket->chain);
+	hlist_add_head_rcu(&new_ex->hlist, &bucket->chain);
 	bucket->depth++;
 	rt6_exception_net(nrt)->ipv6.rt6_stats->fib_rt_cache++;
 
-- 
2.54.0 (Apple Git-157)
Technical Details
Message-ID: <20261201174021.7211-2-dsahern@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375253-linux-kernel-netdev=dewy.ru
References: <20261201174021.7211-1-dsahern@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375253-linux-kernel-netdev=dewy.ru
From: dsahern@kernel.org (David Ahern)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v3 01/13] ipv6: allocate the exception entry before removing the one it replaces
Date: Tue,  1 Dec 2026 10:40:02 -0700
Organization: Usenet Network
Message-ID: <20261201174021.7211-2-dsahern@kernel.org>
References: <20261201174021.7211-1-dsahern@kernel.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1781555"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:pvpOiJ8OyCt6/BYfP1vDDurAV8w= sha256:ypZ9t2gu75dS5sohfXv9Vkye1u1sbutk0pQovnM3tb8=
	sha1:02VPea/n8+bjoGQEdYuy3puKnC8= sha256:F7c91ELyTE3U41W/e5g7QZ69Tt7mqHQkkaQ2ruArr9Q=
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 AC9E0117408; Tue,  1 Dec 2026 20:49:58 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, 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 P-i1HAl96Cyz;
	Tue,  1 Dec 2026 20:49:56 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-375253-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 9DAF811744A; Tue,  1 Dec 2026 20:49:47 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 6616B23642; Tue,  1 Dec 2026 17:41:03 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796146859;
	b=wBu6dO9TCjkHqzzETyNGY/a/MVZ6l43jvWQE5wboNx2QJL1OJ+fbhhz8NsIBaueD3waL
	 T4TrWo2eWIo65AHDp9p6GLK+waJOPWgLvUKK6uK/fHYPTw3/Buk5XeSKJJduXUbnfpF5v
	 tGRnO6/F/uuZqutAXq39x31HApOGgPubyOJVf8zqLwq9cpUW3r0WJf+G8NL6FpdaO6znB
	 WT1TRkLOAQPm0Qk27OkqvP5IZaqDWnQ5TB8/bYDAPhUNjDfrTY40EYMvwMC21K3O2rYAn
	 fB3q3p5RsDLOUc0PUaiF8PsKlpI377aj8U12spfsNPyC8pDEcN2ZfsdTXvNgSvQQBwQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796146859;
	h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding;
	bh=tmgJbiib1733cChyg+mnRX5/0bst+si1D86Nhl6hA/Q=;
	b=cFUZp24otEshnfAT4IRTMxcxTL8UJD7Ro0rxXcvrtkNX+0qW2bzYVUQteiQb8MxRAy6N
	 PqPsciN84/RDWQqkgzdP+tlcEtB/45xwvQ2gZtEYERxH+uzyvJHX197hlD2FAey1ulLHv
	 19mk51O/wgxvh3paLJ8kAPXvEbPGd3JcaC/GQxCt9QEqIYrZN4HG0WMl/vwPDO73yNZ/I
	 HNePXXrjC0HC+nUCGFe+uXm1H/xPdj+VTsqWjTlWm+sV6QF7VfvtSv4g+xbJZW4qEAY0G
	 C6z3vwB3zNMvbkmXIimUIuxzCBIQU1yO9k/My3hvnUyuregODzZw2U310daMWcJtnwA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bR6U3KAL;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D2E7606A33B;
	Tue,  1 Dec 2026 17:40:59 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bR6U3KAL
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796146858;
	b=l9GuAmBMzEzpmgL/Ojk55RHbMDgzKj9WQVRlWTJ8BzGbej+W+B/Ed7D1NNp5xB7tbzkd
	 wo8Exo9+iUY8thQ4VvQcEsNBwM/ni5NS3VKgMkCortDC2zwi5GC26Gd27ErffziH1alMi
	 xfz8db4WMKxQF8BAiJQL0jOyirhOUeR5Jd6nGAZkCDceVyhFRiQLosEAqVu7H65ZCAk/1
	 XAYmXUeygyFvoUFrB7tPrMstLfTGkRoCrwed3FwS9TdLZtOtUW6Ic4XRKVQv1Ylx4XuQD
	 omL90h2n4Ko3AU/2IALRHNzCMhcZgSb58XjMaLKt1bBQU9x/LJfFUSaoPz+M8162lZQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796146858;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:MIME-Version:Content-Transfer-Encoding;
	bh=tmgJbiib1733cChyg+mnRX5/0bst+si1D86Nhl6hA/Q=;
	b=TopiO8xYDlKJS3ff1KNhBa0LXvD4YTuV/nxYiyg+lQ5XnO0ghTVFqMwvF7+QB/uIpks5
	 Pmp8XvhAfZ/Th6B30zuIT8zmeDmwnxpC5xeDcg5aywtm1UQVX+IPnlTDuMNnodDz0vTuI
	 Y9hMRDAUqyfHFTkIAtTCh/5FHzryvkjDvsrH5GNEFGM7x4Jis4xCHrkJ19j55r9U4R6rZ
	 RnQCdEkd1r2u/SdW5VQglxUEuLOr30u92oMqfbwsgoHxvInLapIThDyGClawpN7lVD0u0
	 H16r/FF3hiARJS0vhZQqbLMMZYWpSCgyVxAhL6pKU/6pvxGam9kUkM94FVIXDFhHe3g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bR6U3KAL;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C6E7606A329
	for <netdev@vger.kernel.org>; Tue,  1 Dec 2026 17:40:58 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E7171F0089A;
	Tue,  1 Dec 2026 17:40:57 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796146858;
	bh=tmgJbiib1733cChyg+mnRX5/0bst+si1D86Nhl6hA/Q=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=bR6U3KALNxyzb9IMbL0d6Jg1yKVymrtd4S31jHzy+2wMuAa119fUmaw7Mrff5aeuU
	 JN2NuWKDlpLbzmOoHgY2fNOu33pH8YeiIwFsmv1v8cEiZEJUesIFWcE9J/0s0JVYbN
	 N6b6q/A2XMweds6aXIJMFrIBfagMLnl/A7/GIvz+T5PcZd0RFquKYf7TC0x8Dws6Y1
	 LlpbfkzE0jEoMnF+7Sah/njGuqq0hO/+KT7gpfzn5gdDhF4nMKHEVMPfqpsYU4rX40
	 VajgmTCsX7NVyXhbbG9XZ71M1/lCDdZngv7lUaAWN6JjycFueu/FqaJz8jS/OzaGN3
	 HHFYNLF/SUx/g==
X-Cc: dsahern@kernel.org,
	idosch@nvidia.com,
	davem@davemloft.net,
	edumazet@kernel.org,
	kuba@kernel.org,
	pabeni@redhat.com,
	horms@kernel.org,
	ralf@mandelbit.com,
	ja@ssi.bg,
	David Ahern <dahern@nvidia.com>
X-Mailer: git-send-email 2.54.0
X-In-Reply-To: <20261201174021.7211-1-dsahern@kernel.org>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list