trinity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix build on older kernels without BPF.
@ 2016-07-12 18:43 Vinson Lee
  2016-07-12 19:02 ` Dave Jones
  0 siblings, 1 reply; 8+ messages in thread
From: Vinson Lee @ 2016-07-12 18:43 UTC (permalink / raw)
  To: trinity

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
---
 configure      |    1 +
 syscalls/bpf.c |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index 8d95929..ca37e4e 100755
--- a/configure
+++ b/configure
@@ -239,6 +239,7 @@ check_header execinfo.h USE_BACKTRACE
 check_header netatalk/at.h USE_APPLETALK
 check_header netrom/netrom.h USE_NETROM
 check_header netrose/rose.h USE_ROSE
+check_header linux/bpf.h USE_BPF
 
 rm -f "$TMP" "$TMP.log" "$TMP.c"
 
diff --git a/syscalls/bpf.c b/syscalls/bpf.c
index b2f57d3..4788082 100644
--- a/syscalls/bpf.c
+++ b/syscalls/bpf.c
@@ -1,13 +1,16 @@
 /*
  * SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size)
  */
+#ifdef USE_BPF
 #include <linux/bpf.h>
+#endif
 #include <linux/filter.h>
 #include "arch.h"
 #include "net.h"
 #include "random.h"
 #include "sanitise.h"
 
+#ifdef USE_BPF
 static unsigned long bpf_prog_types[] = {
 	BPF_PROG_TYPE_UNSPEC,
 	BPF_PROG_TYPE_SOCKET_FILTER,
@@ -15,9 +18,11 @@ static unsigned long bpf_prog_types[] = {
 	BPF_PROG_TYPE_SCHED_CLS,
 	BPF_PROG_TYPE_SCHED_ACT,
 };
+#endif
 
 static const char license[] = "GPLv2";
 
+#ifdef USE_BPF
 static void bpf_prog_load(struct syscallrecord *rec)
 {
 	unsigned long *insns = NULL, len = 0;
@@ -49,18 +54,22 @@ static void bpf_prog_load(struct syscallrecord *rec)
 	rec->a2 = (unsigned long) attr;
 	rec->a3 = sizeof(attr);
 }
+#endif
 
 static void sanitise_bpf(struct syscallrecord *rec)
 {
 	switch (rec->a1) {
+#ifdef USE_BPF
 	case BPF_PROG_LOAD:
 		bpf_prog_load(rec);
 		break;
+#endif
 	default:
 		break;
 	}
 }
 
+#ifdef USE_BPF
 static void post_bpf(struct syscallrecord *rec)
 {
 	union bpf_attr *attr;
@@ -84,10 +93,15 @@ static void post_bpf(struct syscallrecord *rec)
 		break;
 	}
 }
+#else
+static void post_bpf(__unused__ struct syscallrecord *rec) { }
+#endif
 
 static unsigned long bpf_flags[] = {
+#ifdef USE_BPF
 	BPF_MAP_CREATE, BPF_MAP_LOOKUP_ELEM, BPF_MAP_UPDATE_ELEM, BPF_MAP_DELETE_ELEM,
 	BPF_MAP_GET_NEXT_KEY, BPF_PROG_LOAD,
+#endif
 };
 
 struct syscallentry syscall_bpf = {
-- 
1.7.1

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

end of thread, other threads:[~2016-08-05 18:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-12 18:43 [PATCH] Fix build on older kernels without BPF Vinson Lee
2016-07-12 19:02 ` Dave Jones
2016-07-12 21:33   ` [PATCH v2] " Vinson Lee
2016-07-21 20:10     ` Dave Jones
2016-07-26  0:24       ` Vinson Lee
2016-07-26  0:59         ` Dave Jones
2016-08-04 20:36           ` Dave Jones
2016-08-05 18:44             ` Dave Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).