From patchwork Mon Aug 8 11:19:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Maximets X-Patchwork-Id: 656659 X-Patchwork-Delegate: diproiettod@vmware.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3s7FM36mqxz9sf9 for ; Mon, 8 Aug 2016 21:20:15 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 70F231075E; Mon, 8 Aug 2016 04:19:59 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 16D811075B for ; Mon, 8 Aug 2016 04:19:58 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id A2C18162571 for ; Mon, 8 Aug 2016 05:19:57 -0600 (MDT) X-ASG-Debug-ID: 1470655196-0b323721d742f070001-byXFYA Received: from mx3-pf2.cudamail.com ([192.168.14.1]) by bar6.cudamail.com with ESMTP id 6knOYBgKb4g0BGW1 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 08 Aug 2016 05:19:56 -0600 (MDT) X-Barracuda-Envelope-From: i.maximets@samsung.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.1 Received: from unknown (HELO mailout2.w1.samsung.com) (210.118.77.12) by mx3-pf2.cudamail.com with ESMTPS (DHE-RSA-AES128-SHA encrypted); 8 Aug 2016 11:19:55 -0000 Received-SPF: none (mx3-pf2.cudamail.com: domain at samsung.com does not designate permitted sender hosts) X-Barracuda-Apparent-Source-IP: 210.118.77.12 X-Barracuda-RBL-IP: 210.118.77.12 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OBL001JM8T4GX60@mailout2.w1.samsung.com> for dev@openvswitch.org; Mon, 08 Aug 2016 12:19:52 +0100 (BST) X-AuditID: cbfec7f4-f796c6d000001486-b7-57a86ad85751 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id FD.6F.05254.8DA68A75; Mon, 8 Aug 2016 12:19:52 +0100 (BST) Received: from imaximets.rnd.samsung.ru ([106.109.129.180]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OBL00B4N8T0KH50@eusync4.samsung.com>; Mon, 08 Aug 2016 12:19:52 +0100 (BST) X-CudaMail-Envelope-Sender: i.maximets@samsung.com From: Ilya Maximets To: dev@openvswitch.org, Daniele Di Proietto X-CudaMail-MID: CM-V2-807004089 X-CudaMail-DTE: 080816 X-CudaMail-Originating-IP: 210.118.77.12 Date: Mon, 08 Aug 2016 14:19:45 +0300 X-ASG-Orig-Subj: [##CM-V2-807004089##][PATCH v2] netdev-dpdk: Avoid reconfiguration on reconnection of same vhost device. Message-id: <1470655185-8676-1-git-send-email-i.maximets@samsung.com> X-Mailer: git-send-email 2.7.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLJMWRmVeSWpSXmKPExsVy+t/xa7o3slaEG3QvU7B4NbmB0aKlfyaz xdHTe5gtXnbfY7eY9vk2u8WV9p/sFpNnSzmweyze85LJ49nN/4wez6/1sHj0bVnF6PFu/lu2 ANYoLpuU1JzMstQifbsEroxfvSdYCg4KVxy7cYS5gfEVbxcjJ4eEgInEivdPmSFsMYkL99az dTFycQgJLGWUaJzayQrhtDJJ/HtwgQWkik1AR+LU6iOMILaIgKvE9Ntv2EGKmAV2M0pMmL+I FSQhLBAncevQeTYQm0VAVeJox2ewFbxADd/WH2SCWCcncfNcJ/MERu4FjAyrGEVTS5MLipPS cw31ihNzi0vz0vWS83M3MUIC5csOxsXHrA4xCnAwKvHwKpQvDxdiTSwrrsw9xCjBwawkwvsi c0W4EG9KYmVValF+fFFpTmrxIUZpDhYlcd65u96HCAmkJ5akZqemFqQWwWSZODilGhiXbopK m1OXep+p0zqnLa+/Vm3ih+ey0qb7uCzzTU3nVLDuClm+Vm3LAbbXEyXLnRSEO6Oe7DpdeOSo zC7OnVnfThkJevXOifFKW53u/E/fme3weq1t7JUMrPu+pNTqXbKZELbXNebPm7MvP8lfid4+ ie3G+T52+U0lDOVTvwRbLXqbO/Vw7WMlluKMREMt5qLiRACY2SF3EAIAAA== X-GBUdb-Analysis: 0, 210.118.77.12, Ugly c=0 p=0 Source New X-MessageSniffer-Rules: 0-0-0-7055-c X-Barracuda-Connect: UNKNOWN[192.168.14.1] X-Barracuda-Start-Time: 1470655196 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-ASG-Whitelist: EmailCat (corporate) Cc: Ilya Maximets , Dyasly Sergey Subject: [ovs-dev] [PATCH v2] netdev-dpdk: Avoid reconfiguration on reconnection of same vhost device. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" 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: 81acebdaaf27 ("netdev-dpdk: Obtain number of queues for vhost ports from attached virtio.") Reported-by: Ciara Loftus Signed-off-by: Ilya Maximets --- Version 2: * Set 'vhost_reconfigured' flag if reconfiguration not required. * Rebased on current master. lib/netdev-dpdk.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index b671601..ea0e16e 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -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);