[CRIU] Re: [PATCH 3/6] util-net: Add declaration of scm_fdset
structure
Pavel Emelyanov
xemul at parallels.com
Wed Mar 21 06:40:10 EDT 2012
On 03/21/2012 11:47 AM, Cyrill Gorcunov wrote:
> This structure will serve for multiple fds
> transmission/receive.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
> include/util-net.h | 21 +++++++++++++++++++++
> 1 files changed, 21 insertions(+), 0 deletions(-)
>
> diff --git a/include/util-net.h b/include/util-net.h
> index c5a8c46..030f518 100644
> --- a/include/util-net.h
> +++ b/include/util-net.h
> @@ -1,6 +1,9 @@
> #ifndef UTIL_NET_H_
> #define UTIL_NET_H_
>
> +#include <sys/socket.h>
> +#include <sys/un.h>
> +
> #define UNIX_PATH_MAX (sizeof(struct sockaddr_un) - \
> (size_t)((struct sockaddr_un *) 0)->sun_path)
>
> @@ -8,6 +11,24 @@
> #define SO_PEEK_OFF 42
> #endif
>
> +/*
> + * Because kernel do kmalloc for user data passed
> + * in SCM messages, and there is SCM_MAX_FD as a limit
> + * for descriptors passed at once -- we're trying to
> + * eliminate pressue on kernel memory manager and use
> + * predefined known to work well size of the message buffer.
> + */
> +#define CR_SCM_MSG_SIZE (1024)
> +#define CR_SCM_MAX_FD (252)
What for 2 constants? Declare one and make the buffer be int[MAX_FD] one.
> +
> +struct scm_fdset {
> + struct msghdr hdr;
> + struct iovec iov;
> + char msg_buf[CR_SCM_MSG_SIZE];
> + int __pad;
> + int nr_fds;
> +};
> +
> extern int send_fd(int sock, struct sockaddr_un *saddr, int len, int fd);
> extern int recv_fd(int sock);
> #endif
More information about the CRIU
mailing list