patch 'ethdev: fix MAC address occupies two entries' has been queued to stable release 21.11.5

Kevin Traynor ktraynor at redhat.com
Thu Jul 20 17:17:40 CEST 2023


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 <lihuisong at huawei.com>
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 <lihuisong at huawei.com>
Acked-by: Chengwen Feng <fengchengwen at huawei.com>
Acked-by: Thomas Monjalon <thomas at monjalon.net>
Reviewed-by: Ferruh Yigit <ferruh.yigit at amd.com>
---
 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 at 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,



More information about the stable mailing list