From patchwork Thu Sep 16 17:30:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Odintsov X-Patchwork-Id: 1529002 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=dIS7sB3z; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4H9PHl5nHCz9sXS for ; Fri, 17 Sep 2021 03:30:43 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 56FD1835C8; Thu, 16 Sep 2021 17:30:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MvRng0zoBvBx; Thu, 16 Sep 2021 17:30:39 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 733AB8341E; Thu, 16 Sep 2021 17:30:38 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2BB6BC0011; Thu, 16 Sep 2021 17:30:38 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3F671C000D for ; Thu, 16 Sep 2021 17:30:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 26A158341E for ; Thu, 16 Sep 2021 17:30:37 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lgTPLChqMrPz for ; Thu, 16 Sep 2021 17:30:36 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by smtp1.osuosl.org (Postfix) with ESMTPS id B88D783412 for ; Thu, 16 Sep 2021 17:30:35 +0000 (UTC) Received: by mail-lf1-x12a.google.com with SMTP id b18so19934302lfb.1 for ; Thu, 16 Sep 2021 10:30:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jJQ/SsCai4owLalCsBsrj8ey2DEm8CmI4OPZMovAd1s=; b=dIS7sB3zYIwkM0SLbO5unbIWdP2mVgyaRCkHz2TJ/0Eb0dQ5kCESRiJDzWJ/FyQjmb LxRQumHjDFtMLIQ9O/Nk+ollK+mRFEwVErlL+MgUlLqn8fitzA0t+FdHlfm58Hq4rAqt ltzm9hYO19qQUA35GmEdDFIXAeuS2kQrd8nazfkfjxF7BQ79aIC0EadF3kYm+3h704zX WrEFzWqHqWKyFWmXR+cZoF4FBPAmX4DzW0rc/2ajp04wdHXXghH+iaEHh+NXo4Fahd2G B3QVXW9kFIm97PI0jmwXZpf0qCNzHSzUDXYzjb0XRhgKIkoVkBvvlWjzFiqzFnYtK81y CwnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jJQ/SsCai4owLalCsBsrj8ey2DEm8CmI4OPZMovAd1s=; b=jKeYbX9sxU7KymOZtROp5NZVeWTXLT8QIIecMT81zZ03XHfnJ4g5oIUstXK+iERtVl Lx2bqPAxi+ZoC0XpsQ6DRW4Ib0uMqSTQkmbUQQ3quQ8OwTDhvfS+w9VQU1ekofvPgGxj LYc4TWENiC5on+AVXRalyDF0gEmQGAPapo3YKXC+TzIx4fsJfbOyA/EGcYJzykPPraVv lOGjQxIBGFh7Yca3xkhE1+A/oqkrAztnMFcUsXsOQlRaEclLW2IKumsKZo9ESKXckaam VsmKwd/mM/1w7FWNf8MRyvq+gQZDMT/R0+cnOALgInN33ssZo1pjEGZDK5Wjo14GCkJk zTZA== X-Gm-Message-State: AOAM533BmB+PHnZxPDWJriMygpNvNja6bLpywyLMevnRE/Z9RzTwnPDX pV8TqU6LCJbcxSYvNsmprRKjK0eYqpQ= X-Google-Smtp-Source: ABdhPJx947IPZQTj8j27uPD+S72XQgPD3Il05FyAwcZ2tvZemRg8am6Y49qoCQVLqsjjnu0jaxoP6A== X-Received: by 2002:a05:6512:3409:: with SMTP id i9mr4974585lfr.659.1631813430254; Thu, 16 Sep 2021 10:30:30 -0700 (PDT) Received: from localhost.localdomain (109-252-131-59.dynamic.spd-mgts.ru. [109.252.131.59]) by smtp.gmail.com with ESMTPSA id m29sm311460lfo.191.2021.09.16.10.30.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Sep 2021 10:30:29 -0700 (PDT) From: Vladislav Odintsov To: dev@openvswitch.org Date: Thu, 16 Sep 2021 20:30:28 +0300 Message-Id: <20210916173028.9527-1-odivlad@gmail.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Cc: Vladislav Odintsov Subject: [ovs-dev] [PATCH ovn] controller: configure only matching encaps between chassis 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" Previously tunnels encap on a chassis was based on the remote chassis "best" encap type. Suppose we have 2 chassis: one with STT, another with GENEVE. In this case on chassis 1 there was configured STT tunnel, and GENEVE on another one. No traffic could be sent between these chassis. With this approach it was impossible to change encap type for chassis one-by-one, because different tunnel types were configured on different edges of the link. Suppose we have 2 chassis: one with STT and VXLAN configured encaps, another with GENEVE and STT. In this case on chassis 1 there was configured STT tunnel (best of VXLAN and STT) and GENEVE on another one ("best" of GENEVE and STT). No traffic could be sent between these chassis. Though the common STT could be used. Now we configure only matching encaps between nodes. Signed-off-by: Vladislav Odintsov Acked-by: Dumitru Ceara --- controller/encaps.c | 23 ++++++++++++++++++----- controller/ovn-controller.h | 3 ++- tests/ovn-controller.at | 14 +++++++++++--- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/controller/encaps.c b/controller/encaps.c index fc93bf1ee..200b4405d 100644 --- a/controller/encaps.c +++ b/controller/encaps.c @@ -248,15 +248,26 @@ exit: smap_destroy(&options); } +static bool +chassis_has_type(const struct sbrec_chassis *chassis, uint32_t tun_type) { + for (int i =0; i < chassis->n_encaps; i++) { + if (get_tunnel_type(chassis->encaps[i]->type) == tun_type) { + return true; + } + } + return false; +} + struct sbrec_encap * -preferred_encap(const struct sbrec_chassis *chassis_rec) +preferred_encap(const struct sbrec_chassis *chassis_rec, + const struct sbrec_chassis *this_chassis) { struct sbrec_encap *best_encap = NULL; uint32_t best_type = 0; for (int i = 0; i < chassis_rec->n_encaps; i++) { uint32_t tun_type = get_tunnel_type(chassis_rec->encaps[i]->type); - if (tun_type > best_type) { + if (tun_type > best_type && chassis_has_type(this_chassis, tun_type)) { best_type = tun_type; best_encap = chassis_rec->encaps[i]; } @@ -270,9 +281,11 @@ preferred_encap(const struct sbrec_chassis *chassis_rec) * as there are VTEP of that type (differentiated by remote_ip) on that chassis. */ static int -chassis_tunnel_add(const struct sbrec_chassis *chassis_rec, const struct sbrec_sb_global *sbg, struct tunnel_ctx *tc) +chassis_tunnel_add(const struct sbrec_chassis *chassis_rec, + const struct sbrec_sb_global *sbg, struct tunnel_ctx *tc, + const struct sbrec_chassis *this_chassis) { - struct sbrec_encap *encap = preferred_encap(chassis_rec); + struct sbrec_encap *encap = preferred_encap(chassis_rec, this_chassis); int tuncnt = 0; if (!encap) { @@ -390,7 +403,7 @@ encaps_run(struct ovsdb_idl_txn *ovs_idl_txn, continue; } - if (chassis_tunnel_add(chassis_rec, sbg, &tc) == 0) { + if (chassis_tunnel_add(chassis_rec, sbg, &tc, this_chassis) == 0) { VLOG_INFO("Creating encap for '%s' failed", chassis_rec->name); continue; } diff --git a/controller/ovn-controller.h b/controller/ovn-controller.h index 78a53312f..ea48a36cb 100644 --- a/controller/ovn-controller.h +++ b/controller/ovn-controller.h @@ -43,7 +43,8 @@ struct ct_zone_pending_entry { const struct ovsrec_bridge *get_bridge(const struct ovsrec_bridge_table *, const char *br_name); -struct sbrec_encap *preferred_encap(const struct sbrec_chassis *); +struct sbrec_encap *preferred_encap(const struct sbrec_chassis *, + const struct sbrec_chassis *); uint32_t get_tunnel_type(const char *name); diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at index 4ae218ed6..3d27ddd2f 100644 --- a/tests/ovn-controller.at +++ b/tests/ovn-controller.at @@ -263,9 +263,8 @@ check_tunnel_property () { test "`ovs-vsctl get interface ovn-fakech-0 $1`" = "$2" } -# Start off with a remote chassis supporting STT -ovn-sbctl chassis-add fakechassis stt 192.168.0.2 -OVS_WAIT_UNTIL([check_tunnel_property type stt]) +# create "empty" chassis. vxlan is used here as a stub +ovn-sbctl chassis-add fakechassis vxlan 192.168.0.2 # See if we switch to Geneve as the first choice when it is available # With multi-VTEP support we support tunnels with different IPs to the @@ -278,6 +277,15 @@ OVS_WAIT_UNTIL([check_tunnel_property type stt]) encap_uuid=$(ovn-sbctl add chassis fakechassis encaps @encap -- --id=@encap create encap type=geneve ip="192.168.0.2") OVS_WAIT_UNTIL([check_tunnel_property type geneve]) +# change geneve to stt and check that tun interface was deleted and there is +# no stt encap on the second chassis, only vxlan +ovn-sbctl set encap ${encap_uuid} type=stt +OVS_WAIT_WHILE([check_tunnel_property type stt]) +OVS_WAIT_UNTIL([check_tunnel_property type vxlan]) + +# change back to geneve +ovn-sbctl set encap ${encap_uuid} type=geneve + # Check that changes within an encap row are propagated ovn-sbctl set encap ${encap_uuid} ip=192.168.0.2 OVS_WAIT_UNTIL([check_tunnel_property options:remote_ip "\"192.168.0.2\""])