From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0075.outbound.protection.outlook.com [104.47.0.75]) by dpdk.org (Postfix) with ESMTP id 2BB857CA9; Sun, 3 Sep 2017 15:19:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=aMzoMh1wPkWsOvl2HYPO8WtyFGVg8ugar01Glb+ld1Q=; b=LCb28+Cv7LYT0a9dNf9aDEIKr7OZCqjzMGNH5r91E0bhev5tEEm+sjjlfxg9KucRjXmzgCD8RdKvwz0kwxuYYb7jMIfCQGfNg8adJq+LdVHznJbjC1IrOGE5XUxcBv7Y6KSFe9csquyh5sTNNir6FIHpNTo/PbkQEDJwSUx6p0g= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM5PR0502MB3042.eurprd05.prod.outlook.com (2603:10a6:203:a1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Sun, 3 Sep 2017 13:19:42 +0000 From: Matan Azrad To: Jingjing Wu , Gaetan Rivet , Thomas Monjalon Cc: dev@dpdk.org, Ori Kam , stable@dpdk.org Date: Sun, 3 Sep 2017 16:19:07 +0300 Message-Id: <1504444747-56298-1-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: HE1PR0102CA0028.eurprd01.prod.exchangelabs.com (2603:10a6:7:14::41) To AM5PR0502MB3042.eurprd05.prod.outlook.com (2603:10a6:203:a1::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6dd141bd-7d3b-41f7-26b0-08d4f2ce713d X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:AM5PR0502MB3042; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0502MB3042; 3:LbkSjMWc9k9rLO6dl/IAD2Ue3PBMwE9/yGc2J0XtiuMjbd68fC8joZKvs+fv5+vBdSf1MysvWKWsb0rE7kPuSOt746hGe++AUFF5in8OOom1mFla4zKCvtL6FSNm5SyvpPSoMtjZvxIvK7wmtVCqpR/418mCjuYJy43S9h0z/CDQuOHxiNnCbVb3G1M2dKt7lxxUCMR7C4Wh2cbxCKGNAYROGp2Sqn98777ejW8L9d4Y3HKvES/9f/1JJhfhPwzR; 25:CHaj6D6gjRIADLtheJQ0CwXw/d6y2162Q/XSoPpHCmDLE76ByGkLgvUPlwdsoB40mNSkb5pF1Lc9ODe8zDiHplVJEiaFUiiYO513kGwGct3YY9uciKSjjglvqzWk8TeHNjNdvVNkAO/HlXBTAhnGDb/WnyeOUAs5zhhicdb9xgFIl+rLr6YDoI6Pao3avK8U4f/L76bpFNuMVDLJTwQTHgaggAXbjVpN5UlN/e2AMC+cOv/fUJF/0VE9ZwralSYnKuByQ9Q+vwKmDPtGcpa4Ygkiwdoelw1QobR+4Y3WWrOMHN3fWR9aRUrfb0spUg4cL1VhKv2W4TCLedxNhfJKAA==; 31:Hy1+8RISftEiCigv9aHZexw5kLkIyjFGbLZc+9k5QjkOOYBXNK5OxKcubE0ayw/ndS/HoEwpl6GpOy4SwjNO16S64rKUOOV9ZSuu6vgllpaStzZ7TnKjZDbL2XQMKavAKrk289yuT99/wm137s1ew74TKMPvcD5TIXRW+y+PETPZ0+KniWteii3SsIM4hsMkbbbfjm2HKEvwvvj34KlQyG5FJfZEvmK1VxGPX8ljLjY= X-MS-TrafficTypeDiagnostic: AM5PR0502MB3042: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM5PR0502MB3042; 20:I+hHr1eEDyjbRrmU0nCyCU/WoVyZAaG/itL8SSWd+GokiV7+U//zXRTG++twV6U7+yIAIozKrQD1GL2qVWXwBwDZXBEj8ntrFcGidrdg7n1L+0Xfbp7W+Ucv6+hZEh/iahonB7UsVprZvZ8q5OHTfFGxKsZuvp+3wCese0aeib3yOgmAenXTazbuZa0HPe6nr4Qr7KjZnd3WjbIJ/2PfwzDYwN5wmraesuPDj6+NquKEy/mJkGhOAjFzTc3nXC2oMmoepuq2ol4Lm2HiB2njXywA7byi/M5lqFZofxkDeYxLm14/jMHIpnd7z6GsaCSDs+dTWd25UxQtxGMyOONIhydXpxXcUz/VvSNqK8WsxGrEOTAD/8kUOQsIRGQWZBPdGxRWOuXEDgiS3qzWRvGnYQGWWk1zASE393zXm0B/ta+qwmiuLDuCRgLcXFZHuQyvAmF3fKa5ldPgEL70OAvhm5N6BrNXmjLBpX43sPj2voCvDtcFax9/Rdela5Wp7TrS; 4:CCCiRzEvXsAMvkOLLdlP57exBpOC0Z235BP9gaR1BGQDtvD/BJFPn8g+4ZAoeRgEMI9WCP9g0hFCIOFswTcqZgAVyujEa2UaoA8dTs5wrYZKWEtDvRdNJfHOWOYCdpSuh/e923pFeL5HBvjVKxURpbkj8/ANlxi1yq537nnrYdKXesXLFJbJcwyy4jZDqwN993u/uGFGMV30nzFFpcxWz7lYhVDymCBVUVr6kccapn8dDOCuh5WhSef/k/l5DKCq X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(20161123564025)(20161123562025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM5PR0502MB3042; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM5PR0502MB3042; X-Forefront-PRVS: 041963B986 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39860400002)(53754006)(76104003)(189002)(199003)(6666003)(101416001)(189998001)(4326008)(5003940100001)(36756003)(5660300001)(50986999)(47776003)(53936002)(7736002)(55016002)(25786009)(2906002)(97736004)(33026002)(21086003)(478600001)(86362001)(50466002)(6116002)(3846002)(8676002)(48376002)(50226002)(69596002)(5890100001)(7350300001)(105586002)(305945005)(33646002)(68736007)(106356001)(66066001)(42186005)(81166006)(81156014); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0502MB3042; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0502MB3042; 23:L5KSYOuGwRX/OwRSdkuZq4dZbwwWgcvJGSCBmat?= =?us-ascii?Q?H1Pn0Vncepoj5doKDTPPKO9f/zziKRFU5wReet2yIuUdCO2WamBvq/88RPEv?= =?us-ascii?Q?68z4AnVg7qYES7Q6pbV9WyDnEvuCFCheK05DwujXjNg35E0YsAqYyUlk3Ie3?= =?us-ascii?Q?V233jyeIdsgt9K9Hc1ng76V70tbZGFziJikXx0CwYQtS6/zN23LZFxbWUvjC?= =?us-ascii?Q?tymU2gEOx5P4NOPhn33UzfZ51PCBBvSlRJb6Uy51rpZ4FMKPNVBgAmFTfPuE?= =?us-ascii?Q?92rdngRFVD79GLneHuzVoT268cUxBE4HlBXZDbQ3BD2SEnPC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yn6V+0fMZkzquaPxmk8RDFF6qQRxkssBSAM6v5IIQp12iW1jRxrOG+Dx1Cx6J+t7f1sFLRhNgCk54MTvq1eAYU9dlkRbyqJwHc4C963OnSN2lzZidQ4y14YHQ/1MARucYVrEr/6zUh2DGtCyB0+TtVibQIKi2LrxbVKJ7qELnX7nYsz9UHlC4eKdsmmbi1GJw5iWMzAzSj9XFyaq9Ju8Rbi/JzS+xIhwPGYYvsVuBRbn2iWGKUIydYZPrIPYamluY6xXvG3h4gYJhJ9rEKchF1QsSwygKmL7mG4t2JDqhhdDJEeXF00BIYA==; 5:Yy6xi50mj4dsBamIX2akFU5uWDP1hPUhTocWVdiTUEpViNYeE8wAH6IuBMbDqIbQcrz+ifrZmW6KHCMaZg0a30rZ6eji+OyO4eNrNLSoFpllGo8YwzdYvUG8pblGXI2zde6pCnjIaUX+jJVyT7Thhg==; 24:B0seZM/PJ3CT8vqzz3khKv4k/ROizjJLIsrfrQlvMOxDxFUK7hjQ0HfO/lGC2nfMEqx3FFFO81VhufqR8j2vP+EuJak/8LAAiXxadyutq2w=; 7:K0ue2erb1JTo4z91/DAVxbsSrNcNNiT9vwWKqylMM3eK6pCi94tQ/XEggYFZPsnQz9gqE0acUBusBCQ7CYFZYY9r+za6991aoV/Y6QDlok9EYIPGPi6mJgRuUj0BwMkn1pa+bsvmWZQa64FahKmdh1sOjhfBAAzk0rlS0O7Za4oFIlwBEfhYpsHrrtv/XhfnYhtOlJhawWWNPDCyEW/dbgVgf+abE4ay69fTm1WkuVw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2017 13:19:42.9818 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0502MB3042 Subject: [dpdk-dev] [PATCH] app/testpmd: fix forward port ids setting 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: Sun, 03 Sep 2017 13:19:46 -0000 The corrupted code didn't check the port availability when it was trying to set the forward port IDs array. However, when it was counting the number of ports, the availability was checked by RTE_ETH_FOREACH_DEV iterator. Hence, even when ETH devices ports were not in ATTACHED state, the testpmd tried to forward traffic by them and got segmentation fault at queue access time. For example: When EAL command line parameters include two devices, the first is failsafe with two sub devices and the second is any device, testpmd gets two devices by the iterator and sets for forwarding both, the failsafe device and the failsafe first sub device (instead of the second sub device). After the first failsafe sub device state was changed to DEFERRED, testpmd tries to forward traffic through the deferred device because it didn't check the port availability in setting time. The fix uses the RTE_ETH_FOREACH_DEV iterator for the forward port IDs default setting. Fixes: af75078fece3 ("first public release") Cc: stable@dpdk.org Signed-off-by: Matan Azrad --- app/test-pmd/testpmd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) Hi All I would like to bring up a discussion to complete this bug fix. When user wants to set the list of forwarding ports by "set portlist" (testpmd command line), the testpmd application checks the availability of the ports by rte_eth_dev_is_valid_port API. By this way, it gets the DEFERRED port as valid port and will try to recieve\send packets via this port. This scenario will cause the same error as this patch fixes. Should testpmd allow user to run traffic by DEFERRED port directly? If any application wants to check a port availability for device usage (conf\rxtx), Which API should be used? According to the patch cb894d99eceb ("ethdev: add deferred intermediate device state"), DEFERRED ports should be invisible to application, So maybe the rte_eth_dev_is_valid_port API should be internal and a new ethdev API should be created for applications. What do you think? diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 7d40139..f9bdbf8 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -463,9 +463,10 @@ static void set_default_fwd_ports_config(void) { portid_t pt_id; + int i = 0; - for (pt_id = 0; pt_id < nb_ports; pt_id++) - fwd_ports_ids[pt_id] = pt_id; + RTE_ETH_FOREACH_DEV(pt_id) + fwd_ports_ids[i++] = pt_id; nb_cfg_ports = nb_ports; nb_fwd_ports = nb_ports; -- 2.7.4