-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path0002-configure-add-CONFIG_HAVE_ARC4RANDOM.patch
111 lines (96 loc) · 3.59 KB
/
0002-configure-add-CONFIG_HAVE_ARC4RANDOM.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
From 445a4c808badbad3942696ecf16fa60e8129a747 Mon Sep 17 00:00:00 2001
From: Jim Harris <james.r.harris@intel.com>
Date: Fri, 12 Aug 2022 05:00:25 +0000
Subject: [PATCH] configure: add CONFIG_HAVE_ARC4RANDOM
glibc 2.36 added arc4random(), which breaks
the SPDK iSCSI build since it always implements its
own arc4random() implementation on non-FreeBSD OS
(meaning always on Linux).
So instead add a CONFIG_HAVE_ARC4RANDOM and remove
the explicit FreeBSD dependency - this will work on
FreeBSD as well as Linux with >= glibc 2.36.
Also fix check_format.sh, so that it does not
enforce spdk/stdinc.h checks on code snippets in
the configure file.
Fixes issue #2637.
Reported-by: Karl Bonde Torp <k.torp@samsung.com>
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14028 (master)
(cherry picked from commit 43a3984c6c8fde7201d6c8dfe1b680cb88237269)
Change-Id: Iab9da8ae30d62a56869530846372ffddf7138eed
Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15750
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
---
CONFIG | 3 +++
configure | 5 +++++
lib/iscsi/iscsi.c | 5 ++---
scripts/check_format.sh | 2 +-
4 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/CONFIG b/CONFIG
index 5f552fe81..481643dcc 100644
--- a/CONFIG
+++ b/CONFIG
@@ -195,3 +195,6 @@ CONFIG_USDT=n
# Build with IDXD kernel support.
# In this mode, SPDK shares the DSA device with the kernel.
CONFIG_IDXD_KERNEL=n
+
+# arc4random is available in stdlib.h
+CONFIG_HAVE_ARC4RANDOM=n
diff --git a/configure b/configure
index a18f34a00..688d72bfb 100755
--- a/configure
+++ b/configure
@@ -850,6 +850,11 @@ if [[ "${CONFIG[TSAN]}" = "y" ]]; then
fi
fi
+if echo -e '#include <stdlib.h>\nint main(void) { arc4random(); return 0; }\n' \
+ | "${BUILD_CMD[@]}" - 2> /dev/null; then
+ CONFIG[HAVE_ARC4RANDOM]="y"
+fi
+
if [[ "${CONFIG[OCF]}" = "y" ]]; then
# If OCF_PATH is a file, assume it is a library and use it to compile with
if [ -f ${CONFIG[OCF_PATH]} ]; then
diff --git a/lib/iscsi/iscsi.c b/lib/iscsi/iscsi.c
index 00b1d62e2..3c403b972 100644
--- a/lib/iscsi/iscsi.c
+++ b/lib/iscsi/iscsi.c
@@ -62,7 +62,6 @@
#ifdef __FreeBSD__
#define HAVE_SRANDOMDEV 1
-#define HAVE_ARC4RANDOM 1
#endif
struct spdk_iscsi_globals g_iscsi = {
@@ -97,7 +96,7 @@ srandomdev(void)
}
#endif /* HAVE_SRANDOMDEV */
-#ifndef HAVE_ARC4RANDOM
+#ifndef SPDK_CONFIG_HAVE_ARC4RANDOM
static int g_arc4random_initialized = 0;
static uint32_t
@@ -115,7 +114,7 @@ arc4random(void)
r = (r1 << 16) | r2;
return r;
}
-#endif /* HAVE_ARC4RANDOM */
+#endif /* SPDK_CONFIG_HAVE_ARC4RANDOM */
static void
gen_random(uint8_t *buf, size_t len)
diff --git a/scripts/check_format.sh b/scripts/check_format.sh
index 1dbc25d20..e2e471315 100755
--- a/scripts/check_format.sh
+++ b/scripts/check_format.sh
@@ -270,7 +270,7 @@ function check_posix_includes() {
local rc=0
echo -n "Checking for POSIX includes..."
- git grep -I -i -f scripts/posix.txt -- './*' ':!include/spdk/stdinc.h' ':!include/linux/**' ':!lib/rte_vhost*/**' ':!scripts/posix.txt' ':!*.patch' > scripts/posix.log || true
+ git grep -I -i -f scripts/posix.txt -- './*' ':!include/spdk/stdinc.h' ':!include/linux/**' ':!lib/rte_vhost*/**' ':!scripts/posix.txt' ':!*.patch' ':!configure' > scripts/posix.log || true
if [ -s scripts/posix.log ]; then
echo "POSIX includes detected. Please include spdk/stdinc.h instead."
cat scripts/posix.log
--
2.31.1