Message ID | 20180227155655.7176-1-hauke@hauke-m.de |
---|---|
State | Accepted |
Delegated to: | Pablo Neira |
Headers | show |
Series | extensions: libxt_bpf: Fix build with old kernel versions | expand |
On Tue, Feb 27, 2018 at 04:56:55PM +0100, Hauke Mehrtens wrote: > In kernel 3.18 the union bpf_attr does not have a pathname attribute and > BPF_OBJ_GET is also not defined in these versions. > This was added in Linux commit b2197755b263 ("bpf: add support for > persistent maps/progs"). Check for the BPF_FS_MAGIC define which was > also added in this Linux commit and only activate this code in case we > find that define. > > This fixes a build problem with Linux 3.18. > Netfilter bug: #1231 Applied, thanks. -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/extensions/libxt_bpf.c b/extensions/libxt_bpf.c index 9510c190..92958247 100644 --- a/extensions/libxt_bpf.c +++ b/extensions/libxt_bpf.c @@ -22,6 +22,7 @@ #include <linux/bpf.h> #endif +#include <linux/magic.h> #include <linux/unistd.h> #define BCODE_FILE_MAX_LEN_B 1024 @@ -62,7 +63,7 @@ static const struct xt_option_entry bpf_opts_v1[] = { static int bpf_obj_get(const char *filepath) { -#if defined HAVE_LINUX_BPF_H && defined __NR_bpf +#if defined HAVE_LINUX_BPF_H && defined __NR_bpf && defined BPF_FS_MAGIC union bpf_attr attr; memset(&attr, 0, sizeof(attr));
In kernel 3.18 the union bpf_attr does not have a pathname attribute and BPF_OBJ_GET is also not defined in these versions. This was added in Linux commit b2197755b263 ("bpf: add support for persistent maps/progs"). Check for the BPF_FS_MAGIC define which was also added in this Linux commit and only activate this code in case we find that define. This fixes a build problem with Linux 3.18. Netfilter bug: #1231 Fixes: f17f9ace8a8 ("extensions: libxt_bpf: support ebpf pinned objects") Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> --- extensions/libxt_bpf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)