From: Stephen Hemminger <shemminger@linux-foundation.org>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: netdev@vger.kernel.org
Subject: Re: [RFC] Zero-length write() does not generate a datagram on connected socket
Date: Tue, 25 Sep 2007 22:36:09 -0700 [thread overview]
Message-ID: <20070925223609.0e89a6a7@freepuppy.rosehill> (raw)
In-Reply-To: <E1IaNQ7-0004DX-00@gondolin.me.apana.org.au>
On Wed, 26 Sep 2007 11:18:39 +0800
Herbert Xu <herbert@gondor.apana.org.au> wrote:
> Stephen Hemminger <shemminger@linux-foundation.org> wrote:
> > The bug http://bugzilla.kernel.org/show_bug.cgi?id=5731
> > describes an issue where write() can't be used to generate a zero-length
> > datagram (but send, and sendto do work).
> >
> > I think the following is needed:
> >
> > --- a/net/socket.c 2007-08-20 09:54:28.000000000 -0700
> > +++ b/net/socket.c 2007-09-24 15:31:25.000000000 -0700
> > @@ -777,8 +777,11 @@ static ssize_t sock_aio_write(struct kio
> > if (pos != 0)
> > return -ESPIPE;
> >
> > - if (iocb->ki_left == 0) /* Match SYS5 behaviour */
> > - return 0;
> > + if (unlikely(iocb->ki_left == 0)) {
> > + struct socket *sock = iocb->ki_filp->private_data;
> > + if (sock->type == SOCK_STREAM)
> > + return 0;
> > + }
>
> I'm not sure whether all STREAM protocols treat zero-length
> sends as no-ops. What about SCTP?
>
> Put it another way, do we really need to keep the short-circuit
> for SOCK_STREAM?
>
> Cheers,
Stream is defined as sequence of bytes. So short circuit makes sense
If the application wants message boundaries it needs to use SOCK_SEQPACKET.
I was paranoid about possible breakage in TCP or SCTP. But since
send(s, buf, 0, 0) already filters through, I guess it doesn't matter.
--
Stephen Hemminger <shemminger@linux-foundation.org>
next prev parent reply other threads:[~2007-09-26 5:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <bug-5731-100@http.bugzilla.kernel.org/>
[not found] ` <20070922094432.E9BEA108010@picon.linux-foundation.org>
2007-09-24 22:34 ` [RFC] Zero-length write() does not generate a datagram on connected socket Stephen Hemminger
2007-09-26 3:18 ` Herbert Xu
2007-09-26 5:36 ` Stephen Hemminger [this message]
2007-09-26 17:17 ` Rick Jones
2007-09-26 18:47 ` Vlad Yasevich
2007-09-27 20:53 ` David Miller
2007-09-27 22:41 ` Stephen Hemminger
2007-09-28 8:49 ` Michael Kerrisk
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=20070925223609.0e89a6a7@freepuppy.rosehill \
--to=shemminger@linux-foundation.org \
--cc=herbert@gondor.apana.org.au \
--cc=netdev@vger.kernel.org \
/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