From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70DF11F000C1; Tue, 1 Dec 2026 09:53:46 +0000 (UTC) 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== Subject: Re: [PATCH net-next v5 3/3] amt: make the per-tunnel group and source limits configurable From: netdev-bot+sashiko@kernel.org To: omar@blockcast.net 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 Date: Tue, 01 Dec 2026 09:53:45 +0000 Message-ID: <179611882597.3146.3123004918131302457@kernel.org> In-Reply-To: <20261130095059.1301582-4-omar@blockcast.net> References: <20261130095059.1301582-4-omar@blockcast.net> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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