Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Aug 2014 14:16:32 +0400
From:      Fedor Indutny <fedor@indutny.com>
To:        =?UTF-8?Q?Jan_Kokem=C3=BCller?= <jan.kokemueller@gmail.com>
Cc:        freebsd-current@freebsd.org
Subject:   Re: KQueue 0-length UDP packet
Message-ID:  <CAEv2VfJDH3WLzFHLE8gTfrqauyZ33G9KAyi-1_TFyDWcQnBunQ@mail.gmail.com>
In-Reply-To: <53FC57EC.2000107@gmail.com>
References:  <CAEv2VfLoPiDtEmwJyWMGJuTOaPUTUJoD3B6VQDBE=4A6U4o4-A@mail.gmail.com> <CAEv2VfK6yoXrWaRKX8u-Pp=ddgDE9%2BGhdUoNCr_AZJUAk29t4w@mail.gmail.com> <CAEv2VfJ_RohvqhnaTX63rZikxVC38JTXoDL03Q=u5TnrPg%2B7-g@mail.gmail.com> <CAEv2VfKVZfOzL6po9Q5ETXXX6v4ErZNW=sKFgec6kAhtyoGTYg@mail.gmail.com> <53FC57EC.2000107@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Ok, thanks for a clarification!


On Tue, Aug 26, 2014 at 1:48 PM, Jan Kokem=C3=BCller <jan.kokemueller@gmail=
.com>
wrote:

> Hi,
>
>
>  What I wanted to ask is: why does FreeBSD kqueue implementation treat
>> `SO_RCVLOWAT` as a raw packet size watermark, and not using the actual
>> data size for filtering out events?
>>
>
> It looks like SO_RCVLOWAT refers to the number of bytes in the socket
> buffer, not raw packet bytes. In the case of an arriving UDP packet there
> is always a 'struct sockaddr' in the buffer that contains the source
> address/port of the message. For IPv4 this is 16 bytes and for IPv6 28
> bytes. I think this is intended behavior, as this is data you can "read"
> with recvfrom or recvmsg.
>
> POSIX says "Receive calls may still return less than the low water mark i=
f
> an error occurs, a signal is caught, or the type of data next in the
> receive queue is different from that returned (for example, out-of-band
> data)." So in this case this data is address data.
>
> On the other hand, NOTE_LOWAT from kevent refers to data/protocol bytes.
> The semantics were changed in 2002:
> http://marc.info/?l=3Dfreebsd-arch&m=3D103587526507822&w=3D2
> The value you get in 'data' also refers to the number of protocol data
> bytes available.
>
> I've had a look at how OpenBSD handles this. It returns the number of
> protocol data bytes with "ioctl(s, FIONREAD, &len)" but the number of byt=
es
> in the socket buffer in the 'data' member of kevent, so exactly the other
> way around compared to FreeBSD. SO_RCVLOWAT works still the same, though.
>
> Cheers,
> Jan
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAEv2VfJDH3WLzFHLE8gTfrqauyZ33G9KAyi-1_TFyDWcQnBunQ>