🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #14466

[PATCH net-next] ipv6: check mc_forwarding before calling ip6mr_get_route()

#14466
From: Wenbo Sun
Date: Wed, 11 Nov 2026 09:45
57 lines
10891 bytes
When CONFIG_IPV6_MROUTE is enabled, rt6_fill_node() unconditionally calls
ip6mr_get_route() whenever an input interface is specified and the
destination address is multicast.

However, if multicast routing is not active (i.e. no multicast routing
daemon is running and mc_forwarding is 0), there is no matching (S,G)
multicast routing cache entry, and skb->dev is NULL in the synthetic route
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 return -EMSGSIZE to userspace ("RTNETLINK answers: Message too long").

In contrast, IPv4 counterpart rt_fill_info() checks
IPV4_DEVCONF_ALL_RO(net, MC_FORWARDING) before attempting to query
ipmr_get_route(), and falls back to emitting RTA_IIF and normal local
delivery route attributes when multicast routing is not enabled.

This discrepancy was identified during code audit of multicast route get
handling. The failure was confirmed on a UML kernel: querying an IPv6
multicast route with an input interface ("ip -6 route get <mcast_addr>
from <src_addr> ...") failed with -EMSGSIZE on an unpatched kernel.

Align IPv6 behavior with IPv4 by checking whether mc_forwarding is active
(atomic_read(&net->ipv6.devconf_all->mc_forwarding)) before calling
ip6mr_get_route(). When mc_forwarding is 0, rt6_fill_node() proceeds to
output RTA_IIF and normal route attributes.

Tested:
- On a UML kernel with CONFIG_IPV6_MROUTE=y, verified that
  "ip -6 route get ff0e::1 from 2001:db8::3 ..." with an input interface
  now succeeds and outputs the route instead of failing with -EMSGSIZE.
- Verified that IPv6 unicast route get and multicast route get without
  an input interface continue to work as expected.
- 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>
---
 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: <20261111094528.425826-1-sunwenbo@cmss.chinamobile.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360961-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360961-linux-kernel-netdev=dewy.ru
From: sunwenbo@cmss.chinamobile.com (Wenbo Sun)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next] ipv6: check mc_forwarding before calling ip6mr_get_route()
Date: Wed, 11 Nov 2026 17:45:28 +0800
Organization: Usenet Network
Message-ID: <20261111094528.425826-1-sunwenbo@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="822710"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:+uwnGRvHxgZEjl89DlP3s5od4Xk= sha256:o/hnLQ3uY/Wf3oR6dKL56BBhfVJ4S/vU1pBiti7e8Xw=
	sha1:lpM9e/ofAHmdkjDENcCMeUR7Ylw= sha256:fDAIu5aaWyRLeN2I6g0jMCcVca17khclHfuJ4hn/Xbk=
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 02365113E88; Wed, 11 Nov 2026 12:46:17 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.85
X-Spam-Status: No, score=-2.85 tagged_above=-9999 required=6.31
	tests=[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 SKV1iBzpdgW1;
	Wed, 11 Nov 2026 12:46:13 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-360961-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 28690113E14; Wed, 11 Nov 2026 12:46:04 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 98E1E640A98; Wed, 11 Nov 2026 09:45:54 +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=1794390353;
	b=QXvjaK8pQ4+T03eT4PP78H/oYRz3qX2b7ulP/1ME112pu81CcrD7okaOREFRUtqboiB6
	 lKyoCyUXupW5Uwtt8ruqJPcBWtIvdaeGqJRCixpuWktdFfjbGVg1m8LNuArby8w2o+SQb
	 09olR7q8I+MMKbDkWmOaWQgy+2rjxe08yn2ddkJs3Kf+RCyAIJcXxqJHWrFy6Ws7Rfgh9
	 r4Cx2LMslrK22Xh7FRPsnBniiCsVKbI/iNu4LuNNUDCZhcSo18lqnoreQQAtzac8jfBhU
	 BpVS/4Uhe2+vzl6LKjkh54FQZtGllt0OwPK2EKztnmZUObFRRnCAPk6iRQg0EEVChqQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794390353;
	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:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=a0PF6itKsbJatHBMiVBSVDsGtFU6B9IuJ4xx/BZZwZo=;
	b=xW8QXXzLjPqKLdep0kFZGTH/+RjKz9GmgHxnIZ56aXY5NpVWlMklYuJnVVZRbOecuDeV
	 mo1g48KetG9H4foQ1bS3A8QivRONr/2LYeqGMiLOqLWXMjCDALTrsvlEeJk/YSr0d6mIQ
	 VDFDQyUKw+teeWTeR9Pb+YkzON7pLakh28/3XGkl0PJkrmv6YVyDiSFEnDQgjrxrkGV5U
	 HV/XcSweOlq2z0HyT+Dn+Z2aeDfgsC1fzVJbe7YacEeCxfhkPGRG5EFKbSFTQniPzWxb7
	 kwDk8Au+Fp3KnutZJohHlUdwxP6YELhCHNugyDnPBhLeA077VTm7Qze3zJjRBeMNBMA==
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=RucgFyUA;
	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 BFA3C606A331;
	Wed, 11 Nov 2026 09:45:53 +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=RucgFyUA
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.139
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794390352;
	b=Mv8D1B+x8t7L8FaaZrakdKmgocpPz41Z7bEKLpYxuuRioBje8iDlqrqJaQrI7PY2zvpQ
	 oO1e6QNtFRisH61QIDNx2GXecnfLaz3MXonN6ZE27TogiWvGV3uEXXFkIyHdwsnxKCBtW
	 F7FXFv8N1VpSkgR83tUmgmq6IhacoqOTJ9tHYNEi47AIpy/iOFLTSKzvU6rngF1SfjLvY
	 Y8jujtklrBcghbKa9WYSTemzoKU/X6o/4aIug6vTqtGXy0qGU43nZKPdbTVcuiRk53LFY
	 5ymyVTi8NONSKy4GGL2d3tMcojNshyRbW2m9twEvEhq8UZyyI+qdJUCiS77WOe04kMg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794390352;
	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:MIME-Version:
	 Content-Transfer-Encoding;
	bh=a0PF6itKsbJatHBMiVBSVDsGtFU6B9IuJ4xx/BZZwZo=;
	b=1g3OCFsqq1w3zGH64nZyCmWRCGQASfRQnq0StLUiInwD5tEUz8YcG0xO4+BUg75iVQhM
	 2cbexAYQJefinwADYMIF+HV/paGzWZeq4wT7jH+V/woM0Y4JlC4JfBADANTL30xi+HOQT
	 TtbKQmX14gEUQ0dcCxtoTQQy/XUEyxKEEQO+sO4Lqlb1sc6IaJ0pRVGeBcjzQUHFQkLQZ
	 /pWMIpts6itgPqYHVvYdOCy71PVRCqBVgwCeWUC8KbOKhLOJdqfMMc0Lle2pnnbQw9oRH
	 hlmZeR0OaYgdpXykLcEHCJqQfNROr77Qh/avuxyjPLYkUyhr5VCFMy/n3WcRzjWRPGg==
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=RucgFyUA;
	arc=none smtp.remote-ip=111.22.67.139
X-Received: from cmccmta6.chinamobile.com (cmccmta6.chinamobile.com [111.22.67.139])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 19A77606A33A;
	Wed, 11 Nov 2026 09:45:49 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 19A77606A33A
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=RucgFyUAAn1FjcbEpDIRJ3eHX3KeEz3AQfvfT0bgxkyN8U7ZPSjhy9tCv8ZEjNa7pwTJl5uq5eFuK
	 rsw6XKLH4yS9lb3fAY8SvDkw43Ry9smE6DUobSje67I7F/c91C5JJyfXZM4FSaGPe59rrzJgbvhWlo
	 qWK/v6XGQqRpzALU=
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-app05-12005 (RichMail) with SMTP id 2ee56af43949f5f-d55d1;
	Wed, 11 Nov 2026 17:45:48 +0800 (CST)
X-RM-TRANSID: 2ee56af43949f5f-d55d1
X-RM-TagInfo: emlType=0                                       
X-RM-SPAM-FLAG: 00000000
X-Received: from localhost.net (unknown[112.23.105.204])
	by rmsmtp-syy-appsvr03-12003 (RichMail) with SMTP id 2ee36af43949db3-d6fa9;
	Wed, 11 Nov 2026 17:45:47 +0800 (CST)
X-RM-TRANSID: 2ee36af43949db3-d6fa9
X-Cc: Simon Horman <horms@kernel.org>,
	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-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