[CRIU] Re: [PATCH 8/8] sockets: Restore in-flight unix stream sockets

Pavel Emelyanov xemul at parallels.com
Fri Jan 27 10:41:58 EST 2012


> @@ -66,13 +66,16 @@ struct pipe_entry {
>  	u8	data[0];
>  } __packed;
>  
> +#define UNIX_SK_STATUS_AUTO		0
> +#define UNIX_SK_STATUS_INFLIGHT		1
> +
>  struct unix_sk_entry {
>  	u32	fd;
>  	u32	id;
>  	u8	type;
>  	u8	state;
>  	u8	namelen; /* fits UNIX_PATH_MAX */
> -	u8	pad;
> +	u8	status;

u8 flags;

#define USK_INFLIGHT	0x1

etc...

>  	u32	backlog;
>  	u32	peer;
>  	u8	name[0];
> diff --git a/sockets.c b/sockets.c
> index 7689b37..2cd98b0 100644
> --- a/sockets.c
> +++ b/sockets.c
> @@ -55,6 +55,18 @@ struct unix_sk_desc {
>  	unsigned int		*icons;
>  };
>  
> +struct unix_sk_memo {
> +	union {
> +		struct {
> +			struct sockaddr_un	addr;
> +			unsigned int		addrlen;
> +		};
> +		void				*p;	/* arbitrary info */
> +	};
> +	unsigned int				ino;
> +	struct unix_sk_memo			*next;
> +};
> +
>  #define INET_ADDR_LEN		40
>  
>  struct inet_sk_desc {
> @@ -75,6 +87,7 @@ struct inet_sk_desc {
>  		(elem)->next = (head)[(key) % SK_HASH_SIZE];		\
>  		(head)[(key) % SK_HASH_SIZE] = (elem);			\
>  	} while (0)
> +
>  #define __gen_static_lookup_func(ret, name, head, _member, _type, _name)\
>  	static ret *name(_type _name) {					\
>  		ret *d;							\
> @@ -86,7 +99,10 @@ struct inet_sk_desc {
>  	}
>  
>  static struct socket_desc *sockets[SK_HASH_SIZE];
> -__gen_static_lookup_func(struct socket_desc, lookup_socket, sockets, ino, int, ino);
> +__gen_static_lookup_func(struct socket_desc, lookup_socket, sockets, ino, unsigned int, ino);

Why do you change int into unsigned int? "While I'm at it" changes should go in separate patches.

> +
> +static struct unix_sk_memo *unix_memos[SK_HASH_SIZE];
> +__gen_static_lookup_func(struct unix_sk_memo, lookup_unix_memo, unix_memos, ino, unsigned int, ino);

This hashtable should be called unix_listeners.
Why can't we put the existing socket desc here? Why yet another unix_sk_memo?

>  static int sk_collect_one(int ino, int family, struct socket_desc *d)
>  {


More information about the CRIU mailing list