From patchwork Fri Jul 2 17:19:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Gray X-Patchwork-Id: 1500206 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::133; helo=smtp2.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=gFTeaCH3; dkim-atps=neutral Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (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 4GGhfn454qz9sS8 for ; Sat, 3 Jul 2021 03:20:17 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id A01D540651; Fri, 2 Jul 2021 17:20:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org 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 o54VJEnCD4vT; Fri, 2 Jul 2021 17:20:13 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id B2B4C40637; Fri, 2 Jul 2021 17:20:12 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 96D62C001A; Fri, 2 Jul 2021 17:20:12 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0C9EDC001F for ; Fri, 2 Jul 2021 17:20:10 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 9E3346065A for ; Fri, 2 Jul 2021 17:20:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 br9t1iFqzL4n for ; Fri, 2 Jul 2021 17:20:07 +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 smtp3.osuosl.org (Postfix) with ESMTPS id CD0AE6069A for ; Fri, 2 Jul 2021 17:20:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625246406; 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=nIWEyvJSn4a2fYfZVMhprMMX5MUKNBZdVkSsfJbkKpM=; b=gFTeaCH3MofU8lKK1g4R+qPGPwhbBxf2pyb9dxdtiMQrUUNAIrrryt+wiXFJO69jyM6aml EDcdTTiFhVL9jXKvD5gjqoRH3AajsajigvBO5EtILNX88iVxZ4t9Zy6y1UhzvpUu5G+Fgr tmMyTaWNT3neHxpRiACjPSgVQ1xShSA= Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-272-xEg0Qg-WMAqy4S-Ow6RySg-1; Fri, 02 Jul 2021 13:20:05 -0400 X-MC-Unique: xEg0Qg-WMAqy4S-Ow6RySg-1 Received: by mail-pf1-f197.google.com with SMTP id k2-20020a056a001342b029030577f46001so6699444pfu.6 for ; Fri, 02 Jul 2021 10:20:05 -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=nIWEyvJSn4a2fYfZVMhprMMX5MUKNBZdVkSsfJbkKpM=; b=eWdKQCPftmL7aatW+ST5fzyx7pDAvAYOdHCQBv11gSyx7YBaUYB1o0Imsj34O3kVFH i1hCFm1B5/d5OH8ptq9xeqqc7/f2h+rc+CGm5xh+IJsNkLCtKm2arYkoT+6FVj/XCz7H BtQiYnlCRN3oQUxKdtD0LrYVDxmeAi3FTro69blSL6w3jIpyn9S5wGigTHU356M5U8ni 15cdYCOZPFgBJul5j9Mr0ZMMoTJFZtKtltdzbC3iXdZ1bWJA/72fp0Dqf3aGjdF5M6g9 pL05wiYJh2lfphzdFGWF8zjXWZl1rPHNnXIm+5fYJaf8KcYiizWggs/83UCLVZ2r44ge g3/w== X-Gm-Message-State: AOAM533B1KoshX02XLG/tzuvbTOdl2xL74e+xEsc241mibvwHc/nMVBT eMvoLQpmCmRHKTdq8/f/hE0miJhoLOYRSQ4tjaoqwg2p4nN8CDZw1/HeNTi4UhXWz9QJYobKO83 RPB8Kt4UnoclCC/sgAZEaVtBEUGevKJMFqh5e1Hlwoqw7kS/75OkfDZ6Mw0Mv5G14yq9e X-Received: by 2002:a05:6a00:8c4:b029:2b4:8334:ed4d with SMTP id s4-20020a056a0008c4b02902b48334ed4dmr816547pfu.36.1625246404426; Fri, 02 Jul 2021 10:20:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJex1WZ+suBpX3pdgthac/UHlykFuoNLE23ozPB9zvG0tfwbitma0OA3mC40JCYFaZWnQlCA== X-Received: by 2002:a05:6a00:8c4:b029:2b4:8334:ed4d with SMTP id s4-20020a056a0008c4b02902b48334ed4dmr816522pfu.36.1625246404124; Fri, 02 Jul 2021 10:20:04 -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 j2sm4055781pfi.111.2021.07.02.10.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Jul 2021 10:20:03 -0700 (PDT) From: Mark Gray To: dev@openvswitch.org Date: Fri, 2 Jul 2021 13:19:50 -0400 Message-Id: <20210702171953.55544-2-mark.d.gray@redhat.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210702171953.55544-1-mark.d.gray@redhat.com> References: <20210702171953.55544-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: dceara@redhat.com, i.maximets@ovn.org Subject: [ovs-dev] [PATCH ovn v5 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' v4: Fix line length errors from 0-day lib/ovn-util.c | 4 ++-- northd/ovn-northd.c | 43 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 42 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..16268925ff7c 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,13 @@ 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 +13392,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 +14263,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);