diff options
author | Florin Coras <fcoras@cisco.com> | 2018-08-03 02:50:43 -0700 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2018-08-04 16:00:32 +0000 |
commit | 466f289c27f290a2764a82f57f5c20d080227ead (patch) | |
tree | f37fd2763c95e3139d57423d06ae993453dc382c /src/vlibmemory/socket_api.c | |
parent | e7a9b3d2545c00689fe7547e7d807fe4a9b3365d (diff) |
socket api: multiple fds in one msg
Change-Id: I77a6e092a42290eed7201ad4a62e0d00ef997d2b
Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vlibmemory/socket_api.c')
-rw-r--r-- | src/vlibmemory/socket_api.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/vlibmemory/socket_api.c b/src/vlibmemory/socket_api.c index 7d271276be2..5587611d65a 100644 --- a/src/vlibmemory/socket_api.c +++ b/src/vlibmemory/socket_api.c @@ -449,12 +449,13 @@ vl_api_sockclnt_delete_t_handler (vl_api_sockclnt_delete_t * mp) } clib_error_t * -vl_sock_api_send_fd_msg (int socket_fd, int fd_to_share) +vl_sock_api_send_fd_msg (int socket_fd, int fds[], int n_fds) { struct msghdr mh = { 0 }; struct iovec iov[1]; - char ctl[CMSG_SPACE (sizeof (int))]; - char *msg = "memfd"; + char ctl[CMSG_SPACE (sizeof (int)) * n_fds]; + struct cmsghdr *cmsg; + char *msg = "fdmsg"; int rv; iov[0].iov_base = msg; @@ -462,15 +463,14 @@ vl_sock_api_send_fd_msg (int socket_fd, int fd_to_share) mh.msg_iov = iov; mh.msg_iovlen = 1; - struct cmsghdr *cmsg; memset (&ctl, 0, sizeof (ctl)); mh.msg_control = ctl; mh.msg_controllen = sizeof (ctl); cmsg = CMSG_FIRSTHDR (&mh); - cmsg->cmsg_len = CMSG_LEN (sizeof (int)); + cmsg->cmsg_len = CMSG_LEN (sizeof (int) * n_fds); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; - memcpy (CMSG_DATA (cmsg), &fd_to_share, sizeof (int)); + memcpy (CMSG_DATA (cmsg), fds, sizeof (int) * n_fds); rv = sendmsg (socket_fd, &mh, 0); if (rv < 0) @@ -629,7 +629,7 @@ reply: cf->write_function (cf); /* Send the magic "here's your sign (aka fd)" socket message */ - vl_sock_api_send_fd_msg (cf->file_descriptor, memfd->fd); + vl_sock_api_send_fd_msg (cf->file_descriptor, &memfd->fd, 1); } #define foreach_vlib_api_msg \ |