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
Subject: Re: [PATCH net-next v4 3/3] amt: make the per-tunnel group and source limits configurable
Date: Sat, 28 Nov 2026 21:28:42 +0000 [thread overview]
Message-ID: <179590132215.3135.4331794816051168597@kernel.org> (raw)
In-Reply-To: <20261124210501.70394-4-omar@blockcast.net>
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
prev parent reply other threads:[~2026-11-28 21:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 21:04 [PATCH net-next v4 0/3] amt: configurable per-tunnel limits, with bounded report work Omar Ramadan
2026-11-24 21:04 ` [PATCH net-next v4 1/3] amt: make the A-B source walk linear Omar Ramadan
2026-11-24 21:05 ` [PATCH net-next v4 2/3] amt: bound the source-state work of one Membership Update Omar Ramadan
2026-11-28 21:28 ` netdev-bot+sashiko
2026-11-24 21:05 ` [PATCH net-next v4 3/3] amt: make the per-tunnel group and source limits configurable Omar Ramadan
2026-11-28 21:28 ` netdev-bot+sashiko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179590132215.3135.4331794816051168597@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=ap420073@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=omar@blockcast.net \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox