From patchwork Fri Sep 3 10:34:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Odintsov X-Patchwork-Id: 1524200 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.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=mHHWroWq; 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 4H1DhP6Qzsz9s5R for ; Fri, 3 Sep 2021 20:35:17 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id A70CB834F1; Fri, 3 Sep 2021 10:35:15 +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 ynbAnA0ZuE4i; Fri, 3 Sep 2021 10:35:14 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id B5ECD8381F; Fri, 3 Sep 2021 10:35:13 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8D062C0010; Fri, 3 Sep 2021 10:35:13 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id EC557C0010 for ; Fri, 3 Sep 2021 10:35:11 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id CD6E7407C3 for ; Fri, 3 Sep 2021 10:35:11 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Dxv08UYxviXI for ; Fri, 3 Sep 2021 10:35:10 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by smtp2.osuosl.org (Postfix) with ESMTPS id 3D46240184 for ; Fri, 3 Sep 2021 10:35:10 +0000 (UTC) Received: by mail-ej1-x62c.google.com with SMTP id jg16so8016951ejc.1 for ; Fri, 03 Sep 2021 03:35:10 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=ECK3yID+iBT+zrenohsCKcKsd7z6vJcsHzu78sS2p1Y=; b=mHHWroWq/umr1YUeQyMKhpyEfp6KvYqLdt5pKj4HFl1G+6nB7saHlUpMH79qzUHlb8 8F50oACHKHkjLbMcsA8aZB6kcO2sQRNI8YDpHl9IsqAwbGUq5rIchJN+OnfHuyqb5YvB gC6LrRf4nxVVGbMJSH3P++Q6U0ZeoH+X/mhDgsyuVdio3MsCnaeNtrfnGUT4usIRvp67 1aanieZ1CPQ+LEzU8i5h5ShOQQI8whlzJKdqakqStgaYbee/ahYs0W9yu09TI841Ibsy fp5jNFbnIh4Ti+qmIdgylFSI1m2VVYp88VhEl4AuBDSUXR+BQmnvjzpxvcaLSAETtyWC sIuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ECK3yID+iBT+zrenohsCKcKsd7z6vJcsHzu78sS2p1Y=; b=ZFEqpA2FBtms+QimHKD5Bu2RIbjitOcundM4dK76uyy6FMEV39Dmv/a3DUfvNTHI57 8Fi5YkApTV9MlL3nKgMNmxcDvzzS24i6BNbmsqGQTW7muc87dOq5v39SJhEXzc++wMFE 5ZgKnebDDoT0Q2rMc8L77rfcNXIthvw6bE/3sSL8T/wCvNShWyQ/RsORnnoPpqtjKtBA UOJRwoyyYnfwZ2qLwX9b+dqnuuqCATb+Wb4wSGckxgBKc8KSPJkYeyXWbS1ixcnx0f3M 6sQ91LHD40ogckNOzrhWhMpyBbAO/ycdYeybj18V94x+LG/n8Jx6AYA1bbVBhpz3LLqT b9bA== X-Gm-Message-State: AOAM533EJSLVAdOREp83SHHPsTspikIvVivci9h5DUSejgpuxIkDYpq1 gVNR6ocP5T1/izwogZZRogNEgIDzHfQ= X-Google-Smtp-Source: ABdhPJwr7A3bKImyBO4HgHRm7EF2113X9GZ29142ERHgz57/9HKf0uwyYkojUBP7kyIE7yqOTaaJHQ== X-Received: by 2002:a17:906:c18c:: with SMTP id g12mr3619991ejz.458.1630665308261; Fri, 03 Sep 2021 03:35:08 -0700 (PDT) Received: from localhost.localdomain ([85.187.18.127]) by smtp.gmail.com with ESMTPSA id d22sm2609897ejj.47.2021.09.03.03.35.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Sep 2021 03:35:07 -0700 (PDT) From: Vladislav Odintsov To: dev@openvswitch.org Date: Fri, 3 Sep 2021 13:34:36 +0300 Message-Id: <20210903103441.33178-2-odivlad@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210903103441.33178-1-odivlad@gmail.com> References: <20210903103441.33178-1-odivlad@gmail.com> MIME-Version: 1.0 Cc: Vladislav Odintsov Subject: [ovs-dev] [PATCH ovn v2 1/6] ic: remove port_binding on ts deletion 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" When IC port_binding exists and transit switch is deleted, the orphan port_binding if left in the IC_SB_DB. This patch fixes such situation and adds test for this case. Signed-off-by: Vladislav Odintsov --- ic/ovn-ic.c | 35 +++++++++++++++++++++++++++++++-- tests/ovn-ic.at | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 2 deletions(-) diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c index 9eb792ea5..418f19147 100644 --- a/ic/ovn-ic.c +++ b/ic/ovn-ic.c @@ -66,6 +66,7 @@ struct ic_context { struct ovsdb_idl_index *nbrec_port_by_name; struct ovsdb_idl_index *sbrec_chassis_by_name; struct ovsdb_idl_index *sbrec_port_binding_by_name; + struct ovsdb_idl_index *icsbrec_port_binding_by_az; struct ovsdb_idl_index *icsbrec_port_binding_by_ts; struct ovsdb_idl_index *icsbrec_route_by_ts; struct ovsdb_idl_index *icsbrec_route_by_ts_az; @@ -175,7 +176,7 @@ allocate_ts_dp_key(struct hmap *dp_tnlids) } static void -ts_run(struct ic_context *ctx) +ts_run(struct ic_context *ctx, const struct icsbrec_availability_zone *az) { const struct icnbrec_transit_switch *ts; @@ -240,8 +241,25 @@ ts_run(struct ic_context *ctx) * SB, to avoid uncommitted ISB datapath tunnel key to be synced back to * AZ. */ if (ctx->ovnisb_txn) { + struct shash isb_pbs = SHASH_INITIALIZER(&isb_pbs); + const struct icsbrec_port_binding *isb_pb; + const struct icsbrec_port_binding *isb_pb_key = + icsbrec_port_binding_index_init_row( + ctx->icsbrec_port_binding_by_az); + + icsbrec_port_binding_index_set_availability_zone(isb_pb_key, az); + + ICSBREC_PORT_BINDING_FOR_EACH (isb_pb, ctx->ovnisb_idl) { + shash_add(&isb_pbs, isb_pb->transit_switch, isb_pb); + } + /* Create ISB Datapath_Binding */ ICNBREC_TRANSIT_SWITCH_FOR_EACH (ts, ctx->ovninb_idl) { + while (shash_find_and_delete(&isb_pbs, ts->name)) { + /* There may be multiple Port_Bindings */ + continue; + } + isb_dp = shash_find_and_delete(&isb_dps, ts->name); if (!isb_dp) { /* Allocate tunnel key */ @@ -261,6 +279,13 @@ ts_run(struct ic_context *ctx) SHASH_FOR_EACH (node, &isb_dps) { icsbrec_datapath_binding_delete(node->data); } + + SHASH_FOR_EACH (node, &isb_pbs) { + icsbrec_port_binding_delete(node->data); + } + + icsbrec_port_binding_index_destroy_row(isb_pb_key); + shash_destroy(&isb_pbs); } ovn_destroy_tnlids(&dp_tnlids); shash_destroy(&isb_dps); @@ -1493,7 +1518,7 @@ ovn_db_run(struct ic_context *ctx) return; } - ts_run(ctx); + ts_run(ctx, az); gateway_run(ctx, az); port_binding_run(ctx, az); route_run(ctx, az); @@ -1684,6 +1709,11 @@ main(int argc, char *argv[]) struct ovsdb_idl_index *sbrec_chassis_by_name = ovsdb_idl_index_create1(ovnsb_idl_loop.idl, &sbrec_chassis_col_name); + + struct ovsdb_idl_index *icsbrec_port_binding_by_az + = ovsdb_idl_index_create1(ovnisb_idl_loop.idl, + &icsbrec_port_binding_col_availability_zone); + struct ovsdb_idl_index *icsbrec_port_binding_by_ts = ovsdb_idl_index_create1(ovnisb_idl_loop.idl, &icsbrec_port_binding_col_transit_switch); @@ -1736,6 +1766,7 @@ main(int argc, char *argv[]) .nbrec_port_by_name = nbrec_port_by_name, .sbrec_port_binding_by_name = sbrec_port_binding_by_name, .sbrec_chassis_by_name = sbrec_chassis_by_name, + .icsbrec_port_binding_by_az = icsbrec_port_binding_by_az, .icsbrec_port_binding_by_ts = icsbrec_port_binding_by_ts, .icsbrec_route_by_ts = icsbrec_route_by_ts, .icsbrec_route_by_ts_az = icsbrec_route_by_ts_az, diff --git a/tests/ovn-ic.at b/tests/ovn-ic.at index ee78f4794..b6a8edb68 100644 --- a/tests/ovn-ic.at +++ b/tests/ovn-ic.at @@ -64,6 +64,58 @@ OVN_CLEANUP_IC([az1]) AT_CLEANUP ]) + +AT_SETUP([ovn-ic -- port bindings]) + +ovn_init_ic_db +net_add n1 + +# 1 GW per AZ +for i in 1 2; do + az=az$i + ovn_start $az + sim_add gw-$az + as gw-$az + check ovs-vsctl add-br br-phys + ovn_az_attach $az n1 br-phys 192.168.1.$i + check ovs-vsctl set open . external-ids:ovn-is-interconn=true +done + +ovn_as az1 + +# create transit switch and connect to LR +check ovn-ic-nbctl ts-add ts1 +check ovn-nbctl lr-add lr1 +check ovn-nbctl lrp-add lr1 lrp1 00:00:00:00:00:01 10.0.0.1/24 +check ovn-nbctl lrp-set-gateway-chassis lrp1 gw-az1 + +check ovn-nbctl lsp-add ts1 lsp1 -- \ + lsp-set-addresses lsp1 router -- \ + lsp-set-type lsp1 router -- \ + lsp-set-options lsp1 router-port=lrp1 + +OVS_WAIT_UNTIL([ovn-sbctl list datapath_binding | grep interconn-ts | grep ts1]) + +# check port binding appeared +AT_CHECK([ovn-ic-sbctl show | grep -A2 lsp1], [0], [dnl + port lsp1 + transit switch: ts1 + address: [["00:00:00:00:00:01 10.0.0.1/24"]] +]) + +# remove transit switch and check if port_binding is deleted +check ovn-ic-nbctl ts-del ts1 +OVS_WAIT_UNTIL([test -z "$(ovn-ic-sbctl show | grep lsp1)"]) + +for i in 1 2; do + az=az$i + OVN_CLEANUP_SBOX(gw-$az) + OVN_CLEANUP_AZ([$az]) +done +OVN_CLEANUP_IC +AT_CLEANUP + + OVN_FOR_EACH_NORTHD([ AT_SETUP([ovn-ic -- gateway sync])