From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10133.outbound.protection.outlook.com [40.107.1.133]) by dpdk.org (Postfix) with ESMTP id 854AA4C96; Tue, 19 Jun 2018 16:38:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cgstowernetworks.onmicrosoft.com; s=selector1-cgstowernetworks-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fvqdsnNvyHsTqargmNibv0lCJVkY0H8Knptvfe3t0tk=; b=ZtsagUJUGgj++XqUXYcuFEPae/0dBdmceVMnE++XD3TuuiByyps1Sj18RVVcdMrm09asfbxI5tlNrdJ7Wk57ezOwDD2ISCu0tBDGz8e/eRrCE5tpe8qiUs8ChP5kkz2tFI3aSWoFsnm3kaGm/HqOBSopggN17N/gBb4Oiz+kzlA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ido@cgstowernetworks.com; Received: from ubuntu.localdomain (5.144.48.231) by VI1PR0901MB1439.eurprd09.prod.outlook.com (2603:10a6:800:8d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.863.19; Tue, 19 Jun 2018 14:38:04 +0000 From: ido goshen To: Ferruh Yigit Cc: dev@dpdk.org, ido goshen , stable@dpdk.org Date: Tue, 19 Jun 2018 17:37:25 +0300 Message-Id: <1529419046-95906-1-git-send-email-ido@cgstowernetworks.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [5.144.48.231] X-ClientProxiedBy: LO2P265CA0190.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a::34) To VI1PR0901MB1439.eurprd09.prod.outlook.com (2603:10a6:800:8d::7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 07e17506-8d8b-4301-cc94-08d5d5f244b7 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(711020)(2017052603328)(7153060)(7193020); SRVR:VI1PR0901MB1439; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0901MB1439; 3:HE0C7qWt5FZn1dEjrjKzqTGu35t3ogqEbQH49KTBX6w058PUcU2JfhwRIehAIBwi9eY4J539LQHyvdZDZ0xgXggcd32043EdMOjbpI9WD3hQ9bDX1wa0ZKXg7NVK3FGuce4dDPbYJU+6KepsmJmFbrSFvEcOT6qOCH7bqWWr4LXRQ6/39tA/xdjWauiii5v8rJP6LA57MnTZVev6c3SCbjnoC8fV13if3tmJkVJXKwHsLP8Y7W90PxjiX0zFxiCI; 25:KQVK8ppOHfM78sIX07BJGg3dYluIV2nCegHThx1zU7lthpWbN2sRc3ZeTrDeJPVnw0ta72HL3vCxQwY9v5/EoCj4oy6ar62Nu0edYZ+Lm9A5U1gN+8woowFN702b20LR5uNgKZppInLw15Ah0RrrMqW9rTX2LfY0vguAADLqqtGnAK7jvh9BQnvFJPJNd7InMTnlkb7OTLB00O33IUTjcDSPxqnYFaKgDLhc04POn7S+VCouW64jSzuyLojRQ3T4pYxfiDgBQIha0Oe6kzGAdndtSWK21hUHLKMcZd7oV3RcIwZbPfAjfsldPPp5l5oXy+xc3DZcOZKD0I3HhcP2+w==; 31:wxx8fDEKEwmnlZmrMa8l4lRJLqhsANtRHq+E5iJgtro7DYX53REgc1Tubf2LWQCjwwTZ/0xvfSyrYR7UHCVJ+pGXV9gr8oIAY3jEF1K4u83LFfRghTkhTQOeqFKuKRalNiN+frK2Qv10eZk78qk1q+GV7hPvLxRSIJktj+nana+Is97xB+bTwA6GxoIC/cmDttqRwk0WxtZ9ai1hERlC+QtAZl0h950iTBlX4twPN3Y= X-MS-TrafficTypeDiagnostic: VI1PR0901MB1439: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231254)(944501410)(52105095)(3002001)(10201501046)(149027)(150027)(6041310)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:VI1PR0901MB1439; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0901MB1439; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0901MB1439; 4:g7QKSnN8+9vfBG14t7y1FVo6miD8dYHi19P++m9KcAnUzqdTvttX6qbNfA3hzfI8Mw+3jYkppKIry3Ik+sy6tQFrcXjnVRazgZ6ayJlVQHosm/GfhE4YB59jNfnovCoeJ3+RQMmqRR38m6xijioXrfGVK/r9uLmkqVR1kI/BJUSE7nemVWVUov/fIirNCi37hvJydrA7kjshfWgYntJqtHMY3MN6QhctRUN941a4MgLXPVcT7kqlbtDfpNMUXJutZLwJfoZiqT6S8u5aK3lvdw== X-Forefront-PRVS: 07083FF734 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(39840400004)(366004)(39380400002)(396003)(376002)(346002)(199004)(189003)(48376002)(86362001)(316002)(305945005)(51416003)(16586007)(53936002)(52116002)(486006)(476003)(2616005)(956004)(50466002)(478600001)(71446004)(72206003)(80792005)(106356001)(25786009)(8936002)(97736004)(4326008)(81166006)(105586002)(8676002)(81156014)(386003)(6506007)(26005)(186003)(16526019)(2906002)(7736002)(6916009)(5660300001)(66066001)(6666003)(36756003)(50226002)(6116002)(3846002)(68736007)(47776003)(6512007)(6486002)(86152003)(37156001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0901MB1439; H:ubuntu.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: cgstowernetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1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yBgw9kmG?= =?us-ascii?Q?/2gDxWaG9wRk0CXYB5hND3nvBqZ1JrF7am9tKQIRnOn6/TOIkZRf1g7ley+g?= =?us-ascii?Q?b8+3RFSh+hsJkjr5m/8X8ZcbOUIdgaE67mqZKxF3SdPWDD9Pgytx63lhRsJG?= =?us-ascii?Q?VIubDnoSdCaW2suX2nvd3SucXhPohUroCIF1mPuEn6gGIDxH8PZWSU+HqCnz?= =?us-ascii?Q?VpShri0UNaWxJAgvs8nS4yRgDfO13y4AWLureFCoUrsJfITT3RYCQ0ffQTwg?= =?us-ascii?Q?P11CrkiDtMcXg4u84A615wiKTbLnVnm1lLgLGmt/xbJPwWuE/IdDgvUHZgIf?= =?us-ascii?Q?NaOJutCKS5saEHKfQCSiYA/KAQxECBPSYIn1djLnC/YxrHyPvPMOo/o31Uw?= =?us-ascii?Q?=3D=3D?= X-Microsoft-Antispam-Message-Info: iuexML23l3prgvO4fR2+evN7BLo7KiBYJh0mRZXJxgl/FWkfGvBXcuUi1V314viyTHy/MquFTWSg38S/8xLproZ0D41z/tFqKcloJYaY4/KqqfNX1lnow03EPPaPKCAbTn7hX+RvfN4hMFqZCGm7hkWDXujn+mZIjzaZCs8DKkxrMb6y3Fpejw2xgI9TdIoH3u6cbwuFxzTcyPC9kKVFpUkUDSL14JBvRYfldG/xXnIPsUsIH1SaIiEP2weIgLXDVGsWlS5U9HK3q/KvIuB0o3MhT1oHtlUlo1Z4q7abZyhcrZhKJu6sKjjXjo7ftX6k X-Microsoft-Exchange-Diagnostics: 1; VI1PR0901MB1439; 6:b2HsW2QG8nn0Ai5MeHWftnESSrbCDyZxT+g/XWeplL016cNWAylvmWe2OkOguR3B44z3RTuJezf1/UtGu7Ip8hrExzuf/sjNHzM4+5F9xFFeveTS95YPcdh7SPIdMjS9T1aDvWcunR7TxOgcDT7VWnd5SIJ0niiefFoiLqpmPE8EJoGmBslyMWFCQ3ifcz85l2okuC1bUb6dZFqGGSpjsX5Php4PcJ17L6gu//XMJopmoU/fwM8wYi/kAGuV1t4/sbJdpeyQJW7F+BaEGjE1clU1++ZMDzYf7RwGLyXAyTa56olf+W26IBnb66SXhTr3v0oa9zmRuySj2KsU4kS3es9P7NpXOtAcJ/gdncXOblTknW85yjz9MmmNlycjgqa0rzvO6FwpNp1Ddf32lkakBASIqp9zJ3KGAocZ264sAIl3zPOquuHUrzTrN5BPsRHb5F1MQuUG/P4vkOE6XKrfJg==; 5:X8Zp3jZQYmdkMWa9zc9fIBUSw12n74DgRbEzjaIfxVW8dSHUwq9ENbNEIGJ4zYB3hwqhGCeXLsRWMYE60j6ASY117pvQZfManLVp2OLX2qlOT9y0mIS1D+sIOXPV2EslDRvsZiwEAzNCowIMJwE1jgn6LfJ8CrKOpb8pt5gWL4k=; 24:jf6N7Ep8WuglUThc9ptLWOoeH5n+mSrpks7HCn+7bvNn437Um+PFHkO9IG7C8egjtKOoHtF558xQ4r8E+xKkgW5s3PKPNsicVy+voEgLgyM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0901MB1439; 7:zvS6qlYDpzjXcO/VolYnm0PqpYK7hzhjYa21xqG65OIjbrzLN2AQSVFm46O9092yXThTPP/6EODXdzh2gBLVNlxvZO24lbG0unSpWhy79fN0kFlYfaWPYzHBTayV/UCMF7P6482JFMjhuTBcysMO9dpsaoAVKOA4wztsIIJtQr7tol+pLUN4MSj5MHorHEZ65pdSKka6SzjP0J6EMtN9DaEUClHuRSsPplImyjze79FlQDLzP8lLJH5W6ma7l7CD X-OriginatorOrg: cgstowernetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2018 14:38:04.7772 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 07e17506-8d8b-4301-cc94-08d5d5f244b7 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fc9e9498-07e8-4b82-b4cf-365bba23cbbf X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0901MB1439 X-Mailman-Approved-At: Wed, 20 Jun 2018 00:55:58 +0200 Subject: [dpdk-dev] [PATCH v2 1/2] net/pcap: multiple queues fix 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: Tue, 19 Jun 2018 14:38:07 -0000 Fixes: 4c173302c307 ("pcap: add new driver") Cc: stable@dpdk.org 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 acheived by the caller rte_kvargs_process Fixes: 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 Signed-off-by: ido goshen --- v2: * fix num of queues check --- 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 6bd4a7d..b4f81ac 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -665,19 +665,19 @@ struct pmd_devargs { 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; } @@ -689,19 +689,19 @@ struct pmd_devargs { 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; } @@ -732,18 +732,18 @@ struct pmd_devargs { 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; } @@ -754,18 +754,18 @@ struct pmd_devargs { 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; } @@ -958,15 +958,8 @@ struct pmd_devargs { * 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, @@ -982,15 +975,8 @@ struct pmd_devargs { * 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, -- 1.9.1