Skip to content

Commit

Permalink
net: switch net_secret key generation to net_get_random_once
Browse files Browse the repository at this point in the history
Cc: Eric Dumazet <edumazet@google.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Hannes Frederic Sowa authored and David S. Miller committed Oct 19, 2013
1 parent 222e83d commit e34c9a6
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions net/core/secure_seq.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <linux/hrtimer.h>
#include <linux/ktime.h>
#include <linux/string.h>
#include <linux/net.h>

#include <net/secure_seq.h>

Expand All @@ -16,18 +17,7 @@ static u32 net_secret[NET_SECRET_SIZE] ____cacheline_aligned;

static void net_secret_init(void)
{
u32 tmp;
int i;

if (likely(net_secret[0]))
return;

for (i = NET_SECRET_SIZE; i > 0;) {
do {
get_random_bytes(&tmp, sizeof(tmp));
} while (!tmp);
cmpxchg(&net_secret[--i], 0, tmp);
}
net_get_random_once(net_secret, sizeof(net_secret));
}

#ifdef CONFIG_INET
Expand Down

0 comments on commit e34c9a6

Please sign in to comment.