netdev
[Top] [All Lists]

Re: MSG_EOR flag

To: eis@xxxxxxxxxxxxx (Henner Eisen)
Subject: Re: MSG_EOR flag
From: Steve Whitehouse <steve@xxxxxxxxxxxxxx>
Date: Tue, 29 Feb 2000 09:30:31 +0000 (GMT)
Cc: netdev@xxxxxxxxxxx
In-reply-to: <oubt516k9e.fsf@xxxxxxxxxxxxx> from "Henner Eisen" at Feb 28, 2000 11:21:33 PM
Organization: ChyGywn Limited
Reply-to: Steve Whitehouse <Steve@xxxxxxxxxxx>
Sender: owner-netdev@xxxxxxxxxxx
> 
> Hi,
> 
> somewhere in 2.3.x, sock_write() was changed to call proto_ops.sendmsg() of
> SOCK_SEQPACK sockets with MSG_EOR flag set (which broke some protocols first).
> 
> My questions now are: how should the MSG_EOR be used consistently?
> 
> Should sockets which do not support sending fragments via sendmsg refuse
> to accept sendmsg without MSG_EOR set? This seems consistent, but can cause
> compatibility problems with 2.2.x kernels.
> 
> How should the MSG_EOR flag affect recvmsg()?
> 
> Henner
> 

Hi,

Guess I should own up since it was I who introduced the change :-) The
reason for it was that DECnet needed to be able to use SEQPACKET sockets.
In the case where there was not enough buffer space kernel side to be
able to copy all the data from user space without blocking (assuming that
you'd set O_NONBLOCK on your socket) there had to be a method for userspace
to send the data in chunks and put a marker in to tell the kernel when the
end of the message segment was. This was the original reason for 
implementation.

The flag is part of the draft POSIX standard, which I followed when
updating the code. Basically it works like this...

 o sendmsg() - MSG_EOR indicates that the data sent is the last in a
   record. Data in a sendmsg() call must all be part of one record.
   If the sendmsg() call returns before all the data is sent, then
   the MSG_EOR is ignored so that the rest of the record may be sent in
   a later sendmsg() call when more buffer space is available.

 o recvmsg() - Each call may only return data from a single record. MSG_EOR
   is returned when the last bit of data from a record is returned.

Aside from the above, SOCK_SEQPACKET works like SOCK_STREAM.

There was an obvious problem, in that with write() you can't specify any
flags, so the implicit MSG_EOR was added so that it could do something
vagely sensible without forcing people to use sendmsg() to terminate
each record. (POSIX doesn't actually say if write() should have an
implicit MSG_EOR or not, it stays slient on the matter)

As to what to do when the sockets don't support sending fragments, I'd
suggest that they ought to print out a message (suitably rate limited)
that the application is an old one and should be updated if it does not
set MSG_EOR. This seems to be the usual approach that I've seen elsewhere
around the kernel. Its probably also a good idea to update as many
applications as possible before this message is added though.

btw, are you thinking about AX.25 ? So far as I'm aware its the only
other SEQPACKET supporting protocol...

Steve.


<Prev in Thread] Current Thread [Next in Thread>
  • MSG_EOR flag, Henner Eisen
    • Re: MSG_EOR flag, Steve Whitehouse <=