pdump: fix default socket path
SOCKET_PATH_HOME is to specify environment variable "HOME", so it should not contain "/pdump_sockets" in the macro. So removed "/pdump_sockets" from SOCKET_PATH_HOME and SOCKET_PATH_VAR_RUN. New changes will create pdump sockets under /var/run/.dpdk/pdump_sockets for root users and under HOME/.dpdk/pdump_sockets for non root users. 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> Acked-by: John McNamara <john.mcnamara@intel.com>
This commit is contained in:
parent
f0cb66e3de
commit
bdd8dcc6e2
@ -50,8 +50,10 @@
|
|||||||
|
|
||||||
#include "rte_pdump.h"
|
#include "rte_pdump.h"
|
||||||
|
|
||||||
#define SOCKET_PATH_VAR_RUN "/var/run/pdump_sockets"
|
#define SOCKET_PATH_VAR_RUN "/var/run"
|
||||||
#define SOCKET_PATH_HOME "HOME/pdump_sockets"
|
#define SOCKET_PATH_HOME "HOME"
|
||||||
|
#define DPDK_DIR "/.dpdk"
|
||||||
|
#define SOCKET_DIR "/pdump_sockets"
|
||||||
#define SERVER_SOCKET "%s/pdump_server_socket"
|
#define SERVER_SOCKET "%s/pdump_server_socket"
|
||||||
#define CLIENT_SOCKET "%s/pdump_client_socket_%d_%u"
|
#define CLIENT_SOCKET "%s/pdump_client_socket_%d_%u"
|
||||||
#define DEVICE_ID_SIZE 64
|
#define DEVICE_ID_SIZE 64
|
||||||
@ -444,17 +446,26 @@ set_pdump_rxtx_cbs(struct pdump_request *p)
|
|||||||
static void
|
static void
|
||||||
pdump_get_socket_path(char *buffer, int bufsz, enum rte_pdump_socktype type)
|
pdump_get_socket_path(char *buffer, int bufsz, enum rte_pdump_socktype type)
|
||||||
{
|
{
|
||||||
const char *dir = NULL;
|
char dpdk_dir[PATH_MAX] = {0};
|
||||||
|
char dir[PATH_MAX] = {0};
|
||||||
|
char *dir_home = NULL;
|
||||||
|
|
||||||
if (type == RTE_PDUMP_SOCKET_SERVER && server_socket_dir[0] != 0)
|
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)
|
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 {
|
else {
|
||||||
if (getuid() != 0)
|
if (getuid() != 0) {
|
||||||
dir = getenv(SOCKET_PATH_HOME);
|
dir_home = getenv(SOCKET_PATH_HOME);
|
||||||
else
|
snprintf(dpdk_dir, sizeof(dpdk_dir), "%s%s",
|
||||||
dir = SOCKET_PATH_VAR_RUN;
|
dir_home, DPDK_DIR);
|
||||||
|
} else
|
||||||
|
snprintf(dpdk_dir, sizeof(dpdk_dir), "%s%s",
|
||||||
|
SOCKET_PATH_VAR_RUN, DPDK_DIR);
|
||||||
|
|
||||||
|
mkdir(dpdk_dir, 700);
|
||||||
|
snprintf(dir, sizeof(dir), "%s%s",
|
||||||
|
dpdk_dir, SOCKET_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir(dir, 700);
|
mkdir(dir, 700);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user