Netdev List
 help / color / mirror / Atom feed
From: Simon Wunderlich <sw@simonwunderlich.de>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	b.a.t.m.a.n@lists.open-mesh.org,
	Sven Eckelmann <sven@narfation.org>,
	Simon Wunderlich <sw@simonwunderlich.de>
Subject: [PATCH net-next 15/15] batman-adv: tt: simplify NEW flag transition code
Date: Tue, 28 Jul 2026 15:39:18 +0200	[thread overview]
Message-ID: <20260728133918.643267-16-sw@simonwunderlich.de> (raw)
In-Reply-To: <20260728133918.643267-1-sw@simonwunderlich.de>

From: Sven Eckelmann <sven@narfation.org>

The function batadv_tt_local_set_flags() implements support for various
flags and to set/unset them. It is also possible to decide whether this
change should increase the TT size or not.

But in reality, this function is only used to transition tt local entries
from the NEW state and count these entries. Remove the rest of the code to
simplify the function.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
 net/batman-adv/translation-table.c | 37 ++++++++----------------------
 1 file changed, 9 insertions(+), 28 deletions(-)

diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 5295e3a59906f..5e10e6bb7bd6a 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -3853,15 +3853,11 @@ void batadv_tt_free(struct batadv_priv *bat_priv)
 }
 
 /**
- * batadv_tt_local_set_flags() - set or unset the specified flags on the local
- *  table and possibly count them in the TT size
+ * batadv_tt_local_transition_new() - unset the NEW flag on the local
+ *  table and count them in the TT size
  * @bat_priv: the bat priv with all the mesh interface information
- * @flags: the flag to switch
- * @enable: whether to set or unset the flag
- * @count: whether to increase the TT size by the number of changed entries
  */
-static void batadv_tt_local_set_flags(struct batadv_priv *bat_priv, u16 flags,
-				      bool enable, bool count)
+static void batadv_tt_local_transition_new(struct batadv_priv *bat_priv)
 {
 	struct batadv_hashtable *hash = bat_priv->tt.local_hash;
 	struct batadv_tt_common_entry *tt_common_entry;
@@ -3882,27 +3878,12 @@ static void batadv_tt_local_set_flags(struct batadv_priv *bat_priv, u16 flags,
 			entry_flags = &tt_common_entry->flags;
 			old_flags = atomic_read(entry_flags);
 
-			/* the old_flags value of the atomic test-and-
-			 * set/clear decides whether this entry counts as
-			 * changed.
-			 */
-			if (enable) {
-				if ((old_flags & flags) == flags)
-					continue;
-
-				old_flags = atomic_fetch_or(flags, entry_flags);
-				if ((old_flags & flags) == flags)
-					continue;
-			} else {
-				if (!(old_flags & flags))
-					continue;
-
-				old_flags = atomic_fetch_andnot(flags, entry_flags);
-				if (!(old_flags & flags))
-					continue;
-			}
+			if (!(old_flags & BATADV_TT_CLIENT_NEW))
+				continue;
 
-			if (!count)
+			old_flags = atomic_fetch_andnot(BATADV_TT_CLIENT_NEW,
+							entry_flags);
+			if (!(old_flags & BATADV_TT_CLIENT_NEW))
 				continue;
 
 			batadv_tt_local_size_inc(bat_priv,
@@ -3977,7 +3958,7 @@ static void batadv_tt_local_commit_changes_nolock(struct batadv_priv *bat_priv)
 		return;
 	}
 
-	batadv_tt_local_set_flags(bat_priv, BATADV_TT_CLIENT_NEW, false, true);
+	batadv_tt_local_transition_new(bat_priv);
 
 	batadv_tt_local_purge_pending_clients(bat_priv);
 	batadv_tt_local_update_crc(bat_priv);
-- 
2.47.3


      parent reply	other threads:[~2026-07-28 13:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28 13:39 [PATCH net-next 00/15] pull request for net-next: batman-adv 2026-07-28 Simon Wunderlich
2026-07-28 13:39 ` [PATCH net-next 01/15] batman-adv: bla: avoid CRC corruption due to parallel claim add Simon Wunderlich
2026-07-28 13:39 ` [PATCH net-next 02/15] batman-adv: bla: prevent CRC corruptions after claim flush Simon Wunderlich
2026-07-28 13:39 ` [PATCH net-next 03/15] batman-adv: dat: avoid unaligned fault in IP extraction Simon Wunderlich
2026-07-28 13:39 ` [PATCH net-next 04/15] batman-adv: dat: atomically update mac addresses Simon Wunderlich
2026-07-28 13:39 ` [PATCH net-next 05/15] batman-adv: fix TX priority extraction for BATADV_FORW_MCAST Simon Wunderlich
2026-07-28 13:39 ` [PATCH net-next 06/15] batman-adv: mcast: ensure unshared skb for multicast packets Simon Wunderlich
2026-07-28 13:39 ` [PATCH net-next 07/15] batman-adv: mcast: linearize skbuff for packet generation Simon Wunderlich
2026-07-28 13:39 ` [PATCH net-next 08/15] batman-adv: dat: drop non-4addr backwards compatibility Simon Wunderlich
2026-07-28 13:39 ` [PATCH net-next 09/15] batman-adv: add missing kernel-doc comments Simon Wunderlich
2026-07-28 13:39 ` [PATCH net-next 10/15] batman-adv: fix kernel-doc for functions holding skb ownership Simon Wunderlich
2026-07-28 13:39 ` [PATCH net-next 11/15] batman-adv: annotate functions which may reallocate the skbuff Simon Wunderlich
2026-07-28 13:39 ` [PATCH net-next 12/15] batman-adv: split multiple declarations per line Simon Wunderlich
2026-07-28 13:39 ` [PATCH net-next 13/15] batman-adv: switch var declarations to reverse x-mas tree order Simon Wunderlich
2026-07-28 13:39 ` [PATCH net-next 14/15] batman-adv: tt: use atomic flag modifications Simon Wunderlich
2026-07-28 13:39 ` Simon Wunderlich [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=20260728133918.643267-16-sw@simonwunderlich.de \
    --to=sw@simonwunderlich.de \
    --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 \
    /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