Commit e1082937 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

tcp: refresh a data about tcp connection after blocking it (v5)

We have a window between getting info about tcp connections
and blocking them.

#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: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 124e7009
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment