๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21979

Re: [PATCH net-next 13/15] batman-adv: tt: commit only the announced local changes

#21979
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 17:20
171 lines
14359 bytes
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] The change does not fully deliver the invariant it states.
- [Low] Two comments no longer match the code after this patch.

--

batman-adv: tt: commit only the announced local changes

batadv_tt_local_commit_changes_nolock() no longer scans the whole local
table when it commits. It now walks the change list it took for the new
TTVN and calls batadv_tt_local_commit_change() for each queued change: an
ADD ends the NEW state of an entry and a DEL removes the pending entry. An
entry whose client was detected again after its DEL was taken is put back
into the NEW state, so it stays out of the CRC until its ADD is committed.

> diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
> index 2a7f50de70fc8..b03d6c74732f4 100644
> --- a/net/batman-adv/translation-table.c
> +++ b/net/batman-adv/translation-table.c

[ ... ]

> @@ -1876,9 +1882,8 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
>   *
>   * All checks and modifications happen under the hash bucket list_lock and the
>   * flags_lock of the entry. This prevents a concurrent
> - * batadv_tt_local_purge_pending_clients() from removing the entry,
> - * batadv_tt_local_transition_new() from clearing BATADV_TT_CLIENT_NEW and
> - * batadv_tt_local_refresh() from modifying the entry after it was checked.
> + * batadv_tt_local_commit_change() from removing the entry and
> + * batadv_tt_local_refresh() from modifying it after it was checked.
>   */

[Severity: Low]
Should batadv_tt_local_purge_pending_clients() still be listed here?

It is still called from batadv_tt_local_resize_to_mtu() with only
commit_lock held:

    batadv_tt_local_purge(bat_priv, timeout);
    batadv_tt_local_purge_pending_clients(bat_priv);

It unhashes PENDING entries through batadv_tt_local_unhash_pending()
under the same list_locks[i] and entry flags_lock. Because
batadv_tt_local_remove_entry() does not take commit_lock, the two can
still run concurrently.

On a related note, the comment in batadv_tt_local_unhash() is no longer
accurate:

    /* An entry which still carries BATADV_TT_CLIENT_NEW was never counted
     * and must not be uncounted here.
     */
    if (!(tt_common->flags & BATADV_TT_CLIENT_NEW))
        batadv_tt_local_size_dec(bat_priv, tt_common->key.vid);

batadv_tt_local_commit_change() can now set NEW again on an entry that
was already counted, and it uncounts that entry with
batadv_tt_local_size_dec(). The accounting is still correct, because NEW
means "not counted right now". But "was never counted" is wrong for such
entries. Could this comment be updated too? Later patches in the series
change neither comment.

[ ... ]

> +/**
> + * batadv_tt_local_commit_change() - apply a committed change to the local table
> + * @bat_priv: the bat priv with all the mesh interface information
> + * @change: the change which is announced with the new ttvn
> + *
> + * The CRC and the full table responses of a ttvn must reflect exactly the
> + * changes announced with it. Only the entry affected by a committed change is
> + * therefore modified. An entry which was added or marked for removal after the
> + * change set was taken stays in its current state until its own change is
> + * committed with a later ttvn.

[ ... ]

> +	hlist_for_each_entry(tt_common, head, hash_entry) {
> +		if (!batadv_compare_tt(&tt_common->hash_entry, &key))
> +			continue;
> +
> +		scoped_guard(spinlock_bh, &tt_common->flags_lock) {
> +			if (!del_op) {
> +				/* an ADD of an already committed entry only
> +				 * announces new flags or cancels its removal
> +				 */
> +				if (!(tt_common->flags & BATADV_TT_CLIENT_NEW))
> +					break;

