DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] PCAP PMD fix: pcap_rx_queue/pcap_tx_queue should store it's own copy of name/type values
@ 2015-04-23 14:32 Konstantin Ananyev
  2015-04-28 14:06 ` Mcnamara, John
  0 siblings, 1 reply; 3+ messages in thread
From: Konstantin Ananyev @ 2015-04-23 14:32 UTC (permalink / raw)
  To: konstantin.ananyev, dev

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 <konstantin.ananyev@intel.com>
---
 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] PCAP PMD fix: pcap_rx_queue/pcap_tx_queue should store it's own copy of name/type values
  2015-04-23 14:32 [dpdk-dev] [PATCH] PCAP PMD fix: pcap_rx_queue/pcap_tx_queue should store it's own copy of name/type values Konstantin Ananyev
@ 2015-04-28 14:06 ` Mcnamara, John
  2015-05-12 10:30   ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Mcnamara, John @ 2015-04-28 14:06 UTC (permalink / raw)
  To: Ananyev, Konstantin, Ananyev, Konstantin, dev



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Konstantin Ananyev
> Sent: Thursday, April 23, 2015 3:33 PM
> To: Ananyev, Konstantin; dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] PCAP PMD fix: pcap_rx_queue/pcap_tx_queue
> should store it's own copy of name/type values
> 
> 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 <konstantin.ananyev@intel.com>


Acked-by: John Mcnamara <john.mcnamara@intel.com>

-- 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] PCAP PMD fix: pcap_rx_queue/pcap_tx_queue should store it's own copy of name/type values
  2015-04-28 14:06 ` Mcnamara, John
@ 2015-05-12 10:30   ` Thomas Monjalon
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2015-05-12 10:30 UTC (permalink / raw)
  To: Ananyev, Konstantin; +Cc: dev

> > 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 <konstantin.ananyev@intel.com>
> 
> Acked-by: John Mcnamara <john.mcnamara@intel.com>

Applied, thanks

Please note the new name for this commit:
	pcap: fix storage of name and type in queues
It begins with the lowercase name of the PMD,
then a verb in imperative form and a short summary.
The verb should be "fix" in case of fixes.
Ideally, the bug (and its consequences) should be explained below.

https://github.com/erlang/otp/wiki/Writing-good-commit-messages

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-12 10:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-23 14:32 [dpdk-dev] [PATCH] PCAP PMD fix: pcap_rx_queue/pcap_tx_queue should store it's own copy of name/type values Konstantin Ananyev
2015-04-28 14:06 ` Mcnamara, John
2015-05-12 10:30   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).