[CentOS] UDP de-fragmentation problem
gordon.messmer at gmail.com
Fri Apr 8 17:38:11 UTC 2016
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 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
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.
More information about the CentOS