[Severity: Medium]
Does this fully meet the invariant in the kernel-doc above ("must
reflect exactly the changes announced with it") when flags change?

The CRC-relevant flags BATADV_TT_CLIENT_WIFI and BATADV_TT_CLIENT_ISOLA
are in BATADV_TT_SYNC_MASK. They are still written to the live entry
when their ADD is queued, not when that ADD is committed. That happens
in batadv_tt_local_refresh_locked(), reached through
batadv_tt_local_add()->batadv_tt_local_refresh(). That path holds only
the bucket list_lock and the entry flags_lock, not tt.commit_lock:

    if (announce &&
        !__batadv_tt_local_event(bat_priv, common, flags))
        return false;

    common->flags = flags;

Consider this sequence:

CPU1 (commit_lock held)
batadv_tt_local_commit_changes_nolock()
    list_splice_init(&bat_priv->tt.changes_list, &changes_list);

CPU2
batadv_tt_local_add()->batadv_tt_local_refresh()
    WIFI or ISOLA of client X changes
    ADD(X) is queued in the fresh tt.changes_list for N+1
    common->flags = flags;

CPU1
    batadv_tt_local_commit_change() for X: entry is not NEW, so break
    batadv_tt_local_update_crc()

batadv_tt_local_crc() hashes the live flags of every entry that is not
NEW:

    if (tt_flags & BATADV_TT_CLIENT_NEW)
        continue;

    flags = tt_flags & BATADV_TT_SYNC_MASK;

Doesn't CRC N then already include flags that are only announced with
N+1?

The same seems to apply when changeset N carries the initial ADD(X, F1)
and a refresh queues ADD(X, F2) for N+1 before the commit runs. This
function clears NEW, and CRC N is computed with F2, while the announced
changeset says F1.

Receivers that apply changeset N would then see a CRC mismatch and fall
back to a full-table TT_REQUEST. The commit message says this patch
removes that symptom. The window is small: one bucket lookup per queued
change between list_splice_init() and batadv_tt_local_update_crc().

The eager common->flags = flags write is still there at the end of the
series. The last patch ("drop ADD+DEL events of never announced
clients") also mentions this window: "An ADD queued by
batadv_tt_local_refresh() in this window (for example for a changed
BATADV_TT_CLIENT_WIFI flag)".

> +
> +				tt_common->flags &= ~BATADV_TT_CLIENT_NEW;
> +				committed = true;
> +				break;
> +			}

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123171827.3294525-2-sw%40simonwunderlich.de
Technical Details
Message-ID: <179554084776.3135.15585552473847641901@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370614-linux-kernel-netdev=dewy.ru
References: <20261123171827.3294525-14-sw@simonwunderlich.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370614-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 13/15] batman-adv: tt: commit only the announced local changes
Date: Tue, 24 Nov 2026 17:20:47 +0000
Organization: Usenet Network
Message-ID: <179554084776.3135.15585552473847641901@kernel.org>
References: <20261123171827.3294525-14-sw@simonwunderlich.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="4188946"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:CWqdnS3MBkSHyQ64XAnwXRO5CNg= sha256:BQcvf1F+UoIziB+DZdebG4SPPPW590Rb9dRpOlIG7LI= sha1:whnIkO6XoSCnAjIMArVkxpp+WhA= sha256:GMJwCeTyU/mId9oYIp32Se3WcJtacbHHN5RPAODoSx4=
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 35FDD125E22; Tue, 24 Nov 2026 20:21:22 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org
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 yGK-26CxgLzF; Tue, 24 Nov 2026 20:21:17 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-370614-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 9BC13125E2D; Tue, 24 Nov 2026 20:21:09 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 0B78136C23; Tue, 24 Nov 2026 17:20:52 +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=1795540849; b=OeKrvi7t463gnvt4VWCQi+gaIx2yGiejBjlm2MqMXWKSFv+lfSsgt0s4tLLILPXdoPla dtvMtlhTveQcPGB2WNMD2PYeYsI/mVOK/tORYn4ijY8oZNIqwwoqKidxW8pZvt15+cxvh 114eb5pRW0cGf6wTrw2eXcLtJW8hncDwtpDbbWWhkQrmfEF85JFZwhkDsUQUjZbK6eRQV YvXQzUlMEgeqEjCdcTIA2oJ0QkbkoGB75aZD5gBl33hw85jViQc9aBDjNOKLJTJCg/PA8 xNC5xoEzKbxf4ET7JKjcMF3I/KZ/dhpKpA9CZ4f/Xtvqj0kl4GC4j7xk8SthjuAOn5Q==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795540849; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=oF3gep8PuNm39VKSTgtUwLjYfM6inrzVn5cOxsyGdW4=; b=0AYY7ZLgMXX+785E7Qp9MuhaI8jgltPWhIHm6WQucfeSR+QBRz9gIaffwJgY641TU3Ko Mk00WE71VisEa95X8qDSbRTXnPRW9p+da8Yam1AqASNfqZu34FababykB4vle2ufhiCAT nNrn5n/FErhkonB0QnrsZqjiJXT2/CEa0mSRfH7P9dwjpKL49y8xJNyANFyuYupj4tcje vE74Ua+cG70YBeaXv63wFdRuCAJlE75caz7KJth82/MAe+n3f9BvOuLs90F0Ua4jXPz/I 7UkxB8k9LVh19UiEUs15q7edfH2DnjQQ2FExYNGYCzCzzYbZkoj38yUOUz5obQqQXZQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ftqDc1Sm; 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 99067606A33D; Tue, 24 Nov 2026 17:20:49 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ftqDc1Sm
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795540848; b=4ihTeiQdFInMQF5MNo8x8p3iqsSqcPJ337Gvw/lefn8NLP+HPiob2jmnMm8+LmYFgqiO brqH6rUbLwtEGz3ks59S4yVcatW5S5HYSuDdn1wu9lzrMswR9moqyoThNczsptwWPZMPy NvsIV7UgnYjyCYZKKpDvkG/8jo8hMNa4RhXp9ZPmY9y2EiuOgAG1caWbYfls6BEzvE4Nw evU6swhGe2y5OqPCWGpY24gVSxb8y1su+j3K5GLF39wokqz0oWLz//1MpKJJZ173oclr+ 5kl1C+0hNCpYwLMway4i7c0IkbXBIgsKEjEkAbiHDVqe50+DyLQ6HiCW0ENkS/K8DXw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795540848; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=oF3gep8PuNm39VKSTgtUwLjYfM6inrzVn5cOxsyGdW4=; b=EqbMOCPOZNQZJPD9/vJ9T1k0vObO8FBzmt+F8neyDbQt8yWYXESakK2He1xx+mqxXTOk R/ESh9bU3l9pvaDUfhFFR6P8AStbnsbHBnKku3nq5cACP40RswydJ1DGPT3+K5aq9C//d CBAmeUgPoWw/dfH9/gDxIyRiQYmaIKCaSn0ClMg7ZNKAW5e7d4YOJB1C8sVi3xXNeUVmL ByTwJtKXO8nEhAAvd1pAWEtE24Jv+dNHHUVn3UMklTWRp9NlaE7Gg+3CHwJy2d5rmo+a4 o+HwTL4DWnkDt0e874AvXoTdkY/v3e6s5s0bV5Sc964SqtDLhUp3/ycfDh+k9BZ94Bg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ftqDc1Sm; arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB94F606A333 for <netdev@vger.kernel.org>; Tue, 24 Nov 2026 17:20:48 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DEE41F000C0; Tue, 24 Nov 2026 17:20:48 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795540848; bh=oF3gep8PuNm39VKSTgtUwLjYfM6inrzVn5cOxsyGdW4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=ftqDc1Sm7x6WDAtzdsj5bEi7RsVmLDLgqybaEyPWIojJn0MFY1QsEFPNiEb+/HOB0 fyuai+LK0Aoaehy6l4TvPvg96XkPzvIfz9OfI7BNvpTH4bB4+UWZOr4JUgHA7V1/G7 rXhj7Yio2DqRxVfQDW/8NixI6LrVYUNFkgDZwL4buzMiFlvuX/pfmL6r7Tvav+wN1B Bm/L0QBPBAalKp4DtP4UA/IBhCZgmaeYBeFuUUj5SYipvicyBD5vIC4A4OFamFd+uj EyRD9nwsRdrkS4Kre2bmvu6awbidENyrZauoKKuO/0zdHUatMiFxAFsX24zu18LXEM +dVwM2Ot+0pMA==
X-Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, b.a.t.m.a.n@lists.open-mesh.org, sven@narfation.org
X-In-Reply-To: <20261123171827.3294525-14-sw@simonwunderlich.de>
X-sashiko-severity: Medium
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