🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #16891

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

#16891
From: Wenbo Sun
Date: Mon, 16 Nov 2026 01:47
64 lines
11419 bytes
When CONFIG_IPV6_MROUTE is enabled, rt6_fill_node() currently calls
ip6mr_get_route() whenever an input interface (RTA_IIF) is specified and
the route destination is multicast.

However, inet6_rtm_getroute() does not set skb->dev on the newly
allocated reply skb, and the looked-up rt6_info carries the matched FIB6
prefix (such as ff00::/8 from addrconf_add_mroute()) rather than the
queried (S,G) addresses. As a result, when multicast forwarding is
disabled (mc_forwarding is 0), ip6mr_get_route() falls into the
cache-miss check and returns -ENODEV, causing rt6_fill_node() to jump to
nla_put_failure and report -EMSGSIZE ("RTNETLINK answers: Message too
long") to userspace. Similarly, interface-local and link-local multicast
groups are never forwarded by ip6_mc_input(), so querying them with
mc_forwarding enabled also enters ip6mr_get_route() and fails instead of
reporting the local route.

In contrast, the IPv4 counterpart rt_fill_info() guards ipmr_get_route()
with !ipv4_is_local_multicast(dst) and IPV4_DEVCONF_ALL_RO(net,
MC_FORWARDING), falling back to emitting RTA_IIF and normal route
attributes.

To align IPv6 behavior with IPv4 and ip6_mc_input(), check that
mc_forwarding is non-zero and that the destination (dest when available,
otherwise rt6_dst->addr) is neither interface-local (IPV6_ADDR_LOOPBACK)
nor link-local (IPV6_ADDR_LINKLOCAL) multicast before calling
ip6mr_get_route().

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 multicast route queries with an input interface
failed on an unpatched kernel, and verified in UML that routable
multicast queries with mc_forwarding disabled as well as link-local
(ff02::1) and interface-local (ff01::1) queries with mc_forwarding
enabled now succeed and report RTA_IIF.

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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 1b2dcc066e19..27597d149672 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -5868,7 +5868,12 @@ 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)) {
+		const struct in6_addr *mc_dst = dest ? : &rt6_dst->addr;
+
+		if (ipv6_addr_is_multicast(mc_dst) &&
+		    !(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);
 
 			if (err == 0)
-- 
2.33.0
Technical Details
Message-ID: <20261116014744.18223-2-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-363981-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-363981-linux-kernel-netdev=dewy.ru
From: sunwenbo@cmss.chinamobile.com (Wenbo Sun)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v3 1/2] ipv6: check mc_forwarding before calling ip6mr_get_route()
Date: Mon, 16 Nov 2026 09:47:43 +0800
Organization: Usenet Network
Message-ID: <20261116014744.18223-2-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="1953779"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:IGey0Y2khKIlwbRwn1jBLgPwFGE= sha256:eS9WiLoSLmxD9IHSE73vaALYjG7lln6CYcjYXU3sy2w=
	sha1:I+ZVCoAzOUbr9hnQ1hQpBl+mJ4I= sha256:huTl1MPWvkKz3lez9VMareBiDWL6n351r81y3DLDgig=
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 E6248114ACC; Mon, 16 Nov 2026 04:48:35 +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 2A6BV-zqFEeH;
	Mon, 16 Nov 2026 04:48:33 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-363981-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 A7A6E114AEA; Mon, 16 Nov 2026 04:48:24 +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 49E702C2D6; Mon, 16 Nov 2026 01:48:09 +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=AjtIX4P+o3ZXpLn1WmdZ4LZkIjkZ8sFNWlZ0h6wtuZBQ2eLx+9EEAu10pNNk9SThOOzX
	 8GUet67k8vWrfz7ajJcqMB6biQkNEFXTVYJizk9k41M+XpHPui80Y2QgdtlrWmcmuVS5f
	 cBqU3fw0TSdJaVDL32y3hHdHCQ8QWqvU+WMIseUr4uPUk7OWO8nough+YU1FvJd8Vl/Jq
	 AYgOuZCpsnx9ZsX0TDm2uKPqivw05z5WILwSZzzYDYSeU9J9XS7G8a9MFJk5y1oR5oulL
	 A0tpOxafu23GZzE+go5kRYX+uaZgqy1u5oSSnDof2tUYNXjFg7ukFsxOJdultBd0cSg==
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=U16UHM6ExIa0np8Ym9kKv5Vd+LKnAL8EesghEHkEZLY=;
	b=g08Dyk1CGiUODrL6+gDz49cuoOPPJkP3cbopL0QlQb5pBEECqldSEBgP9ddLSQaIuca7
	 XAK7vK67EMl1cn/kT7Ni8axHFc0CXKkSnPb+CuM+DCYQJ3mJ0S9VN5/tNSW/DPyTnKUCt
	 HXC1y+tmmICIf+lzyYbGV6RofpMsiZdm3KPXdEYeTE6Gw52zf57aL8wkdpK7RAXIvairr
	 994nwdkC6L3vWlzNG5qRxNEksEEqmUXW9I+3eXFiDyDmFmHvNhsYBFtu1YpcDazrVMPGU
	 i3KCV0Xb+h8TzpfiR2mpWgOGIptxep0rt5rKVvGxMcLwcdc0RUABH9o0lgW2sG4mFig==
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=sYZgBawm;
	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 B89EA606A88A;
	Mon, 16 Nov 2026 01:48:07 +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=sYZgBawm
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=1794793686;
	b=B+jOQsLorPVsTiZ/DInjDna/ytnenrsH1R3yDG1ipyo61/xVp6joF8u1xMQbKKc7+hGL
	 /GGhvOdBkTNXmjEva6/85k4tQNDIWN9R+uTg2cepaHFy7lPIZA/0N3OMDWgz4HTlJC2h4
	 saQYy4CTxNYQiFN6l56gD704mydSsO9EYQnj0M6FkqLu91dP32CWLMbttBT6nVKV8JEJv
	 5tIHi7DvfUpyIfh3775Nfha2B8loDHuOMDZK6fU6bkeqp5ZUXBKooE6lirrPkJts+4BfH
	 l/q2cuDCrVyFdnopzM2CnqnW9yHerF6KK1JWbkQc2Bbem7qYz2V2E8elHluU/BI7Cxg==
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=U16UHM6ExIa0np8Ym9kKv5Vd+LKnAL8EesghEHkEZLY=;
	b=c8hKsDtIJ9rd/mD7dQfSs+c6spDuzT0N+3SogARc96hjCj72DTS2UXZt6atEtvqBisEI
	 SDSzPLMZyMOzEO2KKVCFiY1Zq3XizCqdeA2xIyBYfYSiAq0yMVs/Lk1ieVuF5yabRDTGV
	 3D3Y6Ezgm4YPGohvxYaZOErgvMaXLAZKgA+mD9pb7wEvv21GfLJeQS3/VISf9AMZLyMQP
	 +ihBDEP52wLMmRcnYbUzUITI2OOvwHfPaXNSVMteuTwpqHiVoQJtZoqqz9FJLRs7V70/z
	 1MQ8KrtcqN6EJFdkxkMNcdQ3NfAhxVCA6rVdiONMCikzAFuU43hzh+gvpEDRIx2nXsQ==
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=sYZgBawm;
	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 7B6BD606A332;
	Mon, 16 Nov 2026 01:48:05 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7B6BD606A332
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=sYZgBawmzsxhoBZgFtn9MuS70kq5u3aa1Ai0gsxqaGKAvQn1+XRy2PnxLsnKLDvG01DhJF4qgzn+H
	 IHxTp+Jm390g4687nVmIdYh60tcR358aEoPXcqzRDGbZMmwbGq0VUAULnGtPq2s0w31x4JE0fZPTax
	 l9Z1SmLu+ozFQpDE=
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 2ee56afa60d38ca-f7211;
	Mon, 16 Nov 2026 09:48:03 +0800 (CST)
X-RM-TRANSID: 2ee56afa60d38ca-f7211
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-77830;
	Mon, 16 Nov 2026 09:48:03 +0800 (CST)
X-RM-TRANSID: 2ee66afa60d087e-77830
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