From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 8C99911C5 for ; Thu, 23 Apr 2015 16:36:36 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 23 Apr 2015 07:35:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,631,1422950400"; d="scan'208";a="684554143" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 23 Apr 2015 07:35:44 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t3NEZh1b026206; Thu, 23 Apr 2015 15:35:43 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id t3NEZh1J020328; Thu, 23 Apr 2015 15:35:43 +0100 Received: (from kananye1@localhost) by sivswdev02.ir.intel.com with id t3NEZgjU020316; Thu, 23 Apr 2015 15:35:42 +0100 From: Konstantin Ananyev To: konstantin.ananyev@intel.com, dev@dpdk.org Date: Thu, 23 Apr 2015 15:32:48 +0100 Message-Id: <1429799568-19899-1-git-send-email-konstantin.ananyev@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] PCAP PMD fix: pcap_rx_queue/pcap_tx_queue should store it's own copy of name/type values X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Apr 2015 14:36:37 -0000 pcap_rx_queue/pcap_tx_queue should store it's own copy of name/type values, not the pointer to temporary allocated space. Signed-off-by: Konstantin Ananyev --- lib/librte_pmd_pcap/rte_eth_pcap.c | 51 +++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/lib/librte_pmd_pcap/rte_eth_pcap.c b/lib/librte_pmd_pcap/rte_eth_pcap.c index e5d2279..a5ede05 100644 --- a/lib/librte_pmd_pcap/rte_eth_pcap.c +++ b/lib/librte_pmd_pcap/rte_eth_pcap.c @@ -56,6 +56,8 @@ #define ETH_PCAP_TX_IFACE_ARG "tx_iface" #define ETH_PCAP_IFACE_ARG "iface" +#define ETH_PCAP_ARG_MAXLEN 64 + static char errbuf[PCAP_ERRBUF_SIZE]; static struct timeval start_time; static uint64_t start_cycles; @@ -67,8 +69,8 @@ struct pcap_rx_queue { struct rte_mempool *mb_pool; volatile unsigned long rx_pkts; volatile unsigned long err_pkts; - const char *name; - const char *type; + char name[PATH_MAX]; + char type[ETH_PCAP_ARG_MAXLEN]; }; struct pcap_tx_queue { @@ -76,8 +78,8 @@ struct pcap_tx_queue { pcap_t *pcap; volatile unsigned long tx_pkts; volatile unsigned long err_pkts; - const char *name; - const char *type; + char name[PATH_MAX]; + char type[ETH_PCAP_ARG_MAXLEN]; }; struct rx_pcaps { @@ -792,14 +794,22 @@ rte_eth_from_pcaps_n_dumpers(const char *name, return -1; for (i = 0; i < nb_rx_queues; i++) { - internals->rx_queue->pcap = rx_queues->pcaps[i]; - internals->rx_queue->name = rx_queues->names[i]; - internals->rx_queue->type = rx_queues->types[i]; + internals->rx_queue[i].pcap = rx_queues->pcaps[i]; + snprintf(internals->rx_queue[i].name, + sizeof(internals->rx_queue[i].name), "%s", + rx_queues->names[i]); + snprintf(internals->rx_queue[i].type, + sizeof(internals->rx_queue[i].type), "%s", + rx_queues->types[i]); } for (i = 0; i < nb_tx_queues; i++) { - internals->tx_queue->dumper = tx_queues->dumpers[i]; - internals->tx_queue->name = tx_queues->names[i]; - internals->tx_queue->type = tx_queues->types[i]; + internals->tx_queue[i].dumper = tx_queues->dumpers[i]; + snprintf(internals->tx_queue[i].name, + sizeof(internals->tx_queue[i].name), "%s", + tx_queues->names[i]); + snprintf(internals->tx_queue[i].type, + sizeof(internals->tx_queue[i].type), "%s", + tx_queues->types[i]); } /* using multiple pcaps/interfaces */ @@ -811,7 +821,6 @@ rte_eth_from_pcaps_n_dumpers(const char *name, return 0; } - struct rx_pcaps pcaps; static int rte_eth_from_pcaps(const char *name, struct rx_pcaps *rx_queues, @@ -837,14 +846,22 @@ rte_eth_from_pcaps(const char *name, return -1; for (i = 0; i < nb_rx_queues; i++) { - internals->rx_queue->pcap = rx_queues->pcaps[i]; - internals->rx_queue->name = rx_queues->names[i]; - internals->rx_queue->type = rx_queues->types[i]; + internals->rx_queue[i].pcap = rx_queues->pcaps[i]; + snprintf(internals->rx_queue[i].name, + sizeof(internals->rx_queue[i].name), "%s", + rx_queues->names[i]); + snprintf(internals->rx_queue[i].type, + sizeof(internals->rx_queue[i].type), "%s", + rx_queues->types[i]); } for (i = 0; i < nb_tx_queues; i++) { - internals->tx_queue->pcap = tx_queues->pcaps[i]; - internals->tx_queue->name = tx_queues->names[i]; - internals->tx_queue->type = tx_queues->types[i]; + internals->tx_queue[i].dumper = tx_queues->dumpers[i]; + snprintf(internals->tx_queue[i].name, + sizeof(internals->tx_queue[i].name), "%s", + tx_queues->names[i]); + snprintf(internals->tx_queue[i].type, + sizeof(internals->tx_queue[i].type), "%s", + tx_queues->types[i]); } /* store wether we are using a single interface for rx/tx or not */ -- 1.8.3.1