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=1795901323; b=X8VPCLZ0EZIf9X95sZBUkA3KgH4ipt8zh4KPIifmiigyefpxwVudFIMR/GlsgN42WVnc OkCjHchZ8UVGAcD19HiVm/NmxzW4IQ8lUmq6wXMp06SrPq92A+C/Ce3FmpJV07EbntUrM 1+1i4fAVv+ZuEZdKe8ZowNOSLujYyDLheqKLoQkjEOBs5PLOkYZxMlta8a8BKvYvPPKfb 63Mpp1bct55bapBJnTLKSRLUf7QCQ7P7CgKSSC2LC4cXwRVBMtBUvEAkHHX5Y2LjcalZv 2AdjVWZfXsb5i+QZicQTinGMzXacS0TMW421hw+Q9wRaxos0nzqNNIgcWnTpd7nhaVA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795901323; 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=Qjr/iWKj2KQfoMMq2rRLzKsmNg3UYvZBRl0xdMc5MdQ=; b=JCWgGwp83JvVQGRvySWDD/YpH3/y9Zgf6nfLex1PQOVtmZVFAjSfV6FF4mORn7FpmfK8 se9i/+OTrAoC0bYPKAFL2tinq9ObwznhmtfCDpvXbhdHDn9XJa5nAkF/pFzCs3jiYAWf5 S+0VxIrt1KVnsuLldz2ezVn8NObzZQDi7qWbfDTWXneCMsjo778rP7I6B4VUu2Linp3Dy wsAYciBoKDlBjTLOe0mqQktvE8+fTNXYIrBOb4Q7v4/yZKT9Rfke1e4x9orJS2Leb16VQ BcsZMC/DLG6H39Xn48jpGyKb5BqrO4LDo34Nh/1lvGhTO989IovWpCmky8Q0hw3ft4Q== 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=kRek+TFj; 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 9A506606A334; Sat, 28 Nov 2026 21:28:43 +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=kRek+TFj Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4E6A1F000C1; Sat, 28 Nov 2026 21:28:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795901323; bh=Qjr/iWKj2KQfoMMq2rRLzKsmNg3UYvZBRl0xdMc5MdQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=kRek+TFjRYRKYRcB/ftc3WT8MhMngq5dnJotYvw97T+l9UHsOJ0efCI+2FmE1NR9r 3buvx9PE54hzijM6JMm9Yr3YanrP/YI6VoJ08QX51PUjaRWDdCh9fSQgUatgUhf9sy d0l3pyipt/Yny0VI4JKl7QnfsZDcZtPePKEnn6OuFHYG+gMPBRrY+cztjeYJQ+7RE5 CuaJ5mx8qCSjOCixlH7gsinQI3RT1cSYh3XekxTdrGn4eIAQ6iZKRZ/MPw3ygHyTGZ ghj1TIjcTDmD4nkG+oC12jCgzsKRisdEHQKR1M24tMNsoR9NOc9byq7531U35mqkzJ JOhN4PC5fVbjA== Subject: Re: [PATCH net-next v4 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 Date: Sat, 28 Nov 2026 21:28:42 +0000 Message-ID: <179590132215.3135.4331794816051168597@kernel.org> In-Reply-To: <20261124210501.70394-4-omar@blockcast.net> References: <20261124210501.70394-4-omar@blockcast.net> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@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: 2 · Low: 0 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] amt_report_budget() (drivers/net/amt.c:2191-2197) now takes the per-Update work budget as min(2 * amt_report_cost(amt,… - [Medium] The patch raises max_sources up to AMT_MAX_SOURCE_LIMIT (4096, include/net/amt.h:403) but keeps the per-group source hash at… -- amt: make the per-tunnel group and source limits configurable This adds IFLA_AMT_MAX_GROUPS and IFLA_AMT_MAX_SOURCES. They let the per-tunnel group and source record limits be raised when the link is created, up to 512 and 4096. It also changes amt_report_budget() to take the smaller of the previous bound and the cost of a report sized to the relay device's MTU. > diff --git a/drivers/net/amt.c b/drivers/net/amt.c > index 177bc0b7cb1fd..fd907eb124189 100644 > --- a/drivers/net/amt.c > +++ b/drivers/net/amt.c > @@ -2167,18 +2167,33 @@ static u64 amt_rec_cost(const struct amt_dev *amt, u32 nr_sources, u16 nsrcs) > (u64)AMT_REC_LOOKUPS * nsrcs; > } > > -/* 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 work of a report naming @recs groups, each walked in full, plus two > + * passes over every source the tunnel may hold and a lookup per source. > + */ > +static u64 amt_report_cost(const struct amt_dev *amt, u64 recs) > +{ > + return (u64)AMT_REC_WALKS * > + (recs * amt->hash_buckets + 2 * (u64)amt->max_sources) + > + (u64)AMT_REC_LOOKUPS * amt->max_sources; > +} > + > +/* 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. > + * > + * Twice what refreshing every group the tunnel may hold costs, but never > + * more than a report as large as this device's MTU can legitimately cost: > + * a host splits its report to the MTU (RFC 3376 s4.2.16, RFC 3810 > + * s5.2.15), so one report names at most mtu / 8 groups, IGMPv3 records > + * being the smallest. The second bound is what limits the work at high > + * IFLA_AMT_MAX_GROUPS; at the defaults the first is the smaller. > */ > 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 recs = READ_ONCE(amt->dev->mtu) / sizeof(struct igmpv3_grec); > + > + return min(2 * amt_report_cost(amt, amt->max_groups), > + amt_report_cost(amt, recs)); > } [Severity: Medium] Do the defaults still keep the previous bound here? recs comes from the relay amt device's own MTU. In relay mode, amt_newlink() lets that MTU go as low as: dev->min_mtu = ETH_MIN_MTU + AMT_RELAY_HLEN; which is 108. The MTU also follows the stream device through amt_device_event() on NETDEV_CHANGEMTU. At the defaults (hash_buckets 256, max_sources 128, AMT_REC_WALKS 7, AMT_REC_LOOKUPS 8), amt_report_cost(amt, recs) is 1792 * recs + 2816. The first term of min() is 120,320, so the MTU term is the smaller one whenever dev->mtu <= 527. That doesn't match the comment above ("at the defaults the first is the smaller") or the commit message ("The defaults keep the previous bound"). Below a relay MTU of 256 the budget is also smaller than a legitimate full refresh. At MTU 200, recs is 25 and the budget is 47,616. A refresh of 32 groups with no sources costs 32 * 1792 = 57,344. A gateway sizes its reports to its own MTU, not the relay's. So amt_igmpv3_report_handler() would reach this on every periodic refresh: work += amt_rec_cost(amt, gnode ? gnode->nr_sources : 0, nsrcs); if (work > budget) { ... break; } It would drop the same tail records each time. Wouldn't those groups then time out? That is the same-tail loss the "not charged" comment in that handler is meant to prevent. At the new ceilings the budget is 224 * mtu + 90,112. A relay MTU below about 1174 would then cut off the largest legitimate reports from a gateway with a 1460-byte MTU. The commit message only covers the case of a jumbo-MTU gateway talking to a standard-MTU relay, not a relay whose own AMT MTU was lowered. [ ... ] > diff --git a/include/net/amt.h b/include/net/amt.h > index 82aaa6b3070fb..fa3a61dfe786b 100644 > --- a/include/net/amt.h > +++ b/include/net/amt.h > @@ -392,6 +392,15 @@ struct amt_dev { > #define AMT_GC_KICK 2048 > #define AMT_MAX_GROUP 32 > #define AMT_MAX_SOURCE 128 > +/* Upper bounds for IFLA_AMT_MAX_GROUPS and IFLA_AMT_MAX_SOURCES. Gateways > + * drive these allocations: at the bounds one tunnel holds about 2 MiB of > + * group nodes (each a kmalloc-4k object with AMT_HSIZE bucket heads) and > + * under 1 MiB of source nodes, and max_tunnels multiplies that. The work > + * one Membership Update may cause is bounded separately, by > + * amt_report_budget(). > + */ > +#define AMT_MAX_GROUP_LIMIT 512 > +#define AMT_MAX_SOURCE_LIMIT 4096 [Severity: Medium] With max_sources up to 4096 and the per-group source hash still at AMT_HSIZE (256) buckets, a full group's chains average about 16 entries. amt_rec_cost() still charges each per-source lookup as one unit: return (u64)AMT_REC_WALKS * (amt->hash_buckets + nr_sources + nsrcs) + (u64)AMT_REC_LOOKUPS * nsrcs; But amt_lookup_src() walks the whole bucket chain on a miss: hlist_for_each_entry_rcu(snode, &gnode->sources[hash], node) if (amt_status_filter(snode, filter) && amt_addr_equal(&snode->source_addr, src)) return snode; Does amt_report_budget() then really cap one Update at "about 416,000 visits at the ceilings", as the commit message says? For example, a gateway that has completed the Request/Query handshake fills one EXCLUDE-mode group with 4096 sources. It then sends a reassembled Membership Update with one BLOCK record listing about 16,000 sources that are not in the group. amt_update_handler() puts no length limit on the encapsulated report. That record is charged 7 * (256 + 4096 + 16000) + 8 * 16000, about 270K. That is under the budget of about 416K at a relay MTU of 1460. The tunnel is full, so amt_add_srcs() returns early. In EXCLUDE mode, amt_mcast_block_handler() still calls amt_lookup_act_srcs() for two SUB_REV passes (two lookups per source on a miss) and two UNI passes (one lookup per source). That is about 6 lookups per source, each walking about 16 nodes. That adds up to about 6 * 16000 * 16 = 1.5M chain-node visits, in softirq under spin_lock_bh(&tunnel->lock). This is about 4x the stated cap and about 13x the default 120,320. At the default limits the same record is charged about 242K and rejected. Should the lookup charge in amt_rec_cost() include the expected chain length once max_sources is larger than hash_buckets? [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124210501.70394-1-omar%40blockcast.net