Commit 458cb41f authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

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: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent c0003804
...@@ -33,6 +33,7 @@ struct inet_sk_info { ...@@ -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);
......
...@@ -403,16 +403,23 @@ static int inet_validate_address(InetSkEntry *ie) ...@@ -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;
} }
......
...@@ -55,7 +55,7 @@ static int tcp_repair_on(int fd) ...@@ -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) ...@@ -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;
} }
......
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