diff mbox series

[net-next] crypto/chtls: Fix compile error when CONFIG_IPV6 is disabled

Message ID 20200603103317.653-1-vinay.yadav@chelsio.com
State Changes Requested
Delegated to: David Miller
Headers show
Series [net-next] crypto/chtls: Fix compile error when CONFIG_IPV6 is disabled | expand

Commit Message

Vinay Kumar Yadav June 3, 2020, 10:33 a.m. UTC
Fix compile error when CONFIG_IPV6 is disabled and inconsistent
indenting.

Fixes: 6abde0b24122 ("crypto/chtls: IPv6 support for inline TLS")
Signed-off-by: Vinay Kumar Yadav <vinay.yadav@chelsio.com>
---
 drivers/crypto/chelsio/chtls/chtls_cm.c   | 40 +++++++++++++++++------
 drivers/crypto/chelsio/chtls/chtls_main.c |  2 ++
 2 files changed, 32 insertions(+), 10 deletions(-)

Comments

kernel test robot June 3, 2020, 1:03 p.m. UTC | #1
Hi Vinay,

I love your patch! Yet something to improve:

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

url:    https://github.com/0day-ci/linux/commits/Vinay-Kumar-Yadav/crypto-chtls-Fix-compile-error-when-CONFIG_IPV6-is-disabled/20200603-184315
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 065fcfd49763ec71ae345bb5c5a74f961031e70e
config: arc-allyesconfig (attached as .config)
compiler: arc-elf-gcc (GCC) 9.3.0
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
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

