}
/* get socket path (/var/run if root, $HOME otherwise) */
-static void
+static int
pdump_get_socket_path(char *buffer, int bufsz, enum rte_pdump_socktype type)
{
char dpdk_dir[PATH_MAX] = {0};
else {
if (getuid() != 0) {
dir_home = getenv(SOCKET_PATH_HOME);
+ if (!dir_home) {
+ RTE_LOG(ERR, PDUMP,
+ "Failed to get environment variable"
+ " value for %s, %s:%d\n",
+ SOCKET_PATH_HOME, __func__, __LINE__);
+ return -1;
+ }
snprintf(dpdk_dir, sizeof(dpdk_dir), "%s%s",
dir_home, DPDK_DIR);
} else
else
snprintf(buffer, bufsz, CLIENT_SOCKET, dir, getpid(),
rte_sys_gettid());
+
+ return 0;
}
static int
struct sockaddr_un addr;
socklen_t addr_len;
- pdump_get_socket_path(addr.sun_path, sizeof(addr.sun_path),
+ ret = pdump_get_socket_path(addr.sun_path, sizeof(addr.sun_path),
RTE_PDUMP_SOCKET_SERVER);
+ if (ret != 0) {
+ RTE_LOG(ERR, PDUMP,
+ "Failed to get server socket path: %s:%d\n",
+ __func__, __LINE__);
+ return -1;
+ }
addr.sun_family = AF_UNIX;
/* remove if file already exists */
struct sockaddr_un addr;
- pdump_get_socket_path(addr.sun_path, sizeof(addr.sun_path),
+ ret = pdump_get_socket_path(addr.sun_path, sizeof(addr.sun_path),
RTE_PDUMP_SOCKET_SERVER);
+ if (ret != 0) {
+ RTE_LOG(ERR, PDUMP,
+ "Failed to get server socket path: %s:%d\n",
+ __func__, __LINE__);
+ return -1;
+ }
ret = unlink(addr.sun_path);
if (ret != 0) {
RTE_LOG(ERR, PDUMP,
return ret;
}
- pdump_get_socket_path(addr.sun_path, sizeof(addr.sun_path),
+ ret = pdump_get_socket_path(addr.sun_path, sizeof(addr.sun_path),
RTE_PDUMP_SOCKET_CLIENT);
+ if (ret != 0) {
+ RTE_LOG(ERR, PDUMP,
+ "Failed to get client socket path: %s:%d\n",
+ __func__, __LINE__);
+ return -1;
+ }
addr.sun_family = AF_UNIX;
addr_len = sizeof(struct sockaddr_un);
serv_len = sizeof(struct sockaddr_un);
memset(&serv_addr, 0, sizeof(serv_addr));
- pdump_get_socket_path(serv_addr.sun_path,
+ ret = pdump_get_socket_path(serv_addr.sun_path,
sizeof(serv_addr.sun_path),
RTE_PDUMP_SOCKET_SERVER);
+ if (ret != 0) {
+ RTE_LOG(ERR, PDUMP,
+ "Failed to get server socket path: %s:%d\n",
+ __func__, __LINE__);
+ break;
+ }
serv_addr.sun_family = AF_UNIX;
n = sendto(socket_fd, p, sizeof(struct pdump_request), 0,