net/ipv4/fou_bpf.c:46:17: warning: no previous declaration for 'bpf_skb_set_fou_encap'

From: kernel test robot
Date: Wed Aug 16 2023 - 08:04:41 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 4853c74bd7ab7fdb83f319bd9ace8a08c031e9b6
commit: c50e96099edb134bf107fafc02715fbc4aa2277f bpf,fou: Add bpf_skb_{set,get}_fou_encap kfuncs
date: 4 months ago
config: x86_64-buildonly-randconfig-r001-20230816 (https://download.01.org/0day-ci/archive/20230816/202308161949.ynVqsx87-lkp@xxxxxxxxx/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce: (https://download.01.org/0day-ci/archive/20230816/202308161949.ynVqsx87-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308161949.ynVqsx87-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

>> net/ipv4/fou_bpf.c:46:17: warning: no previous declaration for 'bpf_skb_set_fou_encap' [-Wmissing-declarations]
__bpf_kfunc int bpf_skb_set_fou_encap(struct __sk_buff *skb_ctx,
^~~~~~~~~~~~~~~~~~~~~
>> net/ipv4/fou_bpf.c:88:17: warning: no previous declaration for 'bpf_skb_get_fou_encap' [-Wmissing-declarations]
__bpf_kfunc int bpf_skb_get_fou_encap(struct __sk_buff *skb_ctx,
^~~~~~~~~~~~~~~~~~~~~


vim +/bpf_skb_set_fou_encap +46 net/ipv4/fou_bpf.c

24
25 __diag_push();
26 __diag_ignore_all("-Wmissing-prototypes",
27 "Global functions as their definitions will be in BTF");
28
29 /* bpf_skb_set_fou_encap - Set FOU encap parameters
30 *
31 * This function allows for using GUE or FOU encapsulation together with an
32 * ipip device in collect-metadata mode.
33 *
34 * It is meant to be used in BPF tc-hooks and after a call to the
35 * bpf_skb_set_tunnel_key helper, responsible for setting IP addresses.
36 *
37 * Parameters:
38 * @skb_ctx Pointer to ctx (__sk_buff) in TC program. Cannot be NULL
39 * @encap Pointer to a `struct bpf_fou_encap` storing UDP src and
40 * dst ports. If sport is set to 0 the kernel will auto-assign a
41 * port. This is similar to using `encap-sport auto`.
42 * Cannot be NULL
43 * @type Encapsulation type for the packet. Their definitions are
44 * specified in `enum bpf_fou_encap_type`
45 */
> 46 __bpf_kfunc int bpf_skb_set_fou_encap(struct __sk_buff *skb_ctx,
47 struct bpf_fou_encap *encap, int type)
48 {
49 struct sk_buff *skb = (struct sk_buff *)skb_ctx;
50 struct ip_tunnel_info *info = skb_tunnel_info(skb);
51
52 if (unlikely(!encap))
53 return -EINVAL;
54
55 if (unlikely(!info || !(info->mode & IP_TUNNEL_INFO_TX)))
56 return -EINVAL;
57
58 switch (type) {
59 case FOU_BPF_ENCAP_FOU:
60 info->encap.type = TUNNEL_ENCAP_FOU;
61 break;
62 case FOU_BPF_ENCAP_GUE:
63 info->encap.type = TUNNEL_ENCAP_GUE;
64 break;
65 default:
66 info->encap.type = TUNNEL_ENCAP_NONE;
67 }
68
69 if (info->key.tun_flags & TUNNEL_CSUM)
70 info->encap.flags |= TUNNEL_ENCAP_FLAG_CSUM;
71
72 info->encap.sport = encap->sport;
73 info->encap.dport = encap->dport;
74
75 return 0;
76 }
77
78 /* bpf_skb_get_fou_encap - Get FOU encap parameters
79 *
80 * This function allows for reading encap metadata from a packet received
81 * on an ipip device in collect-metadata mode.
82 *
83 * Parameters:
84 * @skb_ctx Pointer to ctx (__sk_buff) in TC program. Cannot be NULL
85 * @encap Pointer to a struct bpf_fou_encap storing UDP source and
86 * destination port. Cannot be NULL
87 */
> 88 __bpf_kfunc int bpf_skb_get_fou_encap(struct __sk_buff *skb_ctx,
89 struct bpf_fou_encap *encap)
90 {
91 struct sk_buff *skb = (struct sk_buff *)skb_ctx;
92 struct ip_tunnel_info *info = skb_tunnel_info(skb);
93
94 if (unlikely(!info))
95 return -EINVAL;
96
97 encap->sport = info->encap.sport;
98 encap->dport = info->encap.dport;
99
100 return 0;
101 }
102

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki