DPDK patches and discussions
 help / color / mirror / Atom feed
From: Amit Prakash Shukla <amitprakashs@marvell.com>
To: Reshma Pattan <reshma.pattan@intel.com>,
	Stephen Hemminger <stephen@networkplumber.org>
Cc: <dev@dpdk.org>, <jerinj@marvell.com>,
	Amit Prakash Shukla <amitprakashs@marvell.com>
Subject: [PATCH v3 1/3] pcapng: comment option support for epb
Date: Thu, 12 Jan 2023 15:31:04 +0530	[thread overview]
Message-ID: <20230112100106.2180665-1-amitprakashs@marvell.com> (raw)
In-Reply-To: <20230111085343.2058993-1-amitprakashs@marvell.com>

This change enhances rte_pcapng_copy to have comment in enhanced
packet block.

Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>
---
v2:
 - Fixed code style issue
 - Fixed CI compilation issue on github-robot

v3:
 - Code review suggestion from Stephen
 - Fixed potential memory leak
 
 app/test/test_pcapng.c  |  4 ++--
 lib/pcapng/rte_pcapng.c | 10 +++++++++-
 lib/pcapng/rte_pcapng.h |  4 +++-
 lib/pdump/rte_pdump.c   |  2 +-
 4 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/app/test/test_pcapng.c b/app/test/test_pcapng.c
index a7acbdc058..303d3d66f9 100644
--- a/app/test/test_pcapng.c
+++ b/app/test/test_pcapng.c
@@ -139,7 +139,7 @@ test_write_packets(void)
 		struct rte_mbuf *mc;
 
 		mc = rte_pcapng_copy(port_id, 0, orig, mp, pkt_len,
-				rte_get_tsc_cycles(), 0);
+				rte_get_tsc_cycles(), 0, NULL);
 		if (mc == NULL) {
 			fprintf(stderr, "Cannot copy packet\n");
 			return -1;
@@ -255,7 +255,7 @@ test_write_over_limit_iov_max(void)
 		struct rte_mbuf *mc;
 
 		mc = rte_pcapng_copy(port_id, 0, orig, mp, pkt_len,
-				rte_get_tsc_cycles(), 0);
+				rte_get_tsc_cycles(), 0, NULL);
 		if (mc == NULL) {
 			fprintf(stderr, "Cannot copy packet\n");
 			return -1;
diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
index 80d08e1a3b..acb31a9d93 100644
--- a/lib/pcapng/rte_pcapng.c
+++ b/lib/pcapng/rte_pcapng.c
@@ -450,7 +450,8 @@ rte_pcapng_copy(uint16_t port_id, uint32_t queue,
 		const struct rte_mbuf *md,
 		struct rte_mempool *mp,
 		uint32_t length, uint64_t cycles,
-		enum rte_pcapng_direction direction)
+		enum rte_pcapng_direction direction,
+		const char *comment)
 {
 	struct pcapng_enhance_packet_block *epb;
 	uint32_t orig_len, data_len, padding, flags;
@@ -511,6 +512,9 @@ rte_pcapng_copy(uint16_t port_id, uint32_t queue,
 	if (rss_hash)
 		optlen += pcapng_optlen(sizeof(uint8_t) + sizeof(uint32_t));
 
+	if (comment)
+		optlen += pcapng_optlen(strlen(comment));
+
 	/* reserve trailing options and block length */
 	opt = (struct pcapng_option *)
 		rte_pktmbuf_append(mc, optlen + sizeof(uint32_t));
@@ -548,6 +552,10 @@ rte_pcapng_copy(uint16_t port_id, uint32_t queue,
 					&hash_opt, sizeof(hash_opt));
 	}
 
+	if (comment)
+		opt = pcapng_add_option(opt, PCAPNG_OPT_COMMENT, comment,
+					strlen(comment));
+
 	/* Note: END_OPT necessary here. Wireshark doesn't do it. */
 
 	/* Add PCAPNG packet header */
diff --git a/lib/pcapng/rte_pcapng.h b/lib/pcapng/rte_pcapng.h
index 7d2697c647..6d286cda41 100644
--- a/lib/pcapng/rte_pcapng.h
+++ b/lib/pcapng/rte_pcapng.h
@@ -100,6 +100,8 @@ enum rte_pcapng_direction {
  *   The timestamp in TSC cycles.
  * @param direction
  *   The direction of the packer: receive, transmit or unknown.
+ * @param comment
+ *   Packet comment.
  *
  * @return
  *   - The pointer to the new mbuf formatted for pcapng_write
@@ -111,7 +113,7 @@ struct rte_mbuf *
 rte_pcapng_copy(uint16_t port_id, uint32_t queue,
 		const struct rte_mbuf *m, struct rte_mempool *mp,
 		uint32_t length, uint64_t timestamp,
-		enum rte_pcapng_direction direction);
+		enum rte_pcapng_direction direction, const char *comment);
 
 
 /**
diff --git a/lib/pdump/rte_pdump.c b/lib/pdump/rte_pdump.c
index a81544cb57..9bc4bab4f2 100644
--- a/lib/pdump/rte_pdump.c
+++ b/lib/pdump/rte_pdump.c
@@ -122,7 +122,7 @@ pdump_copy(uint16_t port_id, uint16_t queue,
 		if (cbs->ver == V2)
 			p = rte_pcapng_copy(port_id, queue,
 					    pkts[i], mp, cbs->snaplen,
-					    ts, direction);
+					    ts, direction, NULL);
 		else
 			p = rte_pktmbuf_copy(pkts[i], mp, 0, cbs->snaplen);
 
-- 
2.25.1


  parent reply	other threads:[~2023-01-12 10:01 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-23 12:02 [RFC PATCH] graph: add support for pcap trace for graph Amit Prakash Shukla
2022-12-23 16:47 ` Stephen Hemminger
2023-01-06 10:40   ` [EXT] " Amit Prakash Shukla
2023-01-06 16:41     ` Stephen Hemminger
2023-01-06 18:56     ` Stephen Hemminger
2023-01-10 11:26       ` Amit Prakash Shukla
2023-01-10 11:58 ` [PATCH v1 1/3] pcapng: comment option support for epb Amit Prakash Shukla
2023-01-10 11:58   ` [PATCH v1 2/3] graph: pcap capture for graph nodes Amit Prakash Shukla
2023-01-10 11:58   ` [PATCH v1 3/3] l3fwd-graph: changes to configure pcap capture Amit Prakash Shukla
2023-01-10 17:05   ` [PATCH v1 1/3] pcapng: comment option support for epb Stephen Hemminger
2023-01-11  8:53   ` [PATCH v2 " Amit Prakash Shukla
2023-01-11  8:53     ` [PATCH v2 2/3] graph: pcap capture for graph nodes Amit Prakash Shukla
2023-01-11 16:07       ` Stephen Hemminger
2023-01-12  9:57         ` [EXT] " Amit Prakash Shukla
2023-01-12 16:30           ` Stephen Hemminger
2023-01-19 14:37             ` Amit Prakash Shukla
2023-01-19 16:48               ` Stephen Hemminger
2023-01-11  8:53     ` [PATCH v2 3/3] l3fwd-graph: changes to configure pcap capture Amit Prakash Shukla
2023-01-12 10:01     ` Amit Prakash Shukla [this message]
2023-01-12 10:01       ` [PATCH v3 2/3] graph: pcap capture for graph nodes Amit Prakash Shukla
2023-01-12 12:18         ` Jerin Jacob
2023-01-19 14:21           ` [EXT] " Amit Prakash Shukla
2023-01-12 10:01       ` [PATCH v3 3/3] l3fwd-graph: changes to configure pcap capture Amit Prakash Shukla
2023-01-24 11:21       ` [PATCH v4 1/3] pcapng: comment option support for epb Amit Prakash Shukla
2023-01-24 11:21         ` [PATCH v4 2/3] graph: pcap capture for graph nodes Amit Prakash Shukla
2023-01-31  8:06           ` Jerin Jacob
2023-02-03  8:15             ` [EXT] " Amit Prakash Shukla
2023-01-24 11:21         ` [PATCH v4 3/3] l3fwd-graph: changes to configure pcap capture Amit Prakash Shukla
2023-01-31  8:14           ` Jerin Jacob
2023-02-03  8:16             ` [EXT] " Amit Prakash Shukla
2023-02-03  8:19         ` [PATCH v5 1/3] pcapng: comment option support for epb Amit Prakash Shukla
2023-02-03  8:19           ` [PATCH v5 2/3] graph: pcap capture for graph nodes Amit Prakash Shukla
2023-02-09  9:12             ` David Marchand
2023-02-09  9:29               ` [EXT] " Amit Prakash Shukla
2023-02-03  8:19           ` [PATCH v5 3/3] examples/l3fwd-graph: changes to configure pcap capture Amit Prakash Shukla
2023-02-09  9:13           ` [PATCH v5 1/3] pcapng: comment option support for epb David Marchand
2023-02-09 16:48             ` Stephen Hemminger
2023-02-09  9:56           ` [PATCH v6 1/4] " Amit Prakash Shukla
2023-02-09  9:56             ` [PATCH v6 2/4] graph: pcap capture for graph nodes Amit Prakash Shukla
2023-02-09  9:56             ` [PATCH v6 3/4] examples/l3fwd-graph: changes to configure pcap capture Amit Prakash Shukla
2023-02-09  9:56             ` [PATCH v6 4/4] test/graph: initialize graph param variable Amit Prakash Shukla
2023-02-09 10:03             ` [PATCH v6 1/4] pcapng: comment option support for epb Amit Prakash Shukla
2023-02-09 10:24             ` [PATCH v7 1/3] " Amit Prakash Shukla
2023-02-09 10:24               ` [PATCH v7 2/3] graph: pcap capture for graph nodes Amit Prakash Shukla
2023-02-09 10:24               ` [PATCH v7 3/3] examples/l3fwd-graph: changes to configure pcap capture Amit Prakash Shukla
2023-02-09 17:28                 ` Jerin Jacob
2023-02-10 12:18                   ` David Marchand

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=20230112100106.2180665-1-amitprakashs@marvell.com \
    --to=amitprakashs@marvell.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=reshma.pattan@intel.com \
    --cc=stephen@networkplumber.org \
    /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.
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).