[CRIU] [PATCH 1/3] tcp: allow to enable repair mode for sockets in any state

Pavel Emelyanov xemul at parallels.com
Wed Mar 5 05:06:07 PST 2014


On 03/05/2014 09:18 AM, Andrey Vagin wrote:
> The repair mode is used for dumping state of tcp connections
> (sequence numbers, queues, options, etc).
> 
> Currently the repair mode can be enalbed only for sockets in the
> TCP_ESTABLISHED state. If a socket in another state, its internal
> state can not be dumped.
> 
> I see nothing wrong to allow enabling of the repair mode for any state.

This lacks checks in e.g. sys_connect() -- if we're calling it and the
socket is in repair, we should check that it's state is TCP_CLOSE.
Similar should be put in other places to avoid forbidden transitions,
e.g. FIN_WAIT1 -> CLOSE_WAIT or LAST_ACK -> ESTABLISHED.

> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  net/ipv4/tcp.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 9f3a2db..819fa37 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -2372,8 +2372,7 @@ void tcp_sock_destruct(struct sock *sk)
>  
>  static inline bool tcp_can_repair_sock(const struct sock *sk)
>  {
> -	return ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN) &&
> -		((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_ESTABLISHED));
> +	return ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN);
>  }
>  
>  static int tcp_repair_options_est(struct tcp_sock *tp,
> 




More information about the CRIU mailing list