Page MenuHomeFreeBSD

socket tests: remove MSG_TRUNC test for unix/seqpacket
ClosedPublic

Authored by glebius on Feb 2 2024, 5:32 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 4, 9:55 PM
Unknown Object (File)
Fri, Oct 4, 9:54 PM
Unknown Object (File)
Fri, Oct 4, 9:53 PM
Unknown Object (File)
Fri, Oct 4, 9:53 PM
Unknown Object (File)
Wed, Sep 18, 6:43 AM
Unknown Object (File)
Tue, Sep 17, 2:36 PM
Unknown Object (File)
Mon, Sep 16, 9:10 PM
Unknown Object (File)
Sep 5 2024, 5:16 AM
Subscribers

Details

Summary

The PF_UNIX/SOCK_SEQPACKET was marked as PR_ATOMIC and that made
soreceive_generic() to treat it pretty much as a datagram socket.
However, POSIX says:

The SOCK_SEQPACKET socket type is similar to the SOCK_STREAM type,
and is also connection-oriented. The only difference between these
types is that record boundaries are maintained using the
SOCK_SEQPACKET type. A record can be sent using one or more output
operations and received using one or more input operations, but a
single operation never transfers parts of more than one record.
Record boundaries are visible to the receiver via the MSG_EOR flag
in the received message flags returned by the recvmsg() function. It
is protocol-specific whether a maximum record size is imposed.

What the test was doing is checking if MSG_TRUNC would report the space
required to return up the end of next mbuf record in the socket buffer.
Apparently the test assumed that this boundary is defined by the write(2)
size on the peer socket. This was true in test conditions, but I'm not
sure it would always be true - sbcompress() may merge mbufs. Anyway, the
mbuf boundaries are internal socket buffer implementation, they are not
SOCK_SEQPACKET records. The records need to be explicitly marked with
MSG_EOR by sender.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable