Subject: Re: [PATCH net-next v2 12/12] gtp: add dst_cache to tunnels

From: kernel test robot <[email-masked]>
Date: Sat, 12 Dec 2020 01:25:57 +0800

Hi Jonas,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Jonas-Bonn/gtp-IPv6-support/20201211-203639
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 91163f82143630a9629a8bf0227d49173697c69c
config: mips-randconfig-r026-20201209 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 5ff35356f1af2bb92785b38c657463924d9ec386)
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
        # install mips cross compiling tool for clang build
        # apt-get install binutils-mips-linux-gnu
        # https://github.com/0day-ci/linux/commit/a8ea47bc0c1903be018f4d566bb96146c156ddce
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Jonas-Bonn/gtp-IPv6-support/20201211-203639
        git checkout a8ea47bc0c1903be018f4d566bb96146c156ddce
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=mips 

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

All error/warnings (new ones prefixed by >>):

   drivers/net/gtp.c:471:2: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (!ptype)
           ^~~~~~~~~~~
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:58:30: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/gtp.c:482:9: note: uninitialized use occurs here
           return err;
                  ^~~
   drivers/net/gtp.c:471:2: note: remove the 'if' if its condition is always false
           if (!ptype)
           ^~~~~~~~~~~
   include/linux/compiler.h:56:23: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                         ^
   drivers/net/gtp.c:465:2: warning: variable 'err' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
           default:
           ^~~~~~~
   drivers/net/gtp.c:482:9: note: uninitialized use occurs here
           return err;
                  ^~~
   drivers/net/gtp.c:441:9: note: initialize the variable 'err' to silence this warning
           int err;
                  ^
                   = 0
>> drivers/net/gtp.c:627:8: error: implicit declaration of function 'dst_cache_get_ip6' [-Werror,-Wimplicit-function-declaration]
           dst = dst_cache_get_ip6(dst_cache, saddr);
                 ^
   drivers/net/gtp.c:627:8: note: did you mean 'dst_cache_get_ip4'?
   include/net/dst_cache.h:33:16: note: 'dst_cache_get_ip4' declared here
   struct rtable *dst_cache_get_ip4(struct dst_cache *dst_cache, __be32 *saddr);
                  ^
>> drivers/net/gtp.c:627:6: warning: incompatible integer to pointer conversion assigning to 'struct dst_entry *' from 'int' [-Wint-conversion]
           dst = dst_cache_get_ip6(dst_cache, saddr);
               ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/net/gtp.c:649:2: error: implicit declaration of function 'dst_cache_set_ip6' [-Werror,-Wimplicit-function-declaration]
           dst_cache_set_ip6(dst_cache, dst, saddr);
           ^
   3 warnings and 2 errors generated.

vim +/dst_cache_get_ip6 +627 drivers/net/gtp.c

   615	
   616	static struct dst_entry *gtp_get_v6_dst(struct sk_buff *skb,
   617						struct net_device *dev,
   618						struct pdp_ctx *pctx,
   619						struct in6_addr *saddr)
   620	{
   621		const struct sock *sk = pctx->sk;
   622		struct dst_entry *dst = NULL;
   623		struct dst_cache *dst_cache;
   624		struct flowi6 fl6;
   625	
   626		dst_cache = (struct dst_cache *)&pctx->dst_cache;
 > 627		dst = dst_cache_get_ip6(dst_cache, saddr);
   628		if (dst)
   629			return dst;
   630	
   631		memset(&fl6, 0, sizeof(fl6));
   632		fl6.flowi6_mark = skb->mark;
   633		fl6.flowi6_proto = IPPROTO_UDP;
   634		fl6.daddr = pctx->peer_addr;
   635	
   636		dst = ipv6_stub->ipv6_dst_lookup_flow(sock_net(sk), sk, &fl6, NULL);
   637		if (IS_ERR(dst)) {
   638			netdev_dbg(pctx->dev, "no route to %pI6\n", &fl6.daddr);
   639			return ERR_PTR(-ENETUNREACH);
   640		}
   641		if (dst->dev == pctx->dev) {
   642			netdev_dbg(pctx->dev, "circular route to %pI6\n", &fl6.daddr);
   643			dst_release(dst);
   644			return ERR_PTR(-ELOOP);
   645		}
   646	
   647		*saddr = fl6.saddr;
   648	
 > 649		dst_cache_set_ip6(dst_cache, dst, saddr);
   650	
   651		return dst;
   652	}
   653	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email-masked]