Article View: linux.kernel.netdev
Article #24865Re: [RFC PATCH net-next 3/9] amt: offload group object, desired state and reconciler
From: Antonio Quartulli
Date: Tue, 01 Dec 2026 00:34
Date: Tue, 01 Dec 2026 00:34
111 lines
14386 bytes
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
Technical Details
Message-ID:
<20261201003458.3731956-4-antonio@mandelbit.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374556-linux-kernel-netdev=dewy.ruReferences:
<20261107184437.2783174-1-omar@blockcast.net> <20261107184437.2783174-4-omar@blockcast.net>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374556-linux-kernel-netdev=dewy.ru From: antonio@mandelbit.com (Antonio Quartulli) Newsgroups: linux.kernel.netdev Subject: Re: [RFC PATCH net-next 3/9] amt: offload group object, desired state and reconciler Date: Tue, 1 Dec 2026 01:34:50 +0100 Organization: Usenet Network Message-ID: <20261201003458.3731956-4-antonio@mandelbit.com> References: <20261107184437.2783174-1-omar@blockcast.net> <20261107184437.2783174-4-omar@blockcast.net> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="1576020"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:L9yiejXM9VAoBkPz5vt2fKvFnGU= sha256:DIDRwBnu5TRczYpmvEazkC7uQIksrmEb3QLXuwW6+/A= sha1:rYxCndPVGJpjwrisXLGqptF54Is= sha256:VtrEGQ5HgFdsYwy426rwe8zVpr5ZgAMOWfs/aZ5ezfM= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 24BD112601A; Tue, 1 Dec 2026 03:35:39 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -1.95 X-Spam-Status: No, score=-1.95 tagged_above=-9999 required=6.31 tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=mandelbit.com X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SduS_lN0PjkE; Tue, 1 Dec 2026 03:35:36 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374556-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=mandelbit.com X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 2024A126018; Tue, 1 Dec 2026 03:35:27 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id C3DAF2C7BF; Tue, 1 Dec 2026 00:35:19 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796085318; b=e9+G9j9SKn5u3ebzR0XQCZM4JMuSvhkK1VOUvnZVyu8Apn3uAAr3OQrTi1qnZRqp5c1x rbDuh09sCKkWgwlOWwtTGdeNBN1fg+YxT93fNnOlnEpXaqo9S0FfMtsa0268UUYYl20Ed 6+1hDytiV1afpPtoU4TBaDg1GRoWeYmwUWFqT3X+gus7nODS8U4q0pZjEVfbNHilKueLB M3SSi3vDfmsbKkED/x/QHMteqhzxuEElP+88+P8itfh8+2EmTB8elGVgXVEk2haokes4B U23T8mDjSlp9x4og9NSia5C8zoH/2rbs1s8/5rqZkjz839JWzXc7bWUc9jrJKGlAxTA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796085318; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:From:To: Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding:X-Rspamd-Queue-Id; bh=NfzU5O0pXCPucBTa7AWhVzU32cZNjStJSPJ36yOTjvU=; b=tp+saQ+Cn6jlMyE4UAvuUB7sIA6OHhue7npf3GVWcpSwYNc7fdlR272zX4UWOIXZNUfq FagEGsj2xVnXqtOpsd1rOE+/E3h5cBSkUhbOufiMYFDJayh0w7fnKd7ww+NY0zzn3d0lX hVXO+oQkKaxpCBxHdZIKo/g0Jn72dE0Q/GZ3sZELqgN6kSCnx9ey7Gr5qi+HtfqPx/fKJ xf2wHHzWTg7S7NRBBBT7WzmvubuaU151deKb28HSh5VrQAvnyphvb5qdKKWTFS+ne4p6h NImQJM1j+qPVlxcHFE7b/Yj+xPYDRUUcnY4N65MeXFC3LXJE0BBNm0OYvbGq97PN37A== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=QoJGPIyr; dmarc=none header.from=mandelbit.com; spf=pass smtp.mailfrom=mandelbit.com; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0ADA5606A695; Tue, 1 Dec 2026 00:35:18 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=QoJGPIyr X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=195.10.208.62 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796085317; b=twtenONqmK4d8xCC8RTTdhw5IMTLSDL+fSaxUuQgQTqK2JX0wARUkQQ2eho71GzvPRWC 5+bjco2p2MpBTumT8MFgqZhaum3apRa9hDpN7fWrTBNn2Gzntb0uFKlugeIJmfyHlT3Xs EABJjZ253jZuWg6VdNODZsvS1X+pRjYGF7/7Z0ZYlVKo+VJAuoHQfB9u3VsSxySOCQ5pn NheAkT3jywGPrY60CKte5RajjoRDHEGvTEIRRJkYv514sfozITIuBPu/1AuynRAN+aI1L jxreCngfp1rNm+wB1Q4EUkGz33TW123IXNGr/IeCJR/qHhGKJPvkYiXLCUUU6fBRTOQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796085317; h=DMARC-Filter:Received:DKIM-Signature:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Rspamd-Queue-Id; bh=NfzU5O0pXCPucBTa7AWhVzU32cZNjStJSPJ36yOTjvU=; b=4mltfVVEcMQ6a9KP/rAACBBoc3AEQnBEiKSdNDZaNA0iBtzJOKs/NBUnufLK6SVqdicS sKqS/KSys0VUuLlNbCd8nxYbxc06AVWw4XEQo/pweXuxtttbKSHsg8Iq6hyG93HJF+I/k KyUl8LZtUebt7/kjELf3oTAfMtDG/kNPprIWuPTS3eRhU9pTjQ5gecYqExrxMWXNeJXhI WsHtk3SUVcN723VHPveX9NalxIq/fLTPAkwA2xOhI5KM0lVxNshL8f41CITEQY/YZcV5p dnyf8KM1TAtQy/w1dwRT3lVlyG0mEHpiFhh0zQfvC/h/oKOnDtiOzxdPZ2EroLwq9IA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=mandelbit.com; spf=pass smtp.mailfrom=mandelbit.com; dkim=pass header.d=mandelbit.com header.i=@mandelbit.com header.a=rsa-sha256 header.s=MBO0001 header.b=QoJGPIyr; arc=none smtp.remote-ip=195.10.208.62 X-Received: from mout-b-202.mailbox.org (mout-b-202.mailbox.org [195.10.208.62]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7363606A33C; Tue, 1 Dec 2026 00:35:16 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A7363606A33C X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mandelbit.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mandelbit.com X-Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-202.mailbox.org (Postfix) with ESMTPS id 4jdhk90Nb1zKm48; Tue, 01 Dec 2026 01:35:13 +0100 (CET) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1796085313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NfzU5O0pXCPucBTa7AWhVzU32cZNjStJSPJ36yOTjvU=; b=QoJGPIyrUnFiLaDz0TSKscq9HM4zRMfqenpgHNG5CgFmWxomLYaN5cDav5HFpwFUJoHCZ8 HR8GToojCxnRnsUuw74aKAU0ZrE/sAq0x3NkViIXgSuPzAlx/Jc1bKDtJlILRVNh/a2eXP y3ts357+yyzL4vvv0mgTyRDOFGRRq1TWAVNJ8BMlYW+3q9dEEVwcGkE+N78MJ5Vr3C4iHm h0878Kf7YvMO2qyApqBoR7KlHw6MlHCG61836BHKNl6vjppUm93XGVV9HwyI16I+6b5jW5 yyTGEweQTy3F7gOtEkx12Oydqu9F+JOeoJ4AqkQtNE916QXhTaZ+3cK3UztaNA== X-Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of antonio@mandelbit.com designates 2001:67c:2050:b231:465::1 as permitted sender) smtp.mailfrom=antonio@mandelbit.com X-Cc: Antonio Quartulli <antonio@mandelbit.com>, Taehee Yoo <ap420073@gmail.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, saeedm@nvidia.com, leon@kernel.org, tariqt@nvidia.com, mbloch@nvidia.com, brett.creeley@amd.com, sgoutham@marvell.com, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, intel-wired-lan@lists.osuosl.org, Ido Schimmel <idosch@nvidia.com>, Satish Kharat <satishkh@cisco.com>, Andrew Lunn <andrew+netdev@lunn.ch>, Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>, Kees Cook <kees@kernel.org>, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-kselftest@vger.kernel.org, linux-hardening@vger.kernel.org X-Mailer: git-send-email 2.56.1 X-In-Reply-To: <20261107184437.2783174-4-omar@blockcast.net> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-Rspamd-Queue-Id: 4jdhk90Nb1zKm48