* [PATCH][nf-next] netfilter: optimize nf_inet_addr_cmp
@ 2019-03-26 12:06 Li RongQing
2019-04-08 21:25 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Li RongQing @ 2019-03-26 12:06 UTC (permalink / raw)
To: netfilter-devel
optimize nf_inet_addr_cmp by 64bit xor computation
similar to ipv6_addr_equal()
Signed-off-by: Yuan Linsi <yuanlinsi01@baidu.com>
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
include/linux/netfilter.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index 72cb19c3db6a..4e0145ea033e 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -24,10 +24,17 @@ static inline int NF_DROP_GETERR(int verdict)
static inline int nf_inet_addr_cmp(const union nf_inet_addr *a1,
const union nf_inet_addr *a2)
{
+#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
+ const unsigned long *ul1 = (const unsigned long *)a1;
+ const unsigned long *ul2 = (const unsigned long *)a2;
+
+ return ((ul1[0] ^ ul2[0]) | (ul1[1] ^ ul2[1])) == 0UL;
+#else
return a1->all[0] == a2->all[0] &&
a1->all[1] == a2->all[1] &&
a1->all[2] == a2->all[2] &&
a1->all[3] == a2->all[3];
+#endif
}
static inline void nf_inet_addr_mask(const union nf_inet_addr *a1,
--
2.16.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][nf-next] netfilter: optimize nf_inet_addr_cmp
2019-03-26 12:06 [PATCH][nf-next] netfilter: optimize nf_inet_addr_cmp Li RongQing
@ 2019-04-08 21:25 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2019-04-08 21:25 UTC (permalink / raw)
To: Li RongQing; +Cc: netfilter-devel
On Tue, Mar 26, 2019 at 08:06:20PM +0800, Li RongQing wrote:
> optimize nf_inet_addr_cmp by 64bit xor computation
> similar to ipv6_addr_equal()
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-08 21:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-26 12:06 [PATCH][nf-next] netfilter: optimize nf_inet_addr_cmp Li RongQing
2019-04-08 21:25 ` Pablo Neira Ayuso
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.