From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Sven Eckelmann <sven@narfation.org>
Subject: [PATCH] batctl: translate: don't overwrite the search key
Date: Sun, 05 Jul 2026 17:09:45 +0200 [thread overview]
Message-ID: <20260705-bugfixes-translate-v1-1-8a09ee0728da@narfation.org> (raw)
translate_mac_netlink_cb() walks the whole global translation table dump
and searches for an originator address for the provided TT mac address. It
stored that originator back into opts->mac (used for the search key). But
since NL_STOP is no longer used, it might continue to traverse the
translation table but would now use the wrong search key.
Split ethernet address in search key and result field to avoid this
confusion.
Fixes: e2a3d3599cb2 ("batctl: Use common genl socket for netlink_query_common")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
I have now splitted the bugfixes for batctl in topic branches to make it a
little bit easier to review. Similar to the "random bugfixes 2026-06-21"
patchset, they are just various (mostly minor) problems which should be
tackled at some point.
---
netlink.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/netlink.c b/netlink.c
index 46fb993..5ee6c02 100644
--- a/netlink.c
+++ b/netlink.c
@@ -684,7 +684,8 @@ static const int translate_mac_netlink_mandatory[] = {
};
struct translate_mac_netlink_opts {
- struct ether_addr mac;
+ struct ether_addr search;
+ struct ether_addr result;
uint8_t found:1;
struct nlquery_opts query_opts;
};
@@ -725,10 +726,10 @@ static int translate_mac_netlink_cb(struct nl_msg *msg, void *arg)
if (!attrs[BATADV_ATTR_FLAG_BEST])
return NL_OK;
- if (memcmp(&opts->mac, addr, ETH_ALEN) != 0)
+ if (memcmp(&opts->search, addr, ETH_ALEN) != 0)
return NL_OK;
- memcpy(&opts->mac, orig, ETH_ALEN);
+ memcpy(&opts->result, orig, ETH_ALEN);
opts->found = true;
opts->query_opts.err = 0;
@@ -746,7 +747,7 @@ int translate_mac_netlink(struct state *state, const struct ether_addr *mac,
};
int ret;
- memcpy(&opts.mac, mac, ETH_ALEN);
+ memcpy(&opts.search, mac, ETH_ALEN);
ret = netlink_query_common(state, state->mesh_ifindex,
BATADV_CMD_GET_TRANSTABLE_GLOBAL,
@@ -758,7 +759,7 @@ int translate_mac_netlink(struct state *state, const struct ether_addr *mac,
if (!opts.found)
return -ENOENT;
- memcpy(mac_out, &opts.mac, ETH_ALEN);
+ memcpy(mac_out, &opts.result, ETH_ALEN);
return 0;
}
---
base-commit: eb9597d4ca6db17c579f5ae9443c51b013e2fe65
change-id: 20260704-bugfixes-translate-bc3a04dc026c
Best regards,
--
Sven Eckelmann <sven@narfation.org>
reply other threads:[~2026-07-05 15:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260705-bugfixes-translate-v1-1-8a09ee0728da@narfation.org \
--to=sven@narfation.org \
--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