]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: align static siphash keys
authorEric Dumazet <edumazet@google.com>
Mon, 15 Nov 2021 17:23:03 +0000 (09:23 -0800)
committerJakub Kicinski <kuba@kernel.org>
Wed, 17 Nov 2021 03:07:54 +0000 (19:07 -0800)
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>
include/linux/siphash.h
net/core/flow_dissector.c
net/core/secure_seq.c
net/ipv4/route.c
net/ipv4/syncookies.c
net/ipv6/route.c
net/ipv6/syncookies.c
net/netfilter/nf_conntrack_core.c
net/netfilter/nf_conntrack_expect.c
net/netfilter/nf_conntrack_netlink.c
net/netfilter/nf_nat_core.c

index bf21591a9e5e653585c26cb3f3f0857256c0eb89..3f7427b9e9357d98b1e21a981cf227195bbdd2aa 100644 (file)
@@ -21,6 +21,8 @@ typedef struct {
        u64 key[2];
 } siphash_key_t;
 
+#define siphash_aligned_key_t siphash_key_t __aligned(16)
+
 static inline bool siphash_key_is_zero(const siphash_key_t *key)
 {
        return !(key->key[0] | key->key[1]);
index 3255f57f5131af315f0148909e69ff4c91e66b94..257976cb55cee86ae16623e240c553eb78ad433f 100644 (file)
@@ -1460,7 +1460,7 @@ out_bad:
 }
 EXPORT_SYMBOL(__skb_flow_dissect);
 
-static siphash_key_t hashrnd __read_mostly;
+static siphash_aligned_key_t hashrnd;
 static __always_inline void __flow_hash_secret_init(void)
 {
        net_get_random_once(&hashrnd, sizeof(hashrnd));
index b5bc680d475536de6da68a9a8815691cf81176a6..9b8443774449f5bb8cd2c62ca34eedf139eeb3ed 100644 (file)
@@ -19,8 +19,8 @@
 #include <linux/in6.h>
 #include <net/tcp.h>
 
-static siphash_key_t net_secret __read_mostly;
-static siphash_key_t ts_secret __read_mostly;
+static siphash_aligned_key_t net_secret;
+static siphash_aligned_key_t ts_secret;
 
 static __always_inline void net_secret_init(void)
 {
index 0b4103b1e6220f97f11a75f960476c161ccb3f39..243a0c52be42b60226a38dce980956b33e583d80 100644 (file)
@@ -602,7 +602,7 @@ static void fnhe_remove_oldest(struct fnhe_hash_bucket *hash)
 
 static u32 fnhe_hashfun(__be32 daddr)
 {
-       static siphash_key_t fnhe_hash_key __read_mostly;
+       static siphash_aligned_key_t fnhe_hash_key;
        u64 hval;
 
        net_get_random_once(&fnhe_hash_key, sizeof(fnhe_hash_key));
index 8696dc343ad2cd08fabfb714a32ac67459e4df7e..2cb3b852d14861231ac47f0b3e4daeb57682ffd2 100644 (file)
@@ -14,7 +14,7 @@
 #include <net/tcp.h>
 #include <net/route.h>
 
-static siphash_key_t syncookie_secret[2] __read_mostly;
+static siphash_aligned_key_t syncookie_secret[2];
 
 #define COOKIEBITS 24  /* Upper bits store count */
 #define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1)
index 3ae25b8ffbd6fbeda4b46438dc14b11235558f10..5e8f2f15607db7e6589b8bdb984e62512ad30589 100644 (file)
@@ -1485,7 +1485,7 @@ static void rt6_exception_remove_oldest(struct rt6_exception_bucket *bucket)
 static u32 rt6_exception_hash(const struct in6_addr *dst,
                              const struct in6_addr *src)
 {
-       static siphash_key_t rt6_exception_key __read_mostly;
+       static siphash_aligned_key_t rt6_exception_key;
        struct {
                struct in6_addr dst;
                struct in6_addr src;
index e8cfb9e997bf062d24cf3e4d4e95a447890c7952..d1b61d00368e1f58725e9997f74a0b144901277e 100644 (file)
@@ -20,7 +20,7 @@
 #define COOKIEBITS 24  /* Upper bits store count */
 #define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1)
 
-static siphash_key_t syncookie6_secret[2] __read_mostly;
+static siphash_aligned_key_t syncookie6_secret[2];
 
 /* RFC 2460, Section 8.3:
  * [ipv6 tcp] MSS must be computed as the maximum packet size minus 60 [..]
index 770a63103c7a4240b8559a97f707588d569beba8..054ee9d25efe174684025d60ea7b72e79c7ca19e 100644 (file)
@@ -189,7 +189,7 @@ EXPORT_SYMBOL_GPL(nf_conntrack_htable_size);
 unsigned int nf_conntrack_max __read_mostly;
 EXPORT_SYMBOL_GPL(nf_conntrack_max);
 seqcount_spinlock_t nf_conntrack_generation __read_mostly;
-static siphash_key_t nf_conntrack_hash_rnd __read_mostly;
+static siphash_aligned_key_t nf_conntrack_hash_rnd;
 
 static u32 hash_conntrack_raw(const struct nf_conntrack_tuple *tuple,
                              unsigned int zoneid,
@@ -482,7 +482,7 @@ EXPORT_SYMBOL_GPL(nf_ct_invert_tuple);
  */
 u32 nf_ct_get_id(const struct nf_conn *ct)
 {
-       static __read_mostly siphash_key_t ct_id_seed;
+       static siphash_aligned_key_t ct_id_seed;
        unsigned long a, b, c, d;
 
        net_get_random_once(&ct_id_seed, sizeof(ct_id_seed));
index f562eeef42349e6e40f15b056405dd53d9916f1e..1e89b595ecd086eb55f6fb8d9aa31f3abe2afc33 100644 (file)
@@ -41,7 +41,7 @@ EXPORT_SYMBOL_GPL(nf_ct_expect_hash);
 unsigned int nf_ct_expect_max __read_mostly;
 
 static struct kmem_cache *nf_ct_expect_cachep __read_mostly;
-static siphash_key_t nf_ct_expect_hashrnd __read_mostly;
+static siphash_aligned_key_t nf_ct_expect_hashrnd;
 
 /* nf_conntrack_expect helper functions */
 void nf_ct_unlink_expect_report(struct nf_conntrack_expect *exp,
index f1e5443fe7c74cde3f5f0a1a01bcbe530bedb75c..3d6c8da3de1fbbfc64dea06ab5946f9e79ff72ee 100644 (file)
@@ -2997,7 +2997,7 @@ static const union nf_inet_addr any_addr;
 
 static __be32 nf_expect_get_id(const struct nf_conntrack_expect *exp)
 {
-       static __read_mostly siphash_key_t exp_id_seed;
+       static siphash_aligned_key_t exp_id_seed;
        unsigned long a, b, c, d;
 
        net_get_random_once(&exp_id_seed, sizeof(exp_id_seed));
index 4d50d51db796276c84fbc3486b870bd591d93796..ab9f6c75524d80c9d3ef032c9911e60b02206b88 100644 (file)
@@ -34,7 +34,7 @@ static unsigned int nat_net_id __read_mostly;
 
 static struct hlist_head *nf_nat_bysource __read_mostly;
 static unsigned int nf_nat_htable_size __read_mostly;
-static siphash_key_t nf_nat_hash_rnd __read_mostly;
+static siphash_aligned_key_t nf_nat_hash_rnd;
 
 struct nf_nat_lookup_hook_priv {
        struct nf_hook_entries __rcu *entries;