From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH v2 2/2] net/nfp: move socket from /tmp to runtime dir
Date: Thu, 23 Jul 2026 11:10:28 -0700 [thread overview]
Message-ID: <20260723181153.195915-3-stephen@networkplumber.org> (raw)
In-Reply-To: <20260723181153.195915-1-stephen@networkplumber.org>
The CPP bridge service created its unix socket at a fixed /tmp/<pci>
path, which is world-writable and shared across DPDK instances. Build
the path under the EAL runtime directory (e.g. /run/dpdk/<prefix>)
instead, so it follows the configured prefix and is isolated per
instance.
The old code copied the path into a struct sockaddr, whose sa_data is
only 14 bytes, and bound sizeof(struct sockaddr); a runtime-dir path
does not fit there. Use struct sockaddr_un so the full path fits, and
bail out if it is still truncated.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/net/nfp/nfp_cpp_bridge.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/net/nfp/nfp_cpp_bridge.c b/drivers/net/nfp/nfp_cpp_bridge.c
index da7ea35d62..c307eca730 100644
--- a/drivers/net/nfp/nfp_cpp_bridge.c
+++ b/drivers/net/nfp/nfp_cpp_bridge.c
@@ -7,6 +7,9 @@
#include <unistd.h>
#include <sys/ioctl.h>
+#include <sys/un.h>
+
+#include <rte_eal.h>
#include "nfpcore/nfp_cpp.h"
#include "nfp_logs.h"
@@ -334,17 +337,22 @@ nfp_cpp_bridge_service_func(void *args)
int datafd;
struct nfp_cpp *cpp;
const char *pci_name;
- char socket_handle[14];
- struct sockaddr address;
+ struct sockaddr_un address = { .sun_family = AF_UNIX };
struct nfp_pf_dev *pf_dev;
struct timeval timeout = {1, 0};
pf_dev = args;
pci_name = strchr(pf_dev->pci_dev->name, ':') + 1;
- snprintf(socket_handle, sizeof(socket_handle), "/tmp/%s", pci_name);
- unlink(socket_handle);
+ ret = snprintf(address.sun_path, sizeof(address.sun_path), "%s/nfp_%s",
+ rte_eal_get_runtime_dir(), pci_name);
+ if (ret < 0 || (size_t)ret >= sizeof(address.sun_path)) {
+ PMD_CPP_LOG(ERR, "Socket path too long. Service failed.");
+ return -EINVAL;
+ }
+
+ unlink(address.sun_path);
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
if (sockfd < 0) {
PMD_CPP_LOG(ERR, "Socket creation error. Service failed.");
@@ -353,13 +361,7 @@ nfp_cpp_bridge_service_func(void *args)
setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout));
- memset(&address, 0, sizeof(struct sockaddr));
-
- address.sa_family = AF_UNIX;
- strcpy(address.sa_data, socket_handle);
-
- ret = bind(sockfd, (const struct sockaddr *)&address,
- sizeof(struct sockaddr));
+ ret = bind(sockfd, (const struct sockaddr *)&address, sizeof(address));
if (ret < 0) {
PMD_CPP_LOG(ERR, "Bind error (%d). Service failed.", errno);
close(sockfd);
--
2.53.0
prev parent reply other threads:[~2026-07-23 18:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-31 18:56 [RFC 0/4] move unix domain sockets from /tmp to /run/dpdk Stephen Hemminger
2025-12-31 18:56 ` [RFC 1/4] net/af_xdp: replace /tmp with /run/dpdk Stephen Hemminger
2025-12-31 18:56 ` [RFC 2/4] examples/vm_power_manager: " Stephen Hemminger
2025-12-31 18:56 ` [RFC 3/4] net/nfp: " Stephen Hemminger
2025-12-31 18:56 ` [RFC 4/4] net/cnxk: move socket from /tmp to /run/dpdk Stephen Hemminger
2026-07-23 18:10 ` [PATCH v2 0/2] drivers: remove use of /tmp Stephen Hemminger
2026-07-23 18:10 ` [PATCH v2 1/2] net/cnxk: move socket from /tmp to runtime dir Stephen Hemminger
2026-07-23 18:10 ` Stephen Hemminger [this message]
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=20260723181153.195915-3-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
/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