]> git.openfabrics.org - ~aditr/compat.git/commitdiff
Move bpf_prog_sub to be exported by compat ofed
authorVladimir Sokolovsky <vlad@mellanox.com>
Wed, 6 Feb 2019 23:42:42 +0000 (01:42 +0200)
committerVladimir Sokolovsky <vlad@mellanox.com>
Wed, 6 Feb 2019 23:44:03 +0000 (01:44 +0200)
Having bpf_prog_sub defined in the header file is causing compilation
issues on RHEL-7.6, since this OS does not really support XDP, it just
has only an empty implementation of it, so some parts can be missing.

The #include <linux/filter.h> caused the build issues, so we move the
backport to a compat C file and export it there, similar to upstream
where they also implement this function in a C file (kernel/bpf/syscall.c).

Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
compat/Makefile
compat/syscall.c [new file with mode: 0644]
include/linux/bpf.h

index 6d174d4c6cbb8e9eac885cc74cbe7a99901ef976..954439fd5a42d70556f0ed6ebde9e49bd382ad47 100644 (file)
@@ -15,5 +15,6 @@ compat-$(CONFIG_COMPAT_KERNEL_4_16) += compat-4.16.o
 
 compat-y += uuid.o
 compat-y += rhashtable.o
+compat-y += syscall.o
 
 compat-y += ../block/blk-mq-rdma.o
diff --git a/compat/syscall.c b/compat/syscall.c
new file mode 100644 (file)
index 0000000..abe22d5
--- /dev/null
@@ -0,0 +1,18 @@
+#ifdef HAVE_XDP_BUFF
+
+#ifndef HAVE_BPF_PROG_SUB
+#include <linux/filter.h>
+#include <linux/bpf.h>
+void bpf_prog_sub(struct bpf_prog *prog, int i)
+{
+       /* Only to be used for undoing previous bpf_prog_add() in some
+        * error path. We still know that another entity in our call
+        * path holds a reference to the program, thus atomic_sub() can
+        * be safely used in such cases!
+        */
+       WARN_ON(atomic_sub_return(i, &prog->aux->refcnt) == 0);
+}
+EXPORT_SYMBOL_GPL(bpf_prog_sub);
+#endif /* HAVE_BPF_PROG_SUB */
+
+#endif /* HAVE_XDP_BUFF */
index b90db74bf18958d40406bcf5307063a0bf77cd0f..657558228afd80562bc45d1f7baf1f586ff1293a 100644 (file)
@@ -15,16 +15,9 @@ static inline struct bpf_prog *bpf_prog_inc(struct bpf_prog *prog)
 #endif
 
 #ifndef HAVE_BPF_PROG_SUB
-#include <linux/filter.h>
-static inline void bpf_prog_sub(struct bpf_prog *prog, int i)
-{
-       /* Only to be used for undoing previous bpf_prog_add() in some
-        * error path. We still know that another entity in our call
-        * path holds a reference to the program, thus atomic_sub() can
-        * be safely used in such cases!
-        */
-       WARN_ON(atomic_sub_return(i, &prog->aux->refcnt) == 0);
-}
+struct bpf_prog;
+#define bpf_prog_sub LINUX_BACKPORT(bpf_prog_sub)
+void bpf_prog_sub(struct bpf_prog *prog, int i);
 #endif
 
 #endif /* HAVE_LINUX_BPF_H */