From patchwork Tue Sep 7 11:50:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Odintsov X-Patchwork-Id: 1525298 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=HbW1pdho; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (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 4H3kBG07rrz9sf8 for ; Tue, 7 Sep 2021 21:51:17 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 2880660BA3; Tue, 7 Sep 2021 11:51:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GnvqTOEYyYZ9; Tue, 7 Sep 2021 11:51:14 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id BCD41613A0; Tue, 7 Sep 2021 11:51:12 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 98D02C000F; Tue, 7 Sep 2021 11:51:12 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2D58CC000D for ; Tue, 7 Sep 2021 11:51:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 1772960C1C for ; Tue, 7 Sep 2021 11:51:12 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 20suWURNNq-5 for ; Tue, 7 Sep 2021 11:51:11 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by smtp3.osuosl.org (Postfix) with ESMTPS id 0EC9361048 for ; Tue, 7 Sep 2021 11:51:07 +0000 (UTC) Received: by mail-ej1-x62a.google.com with SMTP id x11so19181780ejv.0 for ; Tue, 07 Sep 2021 04:51:07 -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=wN5effHWMMAzXlyRRF8m3NsipHTs6JbS6txgKO3xm/E=; b=HbW1pdhoyPVCKhwjCqjA1nDRLkpJNJ5E9WWj22FctIrsZP/1pekeRMdhZJPSESny4b LLyaA5qKAQ5d9bNkhoetaOO2fs2uc02K6gqym1t95O+rQWWLgsEM4PJOWUWDdqROmA6b 7DvJV4tJgb92dU9N8ILsKIePxGLEuK5dA03Chc0gn16MTu3oQi+FHkFxcGhaGgSS8Fp2 VLgvV+cW6S8EArWoCSJfpe+I1ItZl6z5ODiqfDnc08n1onjj1E6cqVkOKij5tIo1gdZ3 i2DJ/TAuDqVBJhYgoz0ruM0P72/4vGHksdVvzWZB6yqslKzfnMxnSe2ce28z3t+hkEDE Qqzg== 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:mime-version :content-transfer-encoding; bh=wN5effHWMMAzXlyRRF8m3NsipHTs6JbS6txgKO3xm/E=; b=cm9/fz6rUnPdZ+2EwhXmYRI8lztQbh/6hqWnKZJ0JDD282SbJvhqQx7WRVKOikwSr6 a6xyZnw3n4on9PfOoQ51cKIrYywigDZwzqgl+YGClfY0+HXldtms3fKFQ9ajO/Zf/vX1 DBr6gk5tAnkZK07sdem4cpvggQgLeUiiy+rO6BBhXqqLY+xO+Zf+2/aEE1/mZfqm1E+r nCJoHA75v/6QN7uiFEsXomwBdECgDHyqe00Vy3QBnCbgX3ulnfpU4vl7LDigROK4r8TA MjRiQcegJ7DFEEvnB6Rnqjs/ZJ7eG9tl8MTcwm2umD7jF8ycw/xDnbE7rQsPPJ5EfeJd Y5eg== X-Gm-Message-State: AOAM5337A1hJNo4MdPFtE8iZ+GDkZruVBFjgPjuAnigPgtkAQn6fLwKd qnm/ef7UCZV202Ligf43tTMf/4oFXLpZrA== X-Google-Smtp-Source: ABdhPJzev51ldcLUvmlrsQJlOVzD/wvGMUjdDh/Kx6dh4rWcpsupDqnsZ7qwVudj+BvvR1Xw80yNnA== X-Received: by 2002:a17:906:130a:: with SMTP id w10mr17904318ejb.89.1631015465934; Tue, 07 Sep 2021 04:51:05 -0700 (PDT) Received: from localhost.localdomain ([85.187.18.223]) by smtp.gmail.com with ESMTPSA id g18sm5439460ejr.99.2021.09.07.04.51.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Sep 2021 04:51:05 -0700 (PDT) From: Vladislav Odintsov To: dev@openvswitch.org Date: Tue, 7 Sep 2021 14:50:52 +0300 Message-Id: <20210907115052.7913-1-odivlad@gmail.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Cc: Vladislav Odintsov Subject: [ovs-dev] [PATCH ovn v2] ic: remove orphan port_binding after 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 is left in the IC_SB_DB. This patch fixes such situation and adds test for this case. Signed-off-by: Vladislav Odintsov --- v1 -> v2: - moved port_binding cleanup from ts_run() to port_binding_run() according to Han's suggestion --- ic/ovn-ic.c | 36 +++++++++++++++++++++++++++++----- tests/ovn-ic.at | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 5 deletions(-) diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c index 5a4a997e1..99356253d 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; @@ -742,6 +743,20 @@ port_binding_run(struct ic_context *ctx, return; } + struct shash isb_all_local_pbs = SHASH_INITIALIZER(&isb_all_local_pbs); + struct shash_node *node; + + 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_EQUAL (isb_pb, isb_pb_key, + ctx->icsbrec_port_binding_by_az) { + shash_add(&isb_all_local_pbs, isb_pb->logical_port, isb_pb); + } + icsbrec_port_binding_index_destroy_row(isb_pb_key); + const struct icnbrec_transit_switch *ts; ICNBREC_TRANSIT_SWITCH_FOR_EACH (ts, ctx->ovninb_idl) { const struct nbrec_logical_switch *ls = find_ts_in_nb(ctx, ts->name); @@ -752,16 +767,16 @@ port_binding_run(struct ic_context *ctx, struct shash local_pbs = SHASH_INITIALIZER(&local_pbs); struct shash remote_pbs = SHASH_INITIALIZER(&remote_pbs); struct hmap pb_tnlids = HMAP_INITIALIZER(&pb_tnlids); - 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_ts); + isb_pb_key = icsbrec_port_binding_index_init_row( + ctx->icsbrec_port_binding_by_ts); icsbrec_port_binding_index_set_transit_switch(isb_pb_key, ts->name); ICSBREC_PORT_BINDING_FOR_EACH_EQUAL (isb_pb, isb_pb_key, ctx->icsbrec_port_binding_by_ts) { if (isb_pb->availability_zone == az) { shash_add(&local_pbs, isb_pb->logical_port, isb_pb); + shash_find_and_delete(&isb_all_local_pbs, + isb_pb->logical_port); } else { shash_add(&remote_pbs, isb_pb->logical_port, isb_pb); } @@ -804,7 +819,6 @@ port_binding_run(struct ic_context *ctx, } /* Delete extra port-binding from ISB */ - struct shash_node *node; SHASH_FOR_EACH (node, &local_pbs) { icsbrec_port_binding_delete(node->data); } @@ -818,6 +832,12 @@ port_binding_run(struct ic_context *ctx, shash_destroy(&remote_pbs); ovn_destroy_tnlids(&pb_tnlids); } + + SHASH_FOR_EACH (node, &isb_all_local_pbs) { + icsbrec_port_binding_delete(node->data); + } + + shash_destroy(&isb_all_local_pbs); } struct ic_router_info { @@ -1684,6 +1704,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 +1761,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])