netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "David S. Miller" <davem@redhat.com>
To: Olaf Kirch <okir@suse.de>
Cc: netdev@oss.sgi.com
Subject: Re: [PATCH] 2.6 UDP recvmsg vs POSIX
Date: Sat, 21 Feb 2004 13:08:53 -0800	[thread overview]
Message-ID: <20040221130853.4c98bad6.davem@redhat.com> (raw)
In-Reply-To: <20040217121726.GD8554@suse.de>

On Tue, 17 Feb 2004 13:17:26 +0100
Olaf Kirch <okir@suse.de> wrote:

> 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.

Well, first things first, using blocking sockets with select/poll is kind
of stupid programming.

Nonetheless, udp_recvmsg() can't return -EAGAIN on a blocking socket.

Andi, TCP does not have this issue, it simply goes back to sleep waiting
for more data to arrive if the prequeue delayed checksumming fails.

I think we should fix it like the following, which is basically the last
part of Olaf's original patch in this thread.  Just wait for another packet
if a blocking socket and checksum fails, else if non-blocking -EAGAIN is OK.

To be honest, I believe this was Alexey's original intention when he wrote this
code.

===== net/ipv4/udp.c 1.56 vs edited =====
--- 1.56/net/ipv4/udp.c	Fri Jan  9 01:50:23 2004
+++ edited/net/ipv4/udp.c	Sat Feb 21 13:03:05 2004
@@ -787,6 +787,7 @@
 	if (flags & MSG_ERRQUEUE)
 		return ip_recv_error(sk, msg, len);
 
+try_again:
 	skb = skb_recv_datagram(sk, flags, noblock, &err);
 	if (!skb)
 		goto out;
@@ -852,7 +853,9 @@
 
 	skb_free_datagram(sk, skb);
 
-	return -EAGAIN;	
+	if (noblock)
+		return -EAGAIN;	
+	goto try_again;
 }
 
 int udp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)

  parent reply	other threads:[~2004-02-21 21:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-17 12:17 [PATCH] 2.6 UDP recvmsg vs POSIX Olaf Kirch
2004-02-18  4:30 ` Andi Kleen
2004-02-18  6:17 ` David S. Miller
2004-02-19  7:07   ` Andi Kleen
2004-02-21 21:08 ` David S. Miller [this message]
2004-02-23  9:42   ` Olaf Kirch
2004-02-23 17:42     ` David S. Miller
2004-02-24  9:32       ` Olaf Kirch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040221130853.4c98bad6.davem@redhat.com \
    --to=davem@redhat.com \
    --cc=netdev@oss.sgi.com \
    --cc=okir@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).