public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [RFC v2] tcp: add support for MSG_PEEK with offset
@ 2023-06-23  2:26 Jon Maloy
  0 siblings, 0 replies; only message in thread
From: Jon Maloy @ 2023-06-23  2:26 UTC (permalink / raw)
  To: sbrivio, lvivier, dgibson, jmaloy, passt-dev

When reading received messages with MSG_PEEK, we would like to eliminate
the need to read the leading bytes over and over again only to reach the
part of the message we really want.

We now introduce support for this feature, when supported by the kernel.

Signed-off-by: Jon Maloy <jmaloy@redhat.com>
---
 tcp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tcp.c b/tcp.c
index 0ed9bfa..ebaf520 100644
--- a/tcp.c
+++ b/tcp.c
@@ -500,7 +500,6 @@ tcp6_l2_buf[TCP_FRAMES_MEM];
 static unsigned int tcp6_l2_buf_used;
 
 /* recvmsg()/sendmsg() data for tap */
-static char 		tcp_buf_discard		[MAX_WINDOW];
 static struct iovec	iov_sock		[TCP_FRAMES_MEM + 1];
 
 static struct iovec	tcp4_l2_iov		[TCP_FRAMES_MEM];
@@ -2239,7 +2238,7 @@ static int tcp_data_from_sock(struct ctx *c, struct tcp_tap_conn *conn)
 	mh_sock.msg_iov = iov_sock;
 	mh_sock.msg_iovlen = fill_bufs + 1;
 
-	iov_sock[0].iov_base = tcp_buf_discard;
+	iov_sock[0].iov_base = NULL;
 	iov_sock[0].iov_len = already_sent;
 
 	if (( v4 && tcp4_l2_buf_used + fill_bufs > ARRAY_SIZE(tcp4_l2_buf)) ||
-- 
@@ -500,7 +500,6 @@ tcp6_l2_buf[TCP_FRAMES_MEM];
 static unsigned int tcp6_l2_buf_used;
 
 /* recvmsg()/sendmsg() data for tap */
-static char 		tcp_buf_discard		[MAX_WINDOW];
 static struct iovec	iov_sock		[TCP_FRAMES_MEM + 1];
 
 static struct iovec	tcp4_l2_iov		[TCP_FRAMES_MEM];
@@ -2239,7 +2238,7 @@ static int tcp_data_from_sock(struct ctx *c, struct tcp_tap_conn *conn)
 	mh_sock.msg_iov = iov_sock;
 	mh_sock.msg_iovlen = fill_bufs + 1;
 
-	iov_sock[0].iov_base = tcp_buf_discard;
+	iov_sock[0].iov_base = NULL;
 	iov_sock[0].iov_len = already_sent;
 
 	if (( v4 && tcp4_l2_buf_used + fill_bufs > ARRAY_SIZE(tcp4_l2_buf)) ||
-- 
2.39.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-23  2:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-23  2:26 [RFC v2] tcp: add support for MSG_PEEK with offset Jon Maloy

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

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 IMAP folder(s).