🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #16890

[PATCH net-next v3 2/2] ipv6: preserve ip6mr_get_route() error in rt6_fill_node()

#16890
From: Wenbo Sun
Date: Mon, 16 Nov 2026 01:47
71 lines
11234 bytes
In rt6_fill_node(), when ip6mr_get_route() fails with a negative error
(for example -ENODEV, -ENOENT, -ENOMEM, or -ENOBUFS), the error path
currently jumps to nla_put_failure and unconditionally returns -EMSGSIZE
("RTNETLINK answers: Message too long").

Among all callers of rt6_fill_node(), only inet6_rtm_getroute() passes
a non-zero input interface (RTA_IIF) and propagates negative errors back
to userspace. Keeping -EMSGSIZE as the default return value for
attribute put failures while preserving the negative error returned by
ip6mr_get_route() lets userspace see the actual failure reason when
multicast forwarding is enabled.

This issue was pointed out during code review of rt6_fill_node() by
Hangbin Liu, confirmed on a UML kernel with MRT6_INIT enabled (where
querying a routable multicast route with an input interface reported
"Message too long" despite the failure in ip6mr_get_route() being
-ENODEV), and verified after the patch that it returns -ENODEV ("No such
device") instead while other rt6_fill_node() paths behave unchanged.

Built with W=1 on UML, x86_64 allmodconfig, and x86_64 allyesconfig with
zero new warnings or errors.

Suggested-by: Hangbin Liu <liuhangbin@kylinos.cn>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Signed-off-by: Wenbo Sun <sunwenbo@cmss.chinamobile.com>
---
 net/ipv6/route.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 27597d149672..d59aa9272a44 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -5814,6 +5814,7 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
 	struct nlmsghdr *nlh;
 	struct rtmsg *rtm;
 	long expires = 0;
+	int err = -EMSGSIZE;
 
 	nlh = nlmsg_put(skb, portid, seq, type, sizeof(*rtm), flags);
 	if (!nlh)
@@ -5874,12 +5875,14 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
 		    !(ipv6_addr_type(mc_dst) &
 		      (IPV6_ADDR_LOOPBACK | IPV6_ADDR_LINKLOCAL)) &&
 		    atomic_read(&net->ipv6.devconf_all->mc_forwarding)) {
-			int err = ip6mr_get_route(net, skb, rtm, portid);
+			int ret = ip6mr_get_route(net, skb, rtm, portid);
 
-			if (err == 0)
+			if (ret == 0)
 				return 0;
-			if (err < 0)
+			if (ret < 0) {
+				err = ret;
 				goto nla_put_failure;
+			}
 		} else
 #endif
 			if (nla_put_u32(skb, RTA_IIF, iif))
@@ -6002,7 +6005,7 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
 
 nla_put_failure:
 	nlmsg_cancel(skb, nlh);
-	return -EMSGSIZE;
+	return err;
 }
 
 static int fib6_info_nh_uses_dev(struct fib6_nh *nh, void *arg)
