🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #22829

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

#22829
From: David Ahern
Date: Thu, 26 Nov 2026 01:33
67 lines
9816 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 4a4c5ace63c5..6f0af090c606 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: <09f2c4510b77554f66cb3c56f8667a2d2864b959.1795642432.git.dahern@nvidia.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371784-linux-kernel-netdev=dewy.ru
References: <cover.1795642432.git.dahern@nvidia.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371784-linux-kernel-netdev=dewy.ru
From: dsahern@kernel.org (David Ahern)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v2 01/13] ipv6: allocate the exception entry before removing the one it replaces
Date: Wed, 25 Nov 2026 18:33:27 -0700
Organization: Usenet Network
Message-ID: <09f2c4510b77554f66cb3c56f8667a2d2864b959.1795642432.git.dahern@nvidia.com>
References: <cover.1795642432.git.dahern@nvidia.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="352733"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:7XjUPvgs9WWMtSmymZYvvW819k8= sha256:dw4wCPkZEJ8TxBLIo+BBn6qUt4qdVF4bYY9EsT8iQHk=
	sha1:VKAAaWdPrBv3HZIU7GgYg9LUGfY= sha256:J6VVnyixip37Qha6X0JdcXsQegDeodnyZlXyAt7C8g4=
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 BBBE7125EAF; Thu, 26 Nov 2026 04:34:04 +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 FzmSOPEEfYe9;
	Thu, 26 Nov 2026 04:34:01 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-371784-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 0A8E3125EAC; Thu, 26 Nov 2026 04:33:51 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id F2A0C30E90; Thu, 26 Nov 2026 01:33:48 +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=1795656828;
	b=bLCOxm2/PhR2QXwkSdyJERgLOuacjZYc/VQ3pPLPmlpNLDoF0D0y7DcZWIHYX2LJM5Pd
	 vLj2vQdVf850QCKP7JVGBgDGXCi75EtC+6pWSqt2vEpSYIupkeuUhyb5OFc6UgI0Cv/IX
	 dkuzj+mVDy6QKZP0Gf8e7umwcANooWucynFJLSfPO6rSbXYyTanny1jJalUEUWX6m5pc6
	 80L3l9Az2yNId7+2BTIG4JWMHdICfr10qUBtH84J9YBi+sz6G91xedCHYEPAiF5u+t/qY
	 hXVlm+nqy3c+/6y2uAAssmGDBb0xhHFMmhm8rVv0gc7L31DuJ4XYHrW057bU0O+AZ5w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795656828;
	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=j6q14PjSENriLgotTkkpQI/MJpCCd3LFrqljQq3PAKM=;
	b=44TFxzx7dJbmRZ+zazJpi9MJXHIBMl4aed7f2RiMwNK8OxjjLFUw5n3RkOH4SuJA9m25
	 LcT4S3eBm7gPRjdSmjYHFpQ6CddqNYhHNAKchG0sSlQnXosKCoUF3jBWdseDsvcgKFru4
	 xA9JJQrbUIflq+kDQoPuoJQM/tOAd4nWiWK8W0HAJ4kE5qxBnJnVbdy3H95Pz44JGO3uY
	 ZWbUBD0UPH3pAqdjRs1GLdEGdNSe16drhjQ5cIhvQY+zlvD57LqNSGlCfSs46hz3ISdZh
	 AMpaDuv9vkSaLRIhO78UojTDel1W1NatBQBYJSm8zEuJbWxdmZGzSFYqAJEFI19Qh4g==
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=UStI+Hwj;
	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 E3C98606A337;
	Thu, 26 Nov 2026 01:33:47 +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=UStI+Hwj
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=1795656827;
	b=o2OF7pFFIiTO4SwrzmTWGV3sNFefvdK3f4Bv1/NxqMpohqucXqFkTrt0keaWd0Lofqk7
	 ZA/GjcNqE7L/1854eYOXAHUtwHDw0pZpELy62IGDB2ar38lPqRaBIzR7LSyU3TcdRAuzm
	 ol3vbqH8Woe3V7bwOmcDcLEz1ABtEpKywcYkluXn1BFpSVUDoZxn50YAbOSdZ03oGhVWb
	 q3OTuE4/qz1JukSjPXoVe69yoCIUIIO1GakpuK/BaiD3mVv62kZX6cs/+pX+4lrz+ja+d
	 OrPfhPfH3w9EsIYoa1WYbVJwqxTQbOBKmznfAlDE0l2P1Z8pQL/NdDH5oWyCT7bJSRg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795656827;
	h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer:
	 In-Reply-To:References:MIME-Version:Content-Transfer-Encoding;
	bh=j6q14PjSENriLgotTkkpQI/MJpCCd3LFrqljQq3PAKM=;
	b=l5OlNJWRpQsAtoD/bU6asjEEKNGXKflMYYZYvSh1TG0RQTqxBYrB7DuE2wNpTQLZ72g5
	 DFNxmLnfwzCzLdv6JntKwjTimXN7r7Ce8MuAcig6J+DUSIQHyWCabFRyTOyLe2tUC4mAW
	 UYLso0Bm1hj/FTfb8jfNobgUgNmaGfBtgCI5b3NBrcQpjJ5kDFE8y2l8jkipurHHNlub5
	 4CqxF6VlrjtrmalqDic0wC8tliuERPmRsr+UE7RPl6Gc2T1wRVmUydwUpJNFWUx1VQ+Gz
	 FglWSm0KmoCaTgtfhPPsoXMdMKC6rSnVPWqMn+TLwpzCzGAv8rLz9iksjAykKUnjxFQ==
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=UStI+Hwj;
	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 0F5E2606A32A
	for <netdev@vger.kernel.org>; Thu, 26 Nov 2026 01:33:47 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 592BE1F000CA;
	Thu, 26 Nov 2026 01:33:46 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795656826;
	bh=j6q14PjSENriLgotTkkpQI/MJpCCd3LFrqljQq3PAKM=;
	h=From:To:Cc:Subject:Date:In-Reply-To:References;
	b=UStI+Hwjv4QqTUZuDEtxDu9IzseOBoAZA+rc88BYRGj0Co+MfsW/2dBSwaEnh7T4l
	 wWPYqQVjvLauFcLQsc/W0FZw8fyOQwtJA7T27taJM7mHToiS0kjb9QoiqrW9MAv10o
	 NLBHF8tPItuZbjC1l0CxQ7JFPZwQCjxGa71n6YYn1fSAzakUxhDvSFTURn4g/Zh/5+
	 E8FgndwtMff7P+3mOkbVWGWha4kCMi+0fFpNKrqxV55jzYKEIY50Ksy3d8uupLEEfu
	 zT9d2NClauzjd2HPI7pomEOd6WsON9P0zCHj4At9WxWWuhvObPExx9Ns65I9lJrzBK
	 D4KARYe7ZqZNw==
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: <cover.1795642432.git.dahern@nvidia.com>
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