Subject: Re: [PATCH] ip_tunnel: Add ip tunnel tunnel_info dst_cache in ip_tunnel_xmit

From: Dan Carpenter <[email-masked]>
Date: Mon, 25 Feb 2019 09:27:06 +0300

Hi wenxu,

Thank you for the patch! Perhaps something to improve:

url:    https://github.com/0day-ci/linux/commits/wenxu-ucloud-cn/ip_tunnel-Add-ip-tunnel-tunnel_info-dst_cache-in-ip_tunnel_xmit/20190224-065214

smatch warnings:
net/ipv4/ip_tunnel.c:734 ip_tunnel_xmit() error: uninitialized symbol 'rt'.

# https://github.com/0day-ci/linux/commit/fb0c8c40052c62033bf5f92559eabe4e7a98851e
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout fb0c8c40052c62033bf5f92559eabe4e7a98851e
vim +/rt +734 net/ipv4/ip_tunnel.c

7d442fab0 Tom Herbert        2014-01-02  717  
b0066da52 Petr Machata       2018-02-27  718  	ip_tunnel_init_flow(&fl4, protocol, dst, tnl_params->saddr,
9830ad4c6 Craig Gallek       2017-04-19  719  			    tunnel->parms.o_key, RT_TOS(tos), tunnel->parms.link,
9830ad4c6 Craig Gallek       2017-04-19  720  			    tunnel->fwmark);
7d442fab0 Tom Herbert        2014-01-02  721  
563284865 Tom Herbert        2014-09-17  722  	if (ip_tunnel_encap(skb, tunnel, &protocol, &fl4) < 0)
563284865 Tom Herbert        2014-09-17  723  		goto tx_error;
563284865 Tom Herbert        2014-09-17  724  
fb0c8c400 wenxu              2019-02-21  725  	if (connected && md) {
fb0c8c400 wenxu              2019-02-21  726  		use_cache = ip_tunnel_dst_cache_usable(skb, tun_info);
fb0c8c400 wenxu              2019-02-21  727  		if (use_cache)
fb0c8c400 wenxu              2019-02-21  728  			rt = dst_cache_get_ip4(&tun_info->dst_cache, &fl4.saddr);

What about if "use_cache" is false?  "rt" is potentially not set.

fb0c8c400 wenxu              2019-02-21  729  	} else {
e09acddf8 Paolo Abeni        2016-02-12  730  		rt = connected ? dst_cache_get_ip4(&tunnel->dst_cache, &fl4.saddr) :
e09acddf8 Paolo Abeni        2016-02-12  731  			 NULL;
fb0c8c400 wenxu              2019-02-21  732  	}
7d442fab0 Tom Herbert        2014-01-02  733  
7d442fab0 Tom Herbert        2014-01-02 @734  	if (!rt) {
                                                    ^^^

7d442fab0 Tom Herbert        2014-01-02  735  		rt = ip_route_output_key(tunnel->net, &fl4);
c54419321 Pravin B Shelar    2013-03-25  736  
c54419321 Pravin B Shelar    2013-03-25  737  		if (IS_ERR(rt)) {
c54419321 Pravin B Shelar    2013-03-25  738  			dev->stats.tx_carrier_errors++;
c54419321 Pravin B Shelar    2013-03-25  739  			goto tx_error;
c54419321 Pravin B Shelar    2013-03-25  740  		}
fb0c8c400 wenxu              2019-02-21  741  		if (use_cache)

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