[PATCH] batctl: dat_cache: fix multicast/unicast filter for MAC address

Sven Eckelmann <[email protected]> Sat, 04 Jul 2026 13:44:29 +0200
Newsgroups org.open-mesh.lists.batman
Message-ID <[email protected]>
The -u/-m filters in the DAT cache callback test addr[0], but addr in this
callback is function is the text representation of the mac address - not
the binary representation like in all other functions. The binary check of
the multicast-bit will therefore not correctly identify multicast entries.

The kernel reply BATADV_ATTR_DAT_CACHE_HWADDRESS has to be checked instead.

Fixes: d8dd1ff1a0fe ("batctl: Use netlink to replace some of debugfs")
Signed-off-by: Sven Eckelmann <[email protected]>
---
 dat_cache.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dat_cache.c b/dat_cache.c
index 2dee27a..b8a9656 100644
--- a/dat_cache.c
+++ b/dat_cache.c
@@ -78,10 +78,10 @@ static int dat_cache_callback(struct nl_msg *msg, void *arg)
 	last_seen_msecs = last_seen_msecs % 60000;
 	last_seen_secs = last_seen_msecs / 1000;
 
-	if (opts->read_opt & MULTICAST_ONLY && !(addr[0] & 0x01))
+	if (opts->read_opt & MULTICAST_ONLY && !(hwaddr[0] & 0x01))
 		return NL_OK;
 
-	if (opts->read_opt & UNICAST_ONLY && (addr[0] & 0x01))
+	if (opts->read_opt & UNICAST_ONLY && (hwaddr[0] & 0x01))
 		return NL_OK;
 
 	printf(" * %15s ", addr);

---
base-commit: e93995999e80513db80eba200ea682b5b15556af
change-id: 20260704-bugfixes-dat_cache-4d73b5b4a5b6

Best regards,
--  
Sven Eckelmann <[email protected]>