-- 
2.33.0
Technical Details
Message-ID: <20261116014744.18223-3-sunwenbo@cmss.chinamobile.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363980-linux-kernel-netdev=dewy.ru
References: <20261116014744.18223-1-sunwenbo@cmss.chinamobile.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363980-linux-kernel-netdev=dewy.ru
From: sunwenbo@cmss.chinamobile.com (Wenbo Sun)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v3 2/2] ipv6: preserve ip6mr_get_route() error in rt6_fill_node()
Date: Mon, 16 Nov 2026 09:47:44 +0800
Organization: Usenet Network
Message-ID: <20261116014744.18223-3-sunwenbo@cmss.chinamobile.com>
References: <20261116014744.18223-1-sunwenbo@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1953727"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:+towWPnlR1YsppmCEEFsqP9wBw0= sha256:Ja9re/08477qf5HI31PpSloehKPZ5tZ/A6w90K0FcJc=
	sha1:U5zs6On3v7VJhPs5TI7LavlN6xA= sha256:1+iBmreGIk33upA49mmokQ8wuU5yRbC++AMGda2zsEg=
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 85639114913; Mon, 16 Nov 2026 04:48:27 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.75
X-Spam-Status: No, score=-2.75 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_INVALID=0.1, DKIM_SIGNED=0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=fail (1024-bit key)
	reason="fail (body has been altered)" header.d=cmss.chinamobile.com
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 90W1X-l9LsTa;
	Mon, 16 Nov 2026 04:48:24 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-363980-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=cmss.chinamobile.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 55576114ACC; Mon, 16 Nov 2026 04:48:15 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 6A2152AF89; Mon, 16 Nov 2026 01:48:07 +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=1794793687;
	b=mQtVXIfx/13BzglVWMozRQySFFZGb9IyvhGrw+RJENIialn3yOizI4DUFH+0gQl4FAk4
	 x7q3k+5ElvzhdkYJv47l/VaOTm0Dww7pbwnv4g4fY1jsURMxEl4tWtxPXxVPSV5j6bwsh
	 8NLtCudy9YUGPTVa9NsHCFUPg6Cplx07I8nUpT3tKS8oSx1hYK8FkXJpXoSSk7B39uIM1
	 3+Y8QimWbOJ+5H1AtkXCh9mvDYOV5cgTLhoWiDFuSWEjpnUAP+cE44/eKEjxxk1Du2mb3
	 05UlQwsYipoKEPbGI4IbAwWpy6Qn0T4T0IYH+NPfcYGAOdB2rkgK7pORLMvCZj8Ri7w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794793687;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:X-RM-TagInfo:
	 X-RM-SPAM-FLAG:Received:X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:
	 Received:X-RM-TRANSID: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=SmMEGUJ3TmY5ehawL87dzihwEU8REbIyAh3hfr0asIM=;
	b=z5Q2MPnKbUrgpJ1M6c2kuV3XQ2KaS2FGHtzLA7Mh4fHRwR6ZzEvuovmbuaWHmm/Tmz+B
	 G//4+U7lvIPLdCVDMVCYGtrUMtDcZL6Ulx8l4R2S+w/+M/o5eOr1Jr2cHcWB9GEFob2jS
	 P9fazbxY9h2AGo308kBBBpsCN5W6dqORM6BI6zIfh77ZANxTPqy1SvjzcS0tGNsNM9kcT
	 q5TqGFOxPcSDwpkEZc3Zr1ycI9UIfehWVDN2ScUOcyxVPAd1x4cB20C1rWFq4CL3wXh4n
	 dq02B6Dpr+kjSQG96lUuqnQfqeVLlu6ThITIVG68nqDZGuSGSIdNKq2uOi18+VGG0KA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=tGdMhjxn;
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	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 E69A4606A32C;
	Mon, 16 Nov 2026 01:48:06 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=tGdMhjxn
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.137
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794793686;
	b=XuvzPGtf3eh30TtiSBfVuRndHZQBRkZDpUmy2TtVeLLvEsZ/V57OPRTBc9MDQxy+yFoy
	 v7fGbiSNtQ1W6PfUuVk5kNl9uzyxx4uuW/ADa0IhZLbX2+iszZBaYNAEV4Y9sGz5t3fNx
	 f5gyugxxdaHS85YQlQeG6kY2u263KdWT1aU+IG9VjYBQvPH7YLjdO5jxdNavjDcAhH6mx
	 3+DruAbdjJ9Xq0FKnbw+vSfZju7f8HDn+FiuNZP6+97cfXmuERNPPRaNckk09GfU/Mbv2
	 afL71MIi+a+o5AYXqodW8r5Y28dvQaZuMYhziFwR8ie6XHzEQuA5Ayxxjrr2hSaDu9w==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794793686;
	h=DMARC-Filter:DKIM-Signature:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:
	 X-RM-TRANSID:X-RM-TagInfo:X-RM-SPAM-FLAG:Received:X-RM-TRANSID:From:
	 To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References:
	 MIME-Version:Content-Transfer-Encoding;
	bh=SmMEGUJ3TmY5ehawL87dzihwEU8REbIyAh3hfr0asIM=;
	b=X+Ve98yvKMDTMQ3gKpwrr09Iw6QKNMCwD5eqkkckKtSsGaij47L9KRyAUehb+ckpcX6p
	 tAKOUivkI/k/RT8/O21vRKBiqVpxQsI1wi+HvwCz1/wD81QSobJqaRrh4E680n/LOM5bZ
	 yCnBVf+hAnjQaq5QHP+mIj2E2ecC7vQUKm/5hBA/zOrn3PgXenFZwqHyxJtDTd5wRnPjz
	 gQOsaTm7bVq9vIqidzFVjlPqtlnSDXq0zDvVVTovETslTFNXlQrPne8r73BAfeg9Sa/2n
	 5FHN2gW69Br5FQ9vvySOo8cmzMiIGQm9WsnQW1oegpmmEVQbCD0puEpIqQTNfjSighA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=cmss.chinamobile.com;
	spf=pass smtp.mailfrom=cmss.chinamobile.com;
	dkim=pass header.d=cmss.chinamobile.com header.i=@cmss.chinamobile.com header.a=rsa-sha256 header.s=default header.b=tGdMhjxn;
	arc=none smtp.remote-ip=111.22.67.137
X-Received: from cmccmta4.chinamobile.com (cmccmta4.chinamobile.com [111.22.67.137])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 0057A606A321;
	Mon, 16 Nov 2026 01:48:04 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0057A606A321
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmss.chinamobile.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
	d=cmss.chinamobile.com; s=default; l=0;
	h=from:subject:message-id:to:cc:mime-version;
	bh=47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=;
	b=tGdMhjxnVgLWwoxU9tS6hZ/HgiNuzsHbxaqBoOMA+Czy6HBzl5auFw8zFadT/FqOSWHlIjXVs0IRv
	 qN6ookmK+outRRqXtvXCLgc0roZLlYzA6yoPLEh4L/zChPJaam14vq32OXIxvDWMYRahKOcNGUgZIY
	 R0JmowXfA8HULJS4=
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from spf.mail.chinamobile.com (unknown[10.188.0.87])
	by rmmx-syy-dmz-app08-12008 (RichMail) with SMTP id 2ee86afa60d366d-99adc;
	Mon, 16 Nov 2026 09:48:04 +0800 (CST)
X-RM-TRANSID: 2ee86afa60d366d-99adc
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from  (unknown[223.64.115.200])
	by rmsmtp-syy-appsvr06-12006 (RichMail) with SMTP id 2ee66afa60d087e-77831;
	Mon, 16 Nov 2026 09:48:04 +0800 (CST)
X-RM-TRANSID: 2ee66afa60d087e-77831
X-Cc: Simon Horman <horms@kernel.org>,
	Hangbin Liu <hangbin.liu@linux.dev>,
	Hangbin Liu <liuhangbin@kylinos.cn>,
	netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	sunwenbo@cmss.chinamobile.com,
	1342116488@qq.com
X-Mailer: git-send-email 2.33.0
X-In-Reply-To: <20261116014744.18223-1-sunwenbo@cmss.chinamobile.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