pdump: fix error handlings
The changes include
1)If mkdir fails for user passed socket paths log error and return.
2)At some places return value was set to errno and that non-negative number
was returned, but the intention was to return negative value.
So now rte_errno was set to errno and returning the actual negative value
that the APIs has returned.
Fixes: 278f945402
("pdump: add new library for packet capture")
Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
This commit is contained in:
parent
6596554669
commit
e4ffa2d3dc
@ -449,6 +449,7 @@ pdump_get_socket_path(char *buffer, int bufsz, enum rte_pdump_socktype type)
|
|||||||
char dpdk_dir[PATH_MAX] = {0};
|
char dpdk_dir[PATH_MAX] = {0};
|
||||||
char dir[PATH_MAX] = {0};
|
char dir[PATH_MAX] = {0};
|
||||||
char *dir_home = NULL;
|
char *dir_home = NULL;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
if (type == RTE_PDUMP_SOCKET_SERVER && server_socket_dir[0] != 0)
|
if (type == RTE_PDUMP_SOCKET_SERVER && server_socket_dir[0] != 0)
|
||||||
snprintf(dir, sizeof(dir), "%s", server_socket_dir);
|
snprintf(dir, sizeof(dir), "%s", server_socket_dir);
|
||||||
@ -475,7 +476,16 @@ pdump_get_socket_path(char *buffer, int bufsz, enum rte_pdump_socktype type)
|
|||||||
dpdk_dir, SOCKET_DIR);
|
dpdk_dir, SOCKET_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir(dir, 700);
|
ret = mkdir(dir, 700);
|
||||||
|
/* if user passed socket path is invalid, return immediately */
|
||||||
|
if (ret < 0 && errno != EEXIST) {
|
||||||
|
RTE_LOG(ERR, PDUMP,
|
||||||
|
"Failed to create dir:%s:%s\n", dir,
|
||||||
|
strerror(errno));
|
||||||
|
rte_errno = errno;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (type == RTE_PDUMP_SOCKET_SERVER)
|
if (type == RTE_PDUMP_SOCKET_SERVER)
|
||||||
snprintf(buffer, bufsz, SERVER_SOCKET, dir);
|
snprintf(buffer, bufsz, SERVER_SOCKET, dir);
|
||||||
else
|
else
|
||||||
@ -667,8 +677,8 @@ pdump_create_client_socket(struct pdump_request *p)
|
|||||||
"client socket(): %s:pid(%d):tid(%u), %s:%d\n",
|
"client socket(): %s:pid(%d):tid(%u), %s:%d\n",
|
||||||
strerror(errno), pid, rte_sys_gettid(),
|
strerror(errno), pid, rte_sys_gettid(),
|
||||||
__func__, __LINE__);
|
__func__, __LINE__);
|
||||||
ret = errno;
|
rte_errno = errno;
|
||||||
return ret;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pdump_get_socket_path(addr.sun_path, sizeof(addr.sun_path),
|
ret = pdump_get_socket_path(addr.sun_path, sizeof(addr.sun_path),
|
||||||
@ -677,6 +687,7 @@ pdump_create_client_socket(struct pdump_request *p)
|
|||||||
RTE_LOG(ERR, PDUMP,
|
RTE_LOG(ERR, PDUMP,
|
||||||
"Failed to get client socket path: %s:%d\n",
|
"Failed to get client socket path: %s:%d\n",
|
||||||
__func__, __LINE__);
|
__func__, __LINE__);
|
||||||
|
rte_errno = errno;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
addr.sun_family = AF_UNIX;
|
addr.sun_family = AF_UNIX;
|
||||||
@ -688,7 +699,7 @@ pdump_create_client_socket(struct pdump_request *p)
|
|||||||
RTE_LOG(ERR, PDUMP,
|
RTE_LOG(ERR, PDUMP,
|
||||||
"client bind(): %s, %s:%d\n",
|
"client bind(): %s, %s:%d\n",
|
||||||
strerror(errno), __func__, __LINE__);
|
strerror(errno), __func__, __LINE__);
|
||||||
ret = errno;
|
rte_errno = errno;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -701,6 +712,7 @@ pdump_create_client_socket(struct pdump_request *p)
|
|||||||
RTE_LOG(ERR, PDUMP,
|
RTE_LOG(ERR, PDUMP,
|
||||||
"Failed to get server socket path: %s:%d\n",
|
"Failed to get server socket path: %s:%d\n",
|
||||||
__func__, __LINE__);
|
__func__, __LINE__);
|
||||||
|
rte_errno = errno;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
serv_addr.sun_family = AF_UNIX;
|
serv_addr.sun_family = AF_UNIX;
|
||||||
@ -711,7 +723,8 @@ pdump_create_client_socket(struct pdump_request *p)
|
|||||||
RTE_LOG(ERR, PDUMP,
|
RTE_LOG(ERR, PDUMP,
|
||||||
"failed to send to server:%s, %s:%d\n",
|
"failed to send to server:%s, %s:%d\n",
|
||||||
strerror(errno), __func__, __LINE__);
|
strerror(errno), __func__, __LINE__);
|
||||||
ret = errno;
|
rte_errno = errno;
|
||||||
|
ret = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -722,7 +735,8 @@ pdump_create_client_socket(struct pdump_request *p)
|
|||||||
RTE_LOG(ERR, PDUMP,
|
RTE_LOG(ERR, PDUMP,
|
||||||
"failed to recv from server:%s, %s:%d\n",
|
"failed to recv from server:%s, %s:%d\n",
|
||||||
strerror(errno), __func__, __LINE__);
|
strerror(errno), __func__, __LINE__);
|
||||||
ret = errno;
|
rte_errno = errno;
|
||||||
|
ret = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ret = server_resp.err_value;
|
ret = server_resp.err_value;
|
||||||
|
Loading…
Reference in New Issue
Block a user