aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/af_unix.h
diff options
context:
space:
mode:
authorKuniyuki Iwashima <kuniyu@google.com>2025-07-02 22:35:16 +0000
committerJakub Kicinski <kuba@kernel.org>2025-07-08 18:05:25 -0700
commitf4e1fb04c12384fb1b69a95c33527b515a652a74 (patch)
tree153a0bb97038b6e4a5e3d9c619a63c2dc662688f /include/net/af_unix.h
parentaf_unix: Don't use skb_recv_datagram() in unix_stream_read_skb(). (diff)
downloadlinux-f4e1fb04c12384fb1b69a95c33527b515a652a74.tar.gz
linux-f4e1fb04c12384fb1b69a95c33527b515a652a74.zip
af_unix: Use cached value for SOCK_STREAM in unix_inq_len().
Compared to TCP, ioctl(SIOCINQ) for AF_UNIX SOCK_STREAM socket is more expensive, as unix_inq_len() requires iterating through the receive queue and accumulating skb->len. Let's cache the value for SOCK_STREAM to a new field during sendmsg() and recvmsg(). The field is protected by the receive queue lock. Note that ioctl(SIOCINQ) for SOCK_DGRAM returns the length of the first skb in the queue. SOCK_SEQPACKET still requires iterating through the queue because we do not touch functions shared with unix_dgram_ops. But, if really needed, we can support it by switching __skb_try_recv_datagram() to a custom version. Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Willem de Bruijn <willemb@google.com> Link: https://patch.msgid.link/20250702223606.1054680-5-kuniyu@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/net/af_unix.h')
-rw-r--r--include/net/af_unix.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index 1af1841b7601..603f8cd026e5 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -47,6 +47,7 @@ struct unix_sock {
#define peer_wait peer_wq.wait
wait_queue_entry_t peer_wake;
struct scm_stat scm_stat;
+ int inq_len;
#if IS_ENABLED(CONFIG_AF_UNIX_OOB)
struct sk_buff *oob_skb;
#endif