Commit 49ecc2e9 authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski
Browse files

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: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 7071732c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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]);
+1 −1
Original line number Diff line number Diff line
@@ -1460,7 +1460,7 @@ bool __skb_flow_dissect(const struct net *net,
}
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));
+2 −2
Original line number Diff line number Diff line
@@ -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)
{
+1 −1
Original line number Diff line number Diff line
@@ -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));
+1 −1
Original line number Diff line number Diff line
@@ -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)
Loading