2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

netdev-dpdk: Avoid reconfiguration on reconnection of same vhost device.

Binding/unbinding of virtio driver inside VM leads to reconfiguration
of PMD threads. This behaviour may be abused by executing bind/unbind
in an infinite loop to break normal networking on all ports attached
to the same instance of Open vSwitch.

Fix that by avoiding reconfiguration if it's not necessary.
Number of queues will not be decreased to 1 on device disconnection but
it's not very important in comparison with possible DOS attack from the
inside of guest OS.

Fixes: 81acebdaaf ("netdev-dpdk: Obtain number of queues for vhost
                      ports from attached virtio.")
Reported-by: Ciara Loftus <ciara.loftus@intel.com>
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Acked-by: Daniele Di Proietto <diproiettod@vmware.com>
This commit is contained in:
Ilya Maximets
2016-08-08 14:19:45 +03:00
committed by Daniele Di Proietto
parent 7ea266e953
commit 7f5f2bd0ce

View File

@@ -2299,10 +2299,17 @@ new_device(int vid)
newnode = dev->socket_id;
}
dev->requested_socket_id = newnode;
dev->requested_n_rxq = qp_num;
dev->requested_n_txq = qp_num;
netdev_request_reconfigure(&dev->up);
if (dev->requested_n_txq != qp_num
|| dev->requested_n_rxq != qp_num
|| dev->requested_socket_id != newnode) {
dev->requested_socket_id = newnode;
dev->requested_n_rxq = qp_num;
dev->requested_n_txq = qp_num;
netdev_request_reconfigure(&dev->up);
} else {
/* Reconfiguration not required. */
dev->vhost_reconfigured = true;
}
ovsrcu_index_set(&dev->vid, vid);
exists = true;
@@ -2362,11 +2369,7 @@ destroy_device(int vid)
ovs_mutex_lock(&dev->mutex);
dev->vhost_reconfigured = false;
ovsrcu_index_set(&dev->vid, -1);
/* Clear tx/rx queue settings. */
netdev_dpdk_txq_map_clear(dev);
dev->requested_n_rxq = NR_QUEUE;
dev->requested_n_txq = NR_QUEUE;
netdev_request_reconfigure(&dev->up);
netdev_change_seq_changed(&dev->up);
ovs_mutex_unlock(&dev->mutex);