Thread View: linux.kernel.netdev
1 messages
1 total messages
Started by netdev-bot+sashiko
Tue, 01 Dec 2026 09:53
Re: [PATCH net-next v5 3/3] amt: make the per-tunnel group and source limits configurable
Author: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 09:53
Date: Tue, 01 Dec 2026 09:53
155 lines
14348 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads