From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <aburakov@ecsmtp.ir.intel.com>
Received: from mga09.intel.com (mga09.intel.com [134.134.136.24])
 by dpdk.org (Postfix) with ESMTP id 59AA9B109
 for <dev@dpdk.org>; Wed, 18 Jun 2014 16:50:25 +0200 (CEST)
Received: from orsmga001.jf.intel.com ([10.7.209.18])
 by orsmga102.jf.intel.com with ESMTP; 18 Jun 2014 07:45:19 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.01,501,1400050800"; d="scan'208";a="530478166"
Received: from irvmail001.ir.intel.com ([163.33.26.43])
 by orsmga001.jf.intel.com with ESMTP; 18 Jun 2014 07:50:39 -0700
Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com
 [10.237.217.45])
 by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id
 s5IEoc8U009276 for <dev@dpdk.org>; Wed, 18 Jun 2014 15:50:39 +0100
Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1])
 by sivswdev01.ir.intel.com with ESMTP id s5IEocJM025988
 for <dev@dpdk.org>; Wed, 18 Jun 2014 15:50:38 +0100
Received: (from aburakov@localhost)
 by sivswdev01.ir.intel.com with  id s5IEoc5q025983
 for dev@dpdk.org; Wed, 18 Jun 2014 15:50:38 +0100
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Date: Wed, 18 Jun 2014 15:50:35 +0100
Message-Id: <0fa2888196214604c6904a56452f43fd6f5dc78e.1403102825.git.anatoly.burakov@intel.com>
X-Mailer: git-send-email 1.7.0.7
In-Reply-To: <cover.1403102825.git.anatoly.burakov@intel.com>
References: <cover.1403102825.git.anatoly.burakov@intel.com>
In-Reply-To: <cover.1403102825.git.anatoly.burakov@intel.com>
References: <cover.1403102825.git.anatoly.burakov@intel.com>
Subject: [dpdk-dev] [PATCH 08/10] ip_fragmentation: small fixes
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Wed, 18 Jun 2014 14:50:25 -0000

Adding check for non-existent ports in portmask.

Also, making everything NUMA-related depend on lcore sockets, not device
sockets. This is because the init_mem() function allocates all data
structures based on NUMA nodes of the lcores in the coremask. Therefore,
when no cores are on socket 0, but there are devices on socket 0, it may
lead to segmentation faults.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 examples/ip_fragmentation/main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c
index 02e40a1..3172ad5 100644
--- a/examples/ip_fragmentation/main.c
+++ b/examples/ip_fragmentation/main.c
@@ -886,6 +886,10 @@ MAIN(int argc, char **argv)
 	if (init_mem() < 0)
 		rte_panic("Cannot initialize memory structures!\n");
 
+	/* check if portmask has non-existent ports */
+	if (enabled_port_mask & ~(RTE_LEN2MASK(nb_ports, unsigned)))
+		rte_exit(EXIT_FAILURE, "Non-existent ports in portmask!\n");
+
 	/* initialize all ports */
 	for (portid = 0; portid < nb_ports; portid++) {
 		/* skip ports that are not enabled */
@@ -907,7 +911,7 @@ MAIN(int argc, char **argv)
 			qconf = &lcore_queue_conf[rx_lcore_id];
 		}
 
-		socket = rte_eth_dev_socket_id(portid);
+		socket = (int) rte_lcore_to_socket_id(rx_lcore_id);
 		if (socket == SOCKET_ID_ANY)
 			socket = 0;
 
-- 
1.8.1.4