[CRIU] Re: [RFC] inet unbound sockets restore

Pavel Emelyanov xemul at parallels.com
Sat May 12 10:30:02 EDT 2012


On 05/12/2012 06:24 PM, Cyrill Gorcunov wrote:
> Pavel, take a look please, this patch brings ability to
> restore unbound inet sockets, thus test unbound_sockets
> become alive.
> 
> (ps. not for merge, I'll send out the whole series later
>  once you confirm if this patch looks good for you)
> 
> 	Cyrill

> @@ -264,7 +431,7 @@ static int open_inet_sk(struct file_desc *d)
>  	 * bind() and listen(), and that's all.
>  	 */
>  
> -	if (inet_bind(sk, ii))
> +	if (ii->ie.state != TCP_CLOSE && inet_bind(sk, ii))
>  		goto err;
>  
>  	if (ii->ie.state == TCP_LISTEN) {

O_o

> +static struct inet_sk_desc *gen_uncon_sk(int lfd, const struct fd_parms *p)
> +{

>From here till the relevant } comes some not yet brushed up code, thus I
haven't looked at it close enough.

> +static unsigned int self_sk_inode(int lfd)
> +{
> +	char path[64], buf[32], *tok;
> +
> +	snprintf(path, sizeof(path), "/proc/self/fd/%d", lfd);
> +	readlink(path, buf, sizeof(buf));
> +
> +	tok = strtok(buf, "[");
> +	tok = strtok(NULL, "]");
> +	BUG_ON(!tok);
> +
> +	return atoi(tok);
> +}

It's MUCH simpler to call fstat for this.


More information about the CRIU mailing list