From patchwork Fri Jul 2 08:57:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Gray X-Patchwork-Id: 1499905 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=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=QthpnKGY; dkim-atps=neutral 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 4GGTVr0zp8z9sV8 for ; Fri, 2 Jul 2021 18:57:40 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 4809D60B7B; Fri, 2 Jul 2021 08:57:37 +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 PMBZAL_DCcma; Fri, 2 Jul 2021 08:57:36 +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 065A260629; Fri, 2 Jul 2021 08:57:35 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 252B6C0021; Fri, 2 Jul 2021 08:57:33 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 784C3C000E for ; Fri, 2 Jul 2021 08:57:31 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 65D32405E9 for ; Fri, 2 Jul 2021 08:57:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iE64qGOmDTEq for ; Fri, 2 Jul 2021 08:57:30 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id 17D42405C7 for ; Fri, 2 Jul 2021 08:57:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625216249; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tCmrfhSqxc/XvpCJRtHsJeHx4GuqO12ljzKuYBU+rbs=; b=QthpnKGYdOf1h3eaPESbWcz95xW4pMv/o23a4u+PFc9mNs+sfP1wonqmV+ysvLEJQF59HJ bFUDQtaVOfHgAaJALEc5INKybyR/WrOupOFpzVDXax+yLgo+P7y36ebH0FQ4ZRxJy6uQBU /Kc4b5Lh8kWnl2n0xbMBtT7Kme2R8iI= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-116-TCgDKj2BOs-A3xukpd21_Q-1; Fri, 02 Jul 2021 04:57:28 -0400 X-MC-Unique: TCgDKj2BOs-A3xukpd21_Q-1 Received: by mail-qk1-f198.google.com with SMTP id z3-20020ae9c1030000b02903b44440a9a9so4776384qki.0 for ; Fri, 02 Jul 2021 01:57:28 -0700 (PDT) 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=tCmrfhSqxc/XvpCJRtHsJeHx4GuqO12ljzKuYBU+rbs=; b=ouPDQRhL9cxv8AjZ/VOlhQHdDBIABrUCHYlYYQKl8bKJo65Tic25CRfdT2CTCAfToL chzJpwYxTiq/+hmXmWMGqVwEg5vUOBrLYzXp3XqueHLF1kjRjLHvsKDb9jd+HW0jGipd YCbvF3J1Et27X8ZuuU6Plk3CKLjb1N+dNawuerJ6YJgyS8HLGMOBGFL8xix4ERhGMVyT j2wTVoNzyP+UAZ+Y9uBqW00qiGotYvZEKD22lTD0siXKOo6ucFWaC65qLCw0/wm77MiG aczodJPzp5lwU/duq1/m9dSlvhyWyHBN3M5OWuxnM6LQDYS6ZPE7Q0qps7IRtB2hcLJ/ CFVQ== X-Gm-Message-State: AOAM530bqebdOydLGZCM38K2UkU5gp/pYD0oNDKyuAsBfLRtCsaij6x2 O+W7C7BbeXJUVWBlda/CjLxw/frFEcbRY692A9McYW6uDvXjGG59/raYXlg0gDwS8K/beZcuhS3 juZjQrTzH1qhgj91VLjpMHJ1Txx1FwHCwO32YK+gqtfqcYvxTMWiyFgv3ec8EErEKDW6d X-Received: by 2002:ac8:7b2e:: with SMTP id l14mr4079646qtu.222.1625216247078; Fri, 02 Jul 2021 01:57:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuVN2j2QwBE2imAKNefmXLntXIcF6RGndBdHfhLAt2jiCKSRGNlyjN/p0RoOsIsFuSnbVgoA== X-Received: by 2002:ac8:7b2e:: with SMTP id l14mr4079635qtu.222.1625216246835; Fri, 02 Jul 2021 01:57:26 -0700 (PDT) Received: from wsfd-netdev91.ntdv.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id p14sm1118805qkg.123.2021.07.02.01.57.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 01:57:26 -0700 (PDT) From: Mark Gray To: dev@openvswitch.org Date: Fri, 2 Jul 2021 04:57:20 -0400 Message-Id: <20210702085723.3188021-2-mark.d.gray@redhat.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210702085723.3188021-1-mark.d.gray@redhat.com> References: <20210702085723.3188021-1-mark.d.gray@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mark.d.gray@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org, dceara@redhat.com Subject: [ovs-dev] [PATCH ovn v3 1/4] northd: update stage-name if changed 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" If a new table is added to a logical flow pipeline, the mapping between 'external_ids:stage-name' from the 'Logical_Flow' table in the 'OVN_Southbound' database and the 'stage' number may change for some tables. If 'ovn-northd' is started against a populated Southbound database, 'external_ids' will not be updated to reflect the new, correct name. This will cause 'external_ids' to be incorrectly displayed by some tools and commands such as `ovn-sbctl dump-flows`. This commit, reconciles these changes as part of build_lflows() when 'ovn_internal_version' is updated. Suggested-by: Ilya Maximets Signed-off-by: Mark Gray --- Notes: v2: Update all 'external_ids' rather than just 'stage-name' lib/ovn-util.c | 4 ++-- northd/ovn-northd.c | 42 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/lib/ovn-util.c b/lib/ovn-util.c index c5af8d1ab340..acf4b1cd6059 100644 --- a/lib/ovn-util.c +++ b/lib/ovn-util.c @@ -758,8 +758,8 @@ ip_address_and_port_from_lb_key(const char *key, char **ip_address, return true; } -/* Increment this for any logical flow changes or if existing OVN action is - * modified. */ +/* Increment this for any logical flow changes, if an existing OVN action is + * modified or a stage is added to a logical pipeline. */ #define OVN_INTERNAL_MINOR_VER 0 /* Returns the OVN version. The caller must free the returned value. */ diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 83746f4ab444..5e5e0ce6d39f 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -12325,7 +12325,8 @@ build_lflows(struct northd_context *ctx, struct hmap *datapaths, struct hmap *ports, struct hmap *port_groups, struct hmap *mcgroups, struct hmap *igmp_groups, struct shash *meter_groups, - struct hmap *lbs, struct hmap *bfd_connections) + struct hmap *lbs, struct hmap *bfd_connections, + bool ovn_internal_version_changed) { struct hmap lflows; @@ -12437,6 +12438,32 @@ build_lflows(struct northd_context *ctx, struct hmap *datapaths, ovn_stage_build(dp_type, pipeline, sbflow->table_id), sbflow->priority, sbflow->match, sbflow->actions, sbflow->hash); if (lflow) { + if (ovn_internal_version_changed) { + const char *stage_name = smap_get_def(&sbflow->external_ids, + "stage-name", ""); + const char *stage_hint = smap_get_def(&sbflow->external_ids, + "stage-hint", ""); + const char *source = smap_get_def(&sbflow->external_ids, + "source", ""); + + if (strcmp(stage_name, ovn_stage_to_str(lflow->stage))) { + sbrec_logical_flow_update_external_ids_setkey(sbflow, + "stage-name", ovn_stage_to_str(lflow->stage)); + } + if (lflow->stage_hint) { + if (strcmp(stage_hint, lflow->stage_hint)) { + sbrec_logical_flow_update_external_ids_setkey(sbflow, + "stage-hint", lflow->stage_hint); + } + } + if (lflow->where) { + if (strcmp(source, lflow->where)) { + sbrec_logical_flow_update_external_ids_setkey(sbflow, + "source", lflow->where); + } + } + } + /* This is a valid lflow. Checking if the datapath group needs * updates. */ bool update_dp_group = false; @@ -13268,6 +13295,7 @@ ovnnb_db_run(struct northd_context *ctx, struct shash meter_groups = SHASH_INITIALIZER(&meter_groups); struct hmap lbs; struct hmap bfd_connections = HMAP_INITIALIZER(&bfd_connections); + bool ovn_internal_version_changed = true; /* Sync ipsec configuration. * Copy nb_cfg from northbound to southbound database. @@ -13319,7 +13347,12 @@ ovnnb_db_run(struct northd_context *ctx, smap_replace(&options, "max_tunid", max_tunid); free(max_tunid); - smap_replace(&options, "northd_internal_version", ovn_internal_version); + if (!strcmp(ovn_internal_version, + smap_get_def(&options, "northd_internal_version", ""))) { + ovn_internal_version_changed = false; + } else { + smap_replace(&options, "northd_internal_version", ovn_internal_version); + } nbrec_nb_global_verify_options(nb); nbrec_nb_global_set_options(nb, &options); @@ -13358,7 +13391,8 @@ ovnnb_db_run(struct northd_context *ctx, build_meter_groups(ctx, &meter_groups); build_bfd_table(ctx, &bfd_connections, ports); build_lflows(ctx, datapaths, ports, &port_groups, &mcast_groups, - &igmp_groups, &meter_groups, &lbs, &bfd_connections); + &igmp_groups, &meter_groups, &lbs, &bfd_connections, + ovn_internal_version_changed); ovn_update_ipv6_prefix(ports); sync_address_sets(ctx); @@ -14228,6 +14262,8 @@ main(int argc, char *argv[]) add_column_noalert(ovnsb_idl_loop.idl, &sbrec_logical_flow_col_priority); add_column_noalert(ovnsb_idl_loop.idl, &sbrec_logical_flow_col_match); add_column_noalert(ovnsb_idl_loop.idl, &sbrec_logical_flow_col_actions); + ovsdb_idl_add_column(ovnsb_idl_loop.idl, + &sbrec_logical_flow_col_external_ids); ovsdb_idl_add_table(ovnsb_idl_loop.idl, &sbrec_table_logical_dp_group);