Hi,
I'm currently investigating a problem in udp recvmsg. In short, a test
program selects on the socket, gets woken up as a packet arrives, but
recvmsg return EAGAIN because the UDP checksum was wrong.
This broke one real-life application, and reportedly this violates POSIX,
as operations on a blocking socket must never return EAGAIN.
The quick and dirty fix would be to always do the checksum in
udp_queue_rcv_skb, but I assume this "checksum-outside-the-bottom-half"
approach is there because it improves performance, so I've tried to
come up with a different solution.
Please find attached a patch that tries to pluck bad udp packets from the
receive queue as part of poll/select handling, so that we never mark a
udp socket as POLLIN when there are only bad packets in the queue. This
is admittedly not very elegant, and it may have side effects I'm not
seeing yet. But it seems to fix things for me here, without slowing
the bottom half handlers down.
The second half of the patch deals with bad checksums in recvmsg. If an
application calls recvmsg on a blocking socket, and we find a packet
with a bad checksum (this may happen if the application didn't select
first), we start over at the top of the function, so that we block in
skb_datagram_receive rather than returning EAGAIN.
Any comments welcome.
Olaf
--
Olaf Kirch | Stop wasting entropy - start using predictable
okir@xxxxxxx | tempfile names today!
---------------+
linux-2.6.2-udpfix.patch
Description: Text document
|