patch 'ethdev: fix MAC address occupies two entries' has been queued to stable release 22.11.3
Xueming Li
xuemingl at nvidia.com
Sun Jun 25 08:34:15 CEST 2023
Hi,
FYI, your patch has been queued to stable release 22.11.3
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 06/27/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://git.dpdk.org/dpdk-stable/log/?h=22.11-staging
This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=22.11-staging&id=631f57f5effabb6b358e47b81c71855c8336a6c9
Thanks.
Xueming Li <xuemingl at nvidia.com>
---
>From 631f57f5effabb6b358e47b81c71855c8336a6c9 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
Cc: Xueming Li <xuemingl at nvidia.com>
[ 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/ethdev_driver.h | 6 +++++-
lib/ethdev/rte_ethdev.c | 10 ++++++++++
lib/ethdev/rte_ethdev.h | 4 ++++
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h
index 6a550cfc83..cd2cd89649 100644
--- a/lib/ethdev/ethdev_driver.h
+++ b/lib/ethdev/ethdev_driver.h
@@ -117,7 +117,11 @@ 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 */
uint64_t mac_pool_sel[RTE_ETH_NUM_RECEIVE_MAC_ADDR];
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index b9c8f79f8c..f21dea7150 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -4499,6 +4499,7 @@ int
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;
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
@@ -4517,6 +4518,15 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr)
if (*dev->dev_ops->mac_addr_set == NULL)
return -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)
return ret;
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index c129ca1eaf..0d83df42a9 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -4354,6 +4354,9 @@ 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
* The port identifier of the Ethernet device.
@@ -4364,6 +4367,7 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id,
* - (-ENOTSUP) if hardware doesn't support.
* - (-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,
struct rte_ether_addr *mac_addr);
--
2.25.1
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2023-06-25 14:31:59.513936300 +0800
+++ 0037-ethdev-fix-MAC-address-occupies-two-entries.patch 2023-06-25 14:31:58.335773900 +0800
@@ -1 +1 @@
-From 8f02f472a29432650d999969359d6a49ea6aadca Mon Sep 17 00:00:00 2001
+From 631f57f5effabb6b358e47b81c71855c8336a6c9 Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit 8f02f472a29432650d999969359d6a49ea6aadca ]
@@ -28 +30,0 @@
-Cc: stable at dpdk.org
@@ -35,23 +37,5 @@
- 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
-@@ -108,6 +108,12 @@ API Changes
- Also, make sure to start the actual text at the margin.
- =======================================================
-
-+* 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
- -----------
+ lib/ethdev/ethdev_driver.h | 6 +++++-
+ lib/ethdev/rte_ethdev.c | 10 ++++++++++
+ lib/ethdev/rte_ethdev.h | 4 ++++
+ 3 files changed, 19 insertions(+), 1 deletion(-)
+
@@ -59 +43 @@
-index 2c9d615fb5..367c0c4878 100644
+index 6a550cfc83..cd2cd89649 100644
@@ -76 +60 @@
-index 4d03255683..d46e74504e 100644
+index b9c8f79f8c..f21dea7150 100644
@@ -79 +63 @@
-@@ -4898,6 +4898,7 @@ int
+@@ -4499,6 +4499,7 @@ int
@@ -87 +71 @@
-@@ -4916,6 +4917,15 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr)
+@@ -4517,6 +4518,15 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr)
@@ -104 +88 @@
-index 99fe9e238b..fe8f7466c8 100644
+index c129ca1eaf..0d83df42a9 100644
@@ -107 +91 @@
-@@ -4381,6 +4381,9 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id,
+@@ -4354,6 +4354,9 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id,
@@ -117 +101 @@
-@@ -4391,6 +4394,7 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id,
+@@ -4364,6 +4367,7 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id,
More information about the stable
mailing list