🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by Antonio Quartulli Tue, 01 Dec 2026 00:34
Re: [RFC PATCH net-next 3/9] amt: offload group object, desired state and reconciler
#24865
Author: Antonio Quartulli
Date: Tue, 01 Dec 2026 00:34
111 lines
14386 bytes
On Sat, Nov 07, 2026 at 06:44:28PM +0000, Omar Ramadan wrote:
> +static bool amt_ofl_op_overran(struct amt_offload_bound *b, ktime_t t0)
> +{
> +	u32 tmo = b->caps.op_timeout_ms;
[...]
> +	return tmo && ktime_ms_delta(ktime_get(), t0) > tmo;
> +}

This runs only after the op has returned, so it can't detect a wedged
provider:

- Hung op: the reconciler keeps st->mutex. amt_offload_teardown() then
  blocks in mutex_lock(&st->mutex) with RTNL held, so any ip link del or
  unregistration of the lower stalls RTNL system-wide.

- Slow but successful op: amt_ofl_reset() flushes every object and
  requeues every group. If the provider is consistently slower than
  op_timeout_ms, the first replayed op overruns again, and the cycle
  repeats with no backoff. Offload never engages. Selftest case 6
  converges only because it sets stall_ms back to 0.

Please drop the timeout and the reset/replay machinery (see 1/9).

> +static bool amt_ofl_op_done(struct amt_offload_state *st,
> +			    struct amt_offload_bound *b, u64 epoch, bool overran)
> +{
> +	if (overran)
> +		amt_ofl_reset(st, b);
> +	if (b->pub.epoch == epoch)
> +		return true;

The ops are serialised under st->mutex, so the epoch only changes
through the reset just above it. "Stale" is therefore exactly
"overran", and the stale counter always equals the reset counter.
I think the epoch is adding nothing here, no?

> +static void amt_ofl_desync(struct amt_offload_state *st)
> +{
> +	if (st->desync)
> +		return;
> +	WRITE_ONCE(st->desync, true);

Nothing ever clears desync: not teardown, not rebind, not provider
re-registration. So one failed GFP_ATOMIC allocation in
amt_ofl_member_add() keeps the relay in software until it is deleted.
Meanwhile offload/bound reads 1, and a required-mode relay keeps
carrier up. As your nomem comment already suggests, rebuild the desired
state from the tunnel walk in process context, then clear the flag.

> +	if (!st->enospc || !st->enospc_at ||
> +	    st->hw_objs + max(st->enospc_at / 8, 1U) > st->enospc_at)
> +		return;

The hysteresis can park groups forever:
- Every error parks a group (-ENOMEM, -EINVAL, -EIO), not only -ENOSPC.

- A refusal with nothing programmed leaves enospc_at == 0, so that
  group is never retried short of a reset or a rebind.

- On a steady or growing relay, hw_objs never falls by an eighth.

- Endpoints added for the refused group stay programmed and keep using
  the table that was full.

- hw_objs mixes endpoints and groups, so endpoint churn can unpark
  groups that were refused for a full group table.

Retrying -ENOSPC on a timer with backoff and rolling back the unused
endpoints would fix it. Better still, leave this policy to the driver.

> +	hlist_for_each_entry(m, &tunnel->offload_members, tun_node) {
> +		if (!memcmp(&m->grp->key, &gkey, sizeof(gkey))) {

Every join and leave walks the tunnel's member list under st->lock,
which is shared by the whole relay and taken with BH disabled. With
max_groups at its policy limit of 4096, a gateway joining all its
groups costs about 8M memcmp() calls with BH off (!)...
Storing the member pointer in the gnode should make this O(1).

> +static unsigned int amt_offload_op_budget = 1000;
> +module_param_named(offload_op_budget, amt_offload_op_budget, uint, 0444);

Please drop the module parameter.

The budget also doesn't bound teardown. A teardown waits on st->mutex
for a running pass, which can still issue up to 1000 group_disable
calls from its gone list, or an unbudgeted release after desync.
Teardown then issues one op per remaining object, all with RTNL held.
Calling ->flush() once at teardown would bound it.

> +static void amt_tunnel_unlink(struct amt_dev *amt,
> +			      struct amt_tunnel_list *tunnel)
> +{
> +	list_del_rcu(&tunnel->list);
> +	amt->nr_tunnels--;
> +	amt_ofl_tunnel_gone(amt, tunnel);
> +}

You list the tunnel-lifetime windows as inherited. In software a gnode
added after amt_clear_groups() is harmless, because the fan-out walks
tunnel_list. Here it becomes a member hanging off a freed tunnel that
no later tunnel_gone removes, so the provider keeps replicating to a
gateway that has left until the relay is deleted. That makes the net
series a hard prerequisite, and member_add should refuse a tunnel that
has already been unlinked.

Regards,
Antonio
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