[CRIU] [PATCH 08/10] inet: raw -- Add restore of raw sockets

Andrey Vagin avagin at virtuozzo.com
Fri Mar 23 00:30:17 MSK 2018


On Thu, Mar 22, 2018 at 12:13:47PM +0300, Cyrill Gorcunov wrote:
> The support for raw sockets is still not covering
> all possible combinations and options but rather
> a first approach.

Could you elloborate what you mean when you say that something are not
covering? Will criu dump fail in such cases?

> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
> ---
>  criu/sk-inet.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/criu/sk-inet.c b/criu/sk-inet.c
> index 5ff79119c37e..d2c4413d0343 100644
> --- a/criu/sk-inet.c
> +++ b/criu/sk-inet.c
> @@ -105,10 +105,8 @@ static void show_one_inet_img(const char *act, const InetSkEntry *e)
>  static int can_dump_ipproto(int ino, int proto, int type)
>  {
>  	/* Raw sockets may have any protocol inside */
> -	if (type == SOCK_RAW) {
> -		pr_err("Unsupported raw socket %x\n", ino);
> -		return 0;
> -	}
> +	if (type == SOCK_RAW)
> +		return 1;
>  
>  	/* Make sure it's a proto we support */
>  	switch (proto) {
> @@ -669,13 +667,18 @@ static int post_open_inet_sk(struct file_desc *d, int sk)
>  	return 0;
>  }
>  
> -int restore_ip_opts(int sk, IpOptsEntry *ioe)
> +int restore_ip_opts(int sk, int family, IpOptsEntry *ioe)
>  {
>  	int ret = 0;
>  
>  	if (ioe->has_freebind)
>  		ret |= restore_opt(sk, SOL_IP, IP_FREEBIND, &ioe->freebind);
> -
> +	if (ioe->has_nodefrag)
> +		ret |= restore_opt(sk, SOL_IP, IP_NODEFRAG, &ioe->nodefrag);
> +	if (ioe->has_hdrincl)
> +		ret |= restore_opt(sk, family == AF_INET6 ? SOL_IPV6 : SOL_IP,
> +				   family == AF_INET6 ? IPV6_HDRINCL : IP_HDRINCL,
> +				   &ioe->hdrincl);
>  	return ret;
>  }
>  static int open_inet_sk(struct file_desc *d, int *new_fd)
> @@ -698,7 +701,7 @@ static int open_inet_sk(struct file_desc *d, int *new_fd)
>  		return -1;
>  	}
>  
> -	if ((ie->type != SOCK_STREAM) && (ie->type != SOCK_DGRAM)) {
> +	if ((ie->type != SOCK_STREAM) && (ie->type != SOCK_DGRAM) && (ie->type != SOCK_RAW)) {
>  		pr_err("Unsupported socket type: %d\n", ie->type);
>  		return -1;
>  	}
> @@ -778,7 +781,7 @@ static int open_inet_sk(struct file_desc *d, int *new_fd)
>  	if (rst_file_params(sk, ie->fown, ie->flags))
>  		goto err;
>  
> -	if (ie->ip_opts && restore_ip_opts(sk, ie->ip_opts))
> +	if (ie->ip_opts && restore_ip_opts(sk, ie->family, ie->ip_opts))
>  		goto err;
>  
>  	if (restore_socket_opts(sk, ie->opts))
> -- 
> 2.14.3
> 


More information about the CRIU mailing list