From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by dpdk.org (Postfix) with ESMTP id 068B298 for ; Tue, 24 Jul 2018 18:08:55 +0200 (CEST) Received: by mail-wr1-f66.google.com with SMTP id h10-v6so4705000wre.6 for ; Tue, 24 Jul 2018 09:08:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5YMcYVYNx6jbgWtC+D+gVTdipuro/MpUhvDCnl9Jfio=; b=P6ODXar2ZvaIESVMHyngH7QJxSRZ3LDVfx6vE+ldjXaE6MVGOusqd6maRzVMo07bHw 67hNH2U8XEwy3lh0A6ZcIuCNmVand6OEwZ8nzR6By3j1G23fy1a1ov2nosNWsiCLOkGM acp+XhUibY5pFadhe7CUe9V9WD2u1ZN4zH/rVgGkxNUewFO4KMuyzlxeUx7JWjjIktI0 RuPsYtMu4oIcm/7Rroo2MLGHSdfK5ctwZSUSX1Tp0Jw7jM69EzVzTxkebKAMc9qmRaET 7cdXnjpIwI0kbd1Y7GR2/otz9qOmXd+oZ0KPcgWbkLn8AchtSUfoRWiFxW4B98t2PDPW SUvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5YMcYVYNx6jbgWtC+D+gVTdipuro/MpUhvDCnl9Jfio=; b=Z6dvPM76oaTGourSZiAFp7KI6JC7kxJlDRBpDVkOrQmKvtexDNjpgN07x4Cj2lt2eZ a0sLzcmxfCcOiDLHBVQqNmRYxsJaHZNUh1QNBbsZjpwjbY9U/FbUNppXK8Om/2tHJ0qQ W+KD65VDjwZejQZz1HCmZ10iibjd6b0M35HbeOJqoxoa2hujKWZYjPq+Frp0aoW/HT5t FduBre09AuVBKqvLyy116jkdGKk05pw5W/zVWhEtZTQAPJAfVb818IezMQExEVF7CXdF +TooEvoDPRimHA4gSHKVSHBG/l9PdLpjuW6Tvz26cR08gBthDgBy5REmojpQI3gMawLh 7ESg== X-Gm-Message-State: AOUpUlEVORX4nNJLCd2WOPnsiMDMaKFcfmDUMvFvL2T1XZ4INxgXC4uP J2P8YgQk62Qg+UW17qTJBv9i3badhWw= X-Google-Smtp-Source: AAOMgpckLVaWY6OtGLeQL/+ySJDjSzWY+du5FgerwKLKHafq1yRx/eaAI4UlB8ROjCDrtpPE6CzP0A== X-Received: by 2002:adf:8325:: with SMTP id 34-v6mr11746542wrd.67.1532448534774; Tue, 24 Jul 2018 09:08:54 -0700 (PDT) Received: from localhost ([2a00:23c5:be94:4600:7b12:f8a0:fd52:f87d]) by smtp.gmail.com with ESMTPSA id o10-v6sm11149890wrw.79.2018.07.24.09.08.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Jul 2018 09:08:53 -0700 (PDT) From: luca.boccassi@gmail.com To: Ido Goshen Cc: Ferruh Yigit , dpdk stable Date: Tue, 24 Jul 2018 17:07:35 +0100 Message-Id: <20180724160752.20287-17-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180724160752.20287-1-luca.boccassi@gmail.com> References: <20180724160752.20287-1-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'net/pcap: fix multiple queues' has been queued to LTS release 16.11.8 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Jul 2018 16:08:55 -0000 Hi, FYI, your patch has been queued to LTS release 16.11.8 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/26/18. So please shout if anyone has objections. Thanks. Luca Boccassi --- >>From 30756d9baf3aa68250881f29ec1eea2362c1aa3c Mon Sep 17 00:00:00 2001 From: Ido Goshen Date: Tue, 19 Jun 2018 17:37:25 +0300 Subject: [PATCH] net/pcap: fix multiple queues [ upstream commit 8ffda7673fa71e6a666963fc0ea4969d65dd09da ] Change open_rx/tx_pcap/iface functions to open only a single pcap/dumper and not loop num_of_queue times The num_of_queue loop is already achieved by the caller rte_kvargs_process Fixing: 1. Opens N requested pcaps/dumpers instead of N^2 2. Leak of pcap/dumper's which are being overwritten by the sequential calls to open_rx/tx_pcap/iface functions 3. Use the filename/iface args per queue and not just the last one that overwrites the previous names Fixes: 4c173302c307 ("pcap: add new driver") Signed-off-by: Ido Goshen Acked-by: Ferruh Yigit --- drivers/net/pcap/rte_eth_pcap.c | 86 ++++++++++++++------------------- 1 file changed, 36 insertions(+), 50 deletions(-) diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index 27590d39d..deca553ee 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -687,19 +687,19 @@ static const struct eth_dev_ops ops = { static int open_rx_pcap(const char *key, const char *value, void *extra_args) { - unsigned int i; const char *pcap_filename = value; struct pmd_devargs *rx = extra_args; pcap_t *pcap = NULL; - for (i = 0; i < rx->num_of_queue; i++) { - if (open_single_rx_pcap(pcap_filename, &pcap) < 0) - return -1; + if (rx->num_of_queue >= RTE_PMD_PCAP_MAX_QUEUES) + return -1; + if (open_single_rx_pcap(pcap_filename, &pcap) < 0) + return -1; - rx->queue[i].pcap = pcap; - rx->queue[i].name = pcap_filename; - rx->queue[i].type = key; - } + rx->queue[rx->num_of_queue].pcap = pcap; + rx->queue[rx->num_of_queue].name = pcap_filename; + rx->queue[rx->num_of_queue].type = key; + rx->num_of_queue++; return 0; } @@ -711,19 +711,19 @@ open_rx_pcap(const char *key, const char *value, void *extra_args) static int open_tx_pcap(const char *key, const char *value, void *extra_args) { - unsigned int i; const char *pcap_filename = value; struct pmd_devargs *dumpers = extra_args; pcap_dumper_t *dumper; - for (i = 0; i < dumpers->num_of_queue; i++) { - if (open_single_tx_pcap(pcap_filename, &dumper) < 0) - return -1; + if (dumpers->num_of_queue >= RTE_PMD_PCAP_MAX_QUEUES) + return -1; + if (open_single_tx_pcap(pcap_filename, &dumper) < 0) + return -1; - dumpers->queue[i].dumper = dumper; - dumpers->queue[i].name = pcap_filename; - dumpers->queue[i].type = key; - } + dumpers->queue[dumpers->num_of_queue].dumper = dumper; + dumpers->queue[dumpers->num_of_queue].name = pcap_filename; + dumpers->queue[dumpers->num_of_queue].type = key; + dumpers->num_of_queue++; return 0; } @@ -754,18 +754,18 @@ open_rx_tx_iface(const char *key, const char *value, void *extra_args) static inline int open_rx_iface(const char *key, const char *value, void *extra_args) { - unsigned int i; const char *iface = value; struct pmd_devargs *rx = extra_args; pcap_t *pcap = NULL; - for (i = 0; i < rx->num_of_queue; i++) { - if (open_single_iface(iface, &pcap) < 0) - return -1; - rx->queue[i].pcap = pcap; - rx->queue[i].name = iface; - rx->queue[i].type = key; - } + if (rx->num_of_queue >= RTE_PMD_PCAP_MAX_QUEUES) + return -1; + if (open_single_iface(iface, &pcap) < 0) + return -1; + rx->queue[rx->num_of_queue].pcap = pcap; + rx->queue[rx->num_of_queue].name = iface; + rx->queue[rx->num_of_queue].type = key; + rx->num_of_queue++; return 0; } @@ -776,18 +776,18 @@ open_rx_iface(const char *key, const char *value, void *extra_args) static int open_tx_iface(const char *key, const char *value, void *extra_args) { - unsigned int i; const char *iface = value; struct pmd_devargs *tx = extra_args; pcap_t *pcap; - for (i = 0; i < tx->num_of_queue; i++) { - if (open_single_iface(iface, &pcap) < 0) - return -1; - tx->queue[i].pcap = pcap; - tx->queue[i].name = iface; - tx->queue[i].type = key; - } + if (tx->num_of_queue >= RTE_PMD_PCAP_MAX_QUEUES) + return -1; + if (open_single_iface(iface, &pcap) < 0) + return -1; + tx->queue[tx->num_of_queue].pcap = pcap; + tx->queue[tx->num_of_queue].name = iface; + tx->queue[tx->num_of_queue].type = key; + tx->num_of_queue++; return 0; } @@ -983,15 +983,8 @@ pmd_pcap_probe(const char *name, const char *params) * We check whether we want to open a RX stream from a real NIC or a * pcap file */ - pcaps.num_of_queue = rte_kvargs_count(kvlist, ETH_PCAP_RX_PCAP_ARG); - if (pcaps.num_of_queue) - is_rx_pcap = 1; - else - pcaps.num_of_queue = rte_kvargs_count(kvlist, - ETH_PCAP_RX_IFACE_ARG); - - if (pcaps.num_of_queue > RTE_PMD_PCAP_MAX_QUEUES) - pcaps.num_of_queue = RTE_PMD_PCAP_MAX_QUEUES; + is_rx_pcap = rte_kvargs_count(kvlist, ETH_PCAP_RX_PCAP_ARG) ? 1 : 0; + pcaps.num_of_queue = 0; if (is_rx_pcap) ret = rte_kvargs_process(kvlist, ETH_PCAP_RX_PCAP_ARG, @@ -1007,15 +1000,8 @@ pmd_pcap_probe(const char *name, const char *params) * We check whether we want to open a TX stream to a real NIC or a * pcap file */ - dumpers.num_of_queue = rte_kvargs_count(kvlist, ETH_PCAP_TX_PCAP_ARG); - if (dumpers.num_of_queue) - is_tx_pcap = 1; - else - dumpers.num_of_queue = rte_kvargs_count(kvlist, - ETH_PCAP_TX_IFACE_ARG); - - if (dumpers.num_of_queue > RTE_PMD_PCAP_MAX_QUEUES) - dumpers.num_of_queue = RTE_PMD_PCAP_MAX_QUEUES; + is_tx_pcap = rte_kvargs_count(kvlist, ETH_PCAP_TX_PCAP_ARG) ? 1 : 0; + dumpers.num_of_queue = 0; if (is_tx_pcap) ret = rte_kvargs_process(kvlist, ETH_PCAP_TX_PCAP_ARG, -- 2.18.0