aboutsummaryrefslogtreecommitdiffstats
path: root/src/nSocket/nstack
diff options
context:
space:
mode:
authoryalei wang <wylandrea@gmail.com>2018-07-18 07:59:13 +0000
committerGerrit Code Review <gerrit@fd.io>2018-07-18 07:59:13 +0000
commitbc4785071529bcfe5bac2aea852c283f4f47f8f8 (patch)
tree3f1c26ca9517113955af0bfcbfdda945509e1e09 /src/nSocket/nstack
parent52241f47567ae07efecaf14b76f3e16fa23d171c (diff)
parent000ee67eeeaa9868a98c9d2d743db90357ba3fa0 (diff)
Merge "Update dpdk version from 16.04 to 18.02"
Diffstat (limited to 'src/nSocket/nstack')
-rw-r--r--src/nSocket/nstack/nstack.c1
-rw-r--r--src/nSocket/nstack/nstack.h1
-rw-r--r--src/nSocket/nstack/nstack_socket.c58
-rw-r--r--src/nSocket/nstack/nstack_socket.h18
4 files changed, 70 insertions, 8 deletions
diff --git a/src/nSocket/nstack/nstack.c b/src/nSocket/nstack/nstack.c
index 749f06d..66281af 100644
--- a/src/nSocket/nstack/nstack.c
+++ b/src/nSocket/nstack/nstack.c
@@ -767,6 +767,7 @@ nstack_fw_init ()
if (NSTACK_MODULE_INIT == g_nStackInfo.fwInited)
{
+ g_nStackInfo.fwInited = NSTACK_MODULE_INITING;
nstack_log_init_app();
if (0 != nstack_stack_module_load())
diff --git a/src/nSocket/nstack/nstack.h b/src/nSocket/nstack/nstack.h
index 6d40a7b..1ec88f0 100644
--- a/src/nSocket/nstack/nstack.h
+++ b/src/nSocket/nstack/nstack.h
@@ -55,6 +55,7 @@ extern "C"{
typedef enum
{
NSTACK_MODULE_INIT,
+ NSTACK_MODULE_INITING,
NSTACK_MODULE_SUCCESS,
NSTACK_MODULE_FAIL
} nstack_module_state;
diff --git a/src/nSocket/nstack/nstack_socket.c b/src/nSocket/nstack/nstack_socket.c
index 5841676..5e96990 100644
--- a/src/nSocket/nstack/nstack_socket.c
+++ b/src/nSocket/nstack/nstack_socket.c
@@ -150,7 +150,7 @@ nstack_socket (int domain, int itype, int protocol)
int selectmod = -1;
/*check whether module init finish or not */
- NSTACK_INIT_CHECK_RET (socket);
+ NSTACK_INIT_CHECK_RET (socket, domain, itype, protocol);
NSSOC_LOGINF ("(domain=%d, type=%d, protocol=%d) [Caller]", domain, itype,
protocol);
@@ -287,6 +287,8 @@ nstack_bind (int fd, const struct sockaddr *addr, socklen_t addrlen)
struct sockaddr_in *iaddr = NULL;
nstack_rd_key rdkey = { 0 };
+ NSTACK_INIT_CHECK_RET (bind, fd, addr, addrlen);
+
NSSOC_LOGINF ("(sockfd=%d, addr=%p, addrlen=%u) [Caller]", fd, addr,
addrlen);
@@ -452,6 +454,8 @@ nstack_listen (int fd, int backlog)
int tfd;
int func_called = 0;
+ NSTACK_INIT_CHECK_RET (listen, fd, backlog);
+
NSSOC_LOGINF ("(sockfd=%d, backlog=%d) [Caller]", fd, backlog);
if (fd < 0)
{
@@ -519,6 +523,8 @@ nstack_accept (int fd, struct sockaddr *addr, socklen_t * addr_len)
nstack_fd_Inf *accInf;
int ret = -1;
+ NSTACK_INIT_CHECK_RET (accept, fd, addr, addr_len);
+
NSSOC_LOGINF ("(sockfd=%d, addr=%p, addrlen=%p) [Caller]", fd, addr,
addr_len);
if (fd < 0)
@@ -672,6 +678,8 @@ nstack_accept4 (int fd, struct sockaddr *addr,
int ret = -1;
nstack_fd_Inf *accInf;
+ NSTACK_INIT_CHECK_RET (accept4, fd, addr, addr_len, flags);
+
NSSOC_LOGINF ("(sockfd=%d, addr=%p, addrlen=%p, flags=%d) [Caller]", fd,
addr, addr_len, flags);
if (fd < 0)
@@ -822,6 +830,8 @@ nstack_connect (int fd, const struct sockaddr *addr, socklen_t addrlen)
int selectmod = -1;
nstack_rd_key rdkey = { 0 };
+ NSTACK_INIT_CHECK_RET (connect, fd, addr, addrlen);
+
NSSOC_LOGINF ("(sockfd=%d, addr=%p, addrlen=%u) [Caller]", fd, addr,
addrlen);
@@ -947,6 +957,8 @@ nstack_shutdown (int fd, int how)
return -1;
}
+ NSTACK_INIT_CHECK_RET (shutdown, fd, how);
+
NSSOC_LOGINF ("(fd=%d, how=%d) [Caller]", fd, how);
NSTACK_FD_LINUX_CHECK (fd, shutdown, fdInf, (fd, how));
@@ -1058,6 +1070,8 @@ nstack_close (int fd)
nstack_fd_Inf *fdInf;
int ret = -1;
+ NSTACK_INIT_CHECK_RET (close, fd);
+
/*linux fd check */
if (!(fdInf = nstack_getValidInf (fd)))
{
@@ -1119,6 +1133,8 @@ nstack_send (int fd, const void *buf, size_t len, int flags)
nstack_fd_Inf *fdInf = NULL;
int size = -1;
+ NSTACK_INIT_CHECK_RET (send, fd, buf, len, flags);
+
NS_LOG_CTRL (LOG_CTRL_SEND, NSOCKET, "NSSOC", NSLOG_DBG,
"(sockfd=%d, buf=%p, len=%zu, flags=%d) [Caller]", fd, buf,
len, flags);
@@ -1152,6 +1168,8 @@ nstack_recv (int fd, void *buf, size_t len, int flags)
nstack_fd_Inf *fdInf = NULL;
int size = -1;
+ NSTACK_INIT_CHECK_RET (recv, fd, buf, len, flags);
+
NS_LOG_CTRL (LOG_CTRL_RECV, NSOCKET, "NSSOC", NSLOG_DBG,
"(sockfd=%d, buf=%p, len=%zu, flags=%d) [Caller]", fd, buf,
len, flags);
@@ -1185,6 +1203,8 @@ nstack_write (int fd, const void *buf, size_t count)
nstack_fd_Inf *fdInf = NULL;
int size = -1;
+ NSTACK_INIT_CHECK_RET (write, fd, buf, count);
+
NSTACK_FD_LINUX_CHECK (fd, write, fdInf, (fd, buf, count));
NS_LOG_CTRL (LOG_CTRL_WRITE, NSOCKET, "NSSOC", NSLOG_DBG,
@@ -1217,6 +1237,8 @@ nstack_read (int fd, void *buf, size_t count)
nstack_fd_Inf *fdInf = NULL;
int size = -1;
+ NSTACK_INIT_CHECK_RET (read, fd, buf, count);
+
NS_LOG_CTRL (LOG_CTRL_READ, NSOCKET, "NSSOC", NSLOG_DBG,
"(fd=%d, buf=%p, count=%zu) [Caller]", fd, buf, count);
@@ -1248,6 +1270,8 @@ nstack_writev (int fd, const struct iovec * iov, int iovcnt)
nstack_fd_Inf *fdInf = NULL;
int size = -1;
+ NSTACK_INIT_CHECK_RET (writev, fd, iov, iovcnt);
+
NS_LOG_CTRL (LOG_CTRL_WRITEV, NSOCKET, "NSSOC", NSLOG_DBG,
"(fd=%d, iov=%p, count=%d) [Caller]", fd, iov, iovcnt);
@@ -1280,6 +1304,8 @@ nstack_readv (int fd, const struct iovec * iov, int iovcnt)
nstack_fd_Inf *fdInf = NULL;
int size = -1;
+ NSTACK_INIT_CHECK_RET (readv, fd, iov, iovcnt);
+
NS_LOG_CTRL (LOG_CTRL_READV, NSOCKET, "NSSOC", NSLOG_DBG,
"(fd=%d, iov=%p, count=%d) [Caller]", fd, iov, iovcnt);
@@ -1318,6 +1344,8 @@ nstack_sendto (int fd, const void *buf, size_t len, int flags,
int retval = 0;
nstack_rd_key rdkey = { 0 };
+ NSTACK_INIT_CHECK_RET (sendto, fd, buf, len, flags, dest_addr,addrlen);
+
NSSOC_LOGDBG
("(sockfd=%d, buf=%p, len=%zu, flags=%d, dest_addr=%p, addrlen=%u) [Caller]",
fd, buf, len, flags, dest_addr, addrlen);
@@ -1400,6 +1428,8 @@ nstack_sendmsg (int fd, const struct msghdr * msg, int flags)
int retval = 0;
nstack_rd_key rdkey = { 0 };
+ NSTACK_INIT_CHECK_RET (sendmsg, fd, msg, flags);
+
NS_LOG_CTRL (LOG_CTRL_SENDMSG, NSOCKET, "NSSOC", NSLOG_DBG,
"(sockfd=%d, msg=%p, flags=%d) [Caller]", fd, msg, flags);
@@ -1482,6 +1512,8 @@ nstack_recvfrom (int fd, void *buf, size_t len, int flags,
nstack_fd_Inf *fdInf = NULL;
int size = -1;
+ NSTACK_INIT_CHECK_RET (recvfrom, fd, buf, len, flags, src_addr, addrlen);
+
NSSOC_LOGDBG
("(sockfd=%d, buf=%p, len=%zu, flags=%d, src_addr=%p, addrlen=%p) [Caller]",
fd, buf, len, flags, src_addr, addrlen);
@@ -1524,6 +1556,8 @@ nstack_recvmsg (int fd, struct msghdr * msg, int flags)
nstack_fd_Inf *fdInf = NULL;
int size = -1;
+ NSTACK_INIT_CHECK_RET (recvmsg, fd, msg, flags);
+
NS_LOG_CTRL (LOG_CTRL_RECVMSG, NSOCKET, "NSSOC", NSLOG_DBG,
"(sockfd=%d, msg=%p, flags=%d) [Caller]", fd, msg, flags);
@@ -1564,6 +1598,8 @@ nstack_getsockname (int fd, struct sockaddr *addr, socklen_t * addrlen)
int tfd = -1;
int ret = -1;
+ NSTACK_INIT_CHECK_RET (getsockname, fd, addr, addrlen);
+
NS_LOG_CTRL (LOG_CTRL_GETSOCKNAME, NSOCKET, "NSSOC", NSLOG_INF,
"(fd=%d, addr=%p, addrlen=%p) [Caller]", fd, addr, addrlen);
@@ -1634,6 +1670,8 @@ nstack_getpeername (int fd, struct sockaddr *addr, socklen_t * addrlen)
int tfd;
int ret = -1;
+ NSTACK_INIT_CHECK_RET (getpeername, fd, addr, addrlen);
+
NS_LOG_CTRL (LOG_CTRL_GETPEERNAME, NSOCKET, "NSSOC", NSLOG_INF,
"(fd=%d, addr=%p, addrlen=%p) [Caller]", fd, addr, addrlen);
@@ -1766,6 +1804,8 @@ nstack_getsockopt (int fd, int level, int optname, void *optval,
int ret = -1;
nstack_socket_ops *ops;
+ NSTACK_INIT_CHECK_RET (getsockopt, fd, level, optname, optval, optlen);
+
NS_LOG_CTRL (LOG_CTRL_GETSOCKOPT, NSOCKET, "NSSOC", NSLOG_INF,
"(fd=%d, level=%d, optname=%d, optval=%p, optlen=%p) [Caller]",
fd, level, optname, optval, optlen);
@@ -1850,6 +1890,8 @@ nstack_setsockopt (int fd, int level, int optname, const void *optval,
int lerror = 0;
int flag = 0;
+ NSTACK_INIT_CHECK_RET (setsockopt, fd, level, optname, optval, optlen);
+
NSSOC_LOGINF
("(fd=%d, level=%d, optname=%d, optval=%p, optlen=%u) [Caller]", fd,
level, optname, optval, optlen);
@@ -1940,6 +1982,8 @@ nstack_ioctl (int fd, unsigned long request, unsigned long argp)
int lerror = 0;
int flag = 0;
+ NSTACK_INIT_CHECK_RET (ioctl, fd, request, argp);
+
NSSOC_LOGINF ("(fd=%d, request=%lu) [Caller]", fd, request);
if (fd < 0)
{
@@ -2019,6 +2063,8 @@ nstack_fcntl (int fd, int cmd, unsigned long argp)
int lerror = 0;
int flag = 0;
+ NSTACK_INIT_CHECK_RET (fcntl, fd, cmd, argp);
+
NSSOC_LOGINF ("(fd=%d, cmd=%d) [Caller]", fd, cmd);
if (fd < 0)
{
@@ -2142,6 +2188,8 @@ nstack_select (int nfds, fd_set * readfds, fd_set * writefds,
int i;
+ NSTACK_INIT_CHECK_RET (select, nfds, readfds, writefds, exceptfds, timeout);
+
if ((nfds > __FD_SETSIZE) || (nfds < 0)
|| ((timeout) && ((timeout->tv_sec < 0) || (timeout->tv_usec < 0))))
{
@@ -2319,6 +2367,8 @@ nstack_epoll_ctl (int epfd, int op, int fd, struct epoll_event *event)
struct epoll_event ep_event = { 0 };
struct epitem *epi = NULL;
+ NSTACK_INIT_CHECK_RET (epoll_ctl, epfd, op, fd, event);
+
NSSOC_LOGINF ("(epfd=%d, op=%d, fd=%d, event=%p) [Caller]", epfd, op, fd,
event);
if (event)
@@ -2450,7 +2500,7 @@ nstack_epoll_create (int size)
nstack_socket_ops *ops;
int ret = 0;
- NSTACK_INIT_CHECK_RET (epoll_create);
+ NSTACK_INIT_CHECK_RET (epoll_create, size);
NSSOC_LOGINF ("(size=%d) [Caller]", size);
@@ -2580,6 +2630,8 @@ nstack_epoll_wait (int epfd, struct epoll_event *events, int maxevents,
int evt = 0;
int ret = 0;
+ NSTACK_INIT_CHECK_RET (epoll_wait, epfd, events, maxevents, timeout);
+
NSTACK_FD_LINUX_CHECK (epfd, epoll_wait, fdInf,
(epfd, events, maxevents, timeout));
@@ -2706,6 +2758,8 @@ nstack_fork (void)
pid_t pid;
pid_t parent_pid = sys_get_hostpid_from_file (getpid ());
+ NSTACK_INIT_CHECK_RET (fork);
+
common_mem_rwlock_write_lock (get_fork_lock ());
if (NSTACK_MODULE_SUCCESS == g_nStackInfo.fwInited)
{
diff --git a/src/nSocket/nstack/nstack_socket.h b/src/nSocket/nstack/nstack_socket.h
index 3bc4a10..3bb7843 100644
--- a/src/nSocket/nstack/nstack_socket.h
+++ b/src/nSocket/nstack/nstack_socket.h
@@ -190,12 +190,18 @@ UNLOCK_CLOSE (nstack_fd_local_lock_info_t * local_lock)
#define UNLOCK_FOR_EP(local_lock) UNLOCK_CLOSE(local_lock)
-#define NSTACK_INIT_CHECK_RET(fun) \
- if (nstack_fw_init()) { \
- NSSOC_LOGERR("nstack %s call, but initial not finished yet [return]", #fun); \
- nstack_set_errno(ENOSYS); \
- return -1; \
- }
+#define NSTACK_INIT_CHECK_RET(fun, args...) \
+ do { \
+ if (NSTACK_MODULE_INITING == g_nStackInfo.fwInited) { \
+ NSSOC_LOGINF ("call kernel func %s", #fun); \
+ return nsfw_base_##fun(args); \
+ } \
+ if (nstack_fw_init()) { \
+ NSSOC_LOGERR("nstack %s call, but initial not finished yet [return]", #fun); \
+ nstack_set_errno(ENOSYS); \
+ return -1; \
+ } \
+ }while(0)
#define NSTACK_MODULE_ERROR_SET(Index)