summaryrefslogtreecommitdiffstats
path: root/package/trinity/0002-fix-build-when_USE_BPF-is-not-defined.patch
blob: 4fb2c690c5ced69d23ca9d553a894fca43412ab1 (plain)
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
From f447db18b389050ecc5e66dbf549d5953633e23e Mon Sep 17 00:00:00 2001
From: Jan Stancek <jstancek@redhat.com>
Date: Mon, 7 Nov 2016 12:50:27 +0100
Subject: [PATCH] fix build when USE_BPF is not defined

net/bpf.o: In function `bpf_gen_filter': bpf.c:852: undefined reference to `get_rand_bpf_fd'

Signed-off-by: Jan Stancek <jstancek@redhat.com>
[Upstream commit: https://github.com/kernelslacker/trinity/commit/f447db18b389050ecc5e66dbf549d5953633e23e]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 net/bpf.c             | 3 +++
 syscalls/prctl.c      | 4 +++-
 syscalls/setsockopt.c | 2 ++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/net/bpf.c b/net/bpf.c
index 4fe94173..d6ca14bd 100644
--- a/net/bpf.c
+++ b/net/bpf.c
@@ -8,6 +8,7 @@
 #include <string.h>
 
 #include "bpf.h"
+#include "config.h"
 #include "debug.h"
 #include "log.h"
 #include "net.h"
@@ -17,6 +18,7 @@
 #include "utils.h"
 #include "compat.h"
 
+#ifdef USE_BPF
 /**
  * BPF filters are used in networking such as in pf_packet, but also
  * in seccomp for application sand-boxing. Additionally, with arch
@@ -885,3 +887,4 @@ void bpf_gen_filter(unsigned long **addr, unsigned long *addrlen)
 	if (dump_bpf)
 		bpf_disasm_all(bpf->filter, bpf->len);
 }
+#endif
diff --git a/syscalls/prctl.c b/syscalls/prctl.c
index 02d2dbc6..cdbcdc21 100644
--- a/syscalls/prctl.c
+++ b/syscalls/prctl.c
@@ -45,9 +45,11 @@ static int prctl_opts[] = {
 #ifdef USE_SECCOMP
 static void do_set_seccomp(struct syscallrecord *rec)
 {
-	unsigned long *optval = NULL, optlen = 0;
+	unsigned long *optval = NULL, __unused__ optlen = 0;
 
+#ifdef USE_BPF
 	bpf_gen_seccomp(&optval, &optlen);
+#endif
 
 	rec->a2 = SECCOMP_MODE_FILTER;
 	rec->a3 = (unsigned long) optval;
diff --git a/syscalls/setsockopt.c b/syscalls/setsockopt.c
index 8189b7a8..d395e54e 100644
--- a/syscalls/setsockopt.c
+++ b/syscalls/setsockopt.c
@@ -48,7 +48,9 @@ static void socket_setsockopt(struct sockopt *so, __unused__ struct socket_tripl
 	case SO_ATTACH_FILTER: {
 		unsigned long *optval = NULL, optlen = 0;
 
+#ifdef USE_BPF
 		bpf_gen_filter(&optval, &optlen);
+#endif
 
 		so->optval = (unsigned long) optval;
 		so->optlen = optlen;
OpenPOWER on IntegriCloud