Skip to content

Commit 7aed9f7

Browse files
zx2c4tytso
authored andcommitted
net/route: use get_random_int for random counter
Using get_random_int 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. Also, semantically, it's not really proper to have been assigning an atomic_t in this way before, even if in practice it works fine. Signed-off-by: Jason A. Donenfeld <[email protected]> Cc: David Miller <[email protected]> Signed-off-by: Theodore Ts'o <[email protected]>
1 parent b3d0f78 commit 7aed9f7

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

net/ipv4/route.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,8 +2936,7 @@ static __net_init int rt_genid_init(struct net *net)
29362936
{
29372937
atomic_set(&net->ipv4.rt_genid, 0);
29382938
atomic_set(&net->fnhe_genid, 0);
2939-
get_random_bytes(&net->ipv4.dev_addr_genid,
2940-
sizeof(net->ipv4.dev_addr_genid));
2939+
atomic_set(&net->ipv4.dev_addr_genid, get_random_int());
29412940
return 0;
29422941
}
29432942

0 commit comments

Comments
 (0)