netdev-dpdk: Fix crash when there is no pci numa info.
authorAlex Wang <alexw@nicira.com>
Thu, 25 Sep 2014 20:10:55 +0000 (13:10 -0700)
committerAlex Wang <alexw@nicira.com>
Thu, 25 Sep 2014 21:17:54 +0000 (14:17 -0700)
When kernel cannot obtain the pci numa info, the numa_node file
in corresponding pci directory in sysfs will show -1.  Then the
rte_eth_dev_socket_id() function will return it to ovs.  On
current master, ovs assumes rte_eth_dev_socket_id() always
returns non-negative value.  So using this -1 in pmd thread
creation will cause ovs crash.

To fix the above issue, this commit makes ovs always check the
return value of rte_eth_dev_socket_id() and use numa node 0 if
the return value is negative.

Reported-by: Daniel Badea <daniel.badea@windriver.com>
Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Daniele Di Proietto <ddiproietto@vmware.com>
AUTHORS
lib/netdev-dpdk.c

diff --git a/AUTHORS b/AUTHORS
index 7593ab0..16f972c 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -189,6 +189,7 @@ Cedric Hobbs            cedric@nicira.com
 Chris Hydon             chydon@aristanetworks.com
 Christian Stigen Larsen cslarsen@gmail.com
 Christopher Paggen      cpaggen@cisco.com
+Daniel Badea            daniel.badea@windriver.com
 Dave Walker             DaveWalker@ubuntu.com
 David Palma             palma@onesource.pt
 Derek Cormier           derek.cormier@lab.ntt.co.jp
index 50ea965..9c93768 100644 (file)
@@ -485,13 +485,18 @@ netdev_dpdk_init(struct netdev *netdev_, unsigned int port_no)
     OVS_REQUIRES(dpdk_mutex)
 {
     struct netdev_dpdk *netdev = netdev_dpdk_cast(netdev_);
+    int sid;
     int err = 0;
 
     ovs_mutex_init(&netdev->mutex);
 
     ovs_mutex_lock(&netdev->mutex);
 
-    netdev->socket_id = rte_eth_dev_socket_id(port_no);
+    /* If the 'sid' is negative, it means that the kernel fails
+     * to obtain the pci numa info.  In that situation, always
+     * use 'SOCKET0'. */
+    sid = rte_eth_dev_socket_id(port_no);
+    netdev->socket_id = sid < 0 ? SOCKET0 : sid;
     netdev_dpdk_alloc_txq(netdev, NR_QUEUE);
     netdev->port_id = port_no;
     netdev->flags = 0;