🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25149

Re: [PATCH net-next v5 3/3] amt: make the per-tunnel group and source limits configurable

#25149
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 09:53
155 lines
14348 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] At the default limits, amt_report_budget() (drivers/net/amt.c)
  cuts the per-Update work budget to exactly one full refresh, with no…
- [Low] The comment on the new amt_report_cost() in drivers/net/amt.c
  describes the wrong units.

--

amt: make the per-tunnel group and source limits configurable

This patch adds IFLA_AMT_MAX_GROUPS and IFLA_AMT_MAX_SOURCES so a relay
operator can raise the per-tunnel group and source limits at link
creation. It also rescales the per-Membership-Update work budget in
amt_report_budget(). The budget now accounts for longer hash chains and
is capped at what one MTU-sized report can legitimately cost.

> diff --git a/drivers/net/amt.c b/drivers/net/amt.c
> index 125db76e0acf7..b3e43fc1e6374 100644
> --- a/drivers/net/amt.c
> +++ b/drivers/net/amt.c

[ ... ]

> @@ -2164,21 +2173,45 @@ static void amt_igmpv2_leave_handler(struct amt_dev *amt, struct sk_buff *skb,
>  static u64 amt_rec_cost(const struct amt_dev *amt, u32 nr_sources, u16 nsrcs)
>  {
>  	return (u64)AMT_REC_WALKS * (amt->hash_buckets + nr_sources + nsrcs) +
> -	       (u64)AMT_REC_LOOKUPS * nsrcs;
> +	       (u64)AMT_REC_LOOKUPS * amt_lookup_cost(amt) * nsrcs;
> +}
> +
> +/* The work of a report naming @recs groups, each walked in full, plus two
> + * passes over every source the tunnel may hold and @lookups source lookups.
> + */
> +static u64 amt_report_cost(const struct amt_dev *amt, u64 recs, u64 lookups)
> +{
> +	return (u64)AMT_REC_WALKS *
> +	       (recs * amt->hash_buckets + 2 * (u64)amt->max_sources) +
> +	       (u64)AMT_REC_LOOKUPS * amt_lookup_cost(amt) * lookups;

[Severity: Low]
This isn't a bug, but does this comment describe the units the code
actually charges?

The code charges AMT_REC_WALKS * (recs * hash_buckets + 2 * max_sources).
That is 7 bucket walks per group and 14 visits per possible source, not
"two passes". It also charges AMT_REC_LOOKUPS * amt_lookup_cost(amt) per
unit of @lookups, which is 8 chain-scaled lookups.

The only caller, amt_report_budget(), passes source counts as @lookups
(amt->max_sources, or srcs), not lookup counts.

The comment on amt_rec_cost() just above names the AMT_REC_WALKS and
AMT_REC_LOOKUPS multipliers. Could this one do the same? As written it
is off by a factor of about 7 to 8 for anyone checking the bound
figures in the commit message.

>  }
>  
> -/* The most work one Membership Update may cause: twice what refreshing
> - * every group the tunnel may hold, with every source, costs.  The packet
> - * length used to be the only bound, and a report that names one full
> - * group many times costs far more than one that refreshes the whole
> - * tunnel.
> +/* The most work one Membership Update may cause.  The packet length used
> + * to be the only bound, and a report that names one full group many times
> + * costs far more than one that refreshes the whole tunnel.

[ ... ]

>  static u64 amt_report_budget(const struct amt_dev *amt)
>  {
> -	return 2 * ((u64)AMT_REC_WALKS *
> -		    ((u64)amt->max_groups * amt->hash_buckets +
> -		     2 * amt->max_sources) +
> -		    (u64)AMT_REC_LOOKUPS * amt->max_sources);
> +	u64 mtu = max_t(u64, READ_ONCE(amt->dev->mtu), ETH_DATA_LEN);
> +	u64 recs = max_t(u64, READ_ONCE(amt->dev->mtu) /
> +			      sizeof(struct igmpv3_grec),
> +			 min_t(u32, amt->max_groups,
> +			       ETH_DATA_LEN / sizeof(struct igmpv3_grec)));
> +	u64 srcs = min_t(u64, amt->max_sources, mtu / sizeof(__be32));
> +
> +	return min(2 * amt_report_cost(amt, amt->max_groups, amt->max_sources),
> +		   amt_report_cost(amt, recs, srcs));

[Severity: Medium]
At the default limits, can this leave the budget with no slack when the
relay's MTU is below 528?

srcs uses the Ethernet-floored mtu, but recs uses the raw
READ_ONCE(amt->dev->mtu). recs is floored only at min(max_groups, 187).
With max_groups 32, max_sources 128 and hash_buckets 256,
amt_lookup_cost() is 1. When dev->mtu < 264, recs is 32, and the second
term is:

    7 * (32 * 256 + 2 * 128) + 8 * 1 * 128 = 60160

That is exactly what refreshing 32 groups holding 128 sources costs.
For 264 <= mtu < 528 the slack is only 1792 * (mtu / 8 - 32). Before
this patch the budget was 120320 at any MTU.

This setup is reachable if the relay MTU is lowered (dev->min_mtu is
ETH_MIN_MTU + AMT_RELAY_HLEN) or the stream device has a small MTU. A
gateway on an Ethernet link sizes its reports to its own MTU, so
ordinary reports can then go over budget in two cases.

First, a host joined to more than 32 groups. Each record for a group
the tunnel has no room for adds amt->max_groups to work.

Second, records that name more sources than the relay holds. For
example, 32 groups with 5 sources each costs
7 * (8192 + 128 + 160) + 8 * 160 = 60640, which is more than 60160.

In both cases amt_igmpv3_report_handler() hits this:

    if (work > budget) {
        netdev_dbg(amt->dev,
                   "Membership Update over work budget, %u of %u records ignored\n",
                   ngrec - i, ngrec);
        break;
    }

amt_mldv2_report_handler() uses the same budget and charges. The tail
records for groups the relay already holds are skipped, so those groups
are not refreshed and expire on their group timer. With the same report
layout, this repeats every cycle.

The handler's comment says the cheap full charge exists so a host does
not "lose the same tail records from every report". The commit message
says the Ethernet assumption keeps "a relay whose own MTU was lowered"
from truncating "a legitimate refresh".

Would computing recs from the Ethernet-floored mtu, as srcs already is,
keep the old 120320 bound at the defaults for every MTU?

>  }
>  
>  static void amt_igmpv3_report_handler(struct amt_dev *amt, struct sk_buff *skb,

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130095059.1301582-1-omar%40blockcast.net
Technical Details
Message-ID: <179611882597.3146.3123004918131302457@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!193.141.40.65.MISMATCH!npeer.as286.net!npeer-ng0.as286.net!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374923-linux-kernel-netdev=dewy.ru
References: <20261130095059.1301582-4-omar@blockcast.net>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!193.141.40.65.MISMATCH!npeer.as286.net!npeer-ng0.as286.net!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374923-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v5 3/3] amt: make the per-tunnel group and source
 limits configurable
Date: Tue, 01 Dec 2026 09:53:45 +0000
Organization: Usenet Network
Message-ID: <179611882597.3146.3123004918131302457@kernel.org>
References: <20261130095059.1301582-4-omar@blockcast.net>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1678369"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:dD6rB9WWSbYU6q7z28TkmpL4H40= sha256:xrDeNv4A+OGaMp0QlREYVRVFRsuTkHhiPUWPZKOFClU=
	sha1:uTzcUgApTX5u1xVBJlTiPHmhsYw= sha256:GbtWvEnE4dqELD1Di02jhj351mB7J0toWvOngHuRLPU=
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 475A5117301; Tue,  1 Dec 2026 12:54:04 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.4
X-Spam-Status: No, score=-3.4 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, URIBL_BLOCKED=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 7K29HouY3I5h;
	Tue,  1 Dec 2026 12:54:00 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374923-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 CAB52117311; Tue,  1 Dec 2026 12:53:50 +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 BD7B63230D; Tue,  1 Dec 2026 09:53:48 +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=1796118828;
	b=Y+4v1y3waeM9po8BtGKis/dxiJMYYZGMvgp8bQ1T32EGgn+Lp77Q0qqDrbGFHt7iPETi
	 2zCVXk0k1nZRYU8T2ivGjRuGprybbM+pwvLjRbQNRuvLwaMaQCudUpu+Wgfrn/Y0c8DMN
	 Ju52Ker5FxoeCe8B7awg3Q/+C1676x94sNRYUdpMpzAhfI93B6oVrBTndyzcTx9iqu04+
	 i/10NFH+py3i0bmQ13L6KAN1yU9xkHg4nXXQHxVSiJrSL/p8/Ag/4v5QAc9c3p+9qXJ2V
	 rx1hXDHEecnNFhG5u3jOWLjFu/ovs5hpkX+rsUY38+wcuudWu7ef9swS3lG7Jm4F/MQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796118828;
	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=PHrEINqrQi+0WR2v2lpdRSuSGRe7DC6ggm3II2Gku/U=;
	b=UiKxKOBDW5ubixgb5+bCQSVR8SGAHix57HbORLjZkNT4wM2cyv2GdmGy2y9IcQjCQZxt
	 oOYCWgPOHk+PJdM5P7cr0mkwI5xaBPe32NG0TY4IdoQpEvcpFZf2AyYfEBPzpKai/Ykn0
	 aXDDvqmtBVq3MXxXumPu5Y/wfhwEL64afrgI3BRnJqtfuxGbfMLJ0RduNjSPZTbZc/J6w
	 kzFUfucqeN5z6RI8C6geK2RQInx+60cMDqnZSfgfwppGxBDlLIgBb19T08tnI71PDCmR0
	 /uESY9neqrsoMsENRThHaK21VyabZOYtLETo5MR00cARRRo3YNTdWToU9qnr04hf++g==
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=mqEbfjou;
	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 5F94E606A683;
	Tue,  1 Dec 2026 09:53:48 +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=mqEbfjou
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=1796118827;
	b=mKKnG8gdZv9Iwsqpjdq+4Mca0xCGkyj8UiSvC9ahFVOs94jqOpGW1cQ+xYv+0JjXs+yo
	 NCmY90CXYMxUY2avqDIvQZ/+i9peE+XHbSRt0lFPULVEPXNSAzpieoMqrHUhfawJUugDx
	 9TT50Kb2v/3zvDMHZSgPDkZrsFNAs1hRRPOYTaRC2mvuE++FHDHdEZRx6XJIdTz7vv2G6
	 /l0URPzZgQGVN8kJU0eQ2pKbCL1CfUR0sFsxQDpVb3uLxLOD62F+dny0w49KC/l0U7Yoi
	 VXqaCEuawIe70M9V98dHwD/MOPBmnRXzyAXGpEvyh/41Q/Geddx70BaeZYdDUyeZTIw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796118827;
	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=PHrEINqrQi+0WR2v2lpdRSuSGRe7DC6ggm3II2Gku/U=;
	b=Nr05bchxTgQqVVUb7QOd1+JbLbtN+yCRfifJxyEoNDLb5tV0xhdMn6RAnuKOlSFKgyJ7
	 s3rYovqMDGmi15LyYf8ti01ZB86cLX1epKi8feaMUWItzs3m9S4Y1FVXk5rxUA4xkGLD6
	 li03wdZva/2GlmxGU+mWcGTdf9P4XCpFLCiCEg7hHpq9cGujB/KYlrPfesNTkdgOFphXB
	 cdN0+J1fcwxK0moowhWneaD8rO6b6Bs80OdxqAwBogvuDQOyfIocnws+D7a1nmwKzZVOh
	 wUZGRUaWNLTOQ8ihc6Z1pnYlU/HcWd18RaZKMXGGfgB1pXZ0BQejL1Sg8kaxQ8IF3hA==
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=mqEbfjou;
	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 7F709606A337;
	Tue,  1 Dec 2026 09:53:47 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70DF11F000C1;
	Tue,  1 Dec 2026 09:53:46 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796118827;
	bh=PHrEINqrQi+0WR2v2lpdRSuSGRe7DC6ggm3II2Gku/U=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=mqEbfjouBd3Mlp/KQkZhXbWrdqi1Y8/kiH5kjNn85yLuIYZWcPFcNlc0gygTlwxos
	 dENT1xEpY/fHH8roMooyN4AuCSJFkvITuwJos8d8hKqL+0pXQwoC8oMudB0JVDG1n0
	 2ZxmmnY8GCvkqjwthrJ87ZFmFqUPeGRaWtvMCDv+f1aK9vTRxdn4QHDAoia13KOVOF
	 o3IrLPqLoK9AsVtXtaBP6Jyhfj4Oiz58CFVNM6gBSaphdAcMVbqKmFVlrtiyneMa3k
	 TEkcrbgccD9UqB9l1zIBPqosju7Tb8apjIq3QNzk6t3jppRSPWpeXhOQ4eB58OZ64s
	 e1PuDpHt+RGqw==
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,
 willemb@google.com
X-In-Reply-To: <20261130095059.1301582-4-omar@blockcast.net>
X-sashiko-severity: Medium
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