From: "Linus Lüssing" <linus.luessing@c0d3.blue>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: "Linus Lüssing" <linus.luessing@c0d3.blue>
Subject: [batadv,v12 4/5] batman-adv: avoid superfluous DAT DHT_PUT if self-candidate
Date: Sat, 3 Oct 2026 09:26:27 +0200 [thread overview]
Message-ID: <20261003072628.28052-5-linus.luessing@c0d3.blue> (raw)
In-Reply-To: <20261003072628.28052-1-linus.luessing@c0d3.blue>
If we are one of the three closest DAT DHT candidates for a given IPv4
address then three DHT_PUTs to three remote DAT DHT candidates, especially
the last selected DAT DHT candidate, is unnecessary: A DAT DHT_GET from
another node would typically not get to it anyway and would reach us
instead. Because the remote node will take us into account, while we so
far don't take ourself into account in batadv_choose_next_candidate().
Instead of reworking batadv_choose_next_candidate() to take ourself into
account, too, simply, potentially kick out the "worst" remote candidate
at the end of calculation if we are a better candidate. To avoid an
unnecessary DAT DHT_PUT / DHT_GET transmission.
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
---
net/batman-adv/distributed-arp-table.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index 321df338fb8d..52dff46a7c52 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -779,6 +779,9 @@ static void batadv_choose_next_candidate(struct batadv_priv *bat_priv,
* Check if we are a better candidate than the last placed, selected DHT
* candidate for the given IP address key.
*
+ * If we are a better candidate then deselects the last placed, selected
+ * DHT candidate.
+ *
* Return: true if we are a better candidate, false otherwise.
*/
static bool batadv_dat_cmp_self_candidate(struct batadv_priv *bat_priv,
@@ -822,6 +825,14 @@ static bool batadv_dat_cmp_self_candidate(struct batadv_priv *bat_priv,
memcmp(own_orig_addr, last_cand->orig_node->orig, ETH_ALEN) >= 0)
goto out;
+ /* deselect last placed, selected candidate, we take its spot */
+ batadv_dbg(BATADV_DBG_DAT, bat_priv,
+ "%s(): deselecting %pM for hash(IP)=%u\n",
+ __func__, last_cand->orig_node->orig, ip_key);
+
+ last_cand->type = BATADV_DAT_CANDIDATE_NOT_FOUND;
+ batadv_orig_node_put(last_cand->orig_node);
+
ret = true;
out:
if (ret)
--
2.55.0
next prev parent reply other threads:[~2026-10-03 7:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-03 7:26 [batadv,v12 0/5] batman-adv: increase DAT DHT timeout Linus Lüssing
2026-10-03 7:26 ` [batadv,v12 1/5] batman-adv: move local ARP reply code to subfunctions Linus Lüssing
2026-10-03 7:26 ` [batadv,v12 2/5] batman-adv: split DAT cache into DAT cache and DAT DHT Linus Lüssing
2026-10-03 8:04 ` Sven Eckelmann
2026-10-03 7:26 ` [batadv,v12 3/5] batman-adv: increase DAT DHT timeout Linus Lüssing
2026-10-03 7:26 ` Linus Lüssing [this message]
2026-10-03 7:26 ` [batadv,v12 5/5] batman-adv: avoid superfluous DAT DHT_PUT additions to local DAT Linus Lüssing
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=20261003072628.28052-5-linus.luessing@c0d3.blue \
--to=linus.luessing@c0d3.blue \
--cc=b.a.t.m.a.n@lists.open-mesh.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