]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
batman-adv: Fix DAT candidate selection on little endian systems
authorSven Eckelmann <sven@narfation.org>
Thu, 28 Nov 2019 11:25:45 +0000 (12:25 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 28 Apr 2020 18:02:38 +0000 (19:02 +0100)
commit 4cc4a1708903f404d2ca0dfde30e71e052c6cbc9 upstream.

The distributed arp table is using a DHT to store and retrieve MAC address
information for an IP address. This is done using unicast messages to
selected peers. The potential peers are looked up using the IP address and
the VID.

While the IP address is always stored in big endian byte order, this is not
the case of the VID. It can (depending on the host system) either be big
endian or little endian. The host must therefore always convert it to big
endian to ensure that all devices calculate the same peers for the same
lookup data.

Fixes: be1db4f6615b ("batman-adv: make the Distributed ARP Table vlan aware")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/batman-adv/distributed-arp-table.c

index ab83d8b16c453b2196c6b024e8609d7e4b83a244..a326c4fe10878b3dd78965c83c0fbba0639e296e 100644 (file)
@@ -207,9 +207,11 @@ static uint32_t batadv_hash_dat(const void *data, uint32_t size)
 {
        uint32_t hash = 0;
        const struct batadv_dat_entry *dat = data;
+       __be16 vid;
 
        hash = batadv_hash_bytes(hash, &dat->ip, sizeof(dat->ip));
-       hash = batadv_hash_bytes(hash, &dat->vid, sizeof(dat->vid));
+       vid = htons(dat->vid);
+       hash = batadv_hash_bytes(hash, &vid, sizeof(vid));
 
        hash += (hash << 3);
        hash ^= (hash >> 11);