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-y += uuid.o
compat-y += rhashtable.o
+compat-y += syscall.o
compat-y += ../block/blk-mq-rdma.o
--- /dev/null
+#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 */
#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 */