From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
stable@dpdk.org, Thomas Monjalon <thomas@monjalon.net>,
Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
Matan Azrad <matan@nvidia.com>,
Suanming Mou <suanmingm@nvidia.com>,
Ajit Khaparde <ajit.khaparde@broadcom.com>
Subject: [RFC 1/6] ethdev: fix flow_ops_mutex for multi-process
Date: Thu, 29 Jan 2026 21:17:32 -0800 [thread overview]
Message-ID: <20260130052142.251649-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20260130052142.251649-1-stephen@networkplumber.org>
The flow_ops_mutex in rte_eth_dev_data is located in shared memory
that is accessed by both primary and secondary processes. However,
the mutex is initialized without PTHREAD_PROCESS_SHARED attribute,
which means synchronization between processes is undefined behavior.
POSIX mutexes are by default private to the process creating them.
When a mutex protects data structures in shared memory that are
accessed by multiple processes, pthread_mutexattr_setpshared() must
be called with PTHREAD_PROCESS_SHARED.
This bug has existed since the flow_ops_mutex was added and affects
any multi-process DPDK application using rte_flow APIs.
Bugzilla ID: 662
Fixes: 80d1a9aff7f6 ("ethdev: make flow API thread safe")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/ethdev/ethdev_driver.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/lib/ethdev/ethdev_driver.c b/lib/ethdev/ethdev_driver.c
index 2ec665be0f..d12395efe0 100644
--- a/lib/ethdev/ethdev_driver.c
+++ b/lib/ethdev/ethdev_driver.c
@@ -89,6 +89,22 @@ eth_dev_set_dummy_fops(struct rte_eth_dev *eth_dev)
eth_dev->recycle_rx_descriptors_refill = rte_eth_recycle_rx_descriptors_refill_dummy;
}
+/*
+ * Initialize mutex for process-shared access.
+ * The rte_eth_dev_data structure is in shared memory, so any mutex
+ * protecting it must use PTHREAD_PROCESS_SHARED.
+ */
+static void
+eth_dev_flow_ops_mutex_init(pthread_mutex_t *mutex)
+{
+ pthread_mutexattr_t attr;
+
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED);
+ pthread_mutex_init(mutex, &attr);
+ pthread_mutexattr_destroy(&attr);
+}
+
RTE_EXPORT_INTERNAL_SYMBOL(rte_eth_dev_allocate)
struct rte_eth_dev *
rte_eth_dev_allocate(const char *name)
@@ -135,7 +151,7 @@ rte_eth_dev_allocate(const char *name)
eth_dev->data->port_id = port_id;
eth_dev->data->backer_port_id = RTE_MAX_ETHPORTS;
eth_dev->data->mtu = RTE_ETHER_MTU;
- pthread_mutex_init(ð_dev->data->flow_ops_mutex, NULL);
+ eth_dev_flow_ops_mutex_init(ð_dev->data->flow_ops_mutex);
RTE_ASSERT(rte_eal_process_type() == RTE_PROC_PRIMARY);
eth_dev_shared_data->allocated_ports++;
--
2.51.0
next prev parent reply other threads:[~2026-01-30 5:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-30 5:17 [RFC 0/6] Fix pthread mutexes for multi-process support Stephen Hemminger
2026-01-30 5:17 ` Stephen Hemminger [this message]
2026-01-30 5:17 ` [RFC 2/6] net/failsafe: fix hotplug_mutex for multi-process Stephen Hemminger
2026-01-30 5:17 ` [RFC 3/6] net/atlantic: fix mbox_mutex " Stephen Hemminger
2026-01-30 5:17 ` [RFC 4/6] net/axgbe: fix mutexes " Stephen Hemminger
2026-01-30 5:17 ` [RFC 5/6] net/bnxt: " Stephen Hemminger
2026-01-30 5:17 ` [RFC 6/6] net/hinic: " Stephen Hemminger
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=20260130052142.251649-2-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=ajit.khaparde@broadcom.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=matan@nvidia.com \
--cc=stable@dpdk.org \
--cc=suanmingm@nvidia.com \
--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