Re: [PATCH net-next v2] amt: make the per-tunnel group and source limits configurable

From: Omar Ramadan

Date: Wed Nov 04 2026 - 22:59:14 EST


On 10/21/26 15:30, Paolo Abeni wrote:
>> + amt->max_sources = nla_get_u32_default(data[IFLA_AMT_MAX_SOURCES], 0) ?:
>> + AMT_MAX_SOURCE;
>> amt->hash_buckets = AMT_HSIZE;
>
> Sashiko noted that with this setting is very easy to livelock the host.
> At very least you should scale `hash_buckets` accordingly, possibly move some
> processing out of the RX path.

Thanks Paolo, and sorry for the slow reply. Agreed: as posted, v2 lets
one Membership Update hold tunnel->lock in softirq for far too long.

I reproduced it at the v2 ceilings in a UML guest. One 64 KiB Update of
about 7,500 empty records, all naming a group that holds 4,096
sources, held tunnel->lock for 1.7 to 2.3 seconds.

For v3 I plan to:

- make the A-B case of amt_lookup_act_srcs() linear, as its own patch.
Today it compares every source in the group with every source in the
record;
- bound the source-state work of one Update. Each group record is
charged for its passes over the group, and the report stops once it
exceeds twice the cost of refreshing the tunnel's whole state;
- size hash_buckets from max_sources (at most 8 sources per bucket,
256 to 512), and lower the group ceiling from 1024 to 512, which
keeps one tunnel's worst case at about 4.75 MiB.

With those, the same Update stops after 26 to 45 ms in the same guest,
while a full refresh at the ceilings (512 groups x 8 sources) stays at
about 5 to 10 ms. UML is slow and noisy, so these numbers are only
useful compared with each other.

That keeps the processing in the RX path. Once the work is bounded, a
per-tunnel work item would add a queue and limits of its own without
changing the worst case much, so I left it out. If you would still
prefer the processing deferred, I'll do that in v3 instead.

Sashiko also flagged an existing race between the source timer and
tunnel teardown. v5 of my net series "amt: relay tunnel lifetime,
validation and request-path hardening" fixes it, and I am posting that
next. v3 of this patch depends on it, so I'll post v3 once that series
is in net-next.

pw-bot: cr