From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 20A90A00C2; Fri, 6 Jan 2023 19:57:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B741740141; Fri, 6 Jan 2023 19:57:07 +0100 (CET) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by mails.dpdk.org (Postfix) with ESMTP id 2D622400EF for ; Fri, 6 Jan 2023 19:57:06 +0100 (CET) Received: by mail-pj1-f50.google.com with SMTP id l1-20020a17090a384100b00226f05b9595so607080pjf.0 for ; Fri, 06 Jan 2023 10:57:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=laeEZaTZd3Bstva9sqPV0bCPLR6zuXASBsM0dWKzP+A=; b=ion79/G2phymNiSA1uMZGWywz5KK7dCwgCdokcsDaMroH+rXPl3LYTXa0irbdFzejc PrgmiSpQff3Vn2LQ9adkHuaQm/sMRT2vvkbUc/PTo+QY4+F2K8QfuodE/6dCC+c/AOLF lanvg4j/t8HjIifrz/Ut+c+p2MK5bXFF+1J8tQmLN7aIjvnh3LSBpNF4NDqRPs1CqKca ehCBg3QK8EF0yqnr/5qQAFnL0ES4nq+eGJTQr2Ocq4A7+IYoz+SReZAUWqdPjg/j9VPF P/MEjSNkK4StPCrdG2xni1Xop2FDmCpa7B27D5ITDR5f+vqTAEZ3Sc2/yR2XfVuS93+n kWqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=laeEZaTZd3Bstva9sqPV0bCPLR6zuXASBsM0dWKzP+A=; b=YRM4DTKhaUW61yXTH78RuTeHpKbpPZmJPlVbUuqm8tDLzG/bauAJbqLMinmXAB+8Cn L9kGzpTO2xmaaB2Cvfv4ANEzvj0oxNdjTpnkFGzYp9s8hGBf+SfBiTJBVtqJz6lChq3M sCbrDzXE9MpRcGgcFhff9/3sRzdGuWmpPnya0nkPtr3QT5OERSS/AjkUwiWavQmk+/va KQXNVW3GcWL2hENAnuqQj7xwWKQlUlPGCTKmVc/iriAsdSmbL426OZ+wLj4iedZe0BmW 92+nx3s1EWtedNAswoSw+dyNCkvyKVM+LyNn9+iBmTU9u0R1QX06AZ0WnsnUYqRsNa9F DMTg== X-Gm-Message-State: AFqh2kpCHxFnxwtyCbfBxPR1FhzVjBOdFovpf50LW8qGP81j1zQY1mmx QG1LcxUTYR9c6zjzf/rN2qGNUQ== X-Google-Smtp-Source: AMrXdXtnHDDWC/aplAOLWpgDNiRam7Z6bsDzP7Ihs2PCkANKj+L3g1TrMs/BnwfP7/9KLrvj8Q3FUA== X-Received: by 2002:a17:902:e789:b0:193:15bb:daff with SMTP id cp9-20020a170902e78900b0019315bbdaffmr1067992plb.16.1673031425036; Fri, 06 Jan 2023 10:57:05 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id j14-20020a170903024e00b00177f25f8ab3sm1293206plh.89.2023.01.06.10.57.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 10:57:04 -0800 (PST) Date: Fri, 6 Jan 2023 10:56:55 -0800 From: Stephen Hemminger To: Amit Prakash Shukla Cc: Jerin Jacob Kollanukkaran , Kiran Kumar Kokkilagadda , Nithin Kumar Dabilpuram , "dev@dpdk.org" Subject: Re: [EXT] Re: [RFC PATCH] graph: add support for pcap trace for graph Message-ID: <20230106105655.3eaa6129@hermes.local> In-Reply-To: References: <20221223120235.3171516-1-amitprakashs@marvell.com> <20221223084714.446ebc08@hermes.local> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 On Fri, 6 Jan 2023 10:40:30 +0000 Amit Prakash Shukla wrote: > Thanks Stephen for the review. Sure, will use lib/pcapng. > > I see dpdk libpcapng adds most of the debugging data, however I would like to add a node name to the packets which I am thinking of adding using 'comment' option under 'Enhanced Packet Block' . > > Please let me know if that's fine. > > Thanks, > Amit Shukla > > > -----Original Message----- > > From: Stephen Hemminger > > Sent: Friday, December 23, 2022 10:17 PM > > To: Amit Prakash Shukla > > Cc: Jerin Jacob Kollanukkaran ; Kiran Kumar > > Kokkilagadda ; Nithin Kumar Dabilpuram > > ; dev@dpdk.org > > Subject: [EXT] Re: [RFC PATCH] graph: add support for pcap trace for graph > > > > External Email > > > > ---------------------------------------------------------------------- > > On Fri, 23 Dec 2022 17:32:35 +0530 > > Amit Prakash Shukla wrote: > > > > > + > > > + pcap_trace.file_descriptor = open(pcap_trace.file_name, > > > + O_CREAT | O_TRUNC | O_WRONLY, > > 0664); > > > + if (pcap_trace.file_descriptor < 0) { > > > + ret = 1; > > > + goto done; > > > + } > > > + pcap_trace.n_pcap_data_written = 0; > > > + > > > + /* Write file header. */ > > > + memset(&file_hdr, 0, sizeof(file_hdr)); > > > + file_hdr.magic = 0xa1b2c3d4; > > > + file_hdr.major_version = 2; > > > + file_hdr.minor_version = 4; > > > + file_hdr.time_zone = 0; > > > + file_hdr.max_packet_size_in_bytes = ((1 << 16) - 1); > > > + file_hdr.packet_type = pcap_trace.packet_type; > > > + n = write(pcap_trace.file_descriptor, &file_hdr, sizeof(file_hdr)); > > > + if (n != sizeof(file_hdr)) { > > > + ret = 1; > > > + goto done; > > > + } > > > + > > > + while (pcap_trace.n_bytes > pcap_trace.n_pcap_data_written) { > > > + int n = pcap_trace.n_bytes - > > pcap_trace.n_pcap_data_written; > > > + > > > + n = write(pcap_trace.file_descriptor, > > > > NAK please use lib/pcapng rather than rolling your own pcap format code Something like this: diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c index cb590ea0096c..216ad80f7ed6 100644 --- a/lib/pcapng/rte_pcapng.c +++ b/lib/pcapng/rte_pcapng.c @@ -492,7 +492,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; @@ -552,6 +553,8 @@ rte_pcapng_copy(uint16_t port_id, uint32_t queue, optlen += pcapng_optlen(sizeof(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 *) @@ -590,6 +593,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 6b8aaffc6e0f..98f35e8ea177 100644 --- a/lib/pcapng/rte_pcapng.h +++ b/lib/pcapng/rte_pcapng.h @@ -126,6 +126,8 @@ enum rte_pcapng_direction { * The timestamp in TSC cycles. * @param direction * The direction of the packer: receive, transmit or unknown. + * @param comment + * Optional: comment on packet * * @return * - The pointer to the new mbuf formatted for pcapng_write @@ -137,7 +139,8 @@ 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); /**