Message ID | 20210811222747.3041445-2-sdf@google.com |
---|---|
State | New |
Headers | show |
Series | [bpf-next,1/2] bpf: Allow bpf_get_netns_cookie in BPF_PROG_TYPE_CGROUP_SOCKOPT | expand |
Hi Stanislav, Thank you for the patch! Yet something to improve: [auto build test ERROR on bpf-next/master] url: https://github.com/0day-ci/linux/commits/Stanislav-Fomichev/bpf-Allow-bpf_get_netns_cookie-in-BPF_PROG_TYPE_CGROUP_SOCKOPT/20210812-062850 base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master config: riscv-randconfig-r026-20210811 (attached as .config) compiler: riscv32-linux-gcc (GCC) 10.3.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/0day-ci/linux/commit/192e9ea84066a6ef07e9d1ce72e7f597b920ada2 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Stanislav-Fomichev/bpf-Allow-bpf_get_netns_cookie-in-BPF_PROG_TYPE_CGROUP_SOCKOPT/20210812-062850 git checkout 192e9ea84066a6ef07e9d1ce72e7f597b920ada2 # save the attached .config to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross O=build_dir ARCH=riscv SHELL=/bin/bash If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): riscv32-linux-ld: kernel/bpf/cgroup.o: in function `.L31': >> cgroup.c:(.text+0x240): undefined reference to `init_net' >> riscv32-linux-ld: cgroup.c:(.text+0x244): undefined reference to `init_net' riscv32-linux-ld: cgroup.c:(.text+0x248): undefined reference to `init_net' --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c index b567ca46555c..2428ecf2b2cf 100644 --- a/kernel/bpf/cgroup.c +++ b/kernel/bpf/cgroup.c @@ -1846,10 +1846,27 @@ const struct bpf_verifier_ops cg_sysctl_verifier_ops = { const struct bpf_prog_ops cg_sysctl_prog_ops = { }; +BPF_CALL_1(bpf_get_netns_cookie_sockopt, struct bpf_sockopt_kern *, ctx) +{ + struct sock *sk = ctx ? ctx->sk : NULL; + const struct net *net = sk ? sock_net(sk) : &init_net; + + return net->net_cookie; +} + +static const struct bpf_func_proto bpf_get_netns_cookie_sockopt_proto = { + .func = bpf_get_netns_cookie_sockopt, + .gpl_only = false, + .ret_type = RET_INTEGER, + .arg1_type = ARG_PTR_TO_CTX_OR_NULL, +}; + static const struct bpf_func_proto * cg_sockopt_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) { switch (func_id) { + case BPF_FUNC_get_netns_cookie: + return &bpf_get_netns_cookie_sockopt_proto; #ifdef CONFIG_NET case BPF_FUNC_sk_storage_get: return &bpf_sk_storage_get_proto;
This is similar to existing BPF_PROG_TYPE_CGROUP_SOCK and BPF_PROG_TYPE_CGROUP_SOCK_ADDR. Signed-off-by: Stanislav Fomichev <sdf@google.com> --- kernel/bpf/cgroup.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)