From patchwork Thu Feb 9 10:24:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Prakash Shukla X-Patchwork-Id: 123575 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3EBB841C4D; Thu, 9 Feb 2023 11:24:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 259474067B; Thu, 9 Feb 2023 11:24:44 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id ACFBB400D5 for ; Thu, 9 Feb 2023 11:24:42 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3199IWh8000545; Thu, 9 Feb 2023 02:24:41 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=gEnic19oUohU93hgGoc1T9fLHnhNiV9Qi7uQhgQjmok=; b=edYoATXg9XkO+qyHe3+UUCDgFOFmVplYJ9AY8fxzi4ti4q9fNUDDdG0LaDk7KpL8HqzV zpJCbNaTG7OER1c21PA6P3TttE0zdLmZ1ngYXkN66fkr2q7fXt2TbNYRBlkSknixDda0 X81OgNwwXlb1+DRMcKYdHyz/lXVjBvQz/F7T3bSFVw1U3bPGQH72kLymujLqtIKINN5n BxKYRjb4en9BY5SL61oM1I7+gfc77aUU5XPogYWvUKXoSO2TV2byo48Ld9WkZUQQ0TjI QAjLkpr5efRgjR2Wv29Xt5EyPRtVNhofJ+KW/8657hCYydgI08oaI6n4tkPmc8mogSal rg== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3nkdys0veb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 09 Feb 2023 02:24:41 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 9 Feb 2023 02:24:40 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Thu, 9 Feb 2023 02:24:39 -0800 Received: from localhost.localdomain (unknown [10.28.36.157]) by maili.marvell.com (Postfix) with ESMTP id 015205B692A; Thu, 9 Feb 2023 02:24:37 -0800 (PST) From: Amit Prakash Shukla To: Reshma Pattan , Stephen Hemminger CC: , , , "Amit Prakash Shukla" Subject: [PATCH v7 1/3] pcapng: comment option support for epb Date: Thu, 9 Feb 2023 15:54:32 +0530 Message-ID: <20230209102434.2460394-1-amitprakashs@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230209095614.2459659-1-amitprakashs@marvell.com> References: <20230209095614.2459659-1-amitprakashs@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 3xmm9vWWvADTNjX2mp95Rrhr0oCLxgkJ X-Proofpoint-GUID: 3xmm9vWWvADTNjX2mp95Rrhr0oCLxgkJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-09_08,2023-02-08_02,2022-06-22_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This change enhances rte_pcapng_copy to have comment in enhanced packet block. Signed-off-by: Amit Prakash Shukla --- v2: - Fixed code style issue - Fixed CI compilation issue on github-robot v3: - Code review suggestion from Stephen - Fixed potential memory leak v4: - Code review suggestion from Jerin v5: - Code review suggestion from Jerin v6: - Squashing test graph param initialize fix v7: - Resending the patch app/test/test_pcapng.c | 4 ++-- doc/guides/rel_notes/release_23_03.rst | 2 ++ lib/pcapng/rte_pcapng.c | 10 +++++++++- lib/pcapng/rte_pcapng.h | 4 +++- lib/pdump/rte_pdump.c | 2 +- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/test/test_pcapng.c b/app/test/test_pcapng.c index edba46d1fe..b8429a02f1 100644 --- a/app/test/test_pcapng.c +++ b/app/test/test_pcapng.c @@ -146,7 +146,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; @@ -262,7 +262,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/doc/guides/rel_notes/release_23_03.rst b/doc/guides/rel_notes/release_23_03.rst index 1fa101c420..bb435dde32 100644 --- a/doc/guides/rel_notes/release_23_03.rst +++ b/doc/guides/rel_notes/release_23_03.rst @@ -116,6 +116,8 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* Experimental function ``rte_pcapng_copy`` was updated to support comment + section in enhanced packet block in pcapng library. ABI Changes ----------- diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c index ea004939e6..65c8c77fa4 100644 --- a/lib/pcapng/rte_pcapng.c +++ b/lib/pcapng/rte_pcapng.c @@ -466,7 +466,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; @@ -527,6 +528,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)); @@ -564,6 +568,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 86b7996e29..4afdec22ef 100644 --- a/lib/pcapng/rte_pcapng.h +++ b/lib/pcapng/rte_pcapng.h @@ -125,6 +125,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 @@ -136,7 +138,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);