From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B9AD642ECF for ; Thu, 20 Jul 2023 17:29:57 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B590A42BD9; Thu, 20 Jul 2023 17:29:57 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id EB0FC400D6 for ; Thu, 20 Jul 2023 17:29:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689866995; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Guscc+SQWlS7CC3dULlhoMyfFc1FOuC46zce/Hs0+Ds=; b=WgGBMUC0r5MVlfkSBUMMf8OfW+ryDWRydwCiRrilklr8fNmb9TD+h9B+QhDoVohqymCGnh /V223oKzjvFtk2db4ZznAB7EhQjY2caUCxoA9RW7D97Tof3iP4cALRwthyltBsdbIoXcih IxS0KaYlxwJOc5eItPzkCCe2z0BMTyI= Received: from mimecast-mx02.redhat.com (66.187.233.88 [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-25-abE6izVUMLSjSppeUzLgGg-1; Thu, 20 Jul 2023 11:21:21 -0400 X-MC-Unique: abE6izVUMLSjSppeUzLgGg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 425CE830DB0; Thu, 20 Jul 2023 15:20:40 +0000 (UTC) Received: from rh.redhat.com (unknown [10.39.192.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7EBE492C13; Thu, 20 Jul 2023 15:20:38 +0000 (UTC) From: Kevin Traynor To: Huisong Li Cc: Chengwen Feng , Thomas Monjalon , Ferruh Yigit , dpdk stable Subject: patch 'ethdev: fix MAC address occupies two entries' has been queued to stable release 21.11.5 Date: Thu, 20 Jul 2023 16:17:40 +0100 Message-ID: <20230720151942.262154-29-ktraynor@redhat.com> In-Reply-To: <20230720151942.262154-1-ktraynor@redhat.com> References: <20230720151942.262154-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 21.11.5 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/25/23. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable/commit/b3741dfb480bba7addb4dc82a863d4904fdc3bb2 Thanks. Kevin --- >From b3741dfb480bba7addb4dc82a863d4904fdc3bb2 Mon Sep 17 00:00:00 2001 From: Huisong Li Date: Fri, 19 May 2023 17:31:55 +0800 Subject: [PATCH] ethdev: fix MAC address occupies two entries [ upstream commit 8f02f472a29432650d999969359d6a49ea6aadca ] The dev->data->mac_addrs[0] will be changed to a new MAC address when applications modify the default MAC address by .mac_addr_set(). However, if the new default one has been added as a non-default MAC address by .mac_addr_add(), the .mac_addr_set() didn't check this address. As a result, this MAC address occupies two entries in the list. Like: add(MAC1) add(MAC2) add(MAC3) add(MAC4) set_default(MAC3) default=MAC3, the rest of the list=MAC1, MAC2, MAC3, MAC4 Note: MAC3 occupies two entries. But .mac_addr_set() cannot remove it implicitly in case of MAC address shrinking in the list. So this patch adds a check on whether the new default address was already in the list and if so requires the user to remove it first. In addition, this patch documents the position of the default MAC address and address unique in the list. Fixes: 854d8ad4ef68 ("ethdev: add default mac address modifier") Signed-off-by: Huisong Li Acked-by: Chengwen Feng Acked-by: Thomas Monjalon Reviewed-by: Ferruh Yigit --- lib/ethdev/rte_ethdev.c | 10 ++++++++++ lib/ethdev/rte_ethdev.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 3796cc02f6..7e29982a4e 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -4486,4 +4486,5 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr) { struct rte_eth_dev *dev; + int index; int ret; @@ -4503,4 +4504,13 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr) RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP); + /* Keep address unique in dev->data->mac_addrs[]. */ + index = eth_dev_get_mac_addr_index(port_id, addr); + if (index > 0) { + RTE_ETHDEV_LOG(ERR, + "New default address for port %u was already in the address list. Please remove it first.\n", + port_id); + return -EEXIST; + } + ret = (*dev->dev_ops->mac_addr_set)(dev, addr); if (ret < 0) diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index 0be04c5809..d4a576965b 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -4164,4 +4164,7 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id, /** * Set the default MAC address. + * It replaces the address at index 0 of the MAC address list. + * If the address was already in the MAC address list, + * please remove it first. * * @param port_id @@ -4174,4 +4177,5 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id, * - (-ENODEV) if *port* invalid. * - (-EINVAL) if MAC address is invalid. + * - (-EEXIST) if MAC address was already in the address list. */ int rte_eth_dev_default_mac_addr_set(uint16_t port_id, -- 2.41.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-07-20 16:17:58.541473020 +0100 +++ 0029-ethdev-fix-MAC-address-occupies-two-entries.patch 2023-07-20 16:17:54.532749981 +0100 @@ -1 +1 @@ -From 8f02f472a29432650d999969359d6a49ea6aadca Mon Sep 17 00:00:00 2001 +From b3741dfb480bba7addb4dc82a863d4904fdc3bb2 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 8f02f472a29432650d999969359d6a49ea6aadca ] + @@ -28 +29,0 @@ -Cc: stable@dpdk.org @@ -35,36 +36,4 @@ - doc/guides/rel_notes/release_23_07.rst | 6 ++++++ - lib/ethdev/ethdev_driver.h | 6 +++++- - lib/ethdev/rte_ethdev.c | 10 ++++++++++ - lib/ethdev/rte_ethdev.h | 4 ++++ - 4 files changed, 25 insertions(+), 1 deletion(-) - -diff --git a/doc/guides/rel_notes/release_23_07.rst b/doc/guides/rel_notes/release_23_07.rst -index 11cf5c6a0c..58d4e59487 100644 ---- a/doc/guides/rel_notes/release_23_07.rst -+++ b/doc/guides/rel_notes/release_23_07.rst -@@ -109,4 +109,10 @@ API Changes - ======================================================= - -+* ethdev: Ensured all entries in MAC address list are uniques. -+ When setting a default MAC address with the function -+ ``rte_eth_dev_default_mac_addr_set``, -+ the default one needs to be removed by the user -+ if it was already in the address list. -+ - - ABI Changes -diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h -index 2c9d615fb5..367c0c4878 100644 ---- a/lib/ethdev/ethdev_driver.h -+++ b/lib/ethdev/ethdev_driver.h -@@ -118,5 +118,9 @@ struct rte_eth_dev_data { - uint64_t rx_mbuf_alloc_failed; /**< Rx ring mbuf allocation failures */ - -- /** Device Ethernet link address. @see rte_eth_dev_release_port() */ -+ /** -+ * Device Ethernet link addresses. -+ * All entries are unique. -+ * The first entry (index zero) is the default address. -+ */ - struct rte_ether_addr *mac_addrs; - /** Bitmap associating MAC addresses to pools */ + lib/ethdev/rte_ethdev.c | 10 ++++++++++ + lib/ethdev/rte_ethdev.h | 4 ++++ + 2 files changed, 14 insertions(+) + @@ -72 +41 @@ -index 4d03255683..d46e74504e 100644 +index 3796cc02f6..7e29982a4e 100644 @@ -75 +44 @@ -@@ -4899,4 +4899,5 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr) +@@ -4486,4 +4486,5 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr) @@ -81,2 +50,2 @@ -@@ -4917,4 +4918,13 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr) - return -ENOTSUP; +@@ -4503,4 +4504,13 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr) + RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP); @@ -96 +65 @@ -index 99fe9e238b..fe8f7466c8 100644 +index 0be04c5809..d4a576965b 100644 @@ -99 +68 @@ -@@ -4382,4 +4382,7 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id, +@@ -4164,4 +4164,7 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id, @@ -107 +76 @@ -@@ -4392,4 +4395,5 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id, +@@ -4174,4 +4177,5 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id,