From: Vinson Lee <vlee@freedesktop.org>
To: trinity@vger.kernel.org
Subject: [PATCH] Fix build on older kernels without BPF.
Date: Tue, 12 Jul 2016 18:43:06 +0000 [thread overview]
Message-ID: <1468348986-13200-1-git-send-email-vlee@freedesktop.org> (raw)
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
next reply other threads:[~2016-07-12 18:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-12 18:43 Vinson Lee [this message]
2016-07-12 19:02 ` [PATCH] Fix build on older kernels without BPF 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1468348986-13200-1-git-send-email-vlee@freedesktop.org \
--to=vlee@freedesktop.org \
--cc=trinity@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.