030-extensions-libxt_bpf-Fix-build-with-old-kernel-versi.patch 1.3 KB

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