21 #include <sys/types.h> 23 #include <sys/ioctl.h> 24 #include <sys/socket.h> 28 #include <sys/prctl.h> 29 #include <sys/eventfd.h> 37 #include <vpp/app/version.h> 51 for (i = 0; i < len; i++)
65 struct msghdr mh = { 0 };
67 char ctl[CMSG_SPACE (
sizeof (
int))];
70 iov[0].iov_base = (
void *) msg;
78 memset (&ctl, 0,
sizeof (ctl));
80 mh.msg_controllen =
sizeof (ctl);
81 cmsg = CMSG_FIRSTHDR (&mh);
82 cmsg->cmsg_len = CMSG_LEN (
sizeof (
int));
83 cmsg->cmsg_level = SOL_SOCKET;
84 cmsg->cmsg_type = SCM_RIGHTS;
85 memcpy (CMSG_DATA (cmsg), &afd,
sizeof (
int));
87 rv = sendmsg (fd, &mh, 0);
90 DBG (
"Message type %u sent (fd %d)", msg->
type, afd);
117 s =
format (0,
"VPP %s%c", VPP_BUILD_VER, 0);
118 strncpy ((
char *) h->
name, (
char *) s, sizeof (h->
name) - 1);
136 s =
format (0,
"VPP %s%c", VPP_BUILD_VER, 0);
137 strncpy ((
char *) i->
name, (
char *) s, sizeof (i->
name) - 1);
165 ASSERT ((mif->
flags & MEMIF_IF_FLAG_IS_SLAVE) != 0);
193 strncpy ((
char *) c->
if_name, (
char *) s, sizeof (c->
if_name) - 1);
208 strncpy ((
char *) c->
if_name, (
char *) s, sizeof (c->
if_name) - 1);
275 if (mif->
flags & MEMIF_IF_FLAG_IS_SLAVE)
427 char ctl[CMSG_SPACE (
sizeof (
int)) +
428 CMSG_SPACE (
sizeof (
struct ucred))] = { 0 };
429 struct msghdr mh = { 0 };
438 iov[0].iov_base = (
void *) &msg;
442 mh.msg_control = ctl;
443 mh.msg_controllen =
sizeof (ctl);
451 "recvmsg: malformed message received on fd %d",
462 struct ucred *cr = 0;
463 struct cmsghdr *cmsg;
465 cmsg = CMSG_FIRSTHDR (&mh);
468 if (cmsg->cmsg_level == SOL_SOCKET)
470 if (cmsg->cmsg_type == SCM_CREDENTIALS)
472 cr = (
struct ucred *) CMSG_DATA (cmsg);
474 else if (cmsg->cmsg_type == SCM_RIGHTS)
476 int *fdp = (
int *) CMSG_DATA (cmsg);
480 cmsg = CMSG_NXTHDR (&mh, cmsg);
483 DBG (
"Message type %u received", msg.type);
561 uword conn_clib_file_index = ~0;
580 ASSERT (conn_clib_file_index != ~0);
700 struct sockaddr_un client;
703 uword clib_file_index = ~0;
707 addr_len =
sizeof (client);
709 (
struct sockaddr *) &client, (socklen_t *) & addr_len);
717 template.file_descriptor = conn_fd;
memif_version_t max_version
memif_interface_mode_t mode
static clib_error_t * memif_msg_receive_connect(memif_if_t *mif, memif_msg_t *msg)
#define vec_foreach_index(var, v)
Iterate over vector indices.
#define hash_set(h, key, value)
sll srl srl sll sra u16x4 i
clib_error_t * memif_master_conn_fd_error(clib_file_t *uf)
clib_error_t * memif_conn_fd_accept_ready(clib_file_t *uf)
#define clib_fifo_sub2(f, p)
memif_msg_add_region_t add_region
clib_error_t * memif_slave_conn_fd_write_ready(clib_file_t *uf)
static uword clib_fifo_elts(void *v)
#define memif_file_del(a)
static clib_error_t * memif_msg_receive_connected(memif_if_t *mif, memif_msg_t *msg)
static clib_error_t * memif_msg_receive_add_ring(memif_if_t *mif, memif_msg_t *msg, int fd)
memif_socket_file_t * socket_files
memif_log2_ring_size_t log2_ring_size
memif_msg_add_ring_t add_ring
#define MEMIF_MSG_ADD_RING_FLAG_S2M
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
memif_region_index_t region
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
static uword clib_file_set_data_available_to_write(clib_file_main_t *um, u32 clib_file_index, uword is_available)
memif_version_t min_version
#define memif_file_del_by_index(a)
struct memif_if_t::@337 cfg
clib_error_t * memif_slave_conn_fd_read_ready(clib_file_t *uf)
static clib_error_t * memif_msg_enq_hello(int fd)
static clib_error_t * memif_msg_send(int fd, memif_msg_t *msg, int afd)
static clib_error_t * memif_msg_receive_hello(memif_if_t *mif, memif_msg_t *msg)
static clib_error_t * memif_conn_fd_write_ready(clib_file_t *uf, memif_if_t *mif)
memif_ring_index_t max_m2s_ring
clib_error_t * memif_init_regions_and_queues(memif_if_t *mif)
static clib_error_t * memif_msg_receive_init(memif_if_t **mifp, memif_msg_t *msg, clib_file_t *uf)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
clib_file_main_t file_main
memif_region_offset_t offset
static void memif_msg_enq_add_region(memif_if_t *mif, u8 region)
#define MEMIF_MAX_M2S_RING
memif_region_offset_t offset
#define memif_file_add(a, b)
#define MEMIF_MAX_LOG2_RING_SIZE
mhash_t dev_instance_by_id
static void memif_msg_enq_init(memif_if_t *mif)
clib_error_t * memif_slave_conn_fd_error(clib_file_t *uf)
static u8 * memif_str2vec(uint8_t *str, int len)
clib_error_t * memif_msg_send_disconnect(memif_if_t *mif, clib_error_t *err)
static void memif_msg_enq_connected(memif_if_t *mif)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
memif_msg_disconnect_t disconnect
#define clib_error_return_unix(e, args...)
static clib_error_t * memif_msg_receive_disconnect(memif_if_t *mif, memif_msg_t *msg)
#define vec_del1(v, i)
Delete the element at index I.
uword int_clib_file_index
static void memif_msg_enq_add_ring(memif_if_t *mif, u8 index, u8 direction)
memif_log2_ring_size_t max_log2_ring_size
memif_queue_t * tx_queues
clib_error_t * memif_connect(memif_if_t *mif)
static void memif_msg_enq_ack(memif_if_t *mif)
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
memif_region_index_t index
clib_error_t * memif_master_conn_fd_write_ready(clib_file_t *uf)
void memif_disconnect(memif_if_t *mif, clib_error_t *err)
memif_log2_ring_size_t log2_ring_size
memif_ring_index_t max_s2m_ring
static uword * mhash_get(mhash_t *h, const void *key)
memif_msg_connect_t connect
#define clib_error_report(e)
#define vec_cmp(v1, v2)
Compare two vectors (only applicable to vectors of signed numbers).
uword conn_clib_file_index
static clib_error_t * memif_msg_receive_add_region(memif_if_t *mif, memif_msg_t *msg, int fd)
static void memif_msg_enq_connect(memif_if_t *mif)
uword * dev_instance_by_fd
struct memif_if_t::@338 run
#define MEMIF_MAX_S2M_RING
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
memif_region_index_t max_region
static clib_error_t * memif_msg_receive(memif_if_t **mifp, clib_file_t *uf)
#define clib_error_free(e)
clib_error_t * memif_master_conn_fd_read_ready(clib_file_t *uf)
memif_log2_ring_size_t log2_ring_size
#define clib_fifo_add2(f, p)
memif_msg_connected_t connected
memif_queue_t * rx_queues
uword * pending_file_indices
#define CLIB_CACHE_LINE_BYTES
memif_msg_fifo_elt_t * msg_queue
memif_region_index_t region
memif_interface_mode_t mode
u8 * format_memif_device_name(u8 *s, va_list *args)
memif_region_size_t region_size