]> git.proxmox.com Git - mirror_ovs.git/commitdiff
netdev-dpdk: Fix a bug in netdev_dpdk_set_multiq().
authorAlex Wang <alexw@nicira.com>
Fri, 19 Sep 2014 17:38:39 +0000 (10:38 -0700)
committerAlex Wang <alexw@nicira.com>
Fri, 19 Sep 2014 18:57:29 +0000 (11:57 -0700)
Commit 5a0340 (dpif-netdev: Create multiple tx/rx queues when
adding dpdk interface.) introduced a bug which causes the function
netdev_dpdk_set_multiq() never resetting the tx queues.  This bug
could cause pmd thread accessing unassigned memory, resulting in
segfault.

This commit fixes the bug.

Reported-by: Ethan Jackson <ethan@nicira.com>
Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Daniele Di Proietto <ddiproietto@vmware.com>
lib/netdev-dpdk.c

index ed39b9c99eee7ce831faeda2a7514d52931f30e4..50ea965dfa00edc3d7a8443b731faaf7ca86364b 100644 (file)
@@ -464,7 +464,7 @@ netdev_dpdk_alloc(void)
 }
 
 static void
-netdev_dpdk_set_txq(struct netdev_dpdk *netdev, unsigned int n_txqs)
+netdev_dpdk_alloc_txq(struct netdev_dpdk *netdev, unsigned int n_txqs)
 {
     int i;
 
@@ -492,7 +492,7 @@ netdev_dpdk_init(struct netdev *netdev_, unsigned int port_no)
     ovs_mutex_lock(&netdev->mutex);
 
     netdev->socket_id = rte_eth_dev_socket_id(port_no);
-    netdev_dpdk_set_txq(netdev, NR_QUEUE);
+    netdev_dpdk_alloc_txq(netdev, NR_QUEUE);
     netdev->port_id = port_no;
     netdev->flags = 0;
     netdev->mtu = ETHER_MTU;
@@ -622,14 +622,15 @@ netdev_dpdk_set_multiq(struct netdev *netdev_, unsigned int n_txq,
 
     ovs_mutex_lock(&dpdk_mutex);
     ovs_mutex_lock(&netdev->mutex);
+
     rte_eth_dev_stop(netdev->port_id);
+
     netdev->up.n_txq = n_txq;
     netdev->up.n_rxq = n_rxq;
+    rte_free(netdev->tx_q);
+    netdev_dpdk_alloc_txq(netdev, n_txq);
     err = dpdk_eth_dev_init(netdev);
-    if (!err && netdev->up.n_txq != n_txq) {
-        rte_free(netdev->tx_q);
-        netdev_dpdk_set_txq(netdev, n_txq);
-    }
+
     ovs_mutex_unlock(&netdev->mutex);
     ovs_mutex_unlock(&dpdk_mutex);