[CRIU] [PATCH] tcp: allow to repair the FIN_WAIT2 state
Andrey Vagin
avagin at openvz.org
Tue Mar 25 05:58:19 PDT 2014
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;
}
--
1.8.5.3
More information about the CRIU
mailing list