Subject: Re: [1/2 bpf-next] bpf: expose net_device from xdp for metadata

From: kernel test robot <[email-masked]>
Date: Fri, 11 Nov 2022 11:04:13 +0800

Hi John,

I love your patch! Perhaps something to improve:

[auto build test WARNING on bpf-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/John-Fastabend/bpf-expose-net_device-from-xdp-for-metadata/20221110-055550
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link:    https://lore.kernel.org/r/20221109215242.1279993-2-john.fastabend%40gmail.com
patch subject: [1/2 bpf-next] bpf: expose net_device from xdp for metadata
config: i386-defconfig
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/410d4baa8908e723a4b0ef7ca54e24462bb0ea16
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review John-Fastabend/bpf-expose-net_device-from-xdp-for-metadata/20221110-055550
        git checkout 410d4baa8908e723a4b0ef7ca54e24462bb0ea16
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash net/core/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email-masked]>

All warnings (new ones prefixed by >>):

   net/core/filter.c: In function 'xdp_is_valid_access':
   net/core/filter.c:8730:29: error: implicit declaration of function 'bpf_get_btf_vmlinux' [-Werror=implicit-function-declaration]
    8730 |                 info->btf = bpf_get_btf_vmlinux();
         |                             ^~~~~~~~~~~~~~~~~~~
>> net/core/filter.c:8730:27: warning: assignment to 'struct btf *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
    8730 |                 info->btf = bpf_get_btf_vmlinux();
         |                           ^
   cc1: some warnings being treated as errors

vim +8730 net/core/filter.c

  8694	
  8695	static bool xdp_is_valid_access(int off, int size,
  8696					enum bpf_access_type type,
  8697					const struct bpf_prog *prog,
  8698					struct bpf_insn_access_aux *info)
  8699	{
  8700		if (prog->expected_attach_type != BPF_XDP_DEVMAP) {
  8701			switch (off) {
  8702			case offsetof(struct xdp_md, egress_ifindex):
  8703				return false;
  8704			}
  8705		}
  8706	
  8707		if (type == BPF_WRITE) {
  8708			if (bpf_prog_is_dev_bound(prog->aux)) {
  8709				switch (off) {
  8710				case offsetof(struct xdp_md, rx_queue_index):
  8711					return __is_valid_xdp_access(off, size);
  8712				}
  8713			}
  8714			return false;
  8715		}
  8716	
  8717		switch (off) {
  8718		case offsetof(struct xdp_md, data):
  8719			info->reg_type = PTR_TO_PACKET;
  8720			break;
  8721		case offsetof(struct xdp_md, data_meta):
  8722			info->reg_type = PTR_TO_PACKET_META;
  8723			break;
  8724		case offsetof(struct xdp_md, data_end):
  8725			info->reg_type = PTR_TO_PACKET_END;
  8726			break;
  8727		case offsetof(struct xdp_md, rx_dev):
  8728			info->reg_type = PTR_TO_BTF_ID;
  8729			info->btf_id = btf_xdp_get_netdev_id[0];
> 8730			info->btf = bpf_get_btf_vmlinux();
  8731		        if (IS_ERR_OR_NULL(info->btf))
  8732				return false;
  8733			if (size != sizeof(u64))
  8734				return false;
  8735			return true;
  8736		}
  8737	
  8738		return __is_valid_xdp_access(off, size);
  8739	}
  8740	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp