|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
23 #include <sys/socket.h>
40 #define vl_print(handle, ...) clib_warning (__VA_ARGS__)
49 u32 vl (
void *p) __attribute__ ((weak));
75 int n, current_rx_index;
117 msg_size =
data_len +
sizeof (*mbp);
181 .gc_mark_timestamp = 0,
185 n = write (scm->
socket_fd, &msgbuf, sizeof (msgbuf));
186 if (n <
sizeof (msgbuf))
193 if (n < scm->socket_tx_nbytes)
269 char ctl[CMSG_SPACE (
sizeof (
int) * n_fds)
270 + CMSG_SPACE (
sizeof (
struct ucred))];
271 struct msghdr mh = { 0 };
274 struct ucred *cr = 0;
275 struct cmsghdr *cmsg;
276 pid_t
pid __attribute__ ((unused));
277 uid_t uid __attribute__ ((unused));
278 gid_t gid __attribute__ ((unused));
284 iov[0].iov_base = msgbuf;
288 mh.msg_control = ctl;
289 mh.msg_controllen =
sizeof (ctl);
297 size = recvmsg (socket_fd, &mh, MSG_DONTWAIT);
300 size = recvmsg (socket_fd, &mh, 0);
309 cmsg = CMSG_FIRSTHDR (&mh);
312 if (cmsg->cmsg_level == SOL_SOCKET)
314 if (cmsg->cmsg_type == SCM_CREDENTIALS)
316 cr = (
struct ucred *) CMSG_DATA (cmsg);
321 else if (cmsg->cmsg_type == SCM_RIGHTS)
326 cmsg = CMSG_NXTHDR (&mh, cmsg);
340 int fds[],
int n_fds,
u32 wait)
385 clib_warning (
"WARNING: segment map returned %d", retval);
391 am->shmem_hdr = (
void *)
am->vlib_rp->user_ctx;
393 new_name =
format (0,
"%v[shm]%c", scm->
name, 0);
403 (
char *) new_name, 32
422 #define foreach_sock_client_api_msg \
423 _(SOCKCLNT_CREATE_REPLY, sockclnt_create_reply) \
424 _(SOCK_INIT_SHM_REPLY, sock_init_shm_reply) \
436 vl_msg_api_set_handlers(VL_API_##N, #n, \
437 vl_api_##n##_t_handler, \
439 vl_api_##n##_t_endian, \
440 vl_api_##n##_t_print, \
441 sizeof(vl_api_##n##_t), 1);
448 char *socket_path,
char *client_name,
449 u32 socket_buffer_size)
460 if (socket_path == 0 || client_name == 0)
464 sock->config = socket_path;
485 mp->_vl_msg_id = htons (VL_API_SOCKCLNT_CREATE);
486 strncpy ((
char *) mp->
name, client_name, sizeof (mp->
name) - 1);
487 mp->
name[
sizeof (mp->
name) - 1] = 0;
503 u32 socket_buffer_size)
506 client_name, socket_buffer_size);
511 char *client_name,
u32 socket_buffer_size)
518 client_name, socket_buffer_size);
537 mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_SOCK_INIT_SHM);
545 cfg = (
u64 *) & config[
i];
svm_queue_t * q
message allocated in this shmem ring
clib_error_t * vl_sock_api_recv_fd_msg(int socket_fd, int fds[], int n_fds, u32 wait)
ssvm_private_t memfd_segment
clib_error_t * vl_socket_client_recv_fd_msg(int fds[], int n_fds, u32 wait)
int socket_enable
Can temporarily disable the connection but still can keep it around...
void vl_socket_client_enable_disable(int enable)
#define CLIB_SOCKET_F_IS_CLIENT
__thread socket_client_main_t * socket_client_ctx
void vl_msg_api_socket_handler(void *the_msg)
int vl_client_connect_to_vlib_no_map(const char *svm_name, const char *client_name, int rx_queue_size)
int vl_socket_client_read(int wait)
#define clib_error_return(e, args...)
#define SOCKET_CLIENT_DEFAULT_BUFFER_SIZE
void ssvm_delete_memfd(ssvm_private_t *memfd)
#define vec_delete(V, N, M)
Delete N elements starting at element M.
u32 data_len
message length not including header
#define clib_error_report(e)
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
int vl_socket_client_connect(char *socket_path, char *client_name, u32 socket_buffer_size)
static void vl_socket_client_ctx_pop(socket_client_main_t *old_ctx)
#define clib_unix_warning(format, args...)
static int vl_socket_client_read_internal(socket_client_main_t *scm, int wait)
__clib_export void clib_time_init(clib_time_t *c)
int vl_socket_client_connect_internal(socket_client_main_t *scm, char *socket_path, char *client_name, u32 socket_buffer_size)
void * vl_socket_client_msg_alloc(int nbytes)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_socket_t client_socket
static void noop_handler(void *notused)
#define foreach_sock_client_api_msg
int control_pings_outstanding
clib_error_t * vl_socket_client_recv_fd_msg2(socket_client_main_t *scm, int fds[], int n_fds, u32 wait)
int vl_socket_client_init_shm_internal(socket_client_main_t *scm, vl_api_shm_elem_config_t *config, int want_pthread)
u8 data[0]
actual message begins here
static api_main_t * vlibapi_get_main(void)
void vl_sock_client_install_message_handlers(void)
void vl_socket_client_disconnect(void)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
static socket_client_main_t * vl_socket_client_ctx_push(socket_client_main_t *ctx)
static f64 clib_time_now(clib_time_t *c)
clib_error_t * vl_sock_api_recv_fd_msg2(socket_client_main_t *scm, int socket_fd, int fds[], int n_fds, u32 wait)
static void vl_api_sockclnt_create_reply_t_handler(vl_api_sockclnt_create_reply_t *mp)
static int vl_socket_client_write_internal(socket_client_main_t *scm)
API main structure, used by both vpp and binary API clients.
void vl_client_disconnect_from_vlib_no_unmap(void)
#define vec_free(V)
Free vector's memory (no header).
void vl_client_install_client_message_handlers(void)
int vl_socket_client_write2(socket_client_main_t *scm)
description fragment has unexpected format
__clib_export clib_error_t * clib_socket_init(clib_socket_t *s)
u8 vl_mem_client_is_connected(void)
#define clib_error_return_unix(e, args...)
int vl_socket_client_connect2(socket_client_main_t *scm, char *socket_path, char *client_name, u32 socket_buffer_size)
Message header structure.
void vl_socket_client_enable_disable2(socket_client_main_t *scm, int enable)
void vl_socket_client_disconnect2(socket_client_main_t *scm)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
int vl_socket_client_init_shm2(socket_client_main_t *scm, vl_api_shm_elem_config_t *config, int want_pthread)
static void vl_api_sock_init_shm_reply_t_handler(vl_api_sock_init_shm_reply_t *mp)
int ssvm_client_init_memfd(ssvm_private_t *memfd)
Initialize memfd segment client.
#define clib_warning(format, args...)
socket_client_main_t socket_client_main
int vl_socket_client_write(void)
u32 client_index
Client index allocated by VPP.
int vl_client_connect_to_vlib_no_rx_pthread_no_map(const char *svm_name, const char *client_name, int rx_queue_size)
struct _socket_t clib_socket_t
static clib_error_t * vl_sock_api_recv_fd_msg_internal(socket_client_main_t *scm, int fds[], int n_fds, u32 wait)
void * vl_socket_client_msg_alloc2(socket_client_main_t *scm, int nbytes)
int vl_socket_client_init_shm(vl_api_shm_elem_config_t *config, int want_pthread)
int vl_socket_client_read2(socket_client_main_t *scm, int wait)