summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2023-01-11 14:06:29 +0100
committerSimon Rettberg2023-01-11 14:06:29 +0100
commitf5ed319b5e804cd81d5eca4d40eacde272d70b55 (patch)
treecd18a909e42ddfdd201cc7e93289e6bad5d7b4a6
parent[KERNEL] Update for Linux 6.1 (diff)
downloaddnbd3-f5ed319b5e804cd81d5eca4d40eacde272d70b55.tar.gz
dnbd3-f5ed319b5e804cd81d5eca4d40eacde272d70b55.tar.xz
dnbd3-f5ed319b5e804cd81d5eca4d40eacde272d70b55.zip
[KERNEL] Actually fix build on 6.0+
-rw-r--r--src/kernel/net.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/kernel/net.c b/src/kernel/net.c
index e24778f..63616ae 100644
--- a/src/kernel/net.c
+++ b/src/kernel/net.c
@@ -26,11 +26,11 @@
#include <dnbd3/shared/serialize.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 14)
-#include <linux/prandom.h>
-#else
#include <linux/random.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)
+#define get_random_u32 prandom_u32
#endif
+
#include <linux/time.h>
#include <linux/ktime.h>
#include <linux/tcp.h>
@@ -203,7 +203,7 @@ static void dnbd3_internal_discover(dnbd3_device_t *dev)
check_order[i] = i;
for (i = 0; i < NUMBER_SERVERS; ++i) {
- j = prandom_u32() % NUMBER_SERVERS;
+ j = get_random_u32() % NUMBER_SERVERS;
if (j != i) {
int tmp = check_order[i];
@@ -231,7 +231,7 @@ static void dnbd3_internal_discover(dnbd3_device_t *dev)
if (host_compare.ss_family == 0)
continue; // Empty slot
// Reduced probability for hosts that have been unreachable
- if (!dev->panic && fails > 50 && (prandom_u32() % 4) != 0)
+ if (!dev->panic && fails > 50 && (get_random_u32() % 4) != 0)
continue; // If not in panic mode, skip server if it failed too many times
if (isize-- <= 0 && !is_same_server(&dev->cur_server.host, &host_compare))
continue; // Only test isize servers plus current server