🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #15046

[PATCH net-next v2 1/2] ipv6: check mc_forwarding before calling ip6mr_get_route()

#15046
From: Wenbo Sun
Date: Thu, 12 Nov 2026 09:46
55 lines
10919 bytes
When CONFIG_IPV6_MROUTE is enabled, rt6_fill_node() calls
ip6mr_get_route() whenever an input interface is specified and the
destination address is multicast.

However, when multicast routing is not enabled in the network namespace
(i.e. mc_forwarding is 0), there is typically no matching (S,G)
multicast routing cache entry, and skb->dev is NULL in the query skb
allocated by inet6_rtm_getroute(). As a result, ip6mr_get_route()
returns -ENODEV, which causes rt6_fill_node() to jump to
nla_put_failure and report -EMSGSIZE ("RTNETLINK answers: Message too
long") to userspace.

In contrast, the IPv4 counterpart rt_fill_info() checks
IPV4_DEVCONF_ALL_RO(net, MC_FORWARDING) before calling ipmr_get_route(),
so queries with mc_forwarding disabled fall back to emitting RTA_IIF and
normal route attributes.

This discrepancy was identified with the assistance of an LLM-based code
review comparing IPv4 and IPv6 multicast route get handling, confirmed on
a UML kernel where "ip -6 route get <mcast_addr> from <src_addr> iif
<dev>" returned -EMSGSIZE on an unpatched kernel, and verified after the
change that multicast route get with iif succeeds while unicast and
non-iif multicast queries continue to work as expected.

Check atomic_read(&net->ipv6.devconf_all->mc_forwarding) before calling
ip6mr_get_route() in rt6_fill_node() so that queries with multicast
forwarding disabled report RTA_IIF and normal route attributes, matching
IPv4 behavior.

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

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

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 2eb884558c24..6dd4a70f6490 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -5862,7 +5862,8 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,
 #endif
 	if (iif) {
 #ifdef CONFIG_IPV6_MROUTE
-		if (ipv6_addr_is_multicast(&rt6_dst->addr)) {
+		if (ipv6_addr_is_multicast(&rt6_dst->addr) &&
+		    atomic_read(&net->ipv6.devconf_all->mc_forwarding)) {
 			int err = ip6mr_get_route(net, skb, rtm, portid);
 
 			if (err == 0)
-- 
2.33.0
Technical Details
Message-ID: <20261112094630.197244-2-sunwenbo@cmss.chinamobile.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361671-linux-kernel-netdev=dewy.ru
References: <20261112094630.197244-1-sunwenbo@cmss.chinamobile.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361671-linux-kernel-netdev=dewy.ru
From: sunwenbo@cmss.chinamobile.com (Wenbo Sun)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v2 1/2] ipv6: check mc_forwarding before calling ip6mr_get_route()
Date: Thu, 12 Nov 2026 17:46:29 +0800
Organization: Usenet Network
Message-ID: <20261112094630.197244-2-sunwenbo@cmss.chinamobile.com>
References: <20261112094630.197244-1-sunwenbo@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1060719"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:vL6/TD0QQtGUgOJtYp1YAfHWu5E= sha256:x6ylnCgrBq1HoVmRZ0MYMSvxzqXQ3YR5oZ9X+WY1c4U=
	sha1:sLMaYCLe5f16h/EW828R0UvEmYM= sha256:rxE412Phjl2SxaJi3SaCkULs012ZwqlRYKp3DpMS0eI=
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 015E31141BE; Thu, 12 Nov 2026 13:31:19 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.751
X-Spam-Status: No, score=-2.751 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]
	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 RQwOY9A0FB9U;
	Thu, 12 Nov 2026 13:31:14 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-361671-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 D49D71141BA; Thu, 12 Nov 2026 13:31:05 +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 4AE0416027F; Thu, 12 Nov 2026 09:47:19 +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=1794476820;
	b=lY4Udao1oPIAGSMkJP3gzAoAp6cy1GLjA9tPGaD9/d/+6ZptkhvNT9K+byYhKTcjqKgE
	 cZhLdiQVV8QUNy3Og+SuQDMthmoWRhswelpRlpLXgE/OYPsp27AFB62r4hiKdtJs2ei4z
	 tMUF9QZXD3e90aiqlDdMrqs0ixHrE5oZJZdq7fwQTQz2vaeDVLnD89VJ0/137yhXHzSn0
	 X80k/Do9aKrevSJI0eXPQUcGmKTCMNilX0yhjY3MjM0egyIg+T9r6D95v6q4Vl/itnMrW
	 mQerLDX4aUkD9ngt3EvGFeYU5iO0vMpnSvmtp+H4SksV37OiUhjpf1y+DGVddD9p0cg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794476820;
	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=Y4YhAhyayvyCbm+IS4ybj27bnorKrlzrUXxTUWhF7GQ=;
	b=zq5nhK2Sws4pB2/JqIszUGVUmMaLonPEs+AFAjLlDJIgruV9rNEeliPUL3ITEMmLc8u0
	 lPIIIaZDbTzQj7EV7UOwhHDTowZUfNAgMDMyYYvMTxrk7LdL7rmHiv34OwOUsMssBpUwc
	 Ine90V497VqdfqepGs5TaEq6e5KYoQgsCKOrVgI8pUkwNJpe59nwYMQtmYPLuFbE3DwSZ
	 1cxT1OJTX5PQMsqfLECdx0rZ2PrYdQuHGNZibv6VNGthYxzyUGQl+rm8PtrDi9MZVuRlV
	 MEQnXcoQ4KrENffsTMoPuq8eH23WdkxGiTrCHwWI07/3xON2ZXaPXAakXllgLVB8tvA==
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=RmN0t7IQ;
	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 5854E606A337;
	Thu, 12 Nov 2026 09:47:00 +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=RmN0t7IQ
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=1794476814;
	b=vQsrTdhimU/P8clIeyGtt2O71kZzNC4Th0gF3gK9kyimMokn2jO2sThezyeDQ9twyuiN
	 xoN5+dB/ZwOrfg45WP+PrVv+x1fh+jz3/AUEwlbQkbc22yOjyqzJv04Pjycx3ERaSKMbz
	 lw9qslqErncSgz6ZIoKmbEKPCc2E/kN2g4lrDonkBEB90TMVNohXJiBR9pFsGRFDBBDB0
	 F7ioIY01j+1d7NJo2x6S30qNvjwLZddABI6kc/80YUBL3pi/YaZlHTiAJpKxskHo7RcxC
	 21opYdp5hkiMtJVGzvdoTev2jhtOrUptgBM/zZe5WUb1L4EJlz/CUY0LH1SsKKsaU/A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794476814;
	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=Y4YhAhyayvyCbm+IS4ybj27bnorKrlzrUXxTUWhF7GQ=;
	b=VefG1S8wV8540YhA5Es6wyiYe2AewwgpsNwg/+hEhPkclR4Flfbzr5XiJWlAL0ddlpqC
	 YjTYXUXeodUP0M/s/DKiI7Cp6SurNyD0V6cKb4cAzNwvGSOE6B0dgzJBeTzBql394cnLL
	 bTeEFk4T8sVzXAJ8dNA7esMdOxGiJ7yEvhUKtC+gMH3PgYy9jMcpytEdbQiMzPPyAxn8/
	 7osA3gzow7b6leV0v+xflSJCYK36x5aEIpyiAuTj2D2qwmBVuHCMYLv8iU5CtS+icFMqx
	 lIaJVCZRQVXusI6lHZg4MLrVADEGtgdbkztuZqKo3tqy9J5D/YNwhhuzvU/WEGWpRqA==
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=RmN0t7IQ;
	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 77C8A606A321;
	Thu, 12 Nov 2026 09:46:52 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 77C8A606A321
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=RmN0t7IQnY+8+6sci+0WgpfDt+qRBy4KujaIG3zvrgsBbzd8+eJChK255EGPGR47Qw1NPlohV/aE4
	 QBrPgNNOHCYoGIxplD6y/56ElAsVPmbC26JcNnBfUYXPqk789MqTeo8YN7vRq9l6Thm37/8ZxaVg5P
	 gMreI/BCfNtSvvBs=
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-app04-12004 (RichMail) with SMTP id 2ee46af58b096e9-816ca;
	Thu, 12 Nov 2026 17:46:49 +0800 (CST)
X-RM-TRANSID: 2ee46af58b096e9-816ca
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from  (unknown[223.64.115.200])
	by rmsmtp-syy-appsvr01-12001 (RichMail) with SMTP id 2ee16af58b07794-fbc62;
	Thu, 12 Nov 2026 17:46:49 +0800 (CST)
X-RM-TRANSID: 2ee16af58b07794-fbc62
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: <20261112094630.197244-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