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 15/15] batman-adv: tt: drop ADD+DEL events of never announced clients
Date: Tue, 24 Nov 2026 17:20:49 +0000 [thread overview]
Message-ID: <179554084949.3135.16426370585063518179@kernel.org> (raw)
In-Reply-To: <20261123171827.3294525-16-sw@simonwunderlich.de>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In net/batman-adv/translation-table.c, batadv_tt_local_event()
allocates the new change node with…
- [Low] The new cancel path in batadv_tt_local_set_pending() (lines
1957-1961) unhashes a NEW local entry as soon as a DEL cancels its…
- [Low] Some kernel-doc still describes removal of a local entry as
always deferred, but after this patch it can be immediate.
--
batman-adv: tt: drop ADD+DEL events of never announced clients
With this patch, a DEL event cancels the queued initial ADD of a local
TT client that was never announced, and the local entry is removed from
the table right away. Each queued change node now records whether it is
the initial ADD of its client. An ADD queued after the initial ADD was
committed therefore stays non-cancellable.
> diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
> index 998c7f285e1df..c17cfee6ff84d 100644
> --- a/net/batman-adv/translation-table.c
> +++ b/net/batman-adv/translation-table.c
> @@ -651,13 +651,20 @@ static u16 batadv_tt_flags_get(struct batadv_tt_common_entry *common)
[ ... ]
> * Only a single change per client is queued. It describes the latest state of
> - * the client and a new event therefore replaces an already queued one.
> + * the client and a new event therefore replaces an already queued one. The
> + * only exception is a DEL for a client whose initial ADD is still queued. The
> + * other nodes don't need to know anything about such a client and the ADD is
> + * cancelled instead.
[ ... ]
> @@ -669,12 +676,12 @@ static u16 batadv_tt_flags_get(struct batadv_tt_common_entry *common)
[ ... ]
> - * Return: true if the event was stored, false if the memory for it could not
> - * be allocated.
> + * Return: true if the event was stored (or cancelled a queued ADD), false if
> + * the memory for it could not be allocated.
[ ... ]
> @@ -685,6 +692,9 @@ static bool __batadv_tt_local_event(struct batadv_priv *bat_priv,
>
> lockdep_assert_held(&common->flags_lock);
>
> + if (cancelled)
> + *cancelled = false;
> +
> tt_change_node = kmem_cache_alloc(batadv_tt_change_cache, GFP_ATOMIC);
> if (!tt_change_node)
> return false;
[Severity: Low]
Can the cancellation be skipped under memory pressure? In
batadv_tt_local_event(), the new change node is allocated before
changes_list is searched for a queued initial ADD.
If this GFP_ATOMIC allocation fails while an initial_add entry for the
client is still queued, the function returns false and *cancelled stays
false. The cancel itself needs no memory. That branch only frees the
queued entry and the new node.
batadv_tt_local_set_pending() then takes the queued == false path. It
sets PENDING and del_unqueued and leaves the initial ADD in the list.
The next batadv_tt_local_commit_changes_nolock() announces the client as
an ADD. batadv_tt_local_purge_list() then requeues a DEL for the
following TTVN.
That matches the pre-patch behaviour, so the tables stay consistent.
However, the kernel-doc above describes the cancellation as
unconditional. The Return text also doesn't say that an allocation
failure skips it.
Would it make sense to search the list first and allocate only when
nothing matched? Alternatively, the kernel-doc could say that the
cancellation is best-effort.
[ ... ]
> @@ -1883,6 +1919,11 @@ static void batadv_tt_local_unhash(struct batadv_priv *bat_priv,
> * retry it. Such an entry is marked as del_unqueued instead. It stays in the
> * local table until batadv_tt_local_purge_list() was able to queue its DEL.
> *
> + * A client whose initial ADD is still queued was never announced to the other
> + * nodes. Its DEL cancels the ADD and the entry is removed from the local table
> + * right away. The caller has to drop the hash reference of the entry after it
> + * released the flags_lock.
> + *
[Severity: Low]
This isn't a bug, but the first paragraph of the
batadv_tt_local_set_pending() kernel-doc still reads:
* The entry is kept in the local table until the next TTVN increment
* so that a consistency-check response can still be answered.
That is no longer always true with the new cancel path. Only this later
paragraph mentions the exception.
The summary line of batadv_tt_local_remove() also still says "logically
remove an entry from the local table". Through
batadv_tt_local_remove()->batadv_tt_local_remove_entry()->
batadv_tt_local_set_pending(), the entry can now be unhashed and freed
before any TTVN increment.
Could both comments be updated? The callers of batadv_tt_local_remove()
in mesh-interface.c and multicast.c rely on that description.
[ ... ]
> @@ -1907,8 +1952,13 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv,
> lockdep_assert_held(&hash->list_locks[i]);
> lockdep_assert_held(&common->flags_lock);
>
> - queued = __batadv_tt_local_event(bat_priv, common,
> - common->flags | flags);
> + queued = batadv_tt_local_event(bat_priv, common, common->flags | flags,
> + false, &cancelled);
> + if (cancelled) {
> + /* the entry was never announced */
> + batadv_tt_local_unhash(bat_priv, tt_local_entry, message);
> + return true;
> + }
[Severity: Low]
Does this hold when the DEL comes from a roaming event? The commit
message says:
The other nodes never heard about the client and don't need a DEL
for it.
When the entry was inserted, batadv_tt_local_add_roam() may already have
sent a ROAMING_ADV to the previous originator:
hlist_for_each_entry_rcu(orig_entry, head, list) {
batadv_send_roam_adv(bat_priv, tt_global->common.key.addr,
tt_global->common.key.vid,
orig_entry->orig_node);
}
The previous originator (call it C) then creates a ROAM-flagged global
entry that points to this node (A). It also marks its own local entry
ROAM|PENDING.
This also happens when a client roams back. When C's ROAMING_ADV is
merged, batadv_tt_global_merge_flags() clears ROAM on the global entry.
The early return in batadv_tt_local_add_roam() therefore doesn't prevent
A's ROAMING_ADV.
Just before this call, batadv_tt_local_remove_entry() marks the entry
for later rerouting:
net/batman-adv/translation-table.c:batadv_tt_local_remove_entry() {
...
/* if this global entry addition is due to a roaming, the node
* has to mark the local entry as "roamed" in order to
* correctly reroute packets later
*/
if (roaming)
common->flags |= BATADV_TT_CLIENT_ROAM;
...
}
With the cancel path, the entry is unhashed in the same flags_lock
section, so this ROAM mark is lost immediately.
First, the local roaming reroute seems to be lost. After the unhash,
batadv_tt_local_client_is_roaming() no longer finds the entry, so
batadv_check_unicast_ttvn() skips the reroute. Take a unicast packet for
the client that carries A's current TTVN, for example one that C
rerouted to A. It is now delivered locally instead of being sent back.
Before this patch it was rerouted until the next commit.
Second, C can keep stale state. Consider client X:
X roams C->A, A sends a ROAMING_ADV to C
C commits DEL|ROAM for X, A frees its global X on that DEL
X reappears at C as a new local entry
batadv_tt_local_add_roam() on C returns early, because C's global
X->A carries ROAM
C announces ADD X, which reaches A before A commits its initial ADD
on A: batadv_tt_global_add()->batadv_tt_global_purge_local()->
batadv_tt_local_remove(roaming=false) cancels A's initial ADD
A then sends nothing for X. Before this patch, the merged change went
out as DEL X, and batadv_tt_global_del() on C removed the stale entry.
Now C keeps the ROAM-flagged global entry X->A until
BATADV_TT_CLIENT_ROAM_TIMEOUT expires (600 seconds).
Should the cancel path be skipped for roaming DELs, or for clients that
already sent a ROAMING_ADV?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123171827.3294525-2-sw%40simonwunderlich.de
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
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 [this message]
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=179554084949.3135.16426370585063518179@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