[CRIU] [PATCH] tcp: refresh a data about tcp connection after blocking it (v2)

Pavel Emelyanov xemul at parallels.com
Thu Nov 15 09:08:05 EST 2012


On 11/15/2012 04:14 PM, Andrey Vagin wrote:
> We have a window between getting info about tcp connections
> and blocking them. States of tcp connections can be changes,
> so they should be refreshed after blocking.
> 
> https://bugzilla.openvz.org/show_bug.cgi?id=2419
> 
> v2: clean up
> 
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  sk-tcp.c | 42 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 42 insertions(+)
> 
> diff --git a/sk-tcp.c b/sk-tcp.c
> index 9e01a08..99c8de2 100644
> --- a/sk-tcp.c
> +++ b/sk-tcp.c
> @@ -51,6 +51,43 @@ static int tcp_repair_on(int fd)
>  	return ret;
>  }
>  
> +static int refresh_inet_sk(int fd, struct inet_sk_desc *sk)
> +{
> +	int size;
> +	struct tcp_info info;
> +
> +	if (sk->state == TCP_CLOSE)
> +		return 0;
> +
> +	if (dump_opt(fd, SOL_TCP, TCP_INFO, &info)) {
> +		pr_perror("Failt to obtain TCP_INFO");
> +		return -1;
> +	}
> +
> +	sk->state = info.tcpi_state;
> +
> +	if (sk->state == TCP_LISTEN) {
> +		sk->rqlen = info.tcpi_unacked;
> +		sk->wqlen = info.tcpi_sacked;

What is this for?

> +	} else {
> +		if (ioctl(fd, SIOCOUTQ, &size) == -1) {
> +			pr_perror("Unable to get size of snd queue");
> +			return -1;
> +		}
> +
> +		sk->wqlen = size;
> +
> +		if (ioctl(fd, SIOCINQ, &size) == -1) {
> +			pr_perror("Unable to get size of recv queue");
> +			return -1;
> +		}
> +
> +		sk->rqlen = size;
> +	}
> +
> +	return 0;
> +}
> +
>  static int tcp_repair_establised(int fd, struct inet_sk_desc *sk)
>  {
>  	int ret;
> @@ -71,6 +108,11 @@ static int tcp_repair_establised(int fd, struct inet_sk_desc *sk)
>  		ret = nf_lock_connection(sk);
>  		if (ret < 0)
>  			goto err2;
> +
> +		/* A state of a tcp connection could be changed */
> +		ret = refresh_inet_sk(sk->rfd, sk);
> +		if (ret < 0)
> +			goto err2;
>  	}
>  
>  	ret = tcp_repair_on(sk->rfd);
> 




More information about the CRIU mailing list