Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: align static siphash keys

siphash keys use 16 bytes.

Define siphash_aligned_key_t macro so that we can make sure they
are not crossing a cache line boundary.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
49ecc2e9 7071732c

+14 -12
+2
include/linux/siphash.h
··· 21 21 u64 key[2]; 22 22 } siphash_key_t; 23 23 24 + #define siphash_aligned_key_t siphash_key_t __aligned(16) 25 + 24 26 static inline bool siphash_key_is_zero(const siphash_key_t *key) 25 27 { 26 28 return !(key->key[0] | key->key[1]);
+1 -1
net/core/flow_dissector.c
··· 1460 1460 } 1461 1461 EXPORT_SYMBOL(__skb_flow_dissect); 1462 1462 1463 - static siphash_key_t hashrnd __read_mostly; 1463 + static siphash_aligned_key_t hashrnd; 1464 1464 static __always_inline void __flow_hash_secret_init(void) 1465 1465 { 1466 1466 net_get_random_once(&hashrnd, sizeof(hashrnd));
+2 -2
net/core/secure_seq.c
··· 19 19 #include <linux/in6.h> 20 20 #include <net/tcp.h> 21 21 22 - static siphash_key_t net_secret __read_mostly; 23 - static siphash_key_t ts_secret __read_mostly; 22 + static siphash_aligned_key_t net_secret; 23 + static siphash_aligned_key_t ts_secret; 24 24 25 25 static __always_inline void net_secret_init(void) 26 26 {
+1 -1
net/ipv4/route.c
··· 602 602 603 603 static u32 fnhe_hashfun(__be32 daddr) 604 604 { 605 - static siphash_key_t fnhe_hash_key __read_mostly; 605 + static siphash_aligned_key_t fnhe_hash_key; 606 606 u64 hval; 607 607 608 608 net_get_random_once(&fnhe_hash_key, sizeof(fnhe_hash_key));
+1 -1
net/ipv4/syncookies.c
··· 14 14 #include <net/tcp.h> 15 15 #include <net/route.h> 16 16 17 - static siphash_key_t syncookie_secret[2] __read_mostly; 17 + static siphash_aligned_key_t syncookie_secret[2]; 18 18 19 19 #define COOKIEBITS 24 /* Upper bits store count */ 20 20 #define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1)
+1 -1
net/ipv6/route.c
··· 1485 1485 static u32 rt6_exception_hash(const struct in6_addr *dst, 1486 1486 const struct in6_addr *src) 1487 1487 { 1488 - static siphash_key_t rt6_exception_key __read_mostly; 1488 + static siphash_aligned_key_t rt6_exception_key; 1489 1489 struct { 1490 1490 struct in6_addr dst; 1491 1491 struct in6_addr src;
+1 -1
net/ipv6/syncookies.c
··· 20 20 #define COOKIEBITS 24 /* Upper bits store count */ 21 21 #define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1) 22 22 23 - static siphash_key_t syncookie6_secret[2] __read_mostly; 23 + static siphash_aligned_key_t syncookie6_secret[2]; 24 24 25 25 /* RFC 2460, Section 8.3: 26 26 * [ipv6 tcp] MSS must be computed as the maximum packet size minus 60 [..]
+2 -2
net/netfilter/nf_conntrack_core.c
··· 189 189 unsigned int nf_conntrack_max __read_mostly; 190 190 EXPORT_SYMBOL_GPL(nf_conntrack_max); 191 191 seqcount_spinlock_t nf_conntrack_generation __read_mostly; 192 - static siphash_key_t nf_conntrack_hash_rnd __read_mostly; 192 + static siphash_aligned_key_t nf_conntrack_hash_rnd; 193 193 194 194 static u32 hash_conntrack_raw(const struct nf_conntrack_tuple *tuple, 195 195 unsigned int zoneid, ··· 482 482 */ 483 483 u32 nf_ct_get_id(const struct nf_conn *ct) 484 484 { 485 - static __read_mostly siphash_key_t ct_id_seed; 485 + static siphash_aligned_key_t ct_id_seed; 486 486 unsigned long a, b, c, d; 487 487 488 488 net_get_random_once(&ct_id_seed, sizeof(ct_id_seed));
+1 -1
net/netfilter/nf_conntrack_expect.c
··· 41 41 unsigned int nf_ct_expect_max __read_mostly; 42 42 43 43 static struct kmem_cache *nf_ct_expect_cachep __read_mostly; 44 - static siphash_key_t nf_ct_expect_hashrnd __read_mostly; 44 + static siphash_aligned_key_t nf_ct_expect_hashrnd; 45 45 46 46 /* nf_conntrack_expect helper functions */ 47 47 void nf_ct_unlink_expect_report(struct nf_conntrack_expect *exp,
+1 -1
net/netfilter/nf_conntrack_netlink.c
··· 2997 2997 2998 2998 static __be32 nf_expect_get_id(const struct nf_conntrack_expect *exp) 2999 2999 { 3000 - static __read_mostly siphash_key_t exp_id_seed; 3000 + static siphash_aligned_key_t exp_id_seed; 3001 3001 unsigned long a, b, c, d; 3002 3002 3003 3003 net_get_random_once(&exp_id_seed, sizeof(exp_id_seed));
+1 -1
net/netfilter/nf_nat_core.c
··· 34 34 35 35 static struct hlist_head *nf_nat_bysource __read_mostly; 36 36 static unsigned int nf_nat_htable_size __read_mostly; 37 - static siphash_key_t nf_nat_hash_rnd __read_mostly; 37 + static siphash_aligned_key_t nf_nat_hash_rnd; 38 38 39 39 struct nf_nat_lookup_hook_priv { 40 40 struct nf_hook_entries __rcu *entries;