]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - net/core/secure_seq.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[karo-tx-linux.git] / net / core / secure_seq.c
index 3f1ec1586ae174d9bea18de2bcada31c3c88a5bb..897da56f3affae13161d4610989667a82244c308 100644 (file)
@@ -7,28 +7,20 @@
 #include <linux/hrtimer.h>
 #include <linux/ktime.h>
 #include <linux/string.h>
+#include <linux/net.h>
 
 #include <net/secure_seq.h>
 
+#if IS_ENABLED(CONFIG_IPV6) || IS_ENABLED(CONFIG_INET)
 #define NET_SECRET_SIZE (MD5_MESSAGE_BYTES / 4)
 
 static u32 net_secret[NET_SECRET_SIZE] ____cacheline_aligned;
 
-static void net_secret_init(void)
+static __always_inline 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));
 }
+#endif
 
 #ifdef CONFIG_INET
 static u32 seq_scale(u32 seq)