netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuck Lever <cel@kernel.org>
To: netdev@vger.kernel.org, linux-rdma@vger.kernel.org
Cc: BMT@zurich.ibm.com, tom@talpey.com
Subject: [PATCH RFC 3/3] RDMA/siw: Require non-zero 6-byte MACs for soft iWARP
Date: Fri, 05 May 2023 11:43:11 -0400	[thread overview]
Message-ID: <168330138101.5953.12575990094340826016.stgit@oracle-102.nfsv4bat.org> (raw)
In-Reply-To: <168330051600.5953.11366152375575299483.stgit@oracle-102.nfsv4bat.org>

From: Chuck Lever <chuck.lever@oracle.com>

In the past, LOOPBACK and NONE (tunnel) devices had all-zero MAC
addresses. siw_device_create() would fall back to copying the
device's name in those cases, because an all-zero MAC address breaks
the RDMA core IP-to-device lookup mechanism.

However, in some cases, the net_device::name field is also empty.
So we're back at square one.

Rather than checking the device type, look at the
net_device::addr_len field. If it's got the right number of octets
and it is not all zeroes, use that.

Then, to enable siw support for that device/address type, change
the device driver to ensure such devices have a valid 6-octet MAC
address. For virtual devices, using eth_hw_addr_random() is
sufficient.

Fixes: a2d36b02c15d ("RDMA/siw: Enable siw on tunnel devices")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 drivers/infiniband/sw/siw/siw_main.c |   22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/drivers/infiniband/sw/siw/siw_main.c b/drivers/infiniband/sw/siw/siw_main.c
index 65b5cda5457b..2c31bf397993 100644
--- a/drivers/infiniband/sw/siw/siw_main.c
+++ b/drivers/infiniband/sw/siw/siw_main.c
@@ -304,10 +304,15 @@ static const struct ib_device_ops siw_device_ops = {
 
 static struct siw_device *siw_device_create(struct net_device *netdev)
 {
+	static const u8 zeromac[ETH_ALEN] = { 0 };
 	struct siw_device *sdev = NULL;
 	struct ib_device *base_dev;
 	int rv;
 
+	if ((netdev->addr_len != ETH_ALEN) ||
+	    (memcmp(netdev->dev_addr, zeromac, ETH_ALEN) == 0))
+		return NULL;
+
 	sdev = ib_alloc_device(siw_device, base_dev);
 	if (!sdev)
 		return NULL;
@@ -316,21 +321,8 @@ static struct siw_device *siw_device_create(struct net_device *netdev)
 
 	sdev->netdev = netdev;
 
-	if (netdev->type != ARPHRD_LOOPBACK && netdev->type != ARPHRD_NONE) {
-		addrconf_addr_eui48((unsigned char *)&base_dev->node_guid,
-				    netdev->dev_addr);
-	} else {
-		/*
-		 * This device does not have a HW address,
-		 * but connection mangagement lib expects gid != 0
-		 */
-		size_t len = min_t(size_t, strlen(base_dev->name), 6);
-		char addr[6] = { };
-
-		memcpy(addr, base_dev->name, len);
-		addrconf_addr_eui48((unsigned char *)&base_dev->node_guid,
-				    addr);
-	}
+	addrconf_addr_eui48((unsigned char *)&base_dev->node_guid,
+			    netdev->dev_addr);
 
 	base_dev->uverbs_cmd_mask |= BIT_ULL(IB_USER_VERBS_CMD_POST_SEND);
 



  parent reply	other threads:[~2023-05-05 15:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-05 15:41 [PATCH RFC 0/3] siw on tunnel devices Chuck Lever
2023-05-05 15:42 ` [PATCH RFC 1/3] net/tun: Ensure tun devices have a MAC address Chuck Lever
2023-05-05 16:59   ` Stephen Hemminger
2023-05-05 17:09     ` Chuck Lever III
2023-05-05 15:42 ` [PATCH RFC 2/3] net/lo: Ensure lo " Chuck Lever
2023-05-05 16:57   ` Stephen Hemminger
2023-05-05 15:43 ` Chuck Lever [this message]
2023-05-05 19:58   ` [PATCH RFC 3/3] RDMA/siw: Require non-zero 6-byte MACs for soft iWARP Jason Gunthorpe
2023-05-05 20:03     ` Chuck Lever III
2023-05-06 18:05       ` Chuck Lever III
2023-05-23 19:18     ` Chuck Lever III
2023-05-23 19:44       ` Tom Talpey
2023-05-23 22:50         ` Chuck Lever III
2023-05-31 19:04       ` Jason Gunthorpe
2023-05-31 19:11         ` Chuck Lever III
2023-05-31 20:09           ` Jason Gunthorpe
2023-05-31 20:19             ` Chuck Lever III

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=168330138101.5953.12575990094340826016.stgit@oracle-102.nfsv4bat.org \
    --to=cel@kernel.org \
    --cc=BMT@zurich.ibm.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).