From: Vladimir Sokolovsky Date: Wed, 6 Feb 2019 23:42:42 +0000 (+0200) Subject: Move bpf_prog_sub to be exported by compat X-Git-Tag: vofed-4.17-1-rc1^0 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fofed_4_17_1;p=compat-rdma%2Fcompat.git Move bpf_prog_sub to be exported by compat 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 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 --- diff --git a/compat/Makefile b/compat/Makefile index 6d174d4..954439f 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -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 index 0000000..abe22d5 --- /dev/null +++ b/compat/syscall.c @@ -0,0 +1,18 @@ +#ifdef HAVE_XDP_BUFF + +#ifndef HAVE_BPF_PROG_SUB +#include +#include +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 */ diff --git a/include/linux/bpf.h b/include/linux/bpf.h index b90db74..6575582 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -15,16 +15,9 @@ static inline struct bpf_prog *bpf_prog_inc(struct bpf_prog *prog) #endif #ifndef HAVE_BPF_PROG_SUB -#include -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 */