[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1699962120-3390-3-git-send-email-yangpc@wangsu.com>
Date: Tue, 14 Nov 2023 19:41:59 +0800
From: Pengcheng Yang <yangpc@...gsu.com>
To: John Fastabend <john.fastabend@...il.com>,
Jakub Sitnicki <jakub@...udflare.com>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
bpf@...r.kernel.org,
netdev@...r.kernel.org
Cc: Pengcheng Yang <yangpc@...gsu.com>
Subject: [PATCH bpf-next 2/3] tcp: Add the data length in skmsg to SIOCINQ ioctl
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@...gsu.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
Powered by blists - more mailing lists