From: netdev-bot+sashiko@kernel.org
To: sw@simonwunderlich.de
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
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 [thread overview]
Message-ID: <179554084776.3135.15585552473847641901@kernel.org> (raw)
In-Reply-To: <20261123171827.3294525-14-sw@simonwunderlich.de>
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
next prev parent reply other threads:[~2026-11-24 17:20 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 17:18 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-11-23 Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 01/15] batman-adv: document refcount of returned objects Simon Wunderlich
2026-11-23 17:23 ` netdev-bot+sinfo
2026-11-23 18:13 ` Sven Eckelmann
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 02/15] batman-adv: mcast: use mla_lock also during mcast_free Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 03/15] batman-adv: mark functions inheriting critical sections Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 04/15] batman-adv: bla: register own backbone gw when claiming for local node Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 05/15] batman-adv: tt: unhash local entries with hlist_del_init_rcu() Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 06/15] batman-adv: tt: refresh local entry in single flags_lock section Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 07/15] batman-adv: tt: don't remove unhashed local entries Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 08/15] batman-adv: tt: don't queue local events for unhashed entries Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 09/15] batman-adv: tt: remove unannounced local entries via pending state Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 10/15] batman-adv: tt: keep local entry unchanged when ADD can't be queued Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 11/15] batman-adv: tt: requeue DEL of pending local entry after failed allocation Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 12/15] batman-adv: tt: extract removal of pending local entry Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
2026-11-23 17:18 ` [PATCH net-next 13/15] batman-adv: tt: commit only the announced local changes Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko [this message]
2026-11-23 17:18 ` [PATCH net-next 14/15] batman-adv: tt: avoid list_lock for unchanged local clients Simon Wunderlich
2026-11-23 17:18 ` [PATCH net-next 15/15] batman-adv: tt: drop ADD+DEL events of never announced clients Simon Wunderlich
2026-11-24 17:20 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179554084776.3135.15585552473847641901@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sven@narfation.org \
--cc=sw@simonwunderlich.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox