From patchwork Sat Jul 3 08:10:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Gray X-Patchwork-Id: 1500329 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=140.211.166.138; helo=smtp1.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=gwotPyJN; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.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 4GH4QD4PSqz9shx for ; Sat, 3 Jul 2021 18:10:44 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 0C39D8432C; Sat, 3 Jul 2021 08:10:42 +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 PwwFsqrLzvqf; Sat, 3 Jul 2021 08:10:41 +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 40472842F1; Sat, 3 Jul 2021 08:10:40 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E8774C000E; Sat, 3 Jul 2021 08:10:39 +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 761F9C000E for ; Sat, 3 Jul 2021 08:10:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 5C9FD60639 for ; Sat, 3 Jul 2021 08:10:38 +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 6YwX6QCIHW9s for ; Sat, 3 Jul 2021 08:10:37 +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 [216.205.24.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 8DFB8605F8 for ; Sat, 3 Jul 2021 08:10:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625299836; 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=gwotPyJNq+SGj4sOIRDaUZZrDjyGpZGJ5wgky0v2xVIXLFgkbF70Nbf70L/nEQI0cS6e4C PhbBcMt+g+k2Bo28sWcbyqHHoie+AheezEEc/CiHX09B+U9EW1IYT1rVJvaMUY6uOc53eN tICwvlX/eLvLkcm8Ac6DXOyX4YgMLWE= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-189-giS-lykdP-GG0eN17fn22w-1; Sat, 03 Jul 2021 04:10:35 -0400 X-MC-Unique: giS-lykdP-GG0eN17fn22w-1 Received: by mail-qk1-f199.google.com with SMTP id d24-20020a05620a1378b02903b477b3922bso4300116qkl.11 for ; Sat, 03 Jul 2021 01:10:35 -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=N6t/BQpccRKzP5+uyRlAZynxa//zJH9DDmn+Bd5WkJmK6hD9FkioAiAqf7Eo6Gxgxs kJO1T29j1uEHGHjEtExnViJES8Gfi/QaXeHBimtT3zHauXgmpJqhGi3UxcPTYEd7nnOH Zfxos56piMa6fIRfboMViByBM37gSaHjOwO2Zxkop3rcnqW3oVxUlekGrGB6os+ThSSB takFla+ZwVJKX+lbDcdKbOVC5HN7OZv1d3DPY1fjsP7aU0C1m4esjMwHsVjKEgb9HyEw xwanVvcTt3gfu+Lxhks1rlzM8WOBrj5gJjI3pe6/auRCt8UXNia7R0AGZwZYE+PxJByQ QVTg== X-Gm-Message-State: AOAM530jbDE7HD6vY9odWxMi5cwgjPuNPl0CnAZbuE/2RfjJmoLf5j72 l43XJhIwQPD3x/zFBtAwaUt3r/zOWXYnDTibs5/OftGFGRItPhQYLRi+G4JQOcISM+5OgwpPnPt /xt9SBXBgPot4kHK4SyYp8zRyUxb3Nolnii5bdh5lYe85kYH0OvO6akzJ6bFzrLjAH1Dt X-Received: by 2002:a37:6652:: with SMTP id a79mr3883225qkc.269.1625299834645; Sat, 03 Jul 2021 01:10:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT8oZqMoPMJdqkwOrXTIdnU7nluxkQ5+KxsYwIL98t2DL86YPD2jWRQWomruR2i5XljOw55A== X-Received: by 2002:a37:6652:: with SMTP id a79mr3883202qkc.269.1625299834402; Sat, 03 Jul 2021 01:10:34 -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 p187sm2517495qkd.57.2021.07.03.01.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Jul 2021 01:10:33 -0700 (PDT) From: Mark Gray To: dev@openvswitch.org Date: Sat, 3 Jul 2021 04:10:28 -0400 Message-Id: <20210703081031.855198-2-mark.d.gray@redhat.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210703081031.855198-1-mark.d.gray@redhat.com> References: <20210703081031.855198-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 v6 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);