batctl: translate: don't overwrite the search key
PATCH 1/1 batctl: translate: don't overwrite the search key
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.
---
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(-)
netlink.c +6 -5
@@ -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,
Signature · 1 line
Sven Eckelmann <[email protected]>