[CRIU] [PATCH 2/2] sk-inet: Use sockaddr_in structure instead of 128 byte address

Cyrill Gorcunov gorcunov at openvz.org
Tue Oct 30 10:47:28 EDT 2012


The kernel expects here to see struct sockaddr_in rather
than some big char slab.

In particular this allows to proceed if the socket is in
close-waiting state, where destination port is present
in kernel but the connection is not yet closed.

http://bugzilla.openvz.org/show_bug.cgi?id=2412

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 sk-inet.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sk-inet.c b/sk-inet.c
index 500aa63..38997c5 100644
--- a/sk-inet.c
+++ b/sk-inet.c
@@ -156,7 +156,7 @@ static int can_dump_inet_sk(const struct inet_sk_desc *sk)
 static struct inet_sk_desc *gen_uncon_sk(int lfd, const struct fd_parms *p)
 {
 	struct inet_sk_desc *sk;
-	char address[128];
+	struct sockaddr_in sin;
 	socklen_t aux;
 	int ret;
 
@@ -165,8 +165,8 @@ static struct inet_sk_desc *gen_uncon_sk(int lfd, const struct fd_parms *p)
 		goto err;
 
 	/* It should has no peer name */
-	aux = sizeof(address);
-	ret = getsockopt(lfd, SOL_SOCKET, SO_PEERNAME, address, &aux);
+	aux = sizeof(sin);
+	ret = getsockopt(lfd, SOL_SOCKET, SO_PEERNAME, &sin, &aux);
 	if (ret < 0) {
 		if (errno != ENOTCONN) {
 			pr_perror("Unexpected error returned from unconnected socket");
-- 
1.7.7.6



More information about the CRIU mailing list