Commit 2ab06c9c authored by Pavel Emelyanov's avatar Pavel Emelyanov

tcp: Schedule tcp socket for repair-off with proper fd

The fd in -> open callback is temporary (the files restoring
engine will re-open one under some other fd). But since we
add this fd to future repair off, this off will fail working
on wrong fd.

Move scheduling for repair-off into port-open where the corrent
fd is known.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 4498dffc
...@@ -74,5 +74,6 @@ int check_tcp(void); ...@@ -74,5 +74,6 @@ int check_tcp(void);
extern int rst_tcp_socks_size; extern int rst_tcp_socks_size;
extern int rst_tcp_socks_remap(void *addr); extern int rst_tcp_socks_remap(void *addr);
extern int rst_tcp_socks_add(int fd, bool reuseaddr);
#endif /* __CR_SK_INET_H__ */ #endif /* __CR_SK_INET_H__ */
...@@ -448,8 +448,12 @@ static int post_open_inet_sk(struct file_desc *d, int sk) ...@@ -448,8 +448,12 @@ static int post_open_inet_sk(struct file_desc *d, int sk)
* TCP sockets are handled at the last moment * TCP sockets are handled at the last moment
* after unlocking connections. * after unlocking connections.
*/ */
if (tcp_connection(ii->ie)) if (tcp_connection(ii->ie)) {
if (rst_tcp_socks_add(sk, ii->ie->opts->reuseaddr))
return -1;
return 0; return 0;
}
/* SO_REUSEADDR is set for all sockets */ /* SO_REUSEADDR is set for all sockets */
if (ii->ie->opts->reuseaddr) if (ii->ie->opts->reuseaddr)
......
...@@ -577,7 +577,7 @@ int rst_tcp_socks_remap(void *addr) ...@@ -577,7 +577,7 @@ int rst_tcp_socks_remap(void *addr)
return 0; return 0;
} }
static int rst_tcp_socks_add(int fd, bool reuseaddr) int rst_tcp_socks_add(int fd, bool reuseaddr)
{ {
/* + 2 = ( new one + guard (-1) ) */ /* + 2 = ( new one + guard (-1) ) */
if ((rst_tcp_socks_num + 2) * sizeof(struct rst_tcp_sock) > rst_tcp_socks_size) { if ((rst_tcp_socks_num + 2) * sizeof(struct rst_tcp_sock) > rst_tcp_socks_size) {
...@@ -601,9 +601,6 @@ int restore_one_tcp(int fd, struct inet_sk_info *ii) ...@@ -601,9 +601,6 @@ int restore_one_tcp(int fd, struct inet_sk_info *ii)
if (tcp_repair_on(fd)) if (tcp_repair_on(fd))
return -1; return -1;
if (rst_tcp_socks_add(fd, ii->ie->opts->reuseaddr))
return -1;
if (restore_tcp_conn_state(fd, ii)) if (restore_tcp_conn_state(fd, ii))
return -1; return -1;
......
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