Skip to contentSkip to conversation

batman-adv: dat: prevent false sharing between VLANs

PATCH New Sven Eckelmann 1 participant 1 message Jun 13 Batman advanced

lore
Share & tools
lore

Sven Eckelmann

author maintainer
#0 lore raw

PATCH 1/1 batman-adv: dat: prevent false sharing between VLANs

The local hash of DAT entries is supposed to be VLAN (VID) aware. But the adding to the hash and the search in the hash were not checking the VID information of the hash entries. The entries would therefore only be correctly separated when batadv_hash_dat() didn't select the same buckets for different VIDs.

Fixes 3e26722bc9f2 ("batman-adv: make the Distributed ARP Table vlan aware")
---
 net/batman-adv/distributed-arp-table.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
net/batman-adv/distributed-arp-table.c +9 -3
index aaea155b..ae39ceaa 100644
@@ -215,10 +215,13 @@ static void batadv_dat_purge(struct work_struct *work)
  */
 static bool batadv_compare_dat(const struct hlist_node *node, const void *data2)
 {
-	const void *data1 = container_of(node, struct batadv_dat_entry,
-					 hash_entry);
+	const struct batadv_dat_entry *entry1;
+	const struct batadv_dat_entry *entry2;
 
-	return memcmp(data1, data2, sizeof(__be32)) == 0;
+	entry1 = container_of(node, struct batadv_dat_entry, hash_entry);
+	entry2 = data2;
+
+	return entry1->ip == entry2->ip && entry1->vid == entry2->vid;
 }
 
 /**
@@ -345,6 +348,9 @@ batadv_dat_entry_hash_find(struct batadv_priv *bat_priv, __be32 ip,
 		if (dat_entry->ip != ip)
 			continue;
 
+		if (dat_entry->vid != vid)
+			continue;
+
 		if (!kref_get_unless_zero(&dat_entry->refcount))
 			continue;
 

---
base-commit: c7518adb8b6ebdc481f6ed1fc42c7f45099806af
change-id: 20260613-dat-vid-33d38e309eb2

Best regards,

Signature · 1 line
Sven Eckelmann <[email protected]>