soccr: move connect from criu to soccr

We will need to disable the repair mode before connect()
to restore syn-sent sockets. And even now connect() looks
like a part of internal logic of libsoccr.

travis-ci: success for series starting with [01/21] build: install libnet-dev
v2: remove libsoccr_set_sk_data_unbound() from soccr.h
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
Andrei Vagin 2016-12-01 11:32:26 +03:00 committed by Pavel Emelyanov
parent cdc6f4c107
commit fd2995cc5b
4 changed files with 24 additions and 39 deletions

View file

@ -323,9 +323,17 @@ static int set_queue_seq(struct libsoccr_sk *sk, int queue, __u32 seq)
return 0;
}
int libsoccr_set_sk_data_unbound(struct libsoccr_sk *sk,
#ifndef TCPOPT_SACK_PERM
#define TCPOPT_SACK_PERM TCPOPT_SACK_PERMITTED
#endif
int libsoccr_set_sk_data_noq(struct libsoccr_sk *sk,
struct libsoccr_sk_data *data, unsigned data_size)
{
struct tcp_repair_opt opts[4];
int addr_size;
int onr = 0;
if (!data || data_size < SOCR_DATA_MIN_SIZE)
return -1;
@ -339,21 +347,15 @@ int libsoccr_set_sk_data_unbound(struct libsoccr_sk *sk,
data->outq_seq - data->outq_len))
return -3;
return 0;
}
if (data->dst_addr.sa.sa_family == AF_INET)
addr_size = sizeof(data->dst_addr.v4);
else
addr_size = sizeof(data->dst_addr.v6);
#ifndef TCPOPT_SACK_PERM
#define TCPOPT_SACK_PERM TCPOPT_SACK_PERMITTED
#endif
int libsoccr_set_sk_data_noq(struct libsoccr_sk *sk,
struct libsoccr_sk_data *data, unsigned data_size)
{
struct tcp_repair_opt opts[4];
int onr = 0;
if (!data || data_size < SOCR_DATA_MIN_SIZE)
if (connect(sk->fd, &data->dst_addr.sa, addr_size) == -1) {
loge("Can't connect inet socket back\n");
return -1;
}
logd("\tRestoring TCP options\n");

View file

@ -178,12 +178,12 @@ char *libsoccr_get_queue_bytes(struct libsoccr_sk *sk, int queue_id, int steal);
* sk = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
*
* h = libsoccr_pause(sk)
* libsoccr_set_sk_data_unbound(h, &data, sizeof(data))
* bind(sk, &name, ...)
* connect(sk, &name, ...)
* libsoccr_set_sk_data(h, &data, sizeof(data))
*
* libsoccr_set_sk_data_noq(h, &data, sizeof(data))
* libsoccr_set_queue_bytes(h, &data, sizeof(data), TCP_RECV_QUEUE, inq)
* libsoccr_set_queue_bytes(h, &data, sizeof(data), TCP_SEND_QUEUE, outq)
* libsoccr_set_sk_data(h, &data, sizeof(data))
*
* libsoccr_resume(h)
*
@ -191,13 +191,6 @@ char *libsoccr_get_queue_bytes(struct libsoccr_sk *sk, int queue_id, int steal);
* enabled back.
*/
/*
* Performs restore action while the socket is not bind()-ed and
* not connect()-ed. The data should be the one from _get_sk_data
* call. The data_size is the amount of bytes sitting in there.
*/
int libsoccr_set_sk_data_unbound(struct libsoccr_sk *sk, struct libsoccr_sk_data *data, unsigned data_size);
/*
* Performs additional restore actions on bind()-ed and connect()-ed
* socket, but without queues restored.