From patchwork Fri May 5 15:42:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13232790 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78286C77B75 for ; Fri, 5 May 2023 15:42:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232867AbjEEPmb (ORCPT ); Fri, 5 May 2023 11:42:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232460AbjEEPma (ORCPT ); Fri, 5 May 2023 11:42:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D0951493A for ; Fri, 5 May 2023 08:42:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B8E3663EFC for ; Fri, 5 May 2023 15:42:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7384C433EF; Fri, 5 May 2023 15:42:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683301349; bh=ndKw3M3u+9Ev/+6Q02FJjDEkuTYXoWl+xEOrU4Avl9o=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=PAl/o3OLb105NkwdVpYZpx+yKgouWOl8pBLFBXuOIZqKvnXgw2RhYlYcyVH7cQ/4t a/OQBK/hfdk97Mn91lurJYxd6qG1JT0t+XxEy5M4MClJ9LSsEPc3yOdlHKuqxILC0v bIGb7sbYaIeN5wKluAJBt1YSRKiVqJmINkuv0jq5lFYGCBs+Lan4QWSA3Kbngy5Ubv qDZCNeJyAQXahQWf3ztodRAyRllKumQE1PlmIuDysQqYKZ6PcKnKfBmdnTV32IxkfM eXqMH54SAcX7pwdesJYmHaIk4uyRJi8gHNgTiC+KmK6k92/ieOi62henoJhq3zgjtX omU/g5wJgFl0Q== Subject: [PATCH RFC 1/3] net/tun: Ensure tun devices have a MAC address From: Chuck Lever To: netdev@vger.kernel.org, linux-rdma@vger.kernel.org Cc: BMT@zurich.ibm.com, tom@talpey.com Date: Fri, 05 May 2023 11:42:17 -0400 Message-ID: <168330132769.5953.7109360341846745035.stgit@oracle-102.nfsv4bat.org> In-Reply-To: <168330051600.5953.11366152375575299483.stgit@oracle-102.nfsv4bat.org> References: <168330051600.5953.11366152375575299483.stgit@oracle-102.nfsv4bat.org> User-Agent: StGit/1.5 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Chuck Lever A non-zero MAC address enables a network device to be assigned as the underlying device for a virtual RDMA device. Without a non- zero MAC address, cma_acquire_dev_by_src_ip() is unable to find the underlying egress device that corresponds to a source IP address, and rdma_resolve_address() fails. Signed-off-by: Chuck Lever --- drivers/net/tun.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index d4d0a41a905a..da85abfcd254 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1384,7 +1384,7 @@ static void tun_net_initialize(struct net_device *dev) /* Point-to-Point TUN Device */ dev->hard_header_len = 0; - dev->addr_len = 0; + dev->addr_len = ETH_ALEN; dev->mtu = 1500; /* Zero header length */ @@ -1399,8 +1399,6 @@ static void tun_net_initialize(struct net_device *dev) dev->priv_flags &= ~IFF_TX_SKB_SHARING; dev->priv_flags |= IFF_LIVE_ADDR_CHANGE; - eth_hw_addr_random(dev); - /* Currently tun does not support XDP, only tap does. */ dev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | @@ -1409,6 +1407,8 @@ static void tun_net_initialize(struct net_device *dev) break; } + eth_hw_addr_random(dev); + dev->min_mtu = MIN_MTU; dev->max_mtu = MAX_MTU - dev->hard_header_len; } From patchwork Fri May 5 15:42:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13232791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14D36C77B7F for ; Fri, 5 May 2023 15:43:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233023AbjEEPm7 (ORCPT ); Fri, 5 May 2023 11:42:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232460AbjEEPm6 (ORCPT ); Fri, 5 May 2023 11:42:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D440516081 for ; Fri, 5 May 2023 08:42:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5FC9A60AD1 for ; Fri, 5 May 2023 15:42:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F3E5C433D2; Fri, 5 May 2023 15:42:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683301375; bh=ztAAxEXfo/rYglxTcfa78z1zwxaUdLDHkCAM9kwLHJQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=cJWlz6HXtyTppL41PMB8QUzObB0HOfM7vtTwotWCxF3JpS0BpC2oczT8lOgozXHxp nx6ynh0tjYsHjEKnNjheNxoeqvZ+u/wM+O30k3VDQuQnXoritq5O21cbhPYSccgcki byvG4osUZNpwMFZgfq1ReLSgos3zKYbmXVfXe2GjeZM8SqkxlgtzLAAD8wfPEnatU+ l27hpxvsluUQsQcBvRa+FsvrTWkiRKdB+ourrPBdcvfI8MVxf3lB6NrHf42k1+Xjbp tnvedYMIOsvUCebn7SELbwA4kyoCO194LTvaTwZlLF4LoPfiY2IxEZN4Qz73EYDNLx ONCeVTY33CKGg== Subject: [PATCH RFC 2/3] net/lo: Ensure lo devices have a MAC address From: Chuck Lever To: netdev@vger.kernel.org, linux-rdma@vger.kernel.org Cc: BMT@zurich.ibm.com, tom@talpey.com Date: Fri, 05 May 2023 11:42:44 -0400 Message-ID: <168330135435.5953.3471584034284499194.stgit@oracle-102.nfsv4bat.org> In-Reply-To: <168330051600.5953.11366152375575299483.stgit@oracle-102.nfsv4bat.org> References: <168330051600.5953.11366152375575299483.stgit@oracle-102.nfsv4bat.org> User-Agent: StGit/1.5 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Chuck Lever A non-zero MAC address enables a network device to be assigned as the underlying device for a virtual RDMA device. Without a non- zero MAC address, cma_acquire_dev_by_src_ip() is unable to find the underlying egress device that corresponds to a source IP address, and rdma_resolve_address() fails. Signed-off-by: Chuck Lever --- drivers/net/loopback.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index f6d53e63ef4e..1ce4f19d8065 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c @@ -192,6 +192,8 @@ static void gen_lo_setup(struct net_device *dev, dev->needs_free_netdev = true; dev->priv_destructor = dev_destructor; + eth_hw_addr_random(dev); + netif_set_tso_max_size(dev, GSO_MAX_SIZE); } From patchwork Fri May 5 15:43:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13232792 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE4C7C77B75 for ; Fri, 5 May 2023 15:43:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232460AbjEEPnn (ORCPT ); Fri, 5 May 2023 11:43:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232060AbjEEPni (ORCPT ); Fri, 5 May 2023 11:43:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62566160AC for ; Fri, 5 May 2023 08:43:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EBD87610A3 for ; Fri, 5 May 2023 15:43:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FF9DC433EF; Fri, 5 May 2023 15:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683301402; bh=I+4Dxsbv/cMRqHUJKBGJuQZex4wx3fvqMLJdFCovs68=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=ghN1e2tQr1X4fgQCWvzLhbRco4DHi82qv9U960Nk9jj4nAx3mwkua3OgW9LZ00TRp sPivH//k+3V0ENsUxc2Fh6q2L6les8qSlqkV6c+1faWqAYv9woxJfnJdMGWdIJBV0g VDXmuqWuZvU6HTatU+2gAfwYnRO61bdt1BRZ9JgWITvTEcqyTVB5HtmiDAmjq0yxIt +sB+k2GdXXAlGta6L3cfIwNv7r3TsQQPH1m6X4xwnZpGU9as5SxvqXiiOf37RbJyWb yW+PCRfH/6+Pe+MURjaa7adgcBX/ufD8xd4cQ9TExSn0Wd16jYpb58YgePRHy7OdqT 6plxOFxBqk4ZA== Subject: [PATCH RFC 3/3] RDMA/siw: Require non-zero 6-byte MACs for soft iWARP From: Chuck Lever To: netdev@vger.kernel.org, linux-rdma@vger.kernel.org Cc: BMT@zurich.ibm.com, tom@talpey.com Date: Fri, 05 May 2023 11:43:11 -0400 Message-ID: <168330138101.5953.12575990094340826016.stgit@oracle-102.nfsv4bat.org> In-Reply-To: <168330051600.5953.11366152375575299483.stgit@oracle-102.nfsv4bat.org> References: <168330051600.5953.11366152375575299483.stgit@oracle-102.nfsv4bat.org> User-Agent: StGit/1.5 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Chuck Lever 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 --- 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);