aboutsummaryrefslogtreecommitdiff
path: root/sys/sys
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2024-04-08 20:16:51 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2024-04-08 20:16:51 +0000
commitd80a97def9a1db6f07f5d2e68f7ad62b27918947 (patch)
treef2c05e07a2efd3d6fbc0f479dbee2396861e5dcc /sys/sys
parentaba79b0f4a3f69f070ace6effd5700d65226bd20 (diff)
downloadsrc-d80a97def9a1db6f07f5d2e68f7ad62b27918947.tar.gz
src-d80a97def9a1db6f07f5d2e68f7ad62b27918947.zip
unix: new implementation of unix/stream & unix/seqpacket
Provide protocol specific pr_sosend and pr_soreceive for PF_UNIX SOCK_STREAM sockets and implement SOCK_SEQPACKET sockets as an extension of SOCK_STREAM. The change meets three goals: get rid of unix(4) specific stuff in the generic socket code, provide a faster and robust unix/stream sockets and bring unix/seqpacket much closer to specification. Highlights follow: - The send buffer now is truly bypassed. Previously it was always empty, but the send(2) still needed to acquire its lock and do a variety of tricks to be woken up in the right time while sleeping on it. Now the only two things we care about in the send buffer is the I/O sx(9) lock that serializes operations and value of so_snd.sb_hiwat, which we can read without obtaining a lock. The sleep of a send(2) happens on the mutex of the receive buffer of the peer. A bulk send/recv of data with large socket buffers will make both syscalls just bounce between owning the receive buffer lock and copyin(9)/copyout(9), no other locks would be involved. - The implementation uses new mchain structure to manipulate mbuf chains. Note that this required converting to mchain two functions that are shared with unix/dgram: unp_internalize() and unp_addsockcred() as well as adding a new shared one uipc_process_kernel_mbuf(). This induces some non- functional changes in the unix/dgram code as well. There is a space for improvement here, as right now it is a mix of mchain and manually managed mbuf chains. - unix/seqpacket previously marked as PR_ADDR & PR_ATOMIC and thus treated as a datagram socket by the generic socket code, now becomes a true stream socket with record markers. - unix/stream loses the sendfile(2) support. This can be brought back, but requires some work. Let's first see if there is any interest in this feature, except purely academical. Reviewed by: markj, tuexen Differential Revision: https://reviews.freebsd.org/D44151
Diffstat (limited to 'sys/sys')
-rw-r--r--sys/sys/sockbuf.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/sys/sockbuf.h b/sys/sys/sockbuf.h
index c6093883be4a..2f1c294339c6 100644
--- a/sys/sys/sockbuf.h
+++ b/sys/sys/sockbuf.h
@@ -131,6 +131,13 @@ struct sockbuf {
struct ktls_session *sb_tls_info; /* TLS state */
};
/*
+ * PF_UNIX/SOCK_STREAM and PF_UNIX/SOCK_SEQPACKET
+ * A most simple stream buffer.
+ */
+ struct {
+ STAILQ_HEAD(, mbuf) sb_mbq;
+ };
+ /*
* PF_UNIX/SOCK_DGRAM
*
* Local protocol, thus we should buffer on the receive side