diff options
author | Li RongQing <lirongqing@baidu.com> | 2019-04-28 09:12:19 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2019-05-06 01:18:58 +0200 |
commit | 522e4077e8dcdfc5b8e96469d3bc2324bc5d6466 (patch) | |
tree | 0c5dc43dc0132d9c355820ec48f1cb8f83e9f1e5 /include | |
parent | netfilter: xt_hashlimit: use struct_size() helper (diff) | |
download | linux-522e4077e8dcdfc5b8e96469d3bc2324bc5d6466.tar.xz linux-522e4077e8dcdfc5b8e96469d3bc2324bc5d6466.zip |
netfilter: slightly optimize nf_inet_addr_mask
using 64bit computation to slightly optimize nf_inet_addr_mask
Signed-off-by: Li RongQing <lirongqing@baidu.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/netfilter.h | 9 |
1 files changed, 9 insertions, 0 deletions
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); |