[CentOS] UDP de-fragmentation problem

Sat Apr 9 19:49:47 UTC 2016
Marcelo Ricardo Leitner <marcelo.leitner at gmail.com>

Em 08-04-2016 14:38, Gordon Messmer escreveu:
> On 04/07/2016 08:19 AM, Volker wrote:
>> I have a strange problem at hand regarding UDP fragmentation on Centos7:
>> Applications are unable to receive UDP packets which have undergone
>> fragmentation UNLESS the netfilter modules are loaded.
> ...
>> The application in question uses Qt, which opens the UDP socket in
>> non-blocking mode - apparently that's an issue because reading from the
>> socket in blocking mode does not cause the problem.
>
> I'm not sure you need to look much further than that.  Using select()
> and non-blocking sockets together doesn't make a whole lot of sense. The

Yes it does. You can mix both. Why not? For example, select will return 
only "data ready" but will not tell you how much is in there. With 
non-blocking he can keep reading until the data is drained and without 
calling select() on it on every single iteration. If the traffic is 
bursty, this may save some syscalls.

> man page for select() says that descriptors listed in readfds will be
> watched "precisely, to see if a read will not block."
>
> So, if the socket returned by select() can be read without blocking, you
> don't need to put the socket in non-blocking mode.
>
> It's hard to say more since your strace output was cut.  I'd expect you
> to get another return from select() when the rest of the data arrives,
> and for recvfrom() to work at that point.  I can't tell if that's

No because that implies that the application has to do the 
defragmentation, which is impossible as it doesn't have the necessary 
information for that. Kernel must hold the fragments until it's 
reconstructed, and only then deliver it to the application.

> happening or not.  If it's not, then you probably have hit a bug.  The
> documented behavior for message-based sockets is to read the entire
> message in one operation, and to discard data on recvfrom() if it's too
> big for the buffer.  Maybe you're creating a condition where the system
> is discarding data if it can't be read in one operation.
>
> Regardless, in the select()/recvfrom() pattern you described, the socket
> should be in blocking mode.
>
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> https://lists.centos.org/mailman/listinfo/centos