[CRIU] Re: [PATCH 4/4] sockets: Restore unconnected dgram sockets v4
Pavel Emelyanov
xemul at parallels.com
Tue Apr 17 11:16:14 EDT 2012
On 04/17/2012 06:32 PM, Cyrill Gorcunov wrote:
> On Tue, Apr 17, 2012 at 06:15:26PM +0400, Pavel Emelyanov wrote:
>>
>>> @@ -1370,6 +1435,16 @@ static int open_unixsk_standalone(struct unix_sk_info *ui)
>>> if (restore_fown(sk, &ui->ue.fown))
>>> return -1;
>>>
>>> + /*
>>> + * No connect should be done over external peers,
>>> + * simply bind only to them, and that's all.
>>> + */
>>> + if (ui->peer && ui->peer->ue.uflags & USK_EXTERN) {
>>> + if (bind_unix_sk(sk, ui->peer))
>>> + return -1;
>>> + return sk;
>>> + }
>>> +
>>> if (bind_unix_sk(sk, ui))
>>> return -1;
>>>
>>
>> I don't understand why this hunk is needed. This only occurs when we meet someone's file
>> descriptor pointing to this socket. External sockets don't have anybody with a descriptor
>> pointing on them (otherwise they would be "internal")
>>
>
> OK, letme explain, the crond uses /dev/log to send messages, lets say our socket
> is sk1 (id = 1), while /dev/log socket is sk2 (id = 2) (and it's external one not bound to
> us).
>
> So in dump we have
>
> sk1: id 1 peer 2 name nil (it correspond some fd inside crond)
> sk2: id 2 peer 0 name /dev/log
>
> once dump complete, on image it looks like
>
> sk1: id 1 peer 2 name nil
> sk2: id 2 peer -1 name /dev/log
>
> so sk1 must be created and bount to peer's name /dev/log,
Not bound, but connected. Himself he can be bound to nothing.
> so I need a special case otherwise bind_unix_sk(sk, ui) will
> simply bind to null string.
sk2 is not tied to any fd and thus open_unix_sk cannot be called on it.
sk2 in the image is ONLY required to make sk1 call connect on some path.
>>> @@ -1483,6 +1558,9 @@ int resolve_unix_peers(void)
>>> if (!ui->ue.peer)
>>> continue;
>>>
>>> + if ((ui->ue.uflags & USK_EXTERN) && opts.ext_unix_sk)
>>> + continue;
>>> +
>>> peer = find_unix_sk(ui->ue.peer);
>>> if (!peer) {
>>> pr_err("FATAL: Peer 0x%x unresolved for 0x%x\n",
>>
>> External socket cannot have a peer on it. Otherwise it's not "external" but "lost internal".
>>
>
> yes, this snippet is redundant.
>
> Cyrill
> .
>
More information about the CRIU
mailing list