Skip to contentSkip to conversation

batadv: Slight optimization of batadv_compare_eth

PATCH Superseded Antonio Quartulli 1 participant 2 messages Dec 10, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 batadv: Slight optimization of batadv_compare_eth

Use the newly added generic routine ether_addr_equal_unaligned to test if possibly unaligned to u16 Ethernet addresses are equal.

This slightly improves comparison time for systems with CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS.

[[email protected]: added compat code for linux <3.14]
---
 compat.h | 6 ++++++
 main.h   | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)
compat.h +6 -0
index 8545b0a..a1c8396 100644
@@ -382,4 +382,10 @@ static int __batadv_interface_kill_vid(struct net_device *dev, __be16 proto,\
 	})
 #endif /* < KERNEL_VERSION(3, 11, 0) */
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0)
+
+#define ether_addr_equal_unaligned(_a, _b) (memcmp(_a, _b, ETH_ALEN) == 0)
+
+#endif /* < KERNEL_VERSION(3, 14, 0) */
+
 #endif /* _NET_BATMAN_ADV_COMPAT_H_ */
main.h +1 -1
index 2f3ac06..d636449 100644
@@ -273,7 +273,7 @@ static inline void batadv_dbg(int type __always_unused,
  */
 static inline int batadv_compare_eth(const void *data1, const void *data2)
 {
-	return memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0;
+	return ether_addr_equal_unaligned(data1, data2);
 }
 
 /**
Signature · 1 line
1.8.5.1
#1 lore raw
Quoted 7 lines · Antonio Quartulli

Use the newly added generic routine ether_addr_equal_unaligned to test if possibly unaligned to u16 Ethernet addresses are equal.

This slightly improves comparison time for systems with CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS.

Joe,

this is just a re-send of your patch for inclusion in our development repo. Sorry for the noise :-)

Cheers,

Signature · 1 line
Antonio Quartulli