From: Dave Jones <davej@codemonkey.org.uk>
To: Vinson Lee <vlee@freedesktop.org>
Cc: trinity@vger.kernel.org
Subject: Re: [PATCH] Fix build on older kernels without BPF.
Date: Tue, 12 Jul 2016 15:02:17 -0400 [thread overview]
Message-ID: <20160712190217.GA5525@codemonkey.org.uk> (raw)
In-Reply-To: <1468348986-13200-1-git-send-email-vlee@freedesktop.org>
On Tue, Jul 12, 2016 at 06:43:06PM +0000, Vinson Lee wrote:
> 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
> };
This might be cleaner to wrap the whole of syscalls/bpf.c in one ifdef, and then
add additional ones to include/syscalls-*.h to look like
#ifdef USE_BPF
{ .entry = &syscall_bpf },
#else
{ .entry = NULL },
#endif
I can't remember if the tables code handles a NULL .entry in the middle though.
Might need some tweaking.
Dave
next prev parent reply other threads:[~2016-07-12 19:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-12 18:43 [PATCH] Fix build on older kernels without BPF Vinson Lee
2016-07-12 19:02 ` Dave Jones [this message]
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=20160712190217.GA5525@codemonkey.org.uk \
--to=davej@codemonkey.org.uk \
--cc=trinity@vger.kernel.org \
--cc=vlee@freedesktop.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 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).