Skip to content

Commit

Permalink
net/neighbor: use get_random_u32 for 32-bit hash random
Browse files Browse the repository at this point in the history
Using get_random_u32 here is faster, more fitting of the use case, and
just as cryptographically secure. It also has the benefit of providing
better randomness at early boot, which is when many of these structures
are assigned.

Signed-off-by: Jason A. Donenfeld <[email protected]>
Cc: David Miller <[email protected]>
Signed-off-by: Theodore Ts'o <[email protected]>
  • Loading branch information
zx2c4 authored and tytso committed Jun 20, 2017
1 parent d48ad08 commit b3d0f78
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions net/core/neighbour.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,7 @@ static struct neighbour *neigh_alloc(struct neigh_table *tbl, struct net_device

static void neigh_get_hash_rnd(u32 *x)
{
get_random_bytes(x, sizeof(*x));
*x |= 1;
*x = get_random_u32() | 1;
}

static struct neigh_hash_table *neigh_hash_alloc(unsigned int shift)
Expand Down

0 comments on commit b3d0f78

Please sign in to comment.