tree:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 
master
head:   f8b33d8e870758ccff13e5f81fd5050b52a42d35
commit: 14ca0751c96f8d3d0f52e8ed3b3236f8b34d3460 [1077/1082] bpf: support for 
access to tunnel options
config: x86_64-randconfig-i0-03080544 (attached as .config)
reproduce:
        git checkout 14ca0751c96f8d3d0f52e8ed3b3236f8b34d3460
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   net/core/filter.c: In function 'bpf_skb_get_tunnel_opt':
>> net/core/filter.c:1824:2: error: implicit declaration of function 
>> 'ip_tunnel_info_opts_get' [-Werror=implicit-function-declaration]
     ip_tunnel_info_opts_get(to, info);
     ^
   net/core/filter.c: In function 'bpf_skb_set_tunnel_opt':
>> net/core/filter.c:1918:2: error: implicit declaration of function 
>> 'ip_tunnel_info_opts_set' [-Werror=implicit-function-declaration]
     ip_tunnel_info_opts_set(info, from, size);
     ^
   cc1: some warnings being treated as errors

vim +/ip_tunnel_info_opts_get +1824 net/core/filter.c

  1818          if (unlikely(!info ||
  1819                       !(info->key.tun_flags & TUNNEL_OPTIONS_PRESENT)))
  1820                  return -ENOENT;
  1821          if (unlikely(size < info->options_len))
  1822                  return -ENOMEM;
  1823  
> 1824          ip_tunnel_info_opts_get(to, info);
  1825  
  1826          return info->options_len;
  1827  }
  1828  
  1829  static const struct bpf_func_proto bpf_skb_get_tunnel_opt_proto = {
  1830          .func           = bpf_skb_get_tunnel_opt,
  1831          .gpl_only       = false,
  1832          .ret_type       = RET_INTEGER,
  1833          .arg1_type      = ARG_PTR_TO_CTX,
  1834          .arg2_type      = ARG_PTR_TO_STACK,
  1835          .arg3_type      = ARG_CONST_STACK_SIZE,
  1836  };
  1837  
  1838  static struct metadata_dst __percpu *md_dst;
  1839  
  1840  static u64 bpf_skb_set_tunnel_key(u64 r1, u64 r2, u64 size, u64 flags, 
u64 r5)
  1841  {
  1842          struct sk_buff *skb = (struct sk_buff *) (long) r1;
  1843          struct bpf_tunnel_key *from = (struct bpf_tunnel_key *) (long) 
r2;
  1844          struct metadata_dst *md = this_cpu_ptr(md_dst);
  1845          u8 compat[sizeof(struct bpf_tunnel_key)];
  1846          struct ip_tunnel_info *info;
  1847  
  1848          if (unlikely(flags & ~(BPF_F_TUNINFO_IPV6 | BPF_F_ZERO_CSUM_TX |
  1849                                 BPF_F_DONT_FRAGMENT)))
  1850                  return -EINVAL;
  1851          if (unlikely(size != sizeof(struct bpf_tunnel_key))) {
  1852                  switch (size) {
  1853                  case offsetof(struct bpf_tunnel_key, remote_ipv6[1]):
  1854                          /* Fixup deprecated structure layouts here, so 
we have
  1855                           * a common path later on.
  1856                           */
  1857                          memcpy(compat, from, size);
  1858                          memset(compat + size, 0, sizeof(compat) - size);
  1859                          from = (struct bpf_tunnel_key *)compat;
  1860                          break;
  1861                  default:
  1862                          return -EINVAL;
  1863                  }
  1864          }
  1865  
  1866          skb_dst_drop(skb);
  1867          dst_hold((struct dst_entry *) md);
  1868          skb_dst_set(skb, (struct dst_entry *) md);
  1869  
  1870          info = &md->u.tun_info;
  1871          info->mode = IP_TUNNEL_INFO_TX;
  1872  
  1873          info->key.tun_flags = TUNNEL_KEY | TUNNEL_CSUM;
  1874          if (flags & BPF_F_DONT_FRAGMENT)
  1875                  info->key.tun_flags |= TUNNEL_DONT_FRAGMENT;
  1876  
  1877          info->key.tun_id = cpu_to_be64(from->tunnel_id);
  1878          info->key.tos = from->tunnel_tos;
  1879          info->key.ttl = from->tunnel_ttl;
  1880  
  1881          if (flags & BPF_F_TUNINFO_IPV6) {
  1882                  info->mode |= IP_TUNNEL_INFO_IPV6;
  1883                  memcpy(&info->key.u.ipv6.dst, from->remote_ipv6,
  1884                         sizeof(from->remote_ipv6));
  1885          } else {
  1886                  info->key.u.ipv4.dst = cpu_to_be32(from->remote_ipv4);
  1887                  if (flags & BPF_F_ZERO_CSUM_TX)
  1888                          info->key.tun_flags &= ~TUNNEL_CSUM;
  1889          }
  1890  
  1891          return 0;
  1892  }
  1893  
  1894  static const struct bpf_func_proto bpf_skb_set_tunnel_key_proto = {
  1895          .func           = bpf_skb_set_tunnel_key,
  1896          .gpl_only       = false,
  1897          .ret_type       = RET_INTEGER,
  1898          .arg1_type      = ARG_PTR_TO_CTX,
  1899          .arg2_type      = ARG_PTR_TO_STACK,
  1900          .arg3_type      = ARG_CONST_STACK_SIZE,
  1901          .arg4_type      = ARG_ANYTHING,
  1902  };
  1903  
  1904  #define BPF_TUNLEN_MAX  255
  1905  
  1906  static u64 bpf_skb_set_tunnel_opt(u64 r1, u64 r2, u64 size, u64 r4, u64 
r5)
  1907  {
  1908          struct sk_buff *skb = (struct sk_buff *) (long) r1;
  1909          u8 *from = (u8 *) (long) r2;
  1910          struct ip_tunnel_info *info = skb_tunnel_info(skb);
  1911          const struct metadata_dst *md = this_cpu_ptr(md_dst);
  1912  
  1913          if (unlikely(info != &md->u.tun_info || (size & (sizeof(u32) - 
1))))
  1914                  return -EINVAL;
  1915          if (unlikely(size > BPF_TUNLEN_MAX))
  1916                  return -ENOMEM;
  1917  
> 1918          ip_tunnel_info_opts_set(info, from, size);
  1919  
  1920          return 0;
  1921  }

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: Binary data

Reply via email to