diff mbox series

[for-next] RDMA/core: fix ENODEV error for iwarp test over vlan

Message ID 20240926060708.82018-1-anumula@chelsio.com (mailing list archive)
State Changes Requested
Headers show
Series [for-next] RDMA/core: fix ENODEV error for iwarp test over vlan | expand

Commit Message

Anumula Murali Mohan Reddy Sept. 26, 2024, 6:07 a.m. UTC
If traffic is over vlan, cma_validate_port() fails to match vlan
net_device ifindex with bound_if_index and results in ENODEV error.
It is because rdma_copy_src_l2_addr() always assigns bound_if_index with
real net_device ifindex.
This patch fixes the issue by assigning bound_if_index with vlan
net_device index if traffic is over vlan.

Signed-off-by: Anumula Murali Mohan Reddy <anumula@chelsio.com>
Signed-off-by: Potnuri Bharat Teja <bharat@chelsio.com>
---
 drivers/infiniband/core/addr.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Dan Carpenter Sept. 27, 2024, 7 a.m. UTC | #1
Hi Anumula,

kernel test robot noticed the following build warnings:

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Anumula-Murali-Mohan-Reddy/RDMA-core-fix-ENODEV-error-for-iwarp-test-over-vlan/20240926-140515
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
patch link:    https://lore.kernel.org/r/20240926060708.82018-1-anumula%40chelsio.com
patch subject: [PATCH for-next] RDMA/core: fix ENODEV error for iwarp test over vlan
config: x86_64-randconfig-161-20240926 (https://download.01.org/0day-ci/archive/20240927/202409270901.6bDFVhkz-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0

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@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202409270901.6bDFVhkz-lkp@intel.com/

smatch warnings:
drivers/infiniband/core/addr.c:272 rdma_find_ndev_for_src_ip_rcu() error: we previously assumed 'dev' could be null (see line 256)

vim +/dev +272 drivers/infiniband/core/addr.c

caf1e3ae9fa648 Parav Pandit               2018-09-05  245  static struct net_device *
caf1e3ae9fa648 Parav Pandit               2018-09-05  246  rdma_find_ndev_for_src_ip_rcu(struct net *net, const struct sockaddr *src_in)
caf1e3ae9fa648 Parav Pandit               2018-09-05  247  {
caf1e3ae9fa648 Parav Pandit               2018-09-05  248  	struct net_device *dev = NULL;
caf1e3ae9fa648 Parav Pandit               2018-09-05  249  	int ret = -EADDRNOTAVAIL;
caf1e3ae9fa648 Parav Pandit               2018-09-05  250  
caf1e3ae9fa648 Parav Pandit               2018-09-05  251  	switch (src_in->sa_family) {
caf1e3ae9fa648 Parav Pandit               2018-09-05  252  	case AF_INET:
caf1e3ae9fa648 Parav Pandit               2018-09-05  253  		dev = __ip_dev_find(net,
caf1e3ae9fa648 Parav Pandit               2018-09-05  254  				    ((const struct sockaddr_in *)src_in)->sin_addr.s_addr,
caf1e3ae9fa648 Parav Pandit               2018-09-05  255  				    false);
caf1e3ae9fa648 Parav Pandit               2018-09-05 @256  		if (dev)

dev can be NULL

caf1e3ae9fa648 Parav Pandit               2018-09-05  257  			ret = 0;
caf1e3ae9fa648 Parav Pandit               2018-09-05  258  		break;
caf1e3ae9fa648 Parav Pandit               2018-09-05  259  #if IS_ENABLED(CONFIG_IPV6)
caf1e3ae9fa648 Parav Pandit               2018-09-05  260  	case AF_INET6:
caf1e3ae9fa648 Parav Pandit               2018-09-05  261  		for_each_netdev_rcu(net, dev) {
caf1e3ae9fa648 Parav Pandit               2018-09-05  262  			if (ipv6_chk_addr(net,
caf1e3ae9fa648 Parav Pandit               2018-09-05  263  					  &((const struct sockaddr_in6 *)src_in)->sin6_addr,
caf1e3ae9fa648 Parav Pandit               2018-09-05  264  					  dev, 1)) {
caf1e3ae9fa648 Parav Pandit               2018-09-05  265  				ret = 0;
caf1e3ae9fa648 Parav Pandit               2018-09-05  266  				break;
caf1e3ae9fa648 Parav Pandit               2018-09-05  267  			}
caf1e3ae9fa648 Parav Pandit               2018-09-05  268  		}
caf1e3ae9fa648 Parav Pandit               2018-09-05  269  		break;
caf1e3ae9fa648 Parav Pandit               2018-09-05  270  #endif
caf1e3ae9fa648 Parav Pandit               2018-09-05  271  	}
b1d29f42e02d0c Anumula Murali Mohan Reddy 2024-09-26 @272  	if (is_vlan_dev(dev))
                                                                                ^^^
Dereferenced inside function.

b1d29f42e02d0c Anumula Murali Mohan Reddy 2024-09-26  273  		dev = vlan_dev_real_dev(dev);
caf1e3ae9fa648 Parav Pandit               2018-09-05  274  	return ret ? ERR_PTR(ret) : dev;
caf1e3ae9fa648 Parav Pandit               2018-09-05  275  }
caf1e3ae9fa648 Parav Pandit               2018-09-05  276
diff mbox series

Patch

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index be0743dac3ff..4e02d5a2b35f 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -269,6 +269,8 @@  rdma_find_ndev_for_src_ip_rcu(struct net *net, const struct sockaddr *src_in)
 		break;
 #endif
 	}
+	if (is_vlan_dev(dev))
+		dev = vlan_dev_real_dev(dev);
 	return ret ? ERR_PTR(ret) : dev;
 }