From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id A989D5A026F for ; Fri, 23 Jun 2023 04:26:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687487192; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=XA632nB9IPdyCT8MfqvkXXEryCW61RfsePI1v+NH6W0=; b=Z3FAl3bHE1aCuVd5nD1waR5vZG+LxI1vKUDy+4Lc9TInIwqA8sg6i5vZyv70qH9G3ZnOIT Wuhg8rJyGRL2OhPdZuVCd6k2bzCt2j92iLiueyHbJprzEO1kk+BCM44BKHvFMbx/jB5kUu Q8MugjDmUPeJpKT5GXr+y+MLij8Ucm4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-374-lrPs-XbiNDqx4tmPXac2gA-1; Thu, 22 Jun 2023 22:26:30 -0400 X-MC-Unique: lrPs-XbiNDqx4tmPXac2gA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6CA808E44E3 for ; Fri, 23 Jun 2023 02:26:30 +0000 (UTC) Received: from fenrir.redhat.com (unknown [10.22.32.81]) by smtp.corp.redhat.com (Postfix) with ESMTP id 266B9112132C; Fri, 23 Jun 2023 02:26:30 +0000 (UTC) From: Jon Maloy 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 Message-Id: <20230623022625.2631870-1-jmaloy@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: C5ELZNB5MO4L5BTPY27DNBQNHF2F67L4 X-Message-ID-Hash: C5ELZNB5MO4L5BTPY27DNBQNHF2F67L4 X-MailFrom: jmaloy@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- 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)) || -- 2.39.0