[Devel] [PATCH criu v7-u5 2/2] sk-inet: udp -- Don't fail on calling shutdown on disconnected socket

Cyrill Gorcunov gorcunov at gmail.com
Sat Jul 22 13:27:09 MSK 2017


If socket has been connected and shutted down, it may get
disconnected then leaving shutdown mode set inside (which
we pull into image). On restore we should not fail when
calling shutdown over -- the kernel has a hack to inform
listeners even on closed sockets. From userspace perspective
to reuse such socket one have to connect it back, so should
be safe.

https://jira.sw.ru/browse/PSBM-68062

Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
---
 criu/sk-inet.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/criu/sk-inet.c b/criu/sk-inet.c
index d44fb08..53918e8 100644
--- a/criu/sk-inet.c
+++ b/criu/sk-inet.c
@@ -735,9 +735,14 @@ static int open_inet_sk(struct file_desc *d, int *new_fd)
 	    (ie->proto == IPPROTO_UDP ||
 	     ie->proto == IPPROTO_UDPLITE)) {
 		if (shutdown(sk, sk_decode_shutdown(ie->shutdown))) {
-			pr_perror("Can't shutdown socket into %d",
+			if (ie->state != TCP_CLOSE && errno != ENOTCONN) {
+				pr_perror("Can't shutdown socket into %d",
 				  sk_decode_shutdown(ie->shutdown));
-			goto err;
+				goto err;
+			} else {
+				pr_debug("Called shutdown on closed socket, proto %d ino %#x",
+					 ie->proto, ie->ino);
+			}
 		}
 	}
 
-- 
2.7.5



More information about the Devel mailing list