We have an application that uses almost the same code for TCP and
AF_UNIX (SOCK_STREAM).
The application uses TCP_INQ for TCP, but AF_UNIX doesn't have it
and requires an extra syscall, ioctl(SIOCINQ) or getsockopt(SO_MEMINFO)
as an alternative.
Also, ioctl(SIOCINQ) for AF_UNIX SOCK_STREAM is more expensive because
it needs to iterate all skb in the receive queue.
This series adds a cached field for SIOCINQ to speed it up and introduce
SO_INQ, the generic version of TCP_INQ to get the queue length as cmsg in
each recvmsg().
Kuniyuki Iwashima (7):
af_unix: Don't hold unix_state_lock() in __unix_dgram_recvmsg().
af_unix: Don't check SOCK_DEAD in unix_stream_read_skb().
af_unix: Don't use skb_recv_datagram() in unix_stream_read_skb().
af_unix: Use cached value for SOCK_STREAM in unix_inq_len().
af_unix: Cache state->msg in unix_stream_read_generic().
af_unix: Introduce SO_INQ.
selftest: af_unix: Add test for SO_INQ.
arch/alpha/include/uapi/asm/socket.h | 3 +
arch/mips/include/uapi/asm/socket.h | 3 +
arch/parisc/include/uapi/asm/socket.h | 3 +
arch/sparc/include/uapi/asm/socket.h | 3 +
include/net/af_unix.h | 2 +
include/uapi/asm-generic/socket.h | 3 +
net/unix/af_unix.c | 180 ++++++++++++------
tools/testing/selftests/net/.gitignore | 1 +
tools/testing/selftests/net/af_unix/Makefile | 2 +-
tools/testing/selftests/net/af_unix/scm_inq.c | 125 ++++++++++++
10 files changed, 269 insertions(+), 56 deletions(-)
create mode 100644 tools/testing/selftests/net/af_unix/scm_inq.c
--
2.50.0.727.gbf7dc18ff4-goog