[dpdk-dev,v4,1/5] pdump: fix default socket path
Commit Message
SOCKET_PATH_HOME is to specify environment variable "HOME",
so it should not contain "/pdump_sockets" in the macro.
So remove "/pdump_sockets" from SOCKET_PATH_HOME
and create new macro for "/pdump_sockets". Similary removed
"/pdump_sockets" from SOCKET_PATH_VAR_RUN.
Changes are done in pdump_get_socket_path() to accommodate
new socket path changes.
Fixes: 278f945402c5 ("pdump: add new library for packet capture")
Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
---
lib/librte_pdump/rte_pdump.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
Comments
2016-06-24 14:54, Reshma Pattan:
> +#define SOCKET_DIR "/pdump_sockets"
I think the default socket directory should contain dpdk as prefix.
Like dpdk-pdump-sockets (I think dash is preferred for filenames).
I wonder whether it should be a hidden directory:
~/.dpdk-pdump-sockets
And after all, why not simply
~/.dpdk/
It would allow other DPDK applications to put some files.
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Friday, June 24, 2016 3:55 PM
> To: Pattan, Reshma <reshma.pattan@intel.com>
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v4 1/5] pdump: fix default socket path
>
> 2016-06-24 14:54, Reshma Pattan:
> > +#define SOCKET_DIR "/pdump_sockets"
>
> I think the default socket directory should contain dpdk as prefix.
> Like dpdk-pdump-sockets (I think dash is preferred for filenames).
> I wonder whether it should be a hidden directory:
> ~/.dpdk-pdump-sockets
> And after all, why not simply
> ~/.dpdk/
Hmm I would keep the name dpdk-pdump-sockets as library creates this only for pdump sockets.
Hidden directory just gives the advantage of not cluttering the display. If your comment is for the same I can add a . in the directory name:-).
> It would allow other DPDK applications to put some files.
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Friday, June 24, 2016 3:55 PM
> To: Pattan, Reshma <reshma.pattan@intel.com>
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v4 1/5] pdump: fix default socket path
>
> 2016-06-24 14:54, Reshma Pattan:
> > +#define SOCKET_DIR "/pdump_sockets"
>
> I think the default socket directory should contain dpdk as prefix.
> Like dpdk-pdump-sockets (I think dash is preferred for filenames).
> I wonder whether it should be a hidden directory:
> ~/.dpdk-pdump-sockets
> And after all, why not simply
> ~/.dpdk/
patch v5 is sent with changes /.dpdk/pdump_sockets.
> It would allow other DPDK applications to put some files.
@@ -50,8 +50,9 @@
#include "rte_pdump.h"
-#define SOCKET_PATH_VAR_RUN "/var/run/pdump_sockets"
-#define SOCKET_PATH_HOME "HOME/pdump_sockets"
+#define SOCKET_PATH_VAR_RUN "/var/run"
+#define SOCKET_PATH_HOME "HOME"
+#define SOCKET_DIR "/pdump_sockets"
#define SERVER_SOCKET "%s/pdump_server_socket"
#define CLIENT_SOCKET "%s/pdump_client_socket_%d_%u"
#define DEVICE_ID_SIZE 64
@@ -444,17 +445,20 @@ set_pdump_rxtx_cbs(struct pdump_request *p)
static void
pdump_get_socket_path(char *buffer, int bufsz, enum rte_pdump_socktype type)
{
- const char *dir = NULL;
+ char dir[PATH_MAX] = {0};
+ char *dir_home = NULL;
if (type == RTE_PDUMP_SOCKET_SERVER && server_socket_dir[0] != 0)
- dir = server_socket_dir;
+ snprintf(dir, sizeof(dir), "%s", server_socket_dir);
else if (type == RTE_PDUMP_SOCKET_CLIENT && client_socket_dir[0] != 0)
- dir = client_socket_dir;
+ snprintf(dir, sizeof(dir), "%s", client_socket_dir);
else {
- if (getuid() != 0)
- dir = getenv(SOCKET_PATH_HOME);
- else
- dir = SOCKET_PATH_VAR_RUN;
+ if (getuid() != 0) {
+ dir_home = getenv(SOCKET_PATH_HOME);
+ strcat(dir, dir_home);
+ } else
+ strcat(dir, SOCKET_PATH_VAR_RUN);
+ strcat(dir, SOCKET_DIR);
}
mkdir(dir, 700);