From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 1A08C1BB51 for ; Fri, 27 Oct 2017 02:24:03 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Oct 2017 17:24:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,302,1505804400"; d="scan'208";a="914236601" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.24.13.44]) ([10.24.13.44]) by FMSMGA003.fm.intel.com with ESMTP; 26 Oct 2017 17:24:02 -0700 To: Stefan Baranoff , dev@dpdk.org References: From: Ferruh Yigit Message-ID: <046bab26-6128-f220-34e9-d5806976e47e@intel.com> Date: Thu, 26 Oct 2017 17:24:01 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] Fwd: Memory Leak: PCAP TX to File X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2017 00:24:04 -0000 On 10/26/2017 10:44 AM, Stefan Baranoff wrote: > All, > > I think I've found a (very minor) memory leak in writing to a PCAP file. In > drivers/net/pcap/rte_eth_pcap.c in open_single_tx_pcap around line 405 a > pcap_t is allocated by pcap_open_dead but is never freed. You are right. > I see two obvious fixes: > 1) Free the pcap_t immediately after either on pcap_dump_open success or > failure > 2) Set the pcap_t pointer internals->tx_queue[i]->tx->pcap so when the > eth_dev_stop callback happens the pcap_t is freed. Option 2 looks more proper, since eth_dev_stop() calls pcap_close() which frees the pcap_t, so nothing special requires to cover the case, But :), open_single_tx_pcap() doesn't returns pcap_t back, so this function and functions using this needs to be updated. I believe doesn't worth to this update and as far as I can see freeing pcap_t immediately is safe, So I would suggest lets go with option 1, it is simpler change. Would you mind providing patch for this fix? Thanks, ferruh > > I believe the first is safe but am not a libpcap guru. Can someone please > confirm this? > > > Thanks, > Stefan >