[CRIU] Re: [PATCH 4/8] util-net: Add send_fds and recv_fds
Pavel Emelyanov
xemul at parallels.com
Sat Mar 24 13:37:53 EDT 2012
On 03/24/2012 09:09 PM, Cyrill Gorcunov wrote:
> On Sat, Mar 24, 2012 at 08:58:39PM +0400, Pavel Emelyanov wrote:
> ...
>>> +int recv_fds(int sock, int *fds, int nr_fds)
>>> +{
>>> + struct scm_fdset fdset;
>>> + int *fds_rx, i, min_fd;
>>> +
>>> + fds_rx = scm_fdset_init(&fdset, NULL, 0);
>>> +
>>> + for (i = min_fd = 0; i < nr_fds; i += min_fd) {
>>> + min_fd = min(CR_SCM_MAX_FD, nr_fds - i);
>>> + scm_fdset_init_chunk(&fdset, min_fd);
>>> +
>>> + min_fd = scm_fdset_recv(sock, &fdset);
>>> + if (min_fd < 0)
>>> + return min_fd;
>>> +
>>> + builtin_memcpy(&fds[i], fds_rx, sizeof(int) * min_fd);
>>
>> We should make sure, that the descriptor set received coincides the
>> descriptor set we expected to receive. I don't see anything about it
>> here.
>
> Letme clarify, you mean we need to make sure the 1:1 map between descriptors
> requested and received is valid? If so, the kernel picks up fds in-order,
> so we simply can't get out of order results where, the question is can
> we received out-of-order 'set' of descriptors -- yes, I fear we can,
> to eliminate this problem we will need kind of sync points between
> parasite code and crtools itself. Do I understand you right?
No. You just use the numbers of fds kernel reports to you without any
checks. You should make sure the number of fds received is the number
of fds we ask for.
> Cyrill
> .
>
More information about the CRIU
mailing list