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

Pavel Emelyanov xemul at parallels.com
Tue Oct 30 11:02:23 EDT 2012


On 10/30/2012 06:47 PM, Cyrill Gorcunov wrote:
> 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);

for ipv6 it should be sizeof(another struct). but to check for conn/unconn it's enough to
pass there 1-byte len.

> +	ret = getsockopt(lfd, SOL_SOCKET, SO_PEERNAME, &sin, &aux);
>  	if (ret < 0) {
>  		if (errno != ENOTCONN) {
>  			pr_perror("Unexpected error returned from unconnected socket");
> 




More information about the CRIU mailing list