Skip to content

Commit b3d0f78

Browse files
zx2c4tytso
authored andcommitted
net/neighbor: use get_random_u32 for 32-bit hash random
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]>
1 parent d48ad08 commit b3d0f78

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

net/core/neighbour.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,7 @@ static struct neighbour *neigh_alloc(struct neigh_table *tbl, struct net_device
312312

313313
static void neigh_get_hash_rnd(u32 *x)
314314
{
315-
get_random_bytes(x, sizeof(*x));
316-
*x |= 1;
315+
*x = get_random_u32() | 1;
317316
}
318317

319318
static struct neigh_hash_table *neigh_hash_alloc(unsigned int shift)

0 commit comments

Comments
 (0)