Skip to contentSkip to conversation

netfilter: slightly optimize nf_inet_addr_mask

PATCH Applied Li RongQing 2 participants 2 messages Apr 28, 2019 – May 5, 2019 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: slightly optimize nf_inet_addr_mask

using 64bit computation to slightly optimize nf_inet_addr_mask

---
 include/linux/netfilter.h | 9 +++++++++
 1 file changed, 9 insertions(+)
include/linux/netfilter.h +9 -0
index a7252f3baeb0..996bc247ef6e 100644
@@ -41,10 +41,19 @@ static inline void nf_inet_addr_mask(const union nf_inet_addr *a1,
 				     union nf_inet_addr *result,
 				     const union nf_inet_addr *mask)
 {
+#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
+	const unsigned long *ua = (const unsigned long *)a1;
+	unsigned long *ur = (unsigned long *)result;
+	const unsigned long *um = (const unsigned long *)mask;
+
+	ur[0] = ua[0] & um[0];
+	ur[1] = ua[1] & um[1];
+#else
 	result->all[0] = a1->all[0] & mask->all[0];
 	result->all[1] = a1->all[1] & mask->all[1];
 	result->all[2] = a1->all[2] & mask->all[2];
 	result->all[3] = a1->all[3] & mask->all[3];
+#endif
 }
 
 int netfilter_init(void);
Signature · 1 line
2.16.2
maintainer Applied
#1 lore raw
Quoted 1 line · Li RongQing

using 64bit computation to slightly optimize nf_inet_addr_mask

Applied, thanks.