๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21379

Re: [PATCH net-next v3 2/3] amt: bound the source-state work of one Membership Update

#21379
From: netdev-bot+sashiko
Date: Mon, 23 Nov 2026 23:57
114 lines
12411 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The constants that size the new work budget are documented as
  exact maxima, but the code never reaches them.
- [Low] The patch fixes a long-standing CPU amplification but carries no
  Fixes: tag.

--

amt: bound the source-state work of one Membership Update

This commit charges each group record in an IGMPv3 or MLDv2 Membership
Update for the bucket walks and per-source lookups it causes. It stops
applying records once the total exceeds twice the cost of refreshing every
group and source the tunnel may hold. Records for groups the tunnel has no
room for are skipped and not charged.

> Found by review (Sashiko, on the limits patch); not triggered at runtime.
>
> Assisted-by: LLM
> Signed-off-by: Omar Ramadan <omar@blockcast.net>

[Severity: Low]
Should this patch carry a Fixes: tag?

Before this patch, ip_mc_may_pull() was the only limit on how many records
amt_igmpv3_report_handler() and amt_mldv2_report_handler() applied under
tunnel->lock in softirq. A reassembled UDP Update of up to about 64 KB can
carry thousands of 8-byte records against one full group.

That behaviour seems to go back to bc54e49c140b ("amt: add multicast(IGMP)
report message handler") and the matching MLDv2 report handler commit.

An earlier fix in this area, 5931fd2440de ("amt: fix use-after-free when a
Membership Update re-arms a freed tunnel"), also addressed a theoretical
issue. It carries Fixes: tags against bc54e49c140b and cbc21dc1cfe9. With no
tag here, backport tooling can't tell which trees need this limit.

The "on the limits patch" note seems to refer to a later patch in this
series, "amt: make the per-tunnel group and source limits configurable".
That note does not take the place of a Fixes: tag. The series adds UAPI, so
it may be net-next material either way, and this could be treated as
hardening.

[ ... ]

> diff --git a/include/net/amt.h b/include/net/amt.h
> index f36efcdd92d0b..96357b3e32fc9 100644
> --- a/include/net/amt.h
> +++ b/include/net/amt.h
> @@ -392,6 +392,12 @@ struct amt_dev {
>  #define AMT_GC_KICK		2048
>  #define AMT_MAX_GROUP		32
>  #define AMT_MAX_SOURCE		128
> +/* Per group record, the most passes the mode handlers plus
> + * amt_cleanup_srcs() make over a group's sources, and the most hash
> + * lookups they make per record source.  See amt_rec_cost().
> + */
> +#define AMT_REC_WALKS		7
> +#define AMT_REC_LOOKUPS		8

[Severity: Low]
Are 7 and 8 really the maximum counts this comment describes?

In amt_lookup_act_srcs(), only AMT_OPS_UNI and AMT_OPS_SUB walk every bucket
of gnode->sources[]. AMT_OPS_INT does one amt_lookup_src() per record
source, and AMT_OPS_SUB_REV does up to two.

The most full passes seem to come from amt_mcast_to_in_handler() in EXCLUDE
mode, which makes three AMT_OPS_UNI calls:

drivers/net/amt.c:amt_mcast_to_in_handler() {
    ...
    } else {
        amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_UNI,
                            AMT_FILTER_NONE_NEW, ...
        amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_UNI,
                            AMT_FILTER_FWD, ...
        amt_lookup_act_srcs(tunnel, gnode, zero_grec, AMT_OPS_UNI,
                            AMT_FILTER_D_FWD, ...
        amt_lookup_act_srcs(tunnel, gnode, grec, AMT_OPS_INT,
                            AMT_FILTER_FWD_NEW, ...
    }
}

The two bucket loops in amt_cleanup_srcs() bring that to 5 passes.

The most lookups per source seem to come from amt_mcast_block_handler() in
EXCLUDE mode. That is SUB_REV (2) + UNI (1) + SUB_REV (2) + UNI (1) = 6,
plus one in amt_add_srcs(), for 7. amt_act_src() starts no further walks.

The commit message figure also seems to rely on the higher pass count:

  "At the current defaults a 1.5 KB Update of about 180 empty records
  against one group already walks the group's 256 buckets over a thousand
  times."

At 5 passes per record, that would be about 178 x 5, or roughly 890.

amt_rec_cost() and amt_report_budget() use the same constants, so behaviour
does not change and the budget is still conservative.

Should the constants be 5 and 7? Or should the comment say they are
deliberately rounded-up bounds? The later patch "amt: make the per-tunnel
group and source limits configurable" leaves both constants and their
comment unchanged.

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122235724.2898320-1-omar%40blockcast.net
Technical Details
Message-ID: <179547826290.3135.17087083328500674943@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369850-linux-kernel-netdev=dewy.ru
References: <20261122235724.2898320-3-omar@blockcast.net>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369850-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v3 2/3] amt: bound the source-state work of one
 Membership Update
Date: Mon, 23 Nov 2026 23:57:42 +0000
Organization: Usenet Network
Message-ID: <179547826290.3135.17087083328500674943@kernel.org>
References: <20261122235724.2898320-3-omar@blockcast.net>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="4011085"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:YR5BiPsstckKSfwOvOxzr2kXgRY= sha256:OywC3QC0smMCUXt+1CDsbAwxI/fDoI8TJVps86oCkjA=
	sha1:teEw1gTFyd2Nm0Gv2fBQckAzaQo= sha256:HghOnw1m+xVwpXyUjlotMEOkGexGfa7O/gQgXKoeyoI=
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 4CEB2125DC9; Tue, 24 Nov 2026 02:58:16 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	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 (2048-bit key)
	header.d=kernel.org
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 6QO9zU6PlkOg;
	Tue, 24 Nov 2026 02:58:08 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369850-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id EE65D125DC8; Tue, 24 Nov 2026 02:57:58 +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 5E6103409F; Mon, 23 Nov 2026 23:57:50 +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=1795478270;
	b=VlagGKA0+NATCVUUTrg+6R3dbyrlqPTtBxEIqgddqRxoFUCiaot6IdP6aDxHdRBygZWo
	 p+of+MjwBdRCzzRkUBtTQIl4Dof9UBRl3De1I4lnVbR4gHbcvnvThiWJm1Ymvi4KYHguW
	 jl6vP6SkfO3DdCjfycJekxPvkUSAyQnAw1C8+mO4AzL7/zhYtlDVFirC/bAYRt0wI1ORa
	 NZzVPM0zf4Tq9H4XoA25/TGJ85zDdxGutitlu4nxt/ly8Pe2hVQ9B69MUP+0huvyr49BP
	 8/2sfv9CVUHD6aCgR1KZuDqFzbp9pgjOKb0e/0qbup29lw7mjfuGeGVYIafglcEy4Ng==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795478270;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=TBsXJBeRRVOImyQ/Szk+YPi0ypRjRqCWylyixyKG2iE=;
	b=1nVBUUFJ+oOn1bHra880iJJvjY7D2c6ptOjV8hBIsndl77u1H1CqKZwmhmNy1BOWj/ng
	 I9CjcEEDdTZEjTVwTwrX+jR+jy5Ax7DEM28CV2pClJtk9CehRYQVaxFWgLtHUpyXM5tmd
	 AgOP9U/XKpW99SPEOb9vV+RWx/GG/UINxszSIs18AVFwcaw9SjwksjpE5wHwjSdNt6jj6
	 jVsmX1ZoTzbQhgzh6eJd+Gr7yXnu/uGy+faHyIlRwr3uqiqq4Ht2mZNqS9VklYJOXUupP
	 mw8YLlmELclAottpSHGzIljF4o/OFN3WzAhsJkzGr4jBVATPD9QrkBHpDCW/58JGnzA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nMU13wN6;
	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 3696E606A32A;
	Mon, 23 Nov 2026 23:57:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nMU13wN6
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795478264;
	b=lHj5kEkvvTT/e7BJ3iRo/kT/nRdlj+0bcWAFSRApGzwv6XmbYgfMupnjLWJ6Slpyh8Ym
	 jqBHrk2uFKGcQkFrBiK3cOiElOZWvyZJY3BcPJgg57ApCO2M8/dbcuIJCMPe7Rc6ATXCY
	 VGwzOL4W/g4Hyv6ip/zrNF+SVCePR+zb57jB+lXBQrXs5jZmKyHXuE0r8HttQQDCWwoP/
	 RQDOkagMO9yHSrqsG43OMNXjztcYdZ4IiorMZCXC25ok/XEkNAi8mbWjpa5xOvqp/Uw7D
	 R8TUFp6v4EaPxPyyo2J1KKv4f/3Rh6nmq0OowwJfMU990AgMmGruVw4XEjSxoNqI3tA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795478264;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=TBsXJBeRRVOImyQ/Szk+YPi0ypRjRqCWylyixyKG2iE=;
	b=Wchs1i5ZvdJryE50ngcOQMdp5nGcJ0ou0axsS3FIyiqjBy5BBb4htiOfXbBF84j188Ji
	 1wkYNJbSalreF0waemtTQ9hJhyARgUGlh4raScvQp9OS99LLjFV9M1ykwKxbrMW4j+r5X
	 niO+uIoctRgFZBoJH0tdukvhEwyaHqCWC6GKHULSPfCiV664zV+rheKSjdD1jvrYOdTV6
	 Gru0Z/fEnin70cz/2h3mD3hTFJtsYaCMZGhfYds8y7N86S+mHKSm6+TpdDws4NN0GnwZc
	 mBKBCLqRfb+m8XVV21QCoxFfm5AkgIyLW39dS4oYYy+cqe3eXH/J3QmzCSpVHxEAwcg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nMU13wN6;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 528CD606A31E;
	Mon, 23 Nov 2026 23:57:44 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59EA11F000C0;
	Mon, 23 Nov 2026 23:57:43 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795478263;
	bh=TBsXJBeRRVOImyQ/Szk+YPi0ypRjRqCWylyixyKG2iE=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=nMU13wN65elXNUFCSEtyveLzrF+uCQCgV1WWHfKEOfiEIbbdrVQM+Li0TEtWGEDSX
	 ZKfiWHmgWgpxC+px6Ir2HEkbrGpxYLcg7gjWhJC2jnrzFvqml0+w2uIDhJ/O/5UWQv
	 M1yHJOBMj6HPMLYgKJnMc0g33CdvqMYiDNdEdPvEPGIGiobZagzzcFeT/+neydkavE
	 fC+YxFaABv/HSO70L6F80CTITvjpot9QLUwyZHtHp0br/EU3yAZUurkkR9VseavD+2
	 7m+Yt20DGSf01U7k/D8P9Qin+gj7BsVw1tOyRVV19xj2sx1IrzUvKISp3ssgoa3et7
	 r19Q5Okm0Cdpg==
X-Cc: ap420073@gmail.com, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 netdev@vger.kernel.org, linux-kernel@vger.kernel.org, horms@kernel.org
X-In-Reply-To: <20261122235724.2898320-3-omar@blockcast.net>
X-sashiko-severity: Low
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