[CRIU] [PATCH] tcp: refresh a data about tcp connection after blocking it
Andrew Vagin
avagin at parallels.com
Thu Nov 15 07:15:12 EST 2012
Pls ignore this one.
On Thu, Nov 15, 2012 at 04:13:12PM +0400, Andrey Vagin wrote:
> We have a window between getting info about tcp connections
> and blocking them. States of tcp connections can be changes,
> so they should be refreshed after blocking.
>
> https://bugzilla.openvz.org/show_bug.cgi?id=2419
>
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
> sk-inet.c | 2 ++
> sk-tcp.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 44 insertions(+)
>
> diff --git a/sk-inet.c b/sk-inet.c
> index f425704..2b9abc8 100644
> --- a/sk-inet.c
> +++ b/sk-inet.c
> @@ -8,6 +8,8 @@
> #include <arpa/inet.h>
> #include <string.h>
> #include <stdlib.h>
> +#include <sys/ioctl.h>
> +#include <linux/sockios.h>
>
> #include "types.h"
> #include "libnetlink.h"
> diff --git a/sk-tcp.c b/sk-tcp.c
> index 9e01a08..99c8de2 100644
> --- a/sk-tcp.c
> +++ b/sk-tcp.c
> @@ -51,6 +51,43 @@ static int tcp_repair_on(int fd)
> return ret;
> }
>
> +static int refresh_inet_sk(int fd, struct inet_sk_desc *sk)
> +{
> + int size;
> + struct tcp_info info;
> +
> + if (sk->state == TCP_CLOSE)
> + return 0;
> +
> + if (dump_opt(fd, SOL_TCP, TCP_INFO, &info)) {
> + pr_perror("Failt to obtain TCP_INFO");
> + return -1;
> + }
> +
> + sk->state = info.tcpi_state;
> +
> + if (sk->state == TCP_LISTEN) {
> + sk->rqlen = info.tcpi_unacked;
> + sk->wqlen = info.tcpi_sacked;
> + } else {
> + if (ioctl(fd, SIOCOUTQ, &size) == -1) {
> + pr_perror("Unable to get size of snd queue");
> + return -1;
> + }
> +
> + sk->wqlen = size;
> +
> + if (ioctl(fd, 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;
> @@ -71,6 +108,11 @@ static int tcp_repair_establised(int fd, struct inet_sk_desc *sk)
> ret = nf_lock_connection(sk);
> if (ret < 0)
> goto err2;
> +
> + /* A state of a tcp connection could be changed */
> + ret = refresh_inet_sk(sk->rfd, sk);
> + if (ret < 0)
> + goto err2;
> }
>
> ret = tcp_repair_on(sk->rfd);
> --
> 1.7.11.7
>
More information about the CRIU
mailing list