From 5ab592f86b20eba62a00157a8d3bad8ff14d913d Mon Sep 17 00:00:00 2001 From: Vladimir Sokolovsky Date: Thu, 7 Feb 2019 01:42:42 +0200 Subject: [PATCH] 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 --- compat/Makefile | 1 + compat/syscall.c | 18 ++++++++++++++++++ include/linux/bpf.h | 13 +++---------- 3 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 compat/syscall.c 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 */ -- 2.46.0