summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
17142b2)
Change-Id: Ib6b52917af717d3341429163fb9ecc903cf717fb
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
}
rv = vppcom_session_bind (vsock->sid, &ep);
}
rv = vppcom_session_bind (vsock->sid, &ep);
- /* TBD: remove libc_bind code snippet
- * once vppcom implements vppcom_session_getsockname */
- if (rv == 0)
- {
- rv = libc_bind (__fd, __addr, __len);
- if (rv != 0)
- {
- rv = -errno;
- }
- }
{
/* 1. for socket level options that are NOT socket attributes
* and that has corresponding vpp options get from vppcom */
{
/* 1. for socket level options that are NOT socket attributes
* and that has corresponding vpp options get from vppcom */
-#endif
-
- /* 2. unhandled options */
- return -ENOPROTOOPT;
session->vrf = vrf;
session->proto = proto;
session->state = STATE_START;
session->vrf = vrf;
session->proto = proto;
session->state = STATE_START;
- session->is_nonblocking = is_nonblocking;
+ session->is_nonblocking = is_nonblocking ? 1 : 0;
clib_spinlock_unlock (&vcm->sessions_lockp);
if (VPPCOM_DEBUG > 0)
clib_spinlock_unlock (&vcm->sessions_lockp);
if (VPPCOM_DEBUG > 0)
clib_spinlock_unlock (&vcm->sessions_lockp);
}
clib_spinlock_unlock (&vcm->sessions_lockp);
}
- if (session->is_cut_thru)
+ if (session->is_cut_thru && session->is_server &&
+ (session->state == STATE_ACCEPT))
- if (session->is_server)
- {
- rv = vppcom_session_unbind_cut_thru (session);
- if ((VPPCOM_DEBUG > 0) && (rv < 0))
- clib_warning ("[%d] unbind cut-thru (session %d) failed, "
- "rv = %s (%d)",
- vcm->my_pid, session_index,
- vppcom_retval_str (rv), rv);
- }
+ rv = vppcom_session_unbind_cut_thru (session);
+ if ((VPPCOM_DEBUG > 0) && (rv < 0))
+ clib_warning ("[%d] unbind cut-thru (session %d) failed, "
+ "rv = %s (%d)",
+ vcm->my_pid, session_index,
+ vppcom_retval_str (rv), rv);
- else if (session->is_server)
+ else if (session->is_server && session->is_listen)
{
rv = vppcom_session_unbind (session_index);
if ((VPPCOM_DEBUG > 0) && (rv < 0))
{
rv = vppcom_session_unbind (session_index);
if ((VPPCOM_DEBUG > 0) && (rv < 0))
vcm->my_pid, session_index,
vppcom_retval_str (rv), rv);
}
vcm->my_pid, session_index,
vppcom_retval_str (rv), rv);
}
+ else if (session->state == STATE_CONNECT)
{
rv = vppcom_session_disconnect (session_index);
if ((VPPCOM_DEBUG > 0) && (rv < 0))
{
rv = vppcom_session_disconnect (session_index);
if ((VPPCOM_DEBUG > 0) && (rv < 0))
+ if (session->is_vep)
+ {
+ clib_spinlock_unlock (&vcm->sessions_lockp);
+ if (VPPCOM_DEBUG > 0)
+ clib_warning ("[%d] invalid session, sid (%u) is an epoll session!",
+ vcm->my_pid, session_index);
+ return VPPCOM_EBADFD;
+ }
+
if (VPPCOM_DEBUG > 0)
clib_warning ("[%d] sid %d", vcm->my_pid, session_index);
if (VPPCOM_DEBUG > 0)
clib_warning ("[%d] sid %d", vcm->my_pid, session_index);
+ if (listen_session->is_vep)
+ {
+ clib_spinlock_unlock (&vcm->sessions_lockp);
+ if (VPPCOM_DEBUG > 0)
+ clib_warning ("[%d] invalid session, sid (%u) is an epoll session!",
+ vcm->my_pid, listen_session_index);
+ return VPPCOM_EBADFD;
+ }
+
if (VPPCOM_DEBUG > 0)
clib_warning ("[%d] sid %d", vcm->my_pid, listen_session_index);
if (VPPCOM_DEBUG > 0)
clib_warning ("[%d] sid %d", vcm->my_pid, listen_session_index);
+ if (listen_session->is_vep)
+ {
+ clib_spinlock_unlock (&vcm->sessions_lockp);
+ if (VPPCOM_DEBUG > 0)
+ clib_warning ("[%d] invalid session, sid (%u) is an epoll session!",
+ vcm->my_pid, listen_session_index);
+ return VPPCOM_EBADFD;
+ }
+
if (listen_session->state != STATE_LISTEN)
{
clib_spinlock_unlock (&vcm->sessions_lockp);
if (listen_session->state != STATE_LISTEN)
{
clib_spinlock_unlock (&vcm->sessions_lockp);
+ if (session->is_vep)
+ {
+ clib_spinlock_unlock (&vcm->sessions_lockp);
+ if (VPPCOM_DEBUG > 0)
+ clib_warning ("[%d] invalid session, sid (%u) is an epoll session!",
+ vcm->my_pid, session_index);
+ return VPPCOM_EBADFD;
+ }
+
if (session->state == STATE_CONNECT)
{
clib_spinlock_unlock (&vcm->sessions_lockp);
if (session->state == STATE_CONNECT)
{
clib_spinlock_unlock (&vcm->sessions_lockp);
int n_read = 0;
int rv;
char *fifo_str;
int n_read = 0;
int rv;
char *fifo_str;
+ if (session->is_vep)
+ {
+ clib_spinlock_unlock (&vcm->sessions_lockp);
+ if (VPPCOM_DEBUG > 0)
+ clib_warning ("[%d] invalid session, sid (%u) is an epoll session!",
+ vcm->my_pid, session_index);
+ return VPPCOM_EBADFD;
+ }
+
if (session->state == STATE_DISCONNECT)
{
clib_spinlock_unlock (&vcm->sessions_lockp);
if (session->state == STATE_DISCONNECT)
{
clib_spinlock_unlock (&vcm->sessions_lockp);
session->server_rx_fifo : session->server_tx_fifo);
fifo_str = ((!session->is_cut_thru || session->is_server) ?
"server_rx_fifo" : "server_tx_fifo");
session->server_rx_fifo : session->server_tx_fifo);
fifo_str = ((!session->is_cut_thru || session->is_server) ?
"server_rx_fifo" : "server_tx_fifo");
+ poll_et = EPOLLET & session->vep.ev.events;
+ clib_spinlock_unlock (&vcm->sessions_lockp);
}
while (!session->is_nonblocking && (n_read <= 0));
}
while (!session->is_nonblocking && (n_read <= 0));
- if (n_read <= 0)
- session->vep.et_mask |= EPOLLIN;
-
- clib_spinlock_unlock (&vcm->sessions_lockp);
+ if (poll_et && (n_read <= 0))
+ {
+ clib_spinlock_lock (&vcm->sessions_lockp);
+ session->vep.et_mask |= EPOLLIN;
+ clib_spinlock_unlock (&vcm->sessions_lockp);
+ }
if ((VPPCOM_DEBUG > 2) && (n_read > 0))
clib_warning ("[%d] sid %d, read %d bytes from %s (%p)", vcm->my_pid,
if ((VPPCOM_DEBUG > 2) && (n_read > 0))
clib_warning ("[%d] sid %d, read %d bytes from %s (%p)", vcm->my_pid,
int ready = 0;
/* Assumes caller has acquired spinlock: vcm->sessions_lockp */
int ready = 0;
/* Assumes caller has acquired spinlock: vcm->sessions_lockp */
+ if (session->is_vep)
+ {
+ clib_spinlock_unlock (&vcm->sessions_lockp);
+ if (VPPCOM_DEBUG > 0)
+ clib_warning ("[%d] invalid session, sid (%u) is an epoll session!",
+ vcm->my_pid, session_index);
+ return VPPCOM_EBADFD;
+ }
+
if (session->state == STATE_DISCONNECT)
{
if (VPPCOM_DEBUG > 0)
if (session->state == STATE_DISCONNECT)
{
if (VPPCOM_DEBUG > 0)
session_index,
session->is_server ? "server_rx_fifo" : "server_tx_fifo",
rx_fifo, ready);
session_index,
session->is_server ? "server_rx_fifo" : "server_tx_fifo",
rx_fifo, ready);
+ if ((session->vep.ev.events & EPOLLET) && (ready == 0))
session->vep.et_mask |= EPOLLIN;
return ready;
session->vep.et_mask |= EPOLLIN;
return ready;
session_fifo_event_t evt;
int rv, n_write;
char *fifo_str;
session_fifo_event_t evt;
int rv, n_write;
char *fifo_str;
+ if (session->is_vep)
+ {
+ clib_spinlock_unlock (&vcm->sessions_lockp);
+ if (VPPCOM_DEBUG > 0)
+ clib_warning ("[%d] invalid session, sid (%u) is an epoll session!",
+ vcm->my_pid, session_index);
+ return VPPCOM_EBADFD;
+ }
+
if (session->state == STATE_DISCONNECT)
{
clib_spinlock_unlock (&vcm->sessions_lockp);
if (session->state == STATE_DISCONNECT)
{
clib_spinlock_unlock (&vcm->sessions_lockp);
session->server_tx_fifo : session->server_rx_fifo);
fifo_str = ((!session->is_cut_thru || session->is_server) ?
"server_tx_fifo" : "server_rx_fifo");
session->server_tx_fifo : session->server_rx_fifo);
fifo_str = ((!session->is_cut_thru || session->is_server) ?
"server_tx_fifo" : "server_rx_fifo");
+ q = session->vpp_event_queue;
+ poll_et = EPOLLET & session->vep.ev.events;
+ clib_spinlock_unlock (&vcm->sessions_lockp);
+
do
{
n_write = svm_fifo_enqueue_nowait (tx_fifo, n, buf);
do
{
n_write = svm_fifo_enqueue_nowait (tx_fifo, n, buf);
rval = vppcom_session_at_index (session_index, &session);
if (PREDICT_FALSE (rval))
{
rval = vppcom_session_at_index (session_index, &session);
if (PREDICT_FALSE (rval))
{
- clib_spinlock_unlock (&vcm->sessions_lockp);
if (VPPCOM_DEBUG > 1)
clib_warning ("[%d] invalid session, sid (%u) has been closed!",
vcm->my_pid, session_index);
return rval;
}
if (VPPCOM_DEBUG > 1)
clib_warning ("[%d] invalid session, sid (%u) has been closed!",
vcm->my_pid, session_index);
return rval;
}
- q = session->vpp_event_queue;
ASSERT (q);
unix_shared_memory_queue_add (q, (u8 *) & evt,
0 /* do wait for mutex */ );
}
ASSERT (q);
unix_shared_memory_queue_add (q, (u8 *) & evt,
0 /* do wait for mutex */ );
}
- if (n_write <= 0)
- session->vep.et_mask |= EPOLLOUT;
-
- clib_spinlock_unlock (&vcm->sessions_lockp);
+ if (poll_et && (n_write <= 0))
+ {
+ clib_spinlock_lock (&vcm->sessions_lockp);
+ session->vep.et_mask |= EPOLLOUT;
+ clib_spinlock_unlock (&vcm->sessions_lockp);
+ }
- clib_warning ("[%d] sid %d, wrote %d bytes to %s (%p)", vcm->my_pid,
- session_index, n_write, fifo_str, tx_fifo);
- return n_write;
+ {
+ if (n_write == -2)
+ clib_warning ("[%d] sid %d, FIFO-FULL %s (%p)", vcm->my_pid,
+ session_index, fifo_str, tx_fifo);
+ else
+ clib_warning ("[%d] sid %d, wrote %d bytes to %s (%p)", vcm->my_pid,
+ session_index, n_write, fifo_str, tx_fifo);
+ }
+ return (n_write < 0) ? VPPCOM_EAGAIN : n_write;
int ready;
/* Assumes caller has acquired spinlock: vcm->sessions_lockp */
int ready;
/* Assumes caller has acquired spinlock: vcm->sessions_lockp */
+ if (session->is_vep)
+ {
+ clib_spinlock_unlock (&vcm->sessions_lockp);
+ if (VPPCOM_DEBUG > 0)
+ clib_warning ("[%d] invalid session, sid (%u) is an epoll session!",
+ vcm->my_pid, session_index);
+ return VPPCOM_EBADFD;
+ }
+
if (session->state == STATE_DISCONNECT)
{
if (VPPCOM_DEBUG > 0)
if (session->state == STATE_DISCONNECT)
{
if (VPPCOM_DEBUG > 0)
if (VPPCOM_DEBUG > 3)
clib_warning ("[%d] sid %d, peek %s (%p), ready = %d", vcm->my_pid,
session_index, fifo_str, tx_fifo, ready);
if (VPPCOM_DEBUG > 3)
clib_warning ("[%d] sid %d, peek %s (%p), ready = %d", vcm->my_pid,
session_index, fifo_str, tx_fifo, ready);
+ if ((session->vep.ev.events & EPOLLET) && (ready == 0))
session->vep.et_mask |= EPOLLOUT;
return ready;
session->vep.et_mask |= EPOLLOUT;
return ready;
-static inline int
-is_vcom_fd (int fd)
-{
-#define VPPCOM_FD_OFFSET (1 << 30)
- return (fd >= VPPCOM_FD_OFFSET);
-}
-
/* TBD: make these constructor/destructor function */
extern int vppcom_app_create (char *app_name);
extern void vppcom_app_destroy (void);
/* TBD: make these constructor/destructor function */
extern int vppcom_app_create (char *app_name);
extern void vppcom_app_destroy (void);