From: Pengcheng Yang <yangpc@wangsu.com>
To: John Fastabend <john.fastabend@gmail.com>,
Jakub Sitnicki <jakub@cloudflare.com>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
bpf@vger.kernel.org, netdev@vger.kernel.org
Cc: Pengcheng Yang <yangpc@wangsu.com>
Subject: [PATCH bpf-next v2 2/3] tcp: Add the data length in skmsg to SIOCINQ ioctl
Date: Tue, 21 Nov 2023 19:22:04 +0800 [thread overview]
Message-ID: <1700565725-2706-3-git-send-email-yangpc@wangsu.com> (raw)
In-Reply-To: <1700565725-2706-1-git-send-email-yangpc@wangsu.com>
SIOCINQ ioctl returns the number unread bytes of the receive
queue but does not include the ingress_msg queue. With the
sk_msg redirect, an application may get a value 0 if it calls
SIOCINQ ioctl before recv() to determine the readable size.
Signed-off-by: Pengcheng Yang <yangpc@wangsu.com>
---
net/ipv4/tcp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 3d3a24f79573..04da0684c397 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -267,6 +267,7 @@
#include <linux/errqueue.h>
#include <linux/static_key.h>
#include <linux/btf.h>
+#include <linux/skmsg.h>
#include <net/icmp.h>
#include <net/inet_common.h>
@@ -613,7 +614,7 @@ int tcp_ioctl(struct sock *sk, int cmd, int *karg)
return -EINVAL;
slow = lock_sock_fast(sk);
- answ = tcp_inq(sk);
+ answ = tcp_inq(sk) + sk_msg_queue_len(sk);
unlock_sock_fast(sk, slow);
break;
case SIOCATMARK:
--
2.38.1
next prev parent reply other threads:[~2023-11-21 11:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-21 11:22 [PATCH bpf-next v2 0/3] skmsg: Add the data length in skmsg to SIOCINQ ioctl and rx_queue Pengcheng Yang
2023-11-21 11:22 ` [PATCH bpf-next v2 1/3] skmsg: Support to get the data length in ingress_msg Pengcheng Yang
2023-12-05 0:23 ` John Fastabend
2023-12-08 11:17 ` Pengcheng Yang
2023-11-21 11:22 ` Pengcheng Yang [this message]
2023-11-21 11:22 ` [PATCH bpf-next v2 3/3] tcp_diag: Add the data length in skmsg to rx_queue Pengcheng Yang
2023-11-22 15:16 ` [PATCH bpf-next v2 0/3] skmsg: Add the data length in skmsg to SIOCINQ ioctl and rx_queue Daniel Borkmann
2023-11-23 11:20 ` Pengcheng Yang
2023-11-23 13:31 ` Daniel Borkmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1700565725-2706-3-git-send-email-yangpc@wangsu.com \
--to=yangpc@wangsu.com \
--cc=bpf@vger.kernel.org \
--cc=edumazet@google.com \
--cc=jakub@cloudflare.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.