[CRIU] [PATCH] tcp: allow to repair the FIN_WAIT2 state

Pavel Emelyanov xemul at parallels.com
Tue Mar 25 06:34:38 PDT 2014


On 03/25/2014 04:58 PM, Andrey Vagin wrote:
> A socket in the FIN_WAIT2 state doesn't have unacknowledged data in a
> queue. We don't need to send anything back and can restore it directly.
> 
> This state allows us to restore socket in the TIME_WAIT state. For that
> we need to set the FIN_WAIT2 state and send the fin packet in a received
> queue.
> 
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  include/uapi/linux/tcp.h |  1 +
>  net/ipv4/tcp.c           | 10 ++++++++++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h
> index b1d5973..d9f7970 100644
> --- a/include/uapi/linux/tcp.h
> +++ b/include/uapi/linux/tcp.h
> @@ -201,5 +201,6 @@ struct tcp_md5sig {
>  
>  /* Control message types to repair tcp connections */
>  #define TCP_REPAIR_SEND_FIN	1
> +#define TCP_REPAIR_FIN_WAIT2	2
>  
>  #endif /* _UAPI_LINUX_TCP_H */
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index d196598..5345980 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -1090,6 +1090,16 @@ static int tcp_repair_cmsg(struct sock *sk, struct msghdr *msg)
>  			else
>  				return -EINVAL;
>  			break;
> +
> +		case TCP_REPAIR_FIN_WAIT2:

Это какой-то странный "пакет". Мне так не нравится. Надо думать.

> +			if (tp->repair_queue != TCP_SEND_QUEUE ||
> +			    sk->sk_state != TCP_ESTABLISHED ||
> +			    tp->snd_una != tp->write_seq)
> +				return -EINVAL;
> +
> +			tcp_set_state(sk, TCP_FIN_WAIT2);
> +
> +			break;
>  		default:
>  			return -EINVAL;
>  		}
> 




More information about the CRIU mailing list