From patchwork Thu Sep 24 21:17:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venugopal Iyer X-Patchwork-Id: 1370893 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nvidia.com header.i=@nvidia.com header.a=rsa-sha256 header.s=n1 header.b=GnbbOJTi; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4By7Bs449Rz9sS8 for ; Fri, 25 Sep 2020 07:16:21 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id ACD2F85B58; Thu, 24 Sep 2020 21:16:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4Ykfr2DCMgQz; Thu, 24 Sep 2020 21:16:19 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id F3B3385ADF; Thu, 24 Sep 2020 21:16:18 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E03AAC0859; Thu, 24 Sep 2020 21:16:18 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 53465C0051 for ; Thu, 24 Sep 2020 21:16:17 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 490FE85B58 for ; Thu, 24 Sep 2020 21:16:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rEFNz3SUXAlf for ; Thu, 24 Sep 2020 21:16:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from hqnvemgate26.nvidia.com (hqnvemgate26.nvidia.com [216.228.121.65]) by whitealder.osuosl.org (Postfix) with ESMTPS id 6135685ADF for ; Thu, 24 Sep 2020 21:16:16 +0000 (UTC) Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Thu, 24 Sep 2020 14:16:03 -0700 Received: from HQMAIL111.nvidia.com (172.20.187.18) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 24 Sep 2020 21:16:15 +0000 Received: from nviyer-1.nvidia.com (10.124.1.5) by mail.nvidia.com (172.20.187.18) with Microsoft SMTP Server id 15.0.1473.3 via Frontend Transport; Thu, 24 Sep 2020 21:16:15 +0000 From: To: Date: Thu, 24 Sep 2020 14:17:04 -0700 Message-ID: <20200924211704.24904-1-venugopali@nvidia.com> X-Mailer: git-send-email 2.17.1 X-NVConfidentiality: public MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1600982163; bh=ajq2pEMxeYMmVa9X/lb/K6R4OTO2VL4CLgt3Ba6Uzds=; h=From:To:CC:Subject:Date:Message-ID:X-Mailer:X-NVConfidentiality: MIME-Version:Content-Type; b=GnbbOJTil1yT9I55e07cMPwclUA3FGgt17kgvxHuuTU1Wm5ocoUbDBoTWngKMrYab jhINcxsWsrqoYe/IZh7vf4L1uZXV1nq9uKCtdPf1k7S7toABSGJoV1yBQ3Ok77ICnX /Rh1b+7QXdrEuTzeWyX+XNozJNnD/BwsPM1PXEdI56c9ZUIo/OiGE5sAq/uYHBaIV4 et0k615EkHZqc2MedlgQ+UG7KRibAuVgeQe+jSx71j2qXuHtqU2EvUhIJy1GiNJzXL JjeTrUAQrMcjsG+9FVlXLW8FZJ+8ItStyevj4Nmz7w/T+LsSPgmEB78r6zjkNaf/0N UUsRY1mWFkLCA== Cc: venugopali@nvidia.com Subject: [ovs-dev] [PATCH ovn v2 1/1] controller: Check for tunnel change in multi-vtep case is incorrect X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: venu iyer Prior to multi-vtep, there was one tunnel for each type, since there was only one encap-ip. So, the check in chassis_tunnels_changed(): sset_count(encap_type_set) != encap_type_count worked. However, with multiple IPs per tunnel type, the above check won't work. So, once multiple encap-ips are configured, ovn-controller will always keep updating the encap list in the SB (due to the above check); this causes a lot of unnecessary churn, including recomputing the flows etc. which will put ovn-controller in overdrive thereby consuming lot of CPU cycles (see almost 100%) Verified ovn-controller cpu utilization with the fix (and also that SB doesn't keep constantly updating). make check didn't show any additional failures. Fixes: Fixes: b520ca7 ("Support for multiple VTEP in OVN") Signed-off-by: venu iyer --- controller/chassis.c | 8 +++++--- tests/ovn.at | 49 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/controller/chassis.c b/controller/chassis.c index a365188e8..a6dfb92df 100644 --- a/controller/chassis.c +++ b/controller/chassis.c @@ -415,14 +415,15 @@ chassis_tunnels_changed(const struct sset *encap_type_set, const char *encap_csum, const struct sbrec_chassis *chassis_rec) { - size_t encap_type_count = 0; + struct sset chassis_rec_encap_type_set; + sset_init(&chassis_rec_encap_type_set); for (size_t i = 0; i < chassis_rec->n_encaps; i++) { if (!sset_contains(encap_type_set, chassis_rec->encaps[i]->type)) { return true; } - encap_type_count++; + sset_add(&chassis_rec_encap_type_set, chassis_rec->encaps[i]->type); if (!sset_contains(encap_ip_set, chassis_rec->encaps[i]->ip)) { return true; @@ -441,7 +442,8 @@ chassis_tunnels_changed(const struct sset *encap_type_set, return true; } - if (sset_count(encap_type_set) != encap_type_count) { + if (sset_count(encap_type_set) != + sset_count(&chassis_rec_encap_type_set)) { return true; } diff --git a/tests/ovn.at b/tests/ovn.at index b6c8622ba..47090fa71 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -22299,3 +22299,52 @@ ovn-sbctl --columns chassis --bare list port_binding sw0-p2 OVN_CLEANUP([hv1]) AT_CLEANUP + +# +# When multiple encap-ips are configued, make sure the +# ovn-controller doesn't get into a state of constantly +# updating the SB Chassis's encap information. The test +# configures multiple vteps and waits for a couple +# of seconds to makes sure the SB encap info remains +# unchanged. +# +# +AT_SETUP([ovn -- multi-vtep SB Chassis encap updates]) +ovn_start + +net_add n1 +sim_add hv1 +as hv1 + +ovs-vsctl add-br br-phys +# Just set the encap type to be geneve for this test. +ovn_attach n1 br-phys 192.168.0.1 24 geneve + +# Get the encap rec, should be just one - with geneve/192.168.0.1 +encap_rec=`ovn-sbctl --data=bare --no-heading --column encaps list chassis hv1` +#echo "Encap Rec before mvtep is $encap_rec" + +# Set multiple IPs +as hv1 +ovs-vsctl \ + -- set Open_vSwitch . external-ids:ovn-encap-ip="192.168.0.1,192.168.1.1" + +# Check if the encap_rec changed - should have, no need to +# compare the exact values. +encap_rec_mvtep=`ovn-sbctl --data=bare --no-heading --column encaps list chassis hv1` +#echo "Encap Rec after mvtep is $encap_rec_mvtep" + +AT_CHECK([test "$encap_rec" != "$encap_rec_mvtep"], [0], []) + +# now, wait for a couple of secs - should be enough time, I suppose. +sleep 2 + +# Check if the encap_rec changed (it should not have) +encap_rec_mvtep1=`ovn-sbctl --data=bare --no-heading --column encaps list chassis hv1` +#echo "Encap Rec after wait is $encap_rec_mvtep1" + +AT_CHECK([test "$encap_rec_mvtep" == "$encap_rec_mvtep1"], [0], []) + +OVN_CLEANUP([hv1]) +AT_CLEANUP +