mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-23 02:17:22 +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:
parent
c00038042d
commit
458cb41f57
@ -33,6 +33,7 @@ struct inet_sk_info {
|
|||||||
int inet_bind(int sk, struct inet_sk_info *);
|
int inet_bind(int sk, struct inet_sk_info *);
|
||||||
int inet_connect(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_unlock_all(void);
|
||||||
void tcp_locked_conn_add(struct inet_sk_info *);
|
void tcp_locked_conn_add(struct inet_sk_info *);
|
||||||
void tcp_unlock_connections(void);
|
void tcp_unlock_connections(void);
|
||||||
|
19
sk-inet.c
19
sk-inet.c
@ -403,16 +403,23 @@ static int inet_validate_address(InetSkEntry *ie)
|
|||||||
static int post_open_inet_sk(struct file_desc *d, int sk)
|
static int post_open_inet_sk(struct file_desc *d, int sk)
|
||||||
{
|
{
|
||||||
struct inet_sk_info *ii;
|
struct inet_sk_info *ii;
|
||||||
int no = 0;
|
int val;
|
||||||
|
|
||||||
ii = container_of(d, struct inet_sk_info, d);
|
ii = container_of(d, struct inet_sk_info, d);
|
||||||
|
|
||||||
if (!ii->ie->opts->reuseaddr) {
|
/* SO_REUSEADDR is set for all sockets */
|
||||||
futex_wait_until(&ii->port->users, 0);
|
if (!tcp_connection(ii->ie) && ii->ie->opts->reuseaddr)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (restore_opt(sk, SOL_SOCKET, SO_REUSEADDR, &no))
|
futex_wait_until(&ii->port->users, 0);
|
||||||
return -1;
|
|
||||||
}
|
/* 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
3
sk-tcp.c
3
sk-tcp.c
@ -55,7 +55,7 @@ static int tcp_repair_on(int fd)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tcp_repair_off(int fd)
|
void tcp_repair_off(int fd)
|
||||||
{
|
{
|
||||||
int aux = 0;
|
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))
|
if (restore_tcp_conn_state(fd, ii))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
tcp_repair_off(fd);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user