🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #14841

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

#14841
From: Hangbin Liu
Date: Thu, 12 Nov 2026 02:14
67 lines
11443 bytes
Hi Wenbo,
On Wed, Nov 11, 2026 at 05:45:28PM +0800, Wenbo Sun wrote:
> 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)

In commit fd61c6ba313d ("net: ipv6: remove nowait arg to rt6_fill_node"),
David Ahern removed the nowait arg. Should we still return immediately
after err == 0? Also later if (err < 0), it still goto nla_put_failure
and return -EMSGSIZE. Maybe we can carry the err to the end and return
a more meaningful reason?

Anyway the added checking makes sense to me.

Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Technical Details
Message-ID: <avUhGnPJk5Kzci3E@fedora>
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-361456-linux-kernel-netdev=dewy.ru
References: <20261111094528.425826-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-361456-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next] ipv6: check mc_forwarding before calling
 ip6mr_get_route()
Date: Thu, 12 Nov 2026 10:14:50 +0800
Organization: Usenet Network
Message-ID: <avUhGnPJk5Kzci3E@fedora>
References: <20261111094528.425826-1-sunwenbo@cmss.chinamobile.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="988715"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:G6MAALLzF7ju82mDpihzBluNTtk= sha256:8eG1BWIUYNIgYJHjUh+0vQAgGCxCD58hNgc/ZhBu23w=
	sha1:WXEyYtAWgty6oJCov4xWZBttRi8= sha256:d2ZR6C4dmwIPIEqqe9IQqKesi6jNB4xlBmXLvjrJYDA=
Content-Disposition: inline
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 6DC5E1140CC; Thu, 12 Nov 2026 05:19:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-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=pass (1024-bit key)
	header.d=linux.dev
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 lXcvsYmv45YL;
	Thu, 12 Nov 2026 05:19:03 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-361456-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id A5FA01140CA; Thu, 12 Nov 2026 05:18:53 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 305FF2DD68; Thu, 12 Nov 2026 02:15:16 +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=1794449709;
	b=WePQB8OuKheEAMPo9ekl1iRjht5voQwMh4Cios6682SLgvXDXkKlgQP12/3MYSkXfXp4
	 xTIWvjcK7m/FafeObYPxAHT3Bw+ZXFSMzDgijIT1BsQzsMFsQNvukwtP8T0vsGYu5VHzc
	 janRqY9ITcaQSzZQa8fHR8D9+KtjH7nP9p1shivRwXuVhFHo1zOuwTqNyNdI16LV8npcc
	 Jc5kkXulWm+A2u/OOMYXbey/urYDKh2cA1ljC1PQp9Gc4Isiko0Jt+LZK5Gw1AME2yT7t
	 8Vzb2a/sipzx8gB4gJDoi3bAYGMgXb6HRF8Uo7HnKoRFimKyeIzA6d2rsgOAN+dE3eQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794449709;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:
	 Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=w/G+bI1y1XPFEXnVVSbx5g6FUS3R8cb54ecVY4rT5Jo=;
	b=f9/5t4EAAiVp8axjvq2Wcw03MBK5glFzeyXVcrUhRGXipqhESM9FrYNbGpiRQdTJ8FrB
	 EP/XBpp81M12JQCX3OhQPkSB8ZNrJ6fscpgpS/Mr+OYZEFfea0IRsLWtO2FK5tQj8gO/A
	 CyYRHXWryJmXtCyEgYn/I9oEE+PxFzXaIscnPbhnQWgde2649zXkDodV52/dc89PxDC4L
	 7j8UjmELDB6uhNO9ByCo7eYWKjEUXUvkCS1i4wLhingk9NJTKvTWfpAk+0C7KJ35SlFvu
	 lZWLD+MV15XBMIparAQddx4cmJswk6xP8qW576CewIv4g3SPLedtCz1tQSUQ4kPrH1g==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=EoJRmJLK;
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	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 200E8606A33F;
	Thu, 12 Nov 2026 02:15:09 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=EoJRmJLK
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.29
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794449708;
	b=AwYMxtU67LE6RoEij7vomlDLuayQLHEuBefTbH0SchXuWTwsERsOsp6SnBPeYxS+7H6a
	 f+19LiFaCmzejGx+bJQGIYRr3yt6oQkBDfwNfVOHreRwkqgP2MJs3NWxNVPLSm3dZt254
	 dKKcu22SwCnfTQxciOCQI3l58w3/SXeOWNUGzW//OCrUucwZpX+NZwhteh5rpwuT3ZMxk
	 mBsEVTb3LkvpGMrEuKUi/7Nj5gWnNkkcWktQis4uh7cOOt+NjeFawT2XOBtLhp7GeVpqT
	 rA5VE72a3/Dwocfwy8lB4lRokl/+V7nlWkFYL04QwW+Z1H5JDCLk6cPFcdV9OLXMzvg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794449708;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=w/G+bI1y1XPFEXnVVSbx5g6FUS3R8cb54ecVY4rT5Jo=;
	b=FZHjW+3WD316fX7TU+9xK9UF8eLkpKI+a4KRzrNVwJJI1c/YqVBpcfq+1pQgHOTWDcR4
	 +N+2bh5krK1eoOTiEYSyQQ7pQl4dPoyJTirPDJ2fz/GMzUBh0QCF0VfPn6rQleoXj4aH6
	 424RlOGgGw38nWsWXeOe/axZvFWdmYCVEb9eM+/ba9E5fEE+UAmjCm7vHekb/zyzC3iA5
	 8jPmgwAxBzlr0DVJn5Ptb4vH81iQJ0Ls8BQSzgmwo6tb0Xc2Od6oC5ECbUAGIXzYGfe5B
	 qtSEALg5B66qArlWZjycG5WOHniWs6sisXZ8gdKDL+LrlMBPq5Ii7WeA8iYsxgNTt+A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=EoJRmJLK;
	arc=none smtp.remote-ip=91.218.175.29
X-Received: from mta0.migadu.com (out-29.mta0.migadu.com [91.218.175.29])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE2E9606A336
	for <netdev@vger.kernel.org>; Thu, 12 Nov 2026 02:15:06 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EE2E9606A336
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=9G2qFQ4sYFCKpZ2fPFqNG76HFv5MjfylAO8756ay2zY=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1794449705; v=1; x=1795054505;
 b=EoJRmJLKm+kw70cJWNKRWqUckONbjm+w8bJvrTe2T0pBpuUrFFktrGezsExIBLjTMxZhgkFa
 nmd3/OHl0lYIgp8tOJRdrYLXbEiOLPjpfNRxm2GY+Fo0Ia4zU/gGYjlxTIakNF13amTs5MXrib0
 ute6cruuUDofSLNGqxXK2Qa4=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta10.migadu.com with ESMTPS id ae91a8d985c07d3d;
	Thu, 12 Nov 2026 02:15:04 +0000
X-Mizu-Trace-ID: ae91a8d985c07d3d
X-Migadu-Flow: FLOW_OUT
X-Cc: David Ahern <dsahern@kernel.org>, Ido Schimmel <idosch@nvidia.com>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, 1342116488@qq.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
X-In-Reply-To: <20261111094528.425826-1-sunwenbo@cmss.chinamobile.com>