From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10090.outbound.protection.outlook.com [40.107.1.90]) by dpdk.org (Postfix) with ESMTP id BF38F1B1FC for ; Sat, 16 Jun 2018 17:37:03 +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=pGtdvKS6NRGChdjIrI4VXQvIUnIcam6G+Ic7IKt3qRc=; b=avYeCox23Z9q2Sr0Rlk/W6XfhnpQdQUwbDqrG/q5WlvyTpWITE6rn4tVOdZj+DXg20qe/9yk1azt0KJehK+ClksKCoTHVXNZKLPnDT83HC/cHnLjcGPVGnpIawXYeQyTIOnXz9atH3fD96842l+MZWyFKzIvPW+gj0rmwF3n7dI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Ido@cgstowernetworks.com; Received: from ubuntu.localdomain (81.218.57.230) by HE1PR0901MB1436.eurprd09.prod.outlook.com (2603:10a6:3:54::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.863.19; Sat, 16 Jun 2018 15:37:00 +0000 From: ido goshen To: Ferruh Yigit Cc: dev@dpdk.org, ido goshen Date: Sat, 16 Jun 2018 18:36:36 +0300 Message-Id: <1529163397-88330-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: [81.218.57.230] X-ClientProxiedBy: CWXP265CA0032.GBRP265.PROD.OUTLOOK.COM (2603:10a6:400:2d::20) To HE1PR0901MB1436.eurprd09.prod.outlook.com (2603:10a6:3:54::8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a1044b87-2516-446a-54f9-08d5d39f0126 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(711020)(2017052603328)(7153060)(7193020); SRVR:HE1PR0901MB1436; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0901MB1436; 3:Bupjvul+K/FiYArk/UDeBlDGFEdIo7vxgP1iNaBCoyp0AnB4pvDbHKi2+QQYG8SR9mRbO62pO2YwmgJ4Qj2NvbkxQ9esGO1hByxqj11H1IoyNYaYoiQXI4Bjtxia0fI6R5XTC424+Jj8DxFsYWyqXXSC4o5MqZbhG1fT1tpZ5FKiZKVamxdT8Zi40ZCYdjlKEpyEBAQjmoTttnSPQ98fZn6WloCMlFMK/mp1A4UqC8TVwHkiP4rd3k2HEJmQQIeG; 25:Z7iBlZw1LfOV2cLMXrOeuNZBObkPwvfuNp8Vw+XiWomrx97LBf7gVera7XNFQlponStkKVLsnnRZM1/ul66Zgfj51ScFYuJONS4LvkqtOdw/O65wwbKMvTvOh/i7HEFleYJ+v/S3yt3yq/ZFdv1bZTrpcH34ovTjWsy/Yzdu8r7tbpZsrAn9lOdprGESXgcc3NHPQCf34yg61KoG8zJM2L2Ddeu6nhJnZVmih9cIMA1iDlzoDiTFO1AJJ+BjPxxxCNyxSr4ZwGc5+5Ybp6MlPTpeyg2WzPiUeVbmZVHaOkqWG/KzT14JE3Q45OMcKpw3Dwv+8HdLs3SvQfwbuNkAXQ==; 31:45siVD5OxsEwcrHjeuqUQEfHGmdJp8nJcHgY4P3mTMi1MJ/ZtoVzg08NukXv9foR3iJVNFwz2itN7wWhzSTUgulz2INuUoiq27XauN9FTnJispYWruernWpxStnPQK94hXDlCgLu3uq0nqSRj48BhxkIfcW6Vl0E+/WS++wFEWbuczfWeX3loDzrAAfRSCC8uYUSxP1TG9L6FZSlsUqiZjo3txlzdqSsfa+oVDEx/U0= X-MS-TrafficTypeDiagnostic: HE1PR0901MB1436: 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)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(3231254)(944501410)(52105095)(149027)(150027)(6041310)(201703131423095)(20161123555045)(201703061421075)(20161123564045)(20161123560045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:HE1PR0901MB1436; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0901MB1436; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0901MB1436; 4:QjuUpOxGjXSIowJ6OPn35JIW4+8mw2rVCno9s88lNY2EpwbxUaqbg6x+yV7xBgJRHrjVHeiRn9Vw4SGCDWYRwl1vw6mc4d2d3XrisKSSBWSy4Aukl3iT8LbEl8k7/YahE9YX7lYNWdO01dU5h+MJUmbwd3BS1GEoiBaFzaNeRRtm2b/g7tGLRpL4dbShIyAVd3u4vphuj0JkaPldjhHDlHcrEzScvOUTaa3XGKO/Fu8AFcwO0iKCN4DHdGCZsmoSHw81x4z1AhKnBudHvMrE2g== X-Forefront-PRVS: 0705EB1700 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(346002)(39380400002)(376002)(189003)(199004)(3846002)(6116002)(5660300001)(956004)(47776003)(476003)(2616005)(50226002)(16526019)(86152003)(16586007)(6916009)(186003)(6666003)(6486002)(7736002)(305945005)(68736007)(486006)(26005)(52116002)(86362001)(36756003)(6512007)(51416003)(106356001)(105586002)(508600001)(8936002)(72206003)(66066001)(25786009)(48376002)(386003)(50466002)(6506007)(53936002)(8676002)(107886003)(81166006)(97736004)(81156014)(4326008)(2906002)(80792005); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0901MB1436; H:ubuntu.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: cgstowernetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0901MB1436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weJzkcWhWLg==; 5:AV/iFDrKNhj5Mw+ivxF3PUFttcuM4RurV+3DFW5MJlvgoj2JEt9MtVAm7YuRwjG0ODvLZOyEoLCb7kkdrPc0KJfixa5928FWGWeLEtZNH5Lbm24pn+JIT934j0VGXr5eV8pPK8uHPtKATlVRDo9hna4B1IMWtfHrsJ6hpMAMpZk=; 24:AYWdaWG3oU58U4X5Kc/h4ipPzZb0TjKNchvhQoeNIWVPesHXl95CzAAB2p6gd7EsYwr5T4FlpfsSEzJuwry4wARROmgOWx6PMgjnm6L0c8M= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0901MB1436; 7:PV5jSn7Ix+zNXU8hsDrEjwejaStvWgXkNojfey9DIbqDCjX/hv2IiVQNWlVSpumPo9TNi0ChhG3ttiKh5vsMujZSJwTKdiIF73+enr+Y4krZDwmZjVYR26JLnkFxErDl5aYTSFDmgDII0ykpXK7IdDJy6n5urqGjRQECiSK2RmmcFc/3CLMxBaUv2s3NU7IVMpqdE7B1bQAgDWd4ZtFpPCBzyKy4YZzYhS+ckbQy6x9NNWWbnVRZvifsQedxmhMJ X-OriginatorOrg: cgstowernetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2018 15:37:00.7396 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a1044b87-2516-446a-54f9-08d5d39f0126 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fc9e9498-07e8-4b82-b4cf-365bba23cbbf X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0901MB1436 X-Mailman-Approved-At: Sat, 16 Jun 2018 22:22:15 +0200 Subject: [dpdk-dev] [PATCH 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: Sat, 16 Jun 2018 15:37:04 -0000 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 --- drivers/net/pcap/rte_eth_pcap.c | 85 +++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 50 deletions(-) diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index 6bd4a7d..444abbb 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -665,19 +665,17 @@ 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 (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 +687,17 @@ 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 (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 +728,16 @@ 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 (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 +748,16 @@ 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 (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 +950,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, @@ -975,6 +960,10 @@ struct pmd_devargs { ret = rte_kvargs_process(kvlist, ETH_PCAP_RX_IFACE_ARG, &open_rx_iface, &pcaps); + if (pcaps.num_of_queue > RTE_PMD_PCAP_MAX_QUEUES) + pcaps.num_of_queue = RTE_PMD_PCAP_MAX_QUEUES; + + if (ret < 0) goto free_kvlist; @@ -982,15 +971,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, @@ -999,6 +981,9 @@ struct pmd_devargs { ret = rte_kvargs_process(kvlist, ETH_PCAP_TX_IFACE_ARG, &open_tx_iface, &dumpers); + if (dumpers.num_of_queue > RTE_PMD_PCAP_MAX_QUEUES) + dumpers.num_of_queue = RTE_PMD_PCAP_MAX_QUEUES; + if (ret < 0) goto free_kvlist; -- 1.9.1