c825eee3a971ab8a9d5cacff6ecf405791f6f5c4
[openwrt/staging/noltari.git] /
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
5
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
11 find that define.
12
13 This fixes a build problem with Linux 3.18.
14 Netfilter bug: #1231
15
16 Fixes: f17f9ace8a8 ("extensions: libxt_bpf: support ebpf pinned objects")
17 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
18 ---
19 extensions/libxt_bpf.c | 3 ++-
20 1 file changed, 2 insertions(+), 1 deletion(-)
21
22 --- a/extensions/libxt_bpf.c
23 +++ b/extensions/libxt_bpf.c
24 @@ -22,6 +22,7 @@
25 #include <linux/bpf.h>
26 #endif
27
28 +#include <linux/magic.h>
29 #include <linux/unistd.h>
30
31 #define BCODE_FILE_MAX_LEN_B 1024
32 @@ -62,7 +63,7 @@ static const struct xt_option_entry bpf_
33
34 static int bpf_obj_get(const char *filepath)
35 {
36 -#if defined HAVE_LINUX_BPF_H && defined __NR_bpf
37 +#if defined HAVE_LINUX_BPF_H && defined __NR_bpf && defined BPF_FS_MAGIC
38 union bpf_attr attr;
39
40 memset(&attr, 0, sizeof(attr));