public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Jon Maloy <jmaloy@redhat.com>
To: sbrivio@redhat.com, lvivier@redhat.com, dgibson@redhat.com,
	jmaloy@redhat.com, passt-dev@passt.top
Subject: [RFC v2] tcp: add support for MSG_PEEK with offset
Date: Thu, 22 Jun 2023 22:26:25 -0400	[thread overview]
Message-ID: <20230623022625.2631870-1-jmaloy@redhat.com> (raw)

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


                 reply	other threads:[~2023-06-23  2:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230623022625.2631870-1-jmaloy@redhat.com \
    --to=jmaloy@redhat.com \
    --cc=dgibson@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /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.
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).