Commit 27582e32 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

inet: Restore SO_REUSEADDR in case of rollback

tcp_repair_off implicitly modifies SO_REUSEADDR option
inside the kernel (thanks avagin@ for pointing this
feature out) thus if we are to rollback and restore
the former settings of socket -- don't forget to
repair this particular one.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
CC: Andrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 93e60c76
...@@ -30,6 +30,7 @@ struct inet_sk_desc { ...@@ -30,6 +30,7 @@ struct inet_sk_desc {
unsigned short shutdown; unsigned short shutdown;
int rfd; int rfd;
int cpt_reuseaddr;
struct list_head rlist; struct list_head rlist;
}; };
......
...@@ -295,6 +295,7 @@ static int do_dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p, int fa ...@@ -295,6 +295,7 @@ static int do_dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p, int fa
show_one_inet("Dumping", sk); show_one_inet("Dumping", sk);
show_one_inet_img("Dumped", &ie); show_one_inet_img("Dumped", &ie);
sk->sd.already_dumped = 1; sk->sd.already_dumped = 1;
sk->cpt_reuseaddr = skopts.reuseaddr;
switch (proto) { switch (proto) {
case IPPROTO_TCP: case IPPROTO_TCP:
......
...@@ -157,6 +157,13 @@ static void tcp_unlock_one(struct inet_sk_desc *sk) ...@@ -157,6 +157,13 @@ static void tcp_unlock_one(struct inet_sk_desc *sk)
pr_perror("Failed to unlock TCP connection"); pr_perror("Failed to unlock TCP connection");
tcp_repair_off(sk->rfd); tcp_repair_off(sk->rfd);
/*
* tcp_repair_off modifies SO_REUSEADDR so
* don't forget to restore original value.
*/
restore_opt(sk->rfd, SOL_SOCKET, SO_REUSEADDR, &sk->cpt_reuseaddr);
close(sk->rfd); close(sk->rfd);
} }
......
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