patches for DPDK stable branches
 help / color / mirror / Atom feed
From: luca.boccassi@gmail.com
To: Huisong Li <lihuisong@huawei.com>
Cc: Chengwen Feng <fengchengwen@huawei.com>,
	Thomas Monjalon <thomas@monjalon.net>,
	Ferruh Yigit <ferruh.yigit@amd.com>,
	dpdk stable <stable@dpdk.org>
Subject: patch 'ethdev: fix MAC address occupies two entries' has been queued to stable release 20.11.9
Date: Thu, 15 Jun 2023 02:32:21 +0100	[thread overview]
Message-ID: <20230615013258.1439718-26-luca.boccassi@gmail.com> (raw)
In-Reply-To: <20230615013258.1439718-1-luca.boccassi@gmail.com>

Hi,

FYI, your patch has been queued to stable release 20.11.9

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/17/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/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/2928ea4fedd0902a8f85af2aceca90e24c116759

Thanks.

Luca Boccassi

---
From 2928ea4fedd0902a8f85af2aceca90e24c116759 Mon Sep 17 00:00:00 2001
From: Huisong Li <lihuisong@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@huawei.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: Ferruh Yigit <ferruh.yigit@amd.com>
---
 lib/librte_ethdev/rte_ethdev.c | 10 ++++++++++
 lib/librte_ethdev/rte_ethdev.h |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 4b59854c12..b5c5af3cf5 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -4150,6 +4150,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);
@@ -4160,6 +4161,15 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr)
 	dev = &rte_eth_devices[port_id];
 	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)
 		return ret;
diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
index 5e8331da1c..709563215f 100644
--- a/lib/librte_ethdev/rte_ethdev.h
+++ b/lib/librte_ethdev/rte_ethdev.h
@@ -3840,6 +3840,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.
@@ -3850,6 +3853,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.39.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-06-15 01:56:36.122879824 +0100
+++ 0026-ethdev-fix-MAC-address-occupies-two-entries.patch	2023-06-15 01:56:34.575541478 +0100
@@ -1 +1 @@
-From 8f02f472a29432650d999969359d6a49ea6aadca Mon Sep 17 00:00:00 2001
+From 2928ea4fedd0902a8f85af2aceca90e24c116759 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 8f02f472a29432650d999969359d6a49ea6aadca ]
+
@@ -28 +29,0 @@
-Cc: stable@dpdk.org
@@ -35,45 +36,9 @@
- 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
- -----------
-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
-@@ -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 4d03255683..d46e74504e 100644
---- a/lib/ethdev/rte_ethdev.c
-+++ b/lib/ethdev/rte_ethdev.c
-@@ -4898,6 +4898,7 @@ int
+ lib/librte_ethdev/rte_ethdev.c | 10 ++++++++++
+ lib/librte_ethdev/rte_ethdev.h |  4 ++++
+ 2 files changed, 14 insertions(+)
+
+diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
+index 4b59854c12..b5c5af3cf5 100644
+--- a/lib/librte_ethdev/rte_ethdev.c
++++ b/lib/librte_ethdev/rte_ethdev.c
+@@ -4150,6 +4150,7 @@ int
@@ -87,3 +52,3 @@
-@@ -4916,6 +4917,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;
+@@ -4160,6 +4161,15 @@ rte_eth_dev_default_mac_addr_set(uint16_t port_id, struct rte_ether_addr *addr)
+ 	dev = &rte_eth_devices[port_id];
+ 	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP);
@@ -103,5 +68,5 @@
-diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
-index 99fe9e238b..fe8f7466c8 100644
---- a/lib/ethdev/rte_ethdev.h
-+++ b/lib/ethdev/rte_ethdev.h
-@@ -4381,6 +4381,9 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id,
+diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h
+index 5e8331da1c..709563215f 100644
+--- a/lib/librte_ethdev/rte_ethdev.h
++++ b/lib/librte_ethdev/rte_ethdev.h
+@@ -3840,6 +3840,9 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id,
@@ -117 +82 @@
-@@ -4391,6 +4394,7 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id,
+@@ -3850,6 +3853,7 @@ int rte_eth_dev_mac_addr_remove(uint16_t port_id,

  parent reply	other threads:[~2023-06-15  1:34 UTC|newest]

Thread overview: 113+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-15  1:31 patch 'kni: fix build with Linux 6.3' " luca.boccassi
2023-06-15  1:31 ` patch 'examples/ip_pipeline: fix build with GCC 13' " luca.boccassi
2023-06-15  1:31 ` patch 'examples/ntb: " luca.boccassi
2023-06-15  1:31 ` patch 'ring: fix use after free' " luca.boccassi
2023-06-15  1:32 ` patch 'vfio: fix include with musl runtime' " luca.boccassi
2023-06-15  1:32 ` patch 'kernel/freebsd: fix function parameter list' " luca.boccassi
2023-06-15  1:32 ` patch 'build: fix case of project language name' " luca.boccassi
2023-06-15  1:32 ` patch 'telemetry: fix autotest on Alpine' " luca.boccassi
2023-06-15  1:32 ` patch 'test/malloc: fix missing free' " luca.boccassi
2023-06-15  1:32 ` patch 'test/malloc: fix statistics checks' " luca.boccassi
2023-06-15  1:32 ` patch 'eal: avoid calling cleanup twice' " luca.boccassi
2023-06-15  1:32 ` patch 'pci: fix comment referencing renamed function' " luca.boccassi
2023-06-15  1:32 ` patch 'eal/x86: improve multiple of 64 bytes memcpy performance' " luca.boccassi
2023-06-15  1:32 ` patch 'eventdev/timer: fix timeout event wait behavior' " luca.boccassi
2023-06-15  1:32 ` patch 'doc: fix event timer adapter guide' " luca.boccassi
2023-06-15  1:32 ` patch 'event/dsw: free rings on close' " luca.boccassi
2023-06-15  1:32 ` patch 'eventdev/timer: fix buffer flush' " luca.boccassi
2023-06-15  1:32 ` patch 'eal/linux: fix secondary process crash for mp hotplug' " luca.boccassi
2023-06-15  1:32 ` patch 'eal/linux: fix legacy mem init with many segments' " luca.boccassi
2023-06-15  1:32 ` patch 'net/hns3: fix build warning' " luca.boccassi
2023-06-15  1:32 ` patch 'net/tap: set locally administered bit for fixed MAC address' " luca.boccassi
2023-06-15  1:32 ` patch 'net/dpaa2: fix checksum good flags' " luca.boccassi
2023-06-15  1:32 ` patch 'app/testpmd: fix GTP L2 length in checksum engine' " luca.boccassi
2023-06-15  1:32 ` patch 'net/vmxnet3: fix drop of empty segments in Tx' " luca.boccassi
2023-06-15  1:32 ` patch 'net/txgbe: fix use-after-free on remove' " luca.boccassi
2023-06-15  1:32 ` luca.boccassi [this message]
2023-06-15  1:32 ` patch 'net/hns3: fix variable type mismatch' " luca.boccassi
2023-06-15  1:32 ` patch 'net/hns3: fix Rx multiple firmware reset interrupts' " luca.boccassi
2023-06-15  1:32 ` patch 'net/hns3: fix FEC mode for 200G ports' " luca.boccassi
2023-06-15  1:32 ` patch 'net/hns3: fix FEC mode check' " luca.boccassi
2023-06-15  1:32 ` patch 'doc: fix format in flow API guide' " luca.boccassi
2023-06-15  1:32 ` patch 'net/hns3: fix mbuf leakage when RxQ started during reset' " luca.boccassi
2023-06-15  1:32 ` patch 'net/hns3: fix mbuf leakage when RxQ started after " luca.boccassi
2023-06-15  1:32 ` patch 'net/hns3: fix device start return value' " luca.boccassi
2023-06-15  1:32 ` patch 'net/hns3: fix uninitialized variable' " luca.boccassi
2023-06-15  1:32 ` patch 'net/hns3: fix inaccurate log' " luca.boccassi
2023-06-15  1:32 ` patch 'net/hns3: fix redundant line break in " luca.boccassi
2023-06-15  1:32 ` patch 'net/hns3: fix IMP reset trigger' " luca.boccassi
2023-06-15  1:32 ` patch 'net/nfp: fix offloading flows' " luca.boccassi
2023-06-15  1:32 ` patch 'net/vmxnet3: fix return code in initializing' " luca.boccassi
2023-06-15  1:32 ` patch 'doc: fix auth algos in cryptoperf app' " luca.boccassi
2023-06-15  1:32 ` patch 'crypto/scheduler: fix last element for valid args' " luca.boccassi
2023-06-15  1:32 ` patch 'test/crypto: fix session creation check' " luca.boccassi
2023-06-15  1:32 ` patch 'vhost: fix invalid call FD handling' " luca.boccassi
2023-06-15  1:32 ` patch 'net/virtio: fix initialization to return negative errno' " luca.boccassi
2023-06-15  1:32 ` patch 'net/virtio-user: fix leak when initialisation fails' " luca.boccassi
2023-06-15  1:32 ` patch 'net/mlx5: enhance error log for tunnel offloading' " luca.boccassi
2023-06-15  1:32 ` patch 'net/mlx5: fix duplicated tag index matching in SWS' " luca.boccassi
2023-06-15  1:32 ` patch 'net/qede: fix RSS indirection table initialization' " luca.boccassi
2023-06-15  1:32 ` patch 'doc: fix typo in cnxk platform guide' " luca.boccassi
2023-06-15  1:32 ` patch 'net/i40e: fix Rx data buffer size' " luca.boccassi
2023-06-15  1:32 ` patch 'net/ice: " luca.boccassi
2023-06-15  1:32 ` patch 'net/iavf: " luca.boccassi
2023-06-15  1:32 ` patch 'net/ice: fix statistics' " luca.boccassi
2023-06-15  1:32 ` patch 'net/ice: fix DCF RSS initialization' " luca.boccassi
2023-06-15  1:32 ` patch 'net/iavf: release large VF when closing device' " luca.boccassi
2023-06-15  1:32 ` patch 'net/ice: fix DCF control thread crash' " luca.boccassi
2023-06-15  1:32 ` patch 'net/ice/base: remove unreachable code' " luca.boccassi
2023-06-15  1:32 ` patch 'net/ice: fix outer UDP checksum offload' " luca.boccassi
2023-06-15  1:32 ` patch 'net/iavf: fix virtchnl command called in interrupt' " luca.boccassi
2023-06-15  1:32 ` patch 'test/mbuf: fix crash in a forked process' " luca.boccassi
2023-06-15  1:32 ` patch 'doc: fix typo in graph guide' " luca.boccassi
2023-06-15  1:32 ` patch 'doc: remove warning with Doxygen 1.9.7' " luca.boccassi
2023-06-28 14:10   ` patch 'examples/l2fwd-cat: fix external build' " luca.boccassi
2023-06-28 14:10     ` patch 'test: add graph tests' " luca.boccassi
2023-06-28 14:55       ` David Marchand
2023-06-28 14:10     ` patch 'mbuf: fix Doxygen comment of distributor metadata' " luca.boccassi
2023-06-28 14:10     ` patch 'crypto/openssl: skip workaround at compilation time' " luca.boccassi
2023-06-28 14:10     ` patch 'ethdev: update documentation for API to set FEC' " luca.boccassi
2023-06-28 14:10     ` patch 'ethdev: check that at least one FEC mode is specified' " luca.boccassi
2023-06-28 14:10     ` patch 'ethdev: update documentation for API to get FEC' " luca.boccassi
2023-06-28 14:10     ` patch 'net/bonding: fix startup when NUMA is not supported' " luca.boccassi
2023-06-28 14:10     ` patch 'net/bonding: fix destroy dedicated queues flow' " luca.boccassi
2023-06-28 14:10     ` patch 'net/txgbe/base: fix Tx with fiber hotplug' " luca.boccassi
2023-06-28 14:10     ` patch 'net/txgbe: fix to set autoneg for 1G speed' " luca.boccassi
2023-06-28 14:10     ` patch 'net/txgbe: fix extended statistics' " luca.boccassi
2023-06-28 14:10     ` patch 'net/nfp: fix address always related with PF ID 0' " luca.boccassi
2023-06-28 14:10     ` patch 'common/sfc_efx/base: fix Rx queue without RSS hash prefix' " luca.boccassi
2023-06-28 14:10     ` patch 'net/ice: fix tunnel packet Tx descriptor' " luca.boccassi
2023-06-28 14:10     ` patch 'net/ixgbe: add proper memory barriers in Rx' " luca.boccassi
2023-06-28 14:10     ` patch 'net/iavf: fix abnormal disable HW interrupt' " luca.boccassi
2023-06-28 14:10     ` patch 'net/i40e: fix tunnel packet Tx descriptor' " luca.boccassi
2023-06-28 14:10     ` patch 'net/e1000: fix queue number initialization' " luca.boccassi
2023-06-28 14:10     ` patch 'net/mlx5: fix risk in NEON Rx descriptor read' " luca.boccassi
2023-06-28 14:10     ` patch 'net/mlx5: fix device removal event handling' " luca.boccassi
2023-06-28 14:10     ` patch 'common/mlx5: adjust fork call with new kernel API' " luca.boccassi
2023-07-14 22:34       ` patch 'ipc: fix file descriptor leakage with unhandled messages' " luca.boccassi
2023-07-14 22:34         ` patch 'fib: fix adding default route' " luca.boccassi
2023-07-14 22:34         ` patch 'mem: fix memsegs exhausted message' " luca.boccassi
2023-07-14 22:34         ` patch 'net/netvsc: fix sizeof calculation' " luca.boccassi
2023-07-14 22:34         ` patch 'app/testpmd: fix checksum engine with GTP on 32-bit' " luca.boccassi
2023-07-14 22:34         ` patch 'net/hns3: fix non-zero weight for disabled TC' " luca.boccassi
2023-07-14 22:34         ` patch 'net/hns3: fix index to look up table in NEON Rx' " luca.boccassi
2023-07-14 22:34         ` patch 'ethdev: fix potential leak in PCI probing helper' " luca.boccassi
2023-07-14 22:34         ` patch 'net/mlx5: forbid MPRQ restart' " luca.boccassi
2023-07-14 22:34         ` patch 'net/ice: fix 32-bit build' " luca.boccassi
2023-07-14 22:34         ` patch 'net/ice: fix RSS hash key generation' " luca.boccassi
2023-07-14 22:34         ` patch 'baseband/fpga_5gnr_fec: fix possible division by zero' " luca.boccassi
2023-07-14 22:34         ` patch 'baseband/fpga_5gnr_fec: fix starting unconfigured queue' " luca.boccassi
2023-07-14 22:34         ` patch 'test/crypto: fix PDCP-SDAP test vectors' " luca.boccassi
2023-07-14 22:34         ` patch 'examples/fips_validation: fix digest length in AES-GCM' " luca.boccassi
2023-07-14 22:34         ` patch 'app/crypto-perf: fix socket ID default value' " luca.boccassi
2023-07-14 22:34         ` patch 'examples/ipsec-secgw: fix TAP default MAC address' " luca.boccassi
2023-07-14 22:34         ` patch 'kni: fix build with Linux 6.5' " luca.boccassi
2023-07-20 10:58           ` patch 'doc: fix typos and wording in flow API guide' " luca.boccassi
2023-07-20 10:58             ` patch 'net/i40e: fix comments' " luca.boccassi
2023-07-20 10:58             ` patch 'net/iavf: fix stop ordering' " luca.boccassi
2023-07-20 10:58             ` patch 'common/iavf: fix MAC type for 710 NIC' " luca.boccassi
2023-07-20 10:58             ` patch 'net/ixgbe: fix Rx and Tx queue status' " luca.boccassi
2023-07-20 10:58             ` patch 'net/igc: " luca.boccassi
2023-07-20 10:58             ` patch 'net/e1000: " luca.boccassi
2023-07-20 10:58             ` patch 'net/mlx5: fix LRO TCP checksum' " luca.boccassi
2023-07-20 10:58             ` patch 'doc: update BIOS settings and supported HW for NTB' " luca.boccassi

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=20230615013258.1439718-26-luca.boccassi@gmail.com \
    --to=luca.boccassi@gmail.com \
    --cc=fengchengwen@huawei.com \
    --cc=ferruh.yigit@amd.com \
    --cc=lihuisong@huawei.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    /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).