netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][nf-next] netfilter: slightly optimize nf_inet_addr_mask
@ 2019-04-28  7:12 Li RongQing
  2019-05-05 23:25 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Li RongQing @ 2019-04-28  7:12 UTC (permalink / raw)
  To: netfilter-devel

using 64bit computation to slightly optimize nf_inet_addr_mask

Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 include/linux/netfilter.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index a7252f3baeb0..996bc247ef6e 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -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);
-- 
2.16.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][nf-next] netfilter: slightly optimize nf_inet_addr_mask
  2019-04-28  7:12 [PATCH][nf-next] netfilter: slightly optimize nf_inet_addr_mask Li RongQing
@ 2019-05-05 23:25 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2019-05-05 23:25 UTC (permalink / raw)
  To: Li RongQing; +Cc: netfilter-devel

On Sun, Apr 28, 2019 at 03:12:19PM +0800, Li RongQing wrote:
> using 64bit computation to slightly optimize nf_inet_addr_mask

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-05 23:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-28  7:12 [PATCH][nf-next] netfilter: slightly optimize nf_inet_addr_mask Li RongQing
2019-05-05 23:25 ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).