[CRIU] [PATCH] tcp: refresh a data about tcp connection after blocking it (v5)
Andrey Vagin
avagin at openvz.org
Fri Nov 16 09:11:38 EST 2012
We have a window between getting info about tcp connections
and blocking them.
https://bugzilla.openvz.org/show_bug.cgi?id=2419
v2: clean upV
v3: don't update lengthes of queues for listen sockets,
they don't used.
v4: check that a state of a tcp connection is ESTABLISHED or CLOSE
v5: * don't check state, because it can be changed only on TCP_CLOSE.
In this case it will be changed again after restoring.
* refresh a socket after enabling the repair mode
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
sk-tcp.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/sk-tcp.c b/sk-tcp.c
index 9e01a08..17f5ab2 100644
--- a/sk-tcp.c
+++ b/sk-tcp.c
@@ -51,6 +51,27 @@ static int tcp_repair_on(int fd)
return ret;
}
+static int refresh_inet_sk(struct inet_sk_desc *sk)
+{
+ int size;
+
+ if (ioctl(sk->rfd, SIOCOUTQ, &size) == -1) {
+ pr_perror("Unable to get size of snd queue");
+ return -1;
+ }
+
+ sk->wqlen = size;
+
+ if (ioctl(sk->rfd, 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;
@@ -78,6 +99,11 @@ static int tcp_repair_establised(int fd, struct inet_sk_desc *sk)
goto err3;
list_add_tail(&sk->rlist, &cpt_tcp_repair_sockets);
+
+ ret = refresh_inet_sk(sk);
+ if (ret < 0)
+ goto err1;
+
return 0;
err3:
--
1.7.11.7
More information about the CRIU
mailing list