public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: use get_random_u32() for net_namespace hash_mix initialization
@ 2026-04-03 10:36 David Carlier
  2026-04-03 11:34 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: David Carlier @ 2026-04-03 10:36 UTC (permalink / raw)
  To: 'David S . Miller', Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Christian Brauner, Kuniyuki Iwashima,
	Jan Kara, Jeff Layton, Qiliang Yuan
  Cc: netdev, David Carlier

Use get_random_u32() instead of get_random_bytes() to initialize
net->hash_mix. This is the preferred API for obtaining a single
random u32 value, as it returns the value directly rather than
writing through a pointer, and requires no size parameter.

Signed-off-by: David Carlier <devnexen@gmail.com>
---
 net/core/net_namespace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 1057d16d5dd2..deb8b2ec5674 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -411,7 +411,7 @@ static __net_init int preinit_net(struct net *net, struct user_namespace *user_n
 	ref_tracker_dir_init(&net->refcnt_tracker, 128, "net_refcnt");
 	ref_tracker_dir_init(&net->notrefcnt_tracker, 128, "net_notrefcnt");
 
-	get_random_bytes(&net->hash_mix, sizeof(u32));
+	net->hash_mix = get_random_u32();
 	net->dev_base_seq = 1;
 	net->user_ns = user_ns;
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-03 11:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-03 10:36 [PATCH] net: use get_random_u32() for net_namespace hash_mix initialization David Carlier
2026-04-03 11:34 ` Eric Dumazet
2026-04-03 11:47   ` David CARLIER

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox