DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yang Ming <ming.1.yang@nokia-sbell.com>
To: dev@dpdk.org
Cc: Yang Ming <ming.1.yang@nokia-sbell.com>,
	bingz@nvidia.com, dsosnowski@nvidia.com,
	stephen@networkplumber.org, julien.meunier@nokia.com
Subject: [PATCH v2 1/2] net/mlx5: enhance socket file path
Date: Fri, 21 Mar 2025 21:27:49 +0800	[thread overview]
Message-ID: <20250321132750.4237-1-ming.1.yang@nokia-sbell.com> (raw)
In-Reply-To: <20241213092444.2987-1-ming.1.yang@nokia-sbell.com>

The directory /var/tmp may not be writable in a container's
read-only mode. To address this issue, use the DPDK runtime
directory as an alternative when /var/tmp is not writable.

Cc: bingz@nvidia.com
Cc: dsosnowski@nvidia.com
Cc: stephen@networkplumber.org
Cc: julien.meunier@nokia.com

Signed-off-by: Yang Ming <ming.1.yang@nokia-sbell.com>
---
 drivers/net/mlx5/linux/mlx5_socket.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_socket.c b/drivers/net/mlx5/linux/mlx5_socket.c
index 6ce0e59643..270a105f1d 100644
--- a/drivers/net/mlx5/linux/mlx5_socket.c
+++ b/drivers/net/mlx5/linux/mlx5_socket.c
@@ -20,7 +20,8 @@
 
 /* PMD socket service for tools. */
 
-#define MLX5_SOCKET_PATH "/var/tmp/dpdk_net_mlx5_%d"
+#define MLX5_SOCKET_DPATH "/var/tmp"
+#define MLX5_SOCKET_FNAME "dpdk_net_mlx5"
 #define MLX5_ALL_PORT_IDS 0xffff
 
 int server_socket = -1; /* Unix socket for primary process. */
@@ -177,8 +178,13 @@ mlx5_pmd_socket_init(void)
 	ret = fcntl(server_socket, F_SETFL, flags | O_NONBLOCK);
 	if (ret < 0)
 		goto close;
-	snprintf(sun.sun_path, sizeof(sun.sun_path), MLX5_SOCKET_PATH,
-		 getpid());
+
+	if (access(MLX5_SOCKET_DPATH, W_OK) == 0)
+		snprintf(sun.sun_path, sizeof(sun.sun_path), "%s/%s_%d",
+			 MLX5_SOCKET_DPATH, MLX5_SOCKET_FNAME, getpid());
+	else
+		snprintf(sun.sun_path, sizeof(sun.sun_path), "%s/%s_%d",
+			 rte_eal_get_runtime_dir(), MLX5_SOCKET_FNAME, getpid());
 	remove(sun.sun_path);
 	ret = bind(server_socket, (const struct sockaddr *)&sun, sizeof(sun));
 	if (ret < 0) {
@@ -223,6 +229,13 @@ mlx5_pmd_socket_uninit(void)
 					  mlx5_pmd_socket_handle, NULL);
 	claim_zero(close(server_socket));
 	server_socket = -1;
-	MKSTR(path, MLX5_SOCKET_PATH, getpid());
-	claim_zero(remove(path));
+	if (access(MLX5_SOCKET_DPATH, W_OK) == 0) {
+		MKSTR(path, "%s/%s_%d", MLX5_SOCKET_DPATH, MLX5_SOCKET_FNAME,
+		      getpid());
+		claim_zero(remove(path));
+	} else {
+		MKSTR(path2, "%s/%s_%d", rte_eal_get_runtime_dir(), MLX5_SOCKET_FNAME,
+		      getpid());
+		claim_zero(remove(path2));
+	}
 }
-- 
2.34.1


  parent reply	other threads:[~2025-03-21 13:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-13  9:24 [PATCH 1/2] net/mlx5: improve " Yang Ming
2024-12-13  9:24 ` [PATCH 2/2] net/mlx5: improve log " Yang Ming
2025-03-04  6:23   ` Bing Zhao
2025-03-05  3:20     ` Yang Ming
2025-03-10 14:59     ` Stephen Hemminger
2025-03-12  2:32       ` [External] " Yang Ming
2025-03-17 16:05         ` Bing Zhao
2025-03-21  9:48           ` Ming 1. Yang (NSB)
2024-12-13 17:12 ` [PATCH 1/2] net/mlx5: improve socket " Stephen Hemminger
2024-12-13 17:16   ` Bruce Richardson
2025-01-03  2:51     ` Yang Ming
2025-03-12  2:55       ` Yang Ming
2025-03-14 11:48         ` Dariusz Sosnowski
2025-03-21 13:27 ` Yang Ming [this message]
2025-03-21 13:27   ` [PATCH v2 2/2] net/mlx5: enhance log " Yang Ming

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=20250321132750.4237-1-ming.1.yang@nokia-sbell.com \
    --to=ming.1.yang@nokia-sbell.com \
    --cc=bingz@nvidia.com \
    --cc=dev@dpdk.org \
    --cc=dsosnowski@nvidia.com \
    --cc=julien.meunier@nokia.com \
    --cc=stephen@networkplumber.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;
as well as URLs for NNTP newsgroup(s).