Re: Bug in short splice to socket?
From: David Howells
Date: Mon Jun 05 2023 - 11:53:06 EST
David Laight <David.Laight@xxxxxxxxxx> wrote:
> > > However, this might well cause a malfunction in UDP, for example.
> > > MSG_MORE corks the current packet, so if I ask sendfile() say shove 32K
> > > into a packet, if, say, 16K is read from the source and entirely
> > > transcribed into the packet,
> >
> > If you use splice() for UDP, I don't think you would normally expect
> > to get all that well-defined packet boundaries.
>
> Especially since (assuming I've understood other bits of this thread)
> the splice() can get split into multiple sendmsg() calls for other
> reasons.
Yes - with SPLICE_F_MORE/MSG_MORE set on all but the last piece. The issue is
what happens if the input side gets a premature EOF after we've passed a chunk
with MSG_MORE set when the caller didn't indicate SPLICE_F_MORE?
> What semantics are you trying to implement for AF_TLS?
As I understand it, deasserting MSG_MORE causes a record boundary to be
interposed on TLS.
> MSG_MORE has different effects on different protocols.
Do you mean "different protocols" in relation to TLS specifically? Software vs
device vs device-specific like Chelsio-TLS?
> For UDP the next data is appended to the datagram being built.
> (This is really pretty pointless, doing it in the caller will be faster!)
Splice with SPLICE_F_MORE seems to work the same as sendmsg with MSG_MORE
here. You get an error if you try to append with splice or sendmsg more than
a single packet will hold.
> For TCP it stops the pending data being sent immediately.
> And more data is appended.
> I'm pretty sure it gets sent on timeout.
Yeah - corking is used by some network filesystem protocols, presumably to
better place RPC messages into TCP packets.
> For SCTP the data chunk created for the sendmsg() isn't sent immediately.
> Any more sendmsg(MSG_MORE) get queued until a full ethernet packet
> is buffered.
> The pending data is sent on timeout.
> This is pretty much the only way to get two (or more) DATA chunks
> into an ethernet frame when Nagle is disabled.
SCTP doesn't support sendpage, so that's not an issue.
> But I get the impression AF_TLS is deciding not to encode/send
> the data because 'there isn't enough'.
> That seems wrong.
>
> Note that you can't use a zero length sendmsg() to flush pending
> data - if there is no pending data some protocols will send a
> zero length data message.
> A socket option/ioctl (eg UNCORK) could be (ab)used to force
> queued data be sent.
Yeah - I've changed that, see v4. I've implemented Linus's ->splice_eof()
idea.
David