Article View: linux.kernel.netdev
Article #14934Re: [PATCH net-next] ipv6: check mc_forwarding before calling ip6mr_get_route()
From: Wenbo Sun
Date: Thu, 12 Nov 2026 07:15
Date: Thu, 12 Nov 2026 07:15
58 lines
11542 bytes
11542 bytes
Hi Hangbin,
Thanks for the review and the Reviewed-by tag!
On Thu, Nov 12, 2026 at 02:14:50AM +0000, Hangbin Liu wrote:
> 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>
Both are very good observations on the existing ip6mr_get_route() error
handling in rt6_fill_node():
1) Regarding `if (err == 0) return 0;`:
Commit fd61c6ba313d only removed the unused `nowait` parameter (whose
value was always 0) and kept the pre-existing `!nowait && err == 0`
early return, mirroring IPv4 rt_fill_info(). Returning 0 from
ip6mr_get_route() means a cache miss was queued via
ip6mr_cache_unresolved() on nl_queries for asynchronous resolution;
falling through in rt6_fill_node() would append normal FIB attributes
without RTA_IIF.
That said, looking closely at inet6_rtm_getroute(), `skb->dev` is
currently never assigned there (unlike inet_rtm_getroute() in IPv4),
so on a cache miss ip6mr_get_route() takes `if (!dev || ...)` and
returns -ENODEV before ever reaching ip6mr_cache_unresolved(). Even
if `err == 0` were reached, returning 0 early skips nlmsg_end() while
inet6_rtm_getroute() still calls rtnl_unicast() when `err >= 0`.
Reworking that path would require changes in ip6mr.c and
inet6_rtm_getroute(), which goes beyond this patch's scope.
2) Regarding returning the real negative `err` instead of -EMSGSIZE:
Agreed -- ip6mr_get_route() can return -ENOENT, -ENODEV, -ENOMEM, or
-ENOBUFS, and jumping to nla_put_failure masks all of them as
-EMSGSIZE ("Message too long") even when mc_forwarding is enabled.
Among all callers of rt6_fill_node(), only inet6_rtm_getroute() passes
a non-zero iif and propagates negative errors back to userspace, so
initializing `int err = -EMSGSIZE;` and returning `err` at the failure
label looks safe and much cleaner.
To make it easy to review both together while keeping each change clear,
I plan to split this into a 2-patch [PATCH net-next v2 1/2] + [2/2]
series after the 24-hour resend window:
- Patch 1/2: check mc_forwarding before calling ip6mr_get_route()
(carrying your Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>).
- Patch 2/2: preserve and return the negative error from
ip6mr_get_route() in rt6_fill_node() instead of -EMSGSIZE.
Thanks,
Wenbo
Technical Details
Message-ID:
<20261112071519.96139-1-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-361558-linux-kernel-netdev=dewy.ruReferences:
<20261111094528.425826-1-sunwenbo@cmss.chinamobile.com> <avUhGnPJk5Kzci3E@fedora>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-361558-linux-kernel-netdev=dewy.ru From: sunwenbo@cmss.chinamobile.com (Wenbo Sun) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next] ipv6: check mc_forwarding before calling ip6mr_get_route() Date: Thu, 12 Nov 2026 15:15:19 +0800 Organization: Usenet Network Message-ID: <20261112071519.96139-1-sunwenbo@cmss.chinamobile.com> References: <20261111094528.425826-1-sunwenbo@cmss.chinamobile.com> <avUhGnPJk5Kzci3E@fedora> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1033508"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Ke3TBuW7WEwLlEGhOfGm0b5Xc2w= sha256:flgpllmLF+2/Ny5OQsQoj4qiqA9X2DX0rgMCrcKFaEI= sha1:C4b/DFl2bcu1bZGDMlp37ZhEBHg= sha256:grt5T9ZAoMtZonBzINd8xsy1cdT67yuaExPWTtJJoZQ= 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 50546114135; Thu, 12 Nov 2026 10:22:24 +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 UYuTLlNEOCaK; Thu, 12 Nov 2026 10:22:20 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-361558-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 3FD60114132; Thu, 12 Nov 2026 10:22:10 +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 7175D102412; Thu, 12 Nov 2026 07:15:53 +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=1794467743; b=UwdNmNY7+Jso/FEH5jYYCW+wb2TIXnJ5Eg/xfw9m3156sMGyuPal86xr0XSfjG7m9DNY 9P66G2mjNlf/x6T5kcoUOnTsMK5CAqvaXktQqLCCvPBmrVd2ONUXGQNCzbvw8tNjdDch6 uhnXMPX8svTkHRZgem3Pen2oIHr7tKn2SnB5n5/2T6Qxab5Wy9fx3fj9gFG61/8pe8j8C F24cH22kPNhPHFf81t2nE93V/eUyDYr7DqdPfe8ntAwtwBY2hEtasSS6VmFEMwhIyNxOu HL7kO2/T9vEGeVlxOkFny+HaClPWycBJ3HCDC0Eslsawgvn8fBW+rB01j6wvrXnH5WA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794467743; 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-Type:Content-Transfer-Encoding; bh=sD4XhwxF8s8xTiMUALl2zDR61pVT/mrOLvoYZrZI+nM=; b=BG3faqpjssgxSGRWz8BALwYNaKnNUn3cHUOfokPeajN+zOq3rsiKFivCixxQplF/WI6f D/da7nvP5SXv/XSVWjmu6B64OQeEPrf3RvVCnEL2izJjbyL/jg6vZn3R4/Pczxx+2kRmc 2UBGb+xg3wPT1+g84ZuZ9BGMG8VOvqfBpRJPhW0DPsq5T5pp68eTrsy6FdgJSLGEoNuXk So7kf/OCAFhSA+atbrmKKABDc4LkFgJLxqFLvdv7OGtmHAxK9rtvrYj7v4o4z4pFtRPRP 5DkQGIU3tr2Tw1h/aJn9PGMTbu1TkPSXpcvArYxi9I4o4G4E8LJjjKSbir6/5ZjcttQ== 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=cQyyEr4N; 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 CB49B606A88C; Thu, 12 Nov 2026 07:15:43 +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=cQyyEr4N X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=111.22.67.151 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794467743; b=dEfyB5fGb38FUS4m3fF7SORuoGUDX99WtONkir9D+9SYF6Sq2YbX3GZ3jLfGM4VDJphQ 0YvFA/eIMi7OW2J0XzqjODE3YMw4NLv1yHhi/PsvUvLa0CA4bYQCA7y94konLHzyH8L3f mE2fcjNPRBtZT1e7KXYYM8+R/iPNEMgDSyAtr5xfEt0y+ItcxIU5aH5fcgmIfanY6mA3H avEit2NJoxxQ1xn4WkC0lCepEi9xMpFdE6sDkZG+bPi/b0ROiUJ/DA2gRzdA7QfB1gQMg c1MYGsap2885lKQw/7QKtpi1rR4EV0iid4KNS2wDS0ssw04p4gBmrF295iHmZ+e4eQw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794467743; 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-Type:Content-Transfer-Encoding; bh=sD4XhwxF8s8xTiMUALl2zDR61pVT/mrOLvoYZrZI+nM=; b=BRbxYytcNztMnyKtJ3x8RwEkNt4jn8ojr37wgE2RiVy6jMUEQCZkGO0hhCCyjEmzl4RP GSJbHR7Drk54Dl1oUQmd41ys0fBdQ5A81PdxG7ZFLke/Se5LgvqvZ1n87ccfAcKERCeeu ZvANF3KokDbV59H1eZHV54Q7+cId0uizuJwYfrM42QWxq6InJFUrkWaB7XO5zU2cnn1zC AovySsC4yM6nLOpAOe76PSwi83tii6/PU0hR8aQFnUDzz2pAjbTB9sEsaRvzL9IUyflk5 JOCumPqEc5rTtpJW8stahmF1HsKKdR+vylow/OnXN/6gDNySFRvJhaaXiStBgD/S/NQ== 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=cQyyEr4N; arc=none smtp.remote-ip=111.22.67.151 X-Received: from cmccmta8.chinamobile.com (cmccmta8.chinamobile.com [111.22.67.151]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B6566606A323; Thu, 12 Nov 2026 07:15:40 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B6566606A323 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=cQyyEr4Nr1ZgpVPx16UzNx00wgG86++ftWFsuRmDnh1aiTWnaDDpbYuPwfla/d8uNJ2GiiOEbqeEI uz64dHp/mfOaOnbbPqM7TjhnVw9WktZdXJli5wsyKrlqAQMqvo1GBPgnD/1ShzQTRkzmV6Lo8ui8p1 IbCEV+wW38MZlp3M= 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-app06-12006 (RichMail) with SMTP id 2ee66af56797f44-abc8d; Thu, 12 Nov 2026 15:15:38 +0800 (CST) X-RM-TRANSID: 2ee66af56797f44-abc8d X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-Received: from localhost.net (unknown[223.64.115.200]) by rmsmtp-syy-appsvr07-12007 (RichMail) with SMTP id 2ee76af56799825-f6c50; Thu, 12 Nov 2026 15:15:38 +0800 (CST) X-RM-TRANSID: 2ee76af56799825-f6c50 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, sunwenbo@cmss.chinamobile.com, 1342116488@qq.com X-Mailer: git-send-email 2.33.0 X-In-Reply-To: <avUhGnPJk5Kzci3E@fedora> 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