2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-23 10:28:05 +00:00

restore: disable repair mode in post_open()

A disabling repair mode drops SO_REUSEADDR.

We can set SO_REUSEADDR after disabling repair mode, but
a small race window exists in this case.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Andrey Vagin 2012-08-27 16:55:00 +04:00 committed by Pavel Emelyanov
parent c00038042d
commit 458cb41f57
3 changed files with 15 additions and 8 deletions

View File

@ -33,6 +33,7 @@ struct inet_sk_info {
int inet_bind(int sk, struct inet_sk_info *);
int inet_connect(int sk, struct inet_sk_info *);
void tcp_repair_off(int sk);
void tcp_unlock_all(void);
void tcp_locked_conn_add(struct inet_sk_info *);
void tcp_unlock_connections(void);

View File

@ -403,16 +403,23 @@ static int inet_validate_address(InetSkEntry *ie)
static int post_open_inet_sk(struct file_desc *d, int sk)
{
struct inet_sk_info *ii;
int no = 0;
int val;
ii = container_of(d, struct inet_sk_info, d);
if (!ii->ie->opts->reuseaddr) {
/* SO_REUSEADDR is set for all sockets */
if (!tcp_connection(ii->ie) && ii->ie->opts->reuseaddr)
return 0;
futex_wait_until(&ii->port->users, 0);
if (restore_opt(sk, SOL_SOCKET, SO_REUSEADDR, &no))
/* Disabling repair mode drops SO_REUSEADDR */
if (tcp_connection(ii->ie))
tcp_repair_off(sk);
val = ii->ie->opts->reuseaddr;
if (restore_opt(sk, SOL_SOCKET, SO_REUSEADDR, &val))
return -1;
}
return 0;
}

View File

@ -55,7 +55,7 @@ static int tcp_repair_on(int fd)
return ret;
}
static void tcp_repair_off(int fd)
void tcp_repair_off(int fd)
{
int aux = 0;
@ -484,7 +484,6 @@ int restore_one_tcp(int fd, struct inet_sk_info *ii)
if (restore_tcp_conn_state(fd, ii))
return -1;
tcp_repair_off(fd);
return 0;
}