Re: [PATCH net] amt: do not store tunnel pointer in skb control block

From: Cen Zhang (Microsoft)

Date: Wed Aug 26 2026 - 00:15:47 EST


Thanks for the feedback. Just getting back to this thread.

On Thu, Aug 20, 2026 at 10:18:43PM +0900, Taehee Yoo wrote:
> This looks like it adds a per-packet linear scan over all tunnels,
> so I'm concerned about performance when there are many tunnels.
> Do you have any idea how to avoid this regression?

I see two possible approaches:

1. Keep the v1 implementation. It is the simplest fix, but changes the
Query dequeue path from an O(1) pointer access to an O(n) lookup. I am
not sure whether that cost is significant in practice for two reasons:
this handles IGMP/MLD Query control packets rather than multicast data
packets [1], while the hotter multicast data path already walks
tunnel_list for each skb [2]; and max_tunnels defaults to 128. However,
max_tunnels is configurable, so users can set it much higher.

2. Add a small per-device bucket hash keyed by (ip4, source_port) to [1],
while keeping tunnel_list for multicast fan-out in [2]. This avoids
a new linear lookup cost, but adds a second index that must be
maintained during tunnel creation, expiry, and device teardown.
I am not sure whether that is overkill for this fix.

I would appreciate your further feedback here and will prepare v2 after
settling on the approach.

> I think this comment is not necessary. Please remove it.

Agreed. I will remove it in v2.

[1] https://github.com/torvalds/linux/blob/0f23d56f17fdfc7db69d51f64c8b91bbab947aa9/drivers/net/amt.c#L1261
[2] https://github.com/torvalds/linux/blob/0f23d56f17fdfc7db69d51f64c8b91bbab947aa9/drivers/net/amt.c#L1276