mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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
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	[thread overview]
Message-ID: <179611882597.3146.3123004918131302457@kernel.org> (raw)
In-Reply-To: <20261130095059.1301582-4-omar@blockcast.net>

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

      reply	other threads:[~2026-12-01  9:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  9:50 [PATCH net-next v5 0/3] amt: configurable per-tunnel limits, with bounded report work Omar Ramadan
2026-11-30  9:50 ` [PATCH net-next v5 1/3] amt: make the A-B source walk linear Omar Ramadan
2026-11-30  9:50 ` [PATCH net-next v5 2/3] amt: bound the source-state work of one Membership Update Omar Ramadan
2026-11-30  9:50 ` [PATCH net-next v5 3/3] amt: make the per-tunnel group and source limits configurable Omar Ramadan
2026-12-01  9:53   ` 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=179611882597.3146.3123004918131302457@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 \
    --cc=willemb@google.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

all inboxes | Powered by JetHome®