1 From a12326ad330c4f7cd8d2b6ae1c4fbcd952c378dc Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Mon, 26 Feb 2018 17:39:09 +0100
4 Subject: [PATCH] extensions: libxt_bpf: Fix build with old kernel versions
6 In kernel 3.18 the union bpf_attr does not have a pathname attribute and
7 BPF_OBJ_GET is also not defined in these versions.
8 This was added in Linux commit b2197755b263 ("bpf: add support for
9 persistent maps/progs"). Check for the BPF_FS_MAGIC define which was
10 also added in this Linux commit and only activate this code in case we
13 This fixes a build problem with Linux 3.18.
16 Fixes: f17f9ace8a8 ("extensions: libxt_bpf: support ebpf pinned objects")
17 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
19 extensions/libxt_bpf.c | 3 ++-
20 1 file changed, 2 insertions(+), 1 deletion(-)
22 --- a/extensions/libxt_bpf.c
23 +++ b/extensions/libxt_bpf.c
25 #include <linux/bpf.h>
28 +#include <linux/magic.h>
29 #include <linux/unistd.h>
31 #define BCODE_FILE_MAX_LEN_B 1024
32 @@ -62,7 +63,7 @@ static const struct xt_option_entry bpf_
34 static int bpf_obj_get(const char *filepath)
36 -#if defined HAVE_LINUX_BPF_H && defined __NR_bpf
37 +#if defined HAVE_LINUX_BPF_H && defined __NR_bpf && defined BPF_FS_MAGIC
40 memset(&attr, 0, sizeof(attr));