netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bpf/sockmap: read psock ingress_msg before sk_receive_queue
@ 2020-01-07  4:22 Lingpeng Chen
  2020-01-07 15:38 ` John Fastabend
  0 siblings, 1 reply; 11+ messages in thread
From: Lingpeng Chen @ 2020-01-07  4:22 UTC (permalink / raw)
  To: John Fastabend; +Cc: Daniel Borkmann, netdev, bpf, Lingpeng Chen

Right now in tcp_bpf_recvmsg, sock read data first from sk_receive_queue
if not empty than psock->ingress_msg otherwise. If a FIN packet arrives
and there's also some data in psock->ingress_msg, the data in
psock->ingress_msg will be purged. It is always happen when request to a
HTTP1.0 server like python SimpleHTTPServer since the server send FIN
packet after data is sent out.

Signed-off-by: Lingpeng Chen <forrest0579@gmail.com>
---
 net/ipv4/tcp_bpf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index e38705165ac9..cd4b699d3d0d 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -123,8 +123,6 @@ int tcp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 
 	if (unlikely(flags & MSG_ERRQUEUE))
 		return inet_recv_error(sk, msg, len, addr_len);
-	if (!skb_queue_empty(&sk->sk_receive_queue))
-		return tcp_recvmsg(sk, msg, len, nonblock, flags, addr_len);
 
 	psock = sk_psock_get(sk);
 	if (unlikely(!psock))
@@ -139,7 +137,7 @@ int tcp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 		timeo = sock_rcvtimeo(sk, nonblock);
 		data = tcp_bpf_wait_data(sk, psock, flags, timeo, &err);
 		if (data) {
-			if (skb_queue_empty(&sk->sk_receive_queue))
+			if (!sk_psock_queue_empty(psock))
 				goto msg_bytes_ready;
 			release_sock(sk);
 			sk_psock_put(sk, psock);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-01-09 22:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-07  4:22 [PATCH] bpf/sockmap: read psock ingress_msg before sk_receive_queue Lingpeng Chen
2020-01-07 15:38 ` John Fastabend
     [not found]   ` <CAH+Qyb+37gaWZzEvvXeX9ghsCYw1JyH_23S+1HW0ML-MZkcYfg@mail.gmail.com>
2020-01-08  3:54     ` John Fastabend
2020-01-08  4:57       ` Lingpeng Chen
2020-01-08 16:50         ` Song Liu
2020-01-08 17:02         ` Daniel Borkmann
2020-01-08 18:01           ` John Fastabend
2020-01-08 18:17             ` Daniel Borkmann
2020-01-08 18:34               ` John Fastabend
2020-01-09  1:48                 ` [PATCH v2] " Lingpeng Chen
2020-01-09 22:16                   ` Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).