drivers/crypto/chelsio/chtls/chtls_cm.c: In function 'chtls_find_netdev':
>> drivers/crypto/chelsio/chtls/chtls_cm.c:105:3: error: a label can only be part of a statement and a declaration is not a statement
105 |   struct net_device *temp;
|   ^~~~~~
>> drivers/crypto/chelsio/chtls/chtls_cm.c:106:3: error: expected expression before 'int'
106 |   int addr_type;
|   ^~~
>> drivers/crypto/chelsio/chtls/chtls_cm.c:108:3: error: 'addr_type' undeclared (first use in this function); did you mean 'iter_type'?
108 |   addr_type = ipv6_addr_type(&sk->sk_v6_rcv_saddr);
|   ^~~~~~~~~
|   iter_type
drivers/crypto/chelsio/chtls/chtls_cm.c:108:3: note: each undeclared identifier is reported only once for each function it appears in
In file included from drivers/crypto/chelsio/chtls/chtls.h:31,
from drivers/crypto/chelsio/chtls/chtls_cm.c:32:
At top level:
drivers/crypto/chelsio/chcr_algo.h:392:17: warning: 'sgl_lengths' defined but not used [-Wunused-const-variable=]
392 | static const u8 sgl_lengths[20] = {
|                 ^~~~~~~~~~~

vim +105 drivers/crypto/chelsio/chtls/chtls_cm.c

    91	
    92	static struct net_device *chtls_find_netdev(struct chtls_dev *cdev,
    93						    struct sock *sk)
    94	{
    95		struct net_device *ndev = cdev->ports[0];
    96	
    97		switch (sk->sk_family) {
    98		case PF_INET:
    99			if (likely(!inet_sk(sk)->inet_rcv_saddr))
   100				return ndev;
   101			ndev = ip_dev_find(&init_net, inet_sk(sk)->inet_rcv_saddr);
   102			break;
   103	#if IS_ENABLED(CONFIG_IPV6)
   104		case PF_INET6:
 > 105			struct net_device *temp;
 > 106			int addr_type;
   107	
 > 108			addr_type = ipv6_addr_type(&sk->sk_v6_rcv_saddr);
   109			if (likely(addr_type == IPV6_ADDR_ANY))
   110				return ndev;
   111	
   112			for_each_netdev_rcu(&init_net, temp) {
   113				if (ipv6_chk_addr(&init_net, (struct in6_addr *)
   114						  &sk->sk_v6_rcv_saddr, temp, 1)) {
   115					ndev = temp;
   116					break;
   117				}
   118			}
   119		break;
   120	#endif
   121		default:
   122			return NULL;
   123		}
   124	
   125		if (!ndev)
   126			return NULL;
   127	
   128		if (is_vlan_dev(ndev))
   129			return vlan_dev_real_dev(ndev);
   130		return ndev;
   131	}
   132	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot June 3, 2020, 2:11 p.m. UTC | #2
Hi Vinay,

I love your patch! Yet something to improve:

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

url:    https://github.com/0day-ci/linux/commits/Vinay-Kumar-Yadav/crypto-chtls-Fix-compile-error-when-CONFIG_IPV6-is-disabled/20200603-184315
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 065fcfd49763ec71ae345bb5c5a74f961031e70e
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 16437992cac249f6fe1efd392d20e3469b47e39e)
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 x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> drivers/crypto/chelsio/chtls/chtls_cm.c:105:3: error: expected expression
struct net_device *temp;
^
>> drivers/crypto/chelsio/chtls/chtls_cm.c:112:34: error: use of undeclared identifier 'temp'; did you mean 'bcmp'?
for_each_netdev_rcu(&init_net, temp) {
^~~~
bcmp
include/linux/netdevice.h:2669:27: note: expanded from macro 'for_each_netdev_rcu'
list_for_each_entry_rcu(d, &(net)->dev_base_head, dev_list)
^
include/linux/rculist.h:382:50: note: expanded from macro 'list_for_each_entry_rcu'
pos = list_entry_rcu((head)->next, typeof(*pos), member);                                                             ^
include/linux/rculist.h:306:31: note: expanded from macro 'list_entry_rcu'
container_of(READ_ONCE(ptr), type, member)
^
note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler.h:350:22: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler.h:338:23: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^
include/linux/compiler.h:330:9: note: expanded from macro '__compiletime_assert'
if (!(condition))                                                                ^
include/linux/string.h:159:12: note: 'bcmp' declared here
extern int bcmp(const void *,const void *,__kernel_size_t);
^
>> drivers/crypto/chelsio/chtls/chtls_cm.c:112:3: error: member reference base type 'typeof (*bcmp)' (aka 'int (const void *, const void *, unsigned long)') is not a structure or union
for_each_netdev_rcu(&init_net, temp) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/netdevice.h:2669:3: note: expanded from macro 'for_each_netdev_rcu'
list_for_each_entry_rcu(d, &(net)->dev_base_head, dev_list)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rculist.h:382:13: note: expanded from macro 'list_for_each_entry_rcu'
pos = list_entry_rcu((head)->next, typeof(*pos), member);                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rculist.h:306:2: note: expanded from macro 'list_entry_rcu'
container_of(READ_ONCE(ptr), type, member)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
include/linux/compiler.h:350:22: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:338:23: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler.h:330:9: note: expanded from macro '__compiletime_assert'
if (!(condition))                                                                ^~~~~~~~~
>> drivers/crypto/chelsio/chtls/chtls_cm.c:112:34: error: use of undeclared identifier 'temp'; did you mean 'bcmp'?
for_each_netdev_rcu(&init_net, temp) {
^~~~
bcmp
include/linux/netdevice.h:2669:27: note: expanded from macro 'for_each_netdev_rcu'
list_for_each_entry_rcu(d, &(net)->dev_base_head, dev_list)
^
include/linux/rculist.h:382:50: note: expanded from macro 'list_for_each_entry_rcu'
pos = list_entry_rcu((head)->next, typeof(*pos), member);                                                             ^
include/linux/rculist.h:306:31: note: expanded from macro 'list_entry_rcu'
container_of(READ_ONCE(ptr), type, member)
^
include/linux/kernel.h:997:4: note: expanded from macro 'container_of'
((type *)(__mptr - offsetof(type, member))); })
^
include/linux/string.h:159:12: note: 'bcmp' declared here
extern int bcmp(const void *,const void *,__kernel_size_t);
^
>> drivers/crypto/chelsio/chtls/chtls_cm.c:112:34: error: use of undeclared identifier 'temp'; did you mean 'bcmp'?
for_each_netdev_rcu(&init_net, temp) {
^~~~
bcmp
include/linux/netdevice.h:2669:27: note: expanded from macro 'for_each_netdev_rcu'
list_for_each_entry_rcu(d, &(net)->dev_base_head, dev_list)
^
include/linux/rculist.h:382:50: note: expanded from macro 'list_for_each_entry_rcu'
pos = list_entry_rcu((head)->next, typeof(*pos), member);                                                             ^
include/linux/rculist.h:306:31: note: expanded from macro 'list_entry_rcu'
container_of(READ_ONCE(ptr), type, member)
^
include/linux/kernel.h:997:30: note: expanded from macro 'container_of'
((type *)(__mptr - offsetof(type, member))); })
^
include/linux/stddef.h:17:52: note: expanded from macro 'offsetof'
#define offsetof(TYPE, MEMBER)  __compiler_offsetof(TYPE, MEMBER)
^
include/linux/compiler_types.h:129:54: note: expanded from macro '__compiler_offsetof'
#define __compiler_offsetof(a, b)       __builtin_offsetof(a, b)
^
include/linux/string.h:159:12: note: 'bcmp' declared here
extern int bcmp(const void *,const void *,__kernel_size_t);
^
>> drivers/crypto/chelsio/chtls/chtls_cm.c:112:3: error: offsetof requires struct, union, or class type, 'typeof (*bcmp)' (aka 'int (const void *, const void *, unsigned long)') invalid
for_each_netdev_rcu(&init_net, temp) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/netdevice.h:2669:3: note: expanded from macro 'for_each_netdev_rcu'
list_for_each_entry_rcu(d, &(net)->dev_base_head, dev_list)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rculist.h:382:13: note: expanded from macro 'list_for_each_entry_rcu'
pos = list_entry_rcu((head)->next, typeof(*pos), member);                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rculist.h:306:2: note: expanded from macro 'list_entry_rcu'
container_of(READ_ONCE(ptr), type, member)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:997:21: note: expanded from macro 'container_of'
((type *)(__mptr - offsetof(type, member))); })
^~~~~~~~~~~~~~~~~~~~~~
include/linux/stddef.h:17:32: note: expanded from macro 'offsetof'
#define offsetof(TYPE, MEMBER)  __compiler_offsetof(TYPE, MEMBER)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/compiler_types.h:129:35: note: expanded from macro '__compiler_offsetof'
#define __compiler_offsetof(a, b)       __builtin_offsetof(a, b)
^                  ~
drivers/crypto/chelsio/chtls/chtls_cm.c:112:34: error: use of undeclared identifier 'temp'
for_each_netdev_rcu(&init_net, temp) {
^
drivers/crypto/chelsio/chtls/chtls_cm.c:112:34: error: use of undeclared identifier 'temp'
drivers/crypto/chelsio/chtls/chtls_cm.c:112:34: error: use of undeclared identifier 'temp'
drivers/crypto/chelsio/chtls/chtls_cm.c:112:34: error: use of undeclared identifier 'temp'
drivers/crypto/chelsio/chtls/chtls_cm.c:112:34: error: use of undeclared identifier 'temp'
drivers/crypto/chelsio/chtls/chtls_cm.c:112:34: error: use of undeclared identifier 'temp'
drivers/crypto/chelsio/chtls/chtls_cm.c:112:34: error: use of undeclared identifier 'temp'
>> drivers/crypto/chelsio/chtls/chtls_cm.c:112:3: error: operand of type 'void' where arithmetic or pointer type is required
for_each_netdev_rcu(&init_net, temp) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/netdevice.h:2669:3: note: expanded from macro 'for_each_netdev_rcu'
list_for_each_entry_rcu(d, &(net)->dev_base_head, dev_list)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rculist.h:384:9: note: expanded from macro 'list_for_each_entry_rcu'
pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/rculist.h:306:2: note: expanded from macro 'list_entry_rcu'
container_of(READ_ONCE(ptr), type, member)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/kernel.h:993:25: note: expanded from macro 'container_of'
void *__mptr = (void *)(ptr);                                                                     ^~~~~
drivers/crypto/chelsio/chtls/chtls_cm.c:112:34: error: use of undeclared identifier 'temp'
for_each_netdev_rcu(&init_net, temp) {
^
drivers/crypto/chelsio/chtls/chtls_cm.c:112:34: error: use of undeclared identifier 'temp'
drivers/crypto/chelsio/chtls/chtls_cm.c:112:34: error: use of undeclared identifier 'temp'
drivers/crypto/chelsio/chtls/chtls_cm.c:112:34: error: use of undeclared identifier 'temp'
drivers/crypto/chelsio/chtls/chtls_cm.c:112:34: error: use of undeclared identifier 'temp'
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

vim +105 drivers/crypto/chelsio/chtls/chtls_cm.c

    91	
    92	static struct net_device *chtls_find_netdev(struct chtls_dev *cdev,
    93						    struct sock *sk)
    94	{
    95		struct net_device *ndev = cdev->ports[0];
    96	
    97		switch (sk->sk_family) {
    98		case PF_INET:
    99			if (likely(!inet_sk(sk)->inet_rcv_saddr))
   100				return ndev;
   101			ndev = ip_dev_find(&init_net, inet_sk(sk)->inet_rcv_saddr);
   102			break;
   103	#if IS_ENABLED(CONFIG_IPV6)
   104		case PF_INET6:
 > 105			struct net_device *temp;
   106			int addr_type;
   107	
   108			addr_type = ipv6_addr_type(&sk->sk_v6_rcv_saddr);
   109			if (likely(addr_type == IPV6_ADDR_ANY))
   110				return ndev;
   111	
 > 112			for_each_netdev_rcu(&init_net, temp) {
   113				if (ipv6_chk_addr(&init_net, (struct in6_addr *)
   114						  &sk->sk_v6_rcv_saddr, temp, 1)) {
   115					ndev = temp;
   116					break;
   117				}
   118			}
   119		break;
   120	#endif
   121		default:
   122			return NULL;
   123		}
   124	
   125		if (!ndev)
   126			return NULL;
   127	
   128		if (is_vlan_dev(ndev))
   129			return vlan_dev_real_dev(ndev);
   130		return ndev;
   131	}
   132	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
David Miller June 3, 2020, 5:46 p.m. UTC | #3
From: Vinay Kumar Yadav <vinay.yadav@chelsio.com>
Date: Wed,  3 Jun 2020 16:03:17 +0530

> @@ -102,19 +100,24 @@ static struct net_device *chtls_find_netdev(struct chtls_dev *cdev,
>  			return ndev;
>  		ndev = ip_dev_find(&init_net, inet_sk(sk)->inet_rcv_saddr);
>  		break;
> +#if IS_ENABLED(CONFIG_IPV6)
>  	case PF_INET6:
> +		struct net_device *temp;
> +		int addr_type;
> +

You never, ever, compiled this code.
kernel test robot June 4, 2020, 3:28 a.m. UTC | #4
Hi Vinay,

I love your patch! Perhaps something to improve:

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

url:    https://github.com/0day-ci/linux/commits/Vinay-Kumar-Yadav/crypto-chtls-Fix-compile-error-when-CONFIG_IPV6-is-disabled/20200603-184315
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 065fcfd49763ec71ae345bb5c5a74f961031e70e
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


cppcheck warnings: (new ones prefixed by >>)

>> drivers/crypto/chelsio/chtls/chtls_cm.c:700:6: warning: Uninitialized variable: ret [uninitvar]
    if (ret > 0)
        ^
>> drivers/crypto/chelsio/chtls/chtls_cm.c:1151:7: warning: Uninitialized variable: n [uninitvar]
    if (!n)
         ^

vim +700 drivers/crypto/chelsio/chtls/chtls_cm.c

cc35c88ae4db21 Atul Gupta        2018-03-31  633  
cc35c88ae4db21 Atul Gupta        2018-03-31  634  int chtls_listen_start(struct chtls_dev *cdev, struct sock *sk)
cc35c88ae4db21 Atul Gupta        2018-03-31  635  {
cc35c88ae4db21 Atul Gupta        2018-03-31  636  	struct net_device *ndev;
cc35c88ae4db21 Atul Gupta        2018-03-31  637  	struct listen_ctx *ctx;
cc35c88ae4db21 Atul Gupta        2018-03-31  638  	struct adapter *adap;
cc35c88ae4db21 Atul Gupta        2018-03-31  639  	struct port_info *pi;
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  640  	bool clip_valid;
cc35c88ae4db21 Atul Gupta        2018-03-31  641  	int stid;
cc35c88ae4db21 Atul Gupta        2018-03-31  642  	int ret;
cc35c88ae4db21 Atul Gupta        2018-03-31  643  
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  644  	clip_valid = false;
cc35c88ae4db21 Atul Gupta        2018-03-31  645  	rcu_read_lock();
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  646  	ndev = chtls_find_netdev(cdev, sk);
cc35c88ae4db21 Atul Gupta        2018-03-31  647  	rcu_read_unlock();
cc35c88ae4db21 Atul Gupta        2018-03-31  648  	if (!ndev)
cc35c88ae4db21 Atul Gupta        2018-03-31  649  		return -EBADF;
cc35c88ae4db21 Atul Gupta        2018-03-31  650  
cc35c88ae4db21 Atul Gupta        2018-03-31  651  	pi = netdev_priv(ndev);
cc35c88ae4db21 Atul Gupta        2018-03-31  652  	adap = pi->adapter;
80f61f19e542ae Arjun Vynipadath  2019-03-04  653  	if (!(adap->flags & CXGB4_FULL_INIT_DONE))
cc35c88ae4db21 Atul Gupta        2018-03-31  654  		return -EBADF;
cc35c88ae4db21 Atul Gupta        2018-03-31  655  
cc35c88ae4db21 Atul Gupta        2018-03-31  656  	if (listen_hash_find(cdev, sk) >= 0)   /* already have it */
cc35c88ae4db21 Atul Gupta        2018-03-31  657  		return -EADDRINUSE;
cc35c88ae4db21 Atul Gupta        2018-03-31  658  
cc35c88ae4db21 Atul Gupta        2018-03-31  659  	ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
cc35c88ae4db21 Atul Gupta        2018-03-31  660  	if (!ctx)
cc35c88ae4db21 Atul Gupta        2018-03-31  661  		return -ENOMEM;
cc35c88ae4db21 Atul Gupta        2018-03-31  662  
cc35c88ae4db21 Atul Gupta        2018-03-31  663  	__module_get(THIS_MODULE);
cc35c88ae4db21 Atul Gupta        2018-03-31  664  	ctx->lsk = sk;
cc35c88ae4db21 Atul Gupta        2018-03-31  665  	ctx->cdev = cdev;
cc35c88ae4db21 Atul Gupta        2018-03-31  666  	ctx->state = T4_LISTEN_START_PENDING;
cc35c88ae4db21 Atul Gupta        2018-03-31  667  	skb_queue_head_init(&ctx->synq);
cc35c88ae4db21 Atul Gupta        2018-03-31  668  
cc35c88ae4db21 Atul Gupta        2018-03-31  669  	stid = cxgb4_alloc_stid(cdev->tids, sk->sk_family, ctx);
cc35c88ae4db21 Atul Gupta        2018-03-31  670  	if (stid < 0)
cc35c88ae4db21 Atul Gupta        2018-03-31  671  		goto free_ctx;
cc35c88ae4db21 Atul Gupta        2018-03-31  672  
cc35c88ae4db21 Atul Gupta        2018-03-31  673  	sock_hold(sk);
cc35c88ae4db21 Atul Gupta        2018-03-31  674  	if (!listen_hash_add(cdev, sk, stid))
cc35c88ae4db21 Atul Gupta        2018-03-31  675  		goto free_stid;
cc35c88ae4db21 Atul Gupta        2018-03-31  676  
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  677  	if (sk->sk_family == PF_INET) {
cc35c88ae4db21 Atul Gupta        2018-03-31  678  		ret = cxgb4_create_server(ndev, stid,
cc35c88ae4db21 Atul Gupta        2018-03-31  679  					  inet_sk(sk)->inet_rcv_saddr,
cc35c88ae4db21 Atul Gupta        2018-03-31  680  					  inet_sk(sk)->inet_sport, 0,
cc35c88ae4db21 Atul Gupta        2018-03-31  681  					  cdev->lldi->rxq_ids[0]);
015ca7982064b6 Vinay Kumar Yadav 2020-06-03  682  #if IS_ENABLED(CONFIG_IPV6)
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  683  	} else {
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  684  		int addr_type;
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  685  
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  686  		addr_type = ipv6_addr_type(&sk->sk_v6_rcv_saddr);
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  687  		if (addr_type != IPV6_ADDR_ANY) {
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  688  			ret = cxgb4_clip_get(ndev, (const u32 *)
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  689  					     &sk->sk_v6_rcv_saddr, 1);
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  690  			if (ret)
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  691  				goto del_hash;
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  692  			clip_valid = true;
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  693  		}
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  694  		ret = cxgb4_create_server6(ndev, stid,
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  695  					   &sk->sk_v6_rcv_saddr,
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  696  					   inet_sk(sk)->inet_sport,
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  697  					   cdev->lldi->rxq_ids[0]);
015ca7982064b6 Vinay Kumar Yadav 2020-06-03  698  #endif
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  699  	}
cc35c88ae4db21 Atul Gupta        2018-03-31 @700  	if (ret > 0)
cc35c88ae4db21 Atul Gupta        2018-03-31  701  		ret = net_xmit_errno(ret);
cc35c88ae4db21 Atul Gupta        2018-03-31  702  	if (ret)
cc35c88ae4db21 Atul Gupta        2018-03-31  703  		goto del_hash;
cc35c88ae4db21 Atul Gupta        2018-03-31  704  	return 0;
cc35c88ae4db21 Atul Gupta        2018-03-31  705  del_hash:
015ca7982064b6 Vinay Kumar Yadav 2020-06-03  706  #if IS_ENABLED(CONFIG_IPV6)
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  707  	if (clip_valid)
6abde0b2412243 Vinay Kumar Yadav 2020-06-02  708  		cxgb4_clip_release(ndev, (const u32 *)&sk->sk_v6_rcv_saddr, 1);
015ca7982064b6 Vinay Kumar Yadav 2020-06-03  709  #endif
cc35c88ae4db21 Atul Gupta        2018-03-31  710  	listen_hash_del(cdev, sk);
cc35c88ae4db21 Atul Gupta        2018-03-31  711  free_stid:
cc35c88ae4db21 Atul Gupta        2018-03-31  712  	cxgb4_free_stid(cdev->tids, stid, sk->sk_family);
cc35c88ae4db21 Atul Gupta        2018-03-31  713  	sock_put(sk);
cc35c88ae4db21 Atul Gupta        2018-03-31  714  free_ctx:
cc35c88ae4db21 Atul Gupta        2018-03-31  715  	kfree(ctx);
cc35c88ae4db21 Atul Gupta        2018-03-31  716  	module_put(THIS_MODULE);
cc35c88ae4db21 Atul Gupta        2018-03-31  717  	return -EBADF;
cc35c88ae4db21 Atul Gupta        2018-03-31  718  }
cc35c88ae4db21 Atul Gupta        2018-03-31  719  

:::::: The code at line 700 was first introduced by commit
:::::: cc35c88ae4db219611e204375d6a4248bc0e84d6 crypto : chtls - CPL handler definition

:::::: TO: Atul Gupta <atul.gupta@chelsio.com>
:::::: CC: David S. Miller <davem@davemloft.net>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/crypto/chelsio/chtls/chtls_cm.c b/drivers/crypto/chelsio/chtls/chtls_cm.c
index 9a642c79a657..b9682ddc6a38 100644
--- a/drivers/crypto/chelsio/chtls/chtls_cm.c
+++ b/drivers/crypto/chelsio/chtls/chtls_cm.c
@@ -93,8 +93,6 @@  static struct net_device *chtls_find_netdev(struct chtls_dev *cdev,
 					    struct sock *sk)
 {
 	struct net_device *ndev = cdev->ports[0];
-	struct net_device *temp;
-	int addr_type;
 
 	switch (sk->sk_family) {
 	case PF_INET:
@@ -102,19 +100,24 @@  static struct net_device *chtls_find_netdev(struct chtls_dev *cdev,
 			return ndev;
 		ndev = ip_dev_find(&init_net, inet_sk(sk)->inet_rcv_saddr);
 		break;
+#if IS_ENABLED(CONFIG_IPV6)
 	case PF_INET6:
+		struct net_device *temp;
+		int addr_type;
+
 		addr_type = ipv6_addr_type(&sk->sk_v6_rcv_saddr);
 		if (likely(addr_type == IPV6_ADDR_ANY))
 			return ndev;
 
-	for_each_netdev_rcu(&init_net, temp) {
-		if (ipv6_chk_addr(&init_net, (struct in6_addr *)
-				  &sk->sk_v6_rcv_saddr, temp, 1)) {
-			ndev = temp;
-			break;
+		for_each_netdev_rcu(&init_net, temp) {
+			if (ipv6_chk_addr(&init_net, (struct in6_addr *)
+					  &sk->sk_v6_rcv_saddr, temp, 1)) {
+				ndev = temp;
+				break;
+			}
 		}
-	}
 	break;
+#endif
 	default:
 		return NULL;
 	}
@@ -476,8 +479,10 @@  void chtls_destroy_sock(struct sock *sk)
 	csk->cdev = NULL;
 	if (sk->sk_family == AF_INET)
 		sk->sk_prot = &tcp_prot;
+#if IS_ENABLED(CONFIG_IPV6)
 	else
 		sk->sk_prot = &tcpv6_prot;
+#endif
 	sk->sk_prot->destroy(sk);
 }
 
@@ -674,6 +679,7 @@  int chtls_listen_start(struct chtls_dev *cdev, struct sock *sk)
 					  inet_sk(sk)->inet_rcv_saddr,
 					  inet_sk(sk)->inet_sport, 0,
 					  cdev->lldi->rxq_ids[0]);
+#if IS_ENABLED(CONFIG_IPV6)
 	} else {
 		int addr_type;
 
@@ -689,6 +695,7 @@  int chtls_listen_start(struct chtls_dev *cdev, struct sock *sk)
 					   &sk->sk_v6_rcv_saddr,
 					   inet_sk(sk)->inet_sport,
 					   cdev->lldi->rxq_ids[0]);
+#endif
 	}
 	if (ret > 0)
 		ret = net_xmit_errno(ret);
@@ -696,8 +703,10 @@  int chtls_listen_start(struct chtls_dev *cdev, struct sock *sk)
 		goto del_hash;
 	return 0;
 del_hash:
+#if IS_ENABLED(CONFIG_IPV6)
 	if (clip_valid)
 		cxgb4_clip_release(ndev, (const u32 *)&sk->sk_v6_rcv_saddr, 1);
+#endif
 	listen_hash_del(cdev, sk);
 free_stid:
 	cxgb4_free_stid(cdev->tids, stid, sk->sk_family);
@@ -711,8 +720,6 @@  int chtls_listen_start(struct chtls_dev *cdev, struct sock *sk)
 void chtls_listen_stop(struct chtls_dev *cdev, struct sock *sk)
 {
 	struct listen_ctx *listen_ctx;
-	struct chtls_sock *csk;
-	int addr_type = 0;
 	int stid;
 
 	stid = listen_hash_del(cdev, sk);
@@ -725,7 +732,11 @@  void chtls_listen_stop(struct chtls_dev *cdev, struct sock *sk)
 	cxgb4_remove_server(cdev->lldi->ports[0], stid,
 			    cdev->lldi->rxq_ids[0], sk->sk_family == PF_INET6);
 
+#if IS_ENABLED(CONFIG_IPV6)
 	if (sk->sk_family == PF_INET6) {
+		struct chtls_sock *csk;
+		int addr_type = 0;
+
 		csk = rcu_dereference_sk_user_data(sk);
 		addr_type = ipv6_addr_type((const struct in6_addr *)
 					  &sk->sk_v6_rcv_saddr);
@@ -733,6 +744,7 @@  void chtls_listen_stop(struct chtls_dev *cdev, struct sock *sk)
 			cxgb4_clip_release(csk->egress_dev, (const u32 *)
 					   &sk->sk_v6_rcv_saddr, 1);
 	}
+#endif
 	chtls_disconnect_acceptq(sk);
 }
 
@@ -941,9 +953,11 @@  static unsigned int chtls_select_mss(const struct chtls_sock *csk,
 	tp = tcp_sk(sk);
 	tcpoptsz = 0;
 
+#if IS_ENABLED(CONFIG_IPV6)
 	if (sk->sk_family == AF_INET6)
 		iphdrsz = sizeof(struct ipv6hdr) + sizeof(struct tcphdr);
 	else
+#endif
 		iphdrsz = sizeof(struct iphdr) + sizeof(struct tcphdr);
 	if (req->tcpopt.tstamp)
 		tcpoptsz += round_up(TCPOLEN_TIMESTAMP, 4);
@@ -1115,6 +1129,7 @@  static struct sock *chtls_recv_sock(struct sock *lsk,
 			goto free_sk;
 
 		n = dst_neigh_lookup(dst, &iph->saddr);
+#if IS_ENABLED(CONFIG_IPV6)
 	} else {
 		const struct ipv6hdr *ip6h;
 		struct flowi6 fl6;
@@ -1131,6 +1146,7 @@  static struct sock *chtls_recv_sock(struct sock *lsk,
 		if (IS_ERR(dst))
 			goto free_sk;
 		n = dst_neigh_lookup(dst, &ip6h->saddr);
+#endif
 	}
 	if (!n)
 		goto free_sk;
@@ -1158,6 +1174,7 @@  static struct sock *chtls_recv_sock(struct sock *lsk,
 		newinet->inet_daddr = iph->saddr;
 		newinet->inet_rcv_saddr = iph->daddr;
 		newinet->inet_saddr = iph->daddr;
+#if IS_ENABLED(CONFIG_IPV6)
 	} else {
 		struct tcp6_sock *newtcp6sk = (struct tcp6_sock *)newsk;
 		struct inet_request_sock *treq = inet_rsk(oreq);
@@ -1175,6 +1192,7 @@  static struct sock *chtls_recv_sock(struct sock *lsk,
 		newinet->inet_opt = NULL;
 		newinet->inet_daddr = LOOPBACK4_IPV6;
 		newinet->inet_saddr = LOOPBACK4_IPV6;
+#endif
 	}
 
 	oreq->ts_recent = PASS_OPEN_TID_G(ntohl(req->tos_stid));
@@ -1337,10 +1355,12 @@  static void chtls_pass_accept_request(struct sock *sk,
 	if (iph->version == 0x4) {
 		chtls_set_req_addr(oreq, iph->daddr, iph->saddr);
 		ip_dsfield = ipv4_get_dsfield(iph);
+#if IS_ENABLED(CONFIG_IPV6)
 	} else {
 		inet_rsk(oreq)->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;
 		inet_rsk(oreq)->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;
 		ip_dsfield = ipv6_get_dsfield(ipv6_hdr(skb));
+#endif
 	}
 	if (req->tcpopt.wsf <= 14 &&
 	    sock_net(sk)->ipv4.sysctl_tcp_window_scaling) {
diff --git a/drivers/crypto/chelsio/chtls/chtls_main.c b/drivers/crypto/chelsio/chtls/chtls_main.c
index 7dfffdde9593..d98b89d0fa6e 100644
--- a/drivers/crypto/chelsio/chtls/chtls_main.c
+++ b/drivers/crypto/chelsio/chtls/chtls_main.c
@@ -608,9 +608,11 @@  static void __init chtls_init_ulp_ops(void)
 	chtls_cpl_prot.recvmsg		= chtls_recvmsg;
 	chtls_cpl_prot.setsockopt	= chtls_setsockopt;
 	chtls_cpl_prot.getsockopt	= chtls_getsockopt;
+#if IS_ENABLED(CONFIG_IPV6)
 	chtls_cpl_protv6		= chtls_cpl_prot;
 	chtls_init_rsk_ops(&chtls_cpl_protv6, &chtls_rsk_opsv6,
 			   &tcpv6_prot, PF_INET6);
+#endif
 }
 
 static int __init chtls_register(void)