From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f181.google.com (mail-pd0-f181.google.com [209.85.192.181]) by dpdk.org (Postfix) with ESMTP id 88F93234 for ; Fri, 27 Feb 2015 08:16:25 +0100 (CET) Received: by pdbnh10 with SMTP id nh10so19039074pdb.11 for ; Thu, 26 Feb 2015 23:16:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=tJru4K2ps9e+We36w8QROlJLWcnGr05cSzyRUL5kJIw=; b=YXtxxt9wgDlQq/w0HQD+MRIAHmvPCdBvVbl/9NR+mbKMZ59jfLvfOMQ8NLBFu0isB3 9se/U35ra1CZ8tQxOEvVbtIFXhelrX5uB1Sj2YWyrhSnDjoeeqYXNydzTlQesbknvQGs cLge9EoyhiFURKkZHubKBGAA7KFn++lHHbShsUgE+dObwKZHUl6T/3VJT1pS7jLbcDtg GU0NMA77vX3uYLakFgshrxj7STLIP1nTIOOVij2OjFO9KNBB6naqKfsbBb60SIteDJsY G5NxS7daUsYr38FDEIRug9lQivJHvXPZhEMpSv0e/SemwvDEgeS9tvRnmtIx5ryZgqEQ FOuQ== X-Gm-Message-State: ALoCoQk+i2KcGdZ7IHRLn2DJAe0hnP2NfPdDcUmYc1kz0z+cD7ZaqTFpn4zFytuKH1dzsJdvyi3h X-Received: by 10.68.95.130 with SMTP id dk2mr21527972pbb.51.1425021384878; Thu, 26 Feb 2015 23:16:24 -0800 (PST) Received: from localhost.localdomain (napt.igel.co.jp. [219.106.231.132]) by mx.google.com with ESMTPSA id y2sm2999201pdm.31.2015.02.26.23.16.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Feb 2015 23:16:24 -0800 (PST) From: Tetsuya Mukawa To: dev@dpdk.org Date: Fri, 27 Feb 2015 16:16:15 +0900 Message-Id: <1425021375-5763-1-git-send-email-mukawa@igel.co.jp> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] testpmd: Fix segmentation fault when portmask is specified X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Feb 2015 07:16:25 -0000 If testpmd is invoked with portmask option like below, segmentation fault will be occured. This patch fixes the issue. Reported-by: De Lara Guarch, Pablo Signed-off-by: Tetsuya Mukawa --- app/test-pmd/testpmd.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 43329ed..61291be 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -579,20 +579,6 @@ init_config(void) socket_num); } - /* Configuration of Ethernet ports. */ - ports = rte_zmalloc("testpmd: ports", - sizeof(struct rte_port) * RTE_MAX_ETHPORTS, - RTE_CACHE_LINE_SIZE); - if (ports == NULL) { - rte_exit(EXIT_FAILURE, - "rte_zmalloc(%d struct rte_port) failed\n", - RTE_MAX_ETHPORTS); - } - - /* enabled allocated ports */ - for (pid = 0; pid < nb_ports; pid++) - ports[pid].enabled = 1; - FOREACH_PORT(pid, ports) { port = &ports[pid]; rte_eth_dev_info_get(pid, &port->dev_info); @@ -1999,6 +1985,26 @@ init_port_dcb_config(portid_t pid,struct dcb_config *dcb_conf) return 0; } +static void +init_port(void) +{ + portid_t pid; + + /* Configuration of Ethernet ports. */ + ports = rte_zmalloc("testpmd: ports", + sizeof(struct rte_port) * RTE_MAX_ETHPORTS, + RTE_CACHE_LINE_SIZE); + if (ports == NULL) { + rte_exit(EXIT_FAILURE, + "rte_zmalloc(%d struct rte_port) failed\n", + RTE_MAX_ETHPORTS); + } + + /* enabled allocated ports */ + for (pid = 0; pid < nb_ports; pid++) + ports[pid].enabled = 1; +} + int main(int argc, char** argv) { @@ -2013,6 +2019,9 @@ main(int argc, char** argv) if (nb_ports == 0) RTE_LOG(WARNING, EAL, "No probed ethernet devices\n"); + /* allocate port structures, and init them */ + init_port(); + set_def_fwd_config(); if (nb_lcores == 0) rte_panic("Empty set of forwarding logical cores - check the " -- 1.9.1