public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: passt-dev@passt.top
Cc: Laurent Vivier <lvivier@redhat.com>,
	David Gibson <david@gibson.dropbear.id.au>
Subject: [PATCH v5 2/5] pcap: Add an offset argument in pcap_iov()
Date: Fri, 27 Sep 2024 15:53:46 +0200	[thread overview]
Message-ID: <20240927135349.675850-3-lvivier@redhat.com> (raw)
In-Reply-To: <20240927135349.675850-1-lvivier@redhat.com>

The offset is passed directly to pcap_frame() and allows
any headers that are not part of the frame to
capture to be skipped.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
---
 pcap.c | 5 +++--
 pcap.h | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/pcap.c b/pcap.c
index e6b5ced4a9f8..6ee6cdfd261a 100644
--- a/pcap.c
+++ b/pcap.c
@@ -138,9 +138,10 @@ void pcap_multiple(const struct iovec *iov, size_t frame_parts, unsigned int n,
  * @iov:	Pointer to the array of struct iovec describing the I/O vector
  *		containing packet data to write, including L2 header
  * @iovcnt:	Number of buffers (@iov entries)
+ * @offset:	Offset of the L2 frame within the full data length
  */
 /* cppcheck-suppress unusedFunction */
-void pcap_iov(const struct iovec *iov, size_t iovcnt)
+void pcap_iov(const struct iovec *iov, size_t iovcnt, size_t offset)
 {
 	struct timespec now;
 
@@ -148,7 +149,7 @@ void pcap_iov(const struct iovec *iov, size_t iovcnt)
 		return;
 
 	clock_gettime(CLOCK_REALTIME, &now);
-	pcap_frame(iov, iovcnt, 0, &now);
+	pcap_frame(iov, iovcnt, offset, &now);
 }
 
 /**
diff --git a/pcap.h b/pcap.h
index 533923749222..9795f2e8adc5 100644
--- a/pcap.h
+++ b/pcap.h
@@ -9,7 +9,7 @@
 void pcap(const char *pkt, size_t l2len);
 void pcap_multiple(const struct iovec *iov, size_t frame_parts, unsigned int n,
 		   size_t offset);
-void pcap_iov(const struct iovec *iov, size_t iovcnt);
+void pcap_iov(const struct iovec *iov, size_t iovcnt, size_t offset);
 void pcap_init(struct ctx *c);
 
 #endif /* PCAP_H */
-- 
@@ -9,7 +9,7 @@
 void pcap(const char *pkt, size_t l2len);
 void pcap_multiple(const struct iovec *iov, size_t frame_parts, unsigned int n,
 		   size_t offset);
-void pcap_iov(const struct iovec *iov, size_t iovcnt);
+void pcap_iov(const struct iovec *iov, size_t iovcnt, size_t offset);
 void pcap_init(struct ctx *c);
 
 #endif /* PCAP_H */
-- 
2.46.0


  parent reply	other threads:[~2024-09-27 13:54 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-27 13:53 [PATCH v5 0/5] tcp: use csum_iov() in tcp_update_check_tcp[4|6]() Laurent Vivier
2024-09-27 13:53 ` [PATCH v5 1/5] tcp: Use tcp_payload_t rather than tcphdr Laurent Vivier
2024-09-27 13:53 ` Laurent Vivier [this message]
2024-09-27 13:53 ` [PATCH v5 3/5] checksum: Add an offset argument in csum_iov() Laurent Vivier
2024-09-30  2:51   ` David Gibson
2024-09-27 13:53 ` [PATCH v5 4/5] tcp: Update TCP checksum using an iovec array Laurent Vivier
2024-09-30  2:56   ` David Gibson
2024-10-01  7:29   ` Stefano Brivio
2024-10-01 18:22     ` Stefano Brivio
2024-10-02  7:39       ` Laurent Vivier
2024-10-02  9:00         ` Stefano Brivio
2024-10-03 12:58           ` Laurent Vivier
2024-09-27 13:53 ` [PATCH v5 5/5] udp: Update UDP " Laurent Vivier
2024-09-30  2:58   ` David Gibson
2024-10-02 14:32 ` [PATCH v5 0/5] tcp: use csum_iov() in tcp_update_check_tcp[4|6]() Stefano Brivio
2024-10-02 14:46   ` Stefano Brivio

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=20240927135349.675850-3-lvivier@redhat.com \
    --to=lvivier@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    /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).