Skip to content

Commit

Permalink
netdev-dpdk: Avoid reconfiguration on reconnection of same vhost device.
Browse files Browse the repository at this point in the history
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: 81acebd ("netdev-dpdk: Obtain number of queues for vhost
                      ports from attached virtio.")
Reported-by: Ciara Loftus <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
Acked-by: Daniele Di Proietto <[email protected]>
  • Loading branch information
igsilya authored and ddiproietto committed Aug 10, 2016
1 parent 7ea266e commit 7f5f2bd
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/netdev-dpdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7f5f2bd

Please sign in to comment.