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 0CE1942383; Wed, 11 Jan 2023 17:07:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E698940E25; Wed, 11 Jan 2023 17:07:14 +0100 (CET) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mails.dpdk.org (Postfix) with ESMTP id A38CC40A7D for ; Wed, 11 Jan 2023 17:07:13 +0100 (CET) Received: by mail-pj1-f53.google.com with SMTP id z1-20020a17090a66c100b00226f05b9595so2605638pjl.0 for ; Wed, 11 Jan 2023 08:07:13 -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=aXA8zbk4orI+wHM8AG/5jzEKQfBLCioMcqwNdM/AypU=; b=rtuY1YTDtnRmxycJtNYmXzwDQYer1nOdCrgk5Pck4CvLwvq/192Fa9yrlp3Egw1PZd kPNKdOqi3JOEhfsn/FZmVy6cSLhNCJH0MyjottJelFgmf+cACOsXepqi9BC65kUUGlo8 gI8Q5gB/5ZblKKy+oa3KRG/iH3Lg2mkx9QgdnL7zMCwpDNAKh+egM5oLAdWKA1LAjQxP 5ys3Ynv9y7Z1GEQNwEu3/yF76HRt9KD/6L7eR6tODDVbNTgo2vma58jZ5dC2+z55dUhz SpphWJYlw0r2+o/araWUTF0Fl8S/4KYz7vZkfzvNecNiIn4cNuBBHn+IkPtUa5P+gdmJ mAAQ== 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=aXA8zbk4orI+wHM8AG/5jzEKQfBLCioMcqwNdM/AypU=; b=Pumq1uMuydTG8O4X59l1VWM4jyFtZEiQxANSoRKh7SdYVVSl6zjZYzzHFUrc9yHyip 8hCB/8yyxQsZKG5VQFDnTp/EInKoCSLxAVzTOGVj82o/9K6Afo3ORCnpkJQHRnOHDXst 5MgBjH6nzGoT29n3diczDOggqUu+lln/AG1iWvzDXvlCjjMGGcBbuKkMk5XZE2kaHNgr KD+X+GHYGIpRXBTB4AXPtL++mddzag5ytKwtEhNIwpmPiwPURY+EGSfPKGDPmNJyrfW+ CFt7s9v2GLdyxEFLeJsbU8f1w6TdPOGqtgItYFgiTeaHHR9gzoW7zxqSlRK5uweGi3VI oUSg== X-Gm-Message-State: AFqh2kqWkkhou5Nq3u9V8zS3Ucu9IEMjdNNb+2BI4I5Z1GH6pnOP+Kyf iYU7U1Jmje65bp7fAMnkhVEi/Q== X-Google-Smtp-Source: AMrXdXv5iBMSvi4+kqslI54Yp1hTRYZY6s5wHueINXTQRXPeL9BLZkH1evW8geT0pzXNqTpKxjpxIw== X-Received: by 2002:a17:902:e483:b0:192:94c4:f98b with SMTP id i3-20020a170902e48300b0019294c4f98bmr44747670ple.64.1673453232710; Wed, 11 Jan 2023 08:07:12 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id im22-20020a170902bb1600b00192c7f19778sm10353731plb.31.2023.01.11.08.07.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 08:07:12 -0800 (PST) Date: Wed, 11 Jan 2023 08:07:10 -0800 From: Stephen Hemminger To: Amit Prakash Shukla Cc: Jerin Jacob , Kiran Kumar K , Nithin Dabilpuram , Subject: Re: [PATCH v2 2/3] graph: pcap capture for graph nodes Message-ID: <20230111080710.0a6f1fb8@hermes.local> In-Reply-To: <20230111085343.2058993-2-amitprakashs@marvell.com> References: <20230110115847.1965096-1-amitprakashs@marvell.com> <20230111085343.2058993-1-amitprakashs@marvell.com> <20230111085343.2058993-2-amitprakashs@marvell.com> 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 Wed, 11 Jan 2023 14:23:41 +0530 Amit Prakash Shukla wrote: > + > +#define PCAP_DUMP_DATA(dbuf, buf_size, cur_len, sbuf, len) \ > +do { \ > + if ((cur_len + len) >= buf_size) \ > + break; \ > + rte_memcpy(dbuf + cur_len, sbuf, len); \ > + cur_len += len; \ > +} while (0) > + Why do you need this to be a macro. Macro's are evil, have side effects and hide code. > +uint16_t > +rte_graph_pcap_trace_dispatch(struct rte_graph *graph __rte_unused, > + struct rte_node *node, void **objs, > + uint16_t nb_objs) > +{ > + uint64_t i, num_packets; > + struct rte_mbuf *mbuf_clones[RTE_GRAPH_BURST_SIZE] = { }; > + char buffer[GRAPH_PCAP_BUF_SZ] = {0}; The initialization probably is not needed here. Couldn't you just do: rte_strlcpy(buffer, node->name, GRAPH_PCAP_BUF_SZ); > + for (i = 0; i < num_packets; i++) { > + struct rte_mbuf *mc; > + mbuf = (struct rte_mbuf *)objs[i]; > + > + mc = rte_pcapng_copy(port_id, 0, mbuf, mp, mbuf->pkt_len, > + rte_get_tsc_cycles(), 0, buffer); > + if (mc == NULL) > + goto done; The code will leak mbuf's if pcapng_copy() fails. Suppose packet #2 caused the pool to get exhausted. That copy would fail, but the mbuf for packets 0 and 1 would already be sitting in mbuf_clones. > + > + mbuf_clones[i] = mc; > + }