From patchwork Fri Dec 3 05:58:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 1563113 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.133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4J52Fm2d0nz9t1r for ; Fri, 3 Dec 2021 16:59:08 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 4EBFB401DE; Fri, 3 Dec 2021 05:59:05 +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 nXg6O9vDBQOy; Fri, 3 Dec 2021 05:59:03 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id E144C400EB; Fri, 3 Dec 2021 05:59:02 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BCFF6C001C; Fri, 3 Dec 2021 05:59:02 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id F1A0DC000A for ; Fri, 3 Dec 2021 05:59:00 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E84A380CA2 for ; Fri, 3 Dec 2021 05:59:00 +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 R4ttF2kclzJy for ; Fri, 3 Dec 2021 05:59:00 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by smtp1.osuosl.org (Postfix) with ESMTPS id 9CF7180CA0 for ; Fri, 3 Dec 2021 05:58:59 +0000 (UTC) Received: (Authenticated sender: hzhou@ovn.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 824B9240006; Fri, 3 Dec 2021 05:58:55 +0000 (UTC) From: Han Zhou To: dev@openvswitch.org Date: Thu, 2 Dec 2021 21:58:37 -0800 Message-Id: <20211203055837.3600985-1-hzhou@ovn.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [ovs-dev] [PATCH ovn] ovn-controller: Add command debug/dump-lflow-conj-ids. 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" Add the debug command in case lflow conjunction ids mapping needs to be checked during trouble shooting. Also use the dump function in test cases. An example output: $ ovn-appctl -t ovn-controller debug/dump-lflow-conj-ids Conjunction IDs allocations: lflow: 4445d4a0-3ca3-4385-a677-c0199d65ea4d, start: 1145427104, n: 1 lflow: 711b0d24-52bc-41a4-9af2-5cdea2d5167d, start: 1897598244, n: 1 lflow: 6e712ecb-f863-4a0c-a7c4-367d59914d35, start: 1852911307, n: 1 ---- Total 3 IDs used. Suggested-by: Numan Siddique Signed-off-by: Han Zhou Acked-by: Numan Siddique --- controller/lflow-conj-ids.c | 29 +++++++++++++++++++++++++ controller/lflow-conj-ids.h | 2 ++ controller/ovn-controller.c | 15 +++++++++++++ controller/test-lflow-conj-ids.c | 5 +++++ tests/ovn-lflow-conj-ids.at | 37 ++++++++++++++++++++++++++++++++ 5 files changed, 88 insertions(+) diff --git a/controller/lflow-conj-ids.c b/controller/lflow-conj-ids.c index fc33c25e5..bfe63862a 100644 --- a/controller/lflow-conj-ids.c +++ b/controller/lflow-conj-ids.c @@ -195,6 +195,35 @@ void lflow_conj_ids_clear(struct conj_ids *conj_ids) { lflow_conj_ids_init(conj_ids); } +void +lflow_conj_ids_dump(struct conj_ids *conj_ids, struct ds *out_data) +{ + struct lflow_conj_node *lflow_conj; + size_t count = 0; + + ds_put_cstr(out_data, "Conjunction IDs allocations:\n"); + HMAP_FOR_EACH (lflow_conj, hmap_node, &conj_ids->lflow_conj_ids) { + bool has_conflict = + (lflow_conj->start_conj_id != lflow_conj->lflow_uuid.parts[0]); + ds_put_format(out_data, "lflow: "UUID_FMT", start: %"PRIu32 + ", n: %"PRIu32"%s\n", + UUID_ARGS(&lflow_conj->lflow_uuid), + lflow_conj->start_conj_id, + lflow_conj->n_conjs, + has_conflict ? " (*)" : ""); + count += lflow_conj->n_conjs; + } + + ds_put_cstr(out_data, "---\n"); + ds_put_format(out_data, "Total %"PRIuSIZE" IDs used.\n", count); + + size_t allocated = hmap_count(&conj_ids->conj_id_allocations); + if (count != allocated) { + ds_put_format(out_data, "WARNING: mismatch - %"PRIuSIZE" allocated\n", + allocated); + } +} + /* Insert n_conjs conjuntion ids starting from start_conj_id into the conj_ids, * assuming the ids are confirmed to be available. */ static void diff --git a/controller/lflow-conj-ids.h b/controller/lflow-conj-ids.h index d333fa8d5..6da0a612c 100644 --- a/controller/lflow-conj-ids.h +++ b/controller/lflow-conj-ids.h @@ -17,6 +17,7 @@ #ifndef LFLOW_CONJ_IDS_H #define LFLOW_CONJ_IDS_H 1 +#include "openvswitch/dynamic-string.h" #include "openvswitch/hmap.h" #include "uuid.h" @@ -37,5 +38,6 @@ void lflow_conj_ids_free(struct conj_ids *, const struct uuid *lflow_uuid); void lflow_conj_ids_init(struct conj_ids *); void lflow_conj_ids_destroy(struct conj_ids *); void lflow_conj_ids_clear(struct conj_ids *); +void lflow_conj_ids_dump(struct conj_ids *, struct ds *out_data); #endif /* controller/lflow-conj-ids.h */ diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 26593bc0d..5fc90a34a 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -89,6 +89,7 @@ static unixctl_cb_func debug_pause_execution; static unixctl_cb_func debug_resume_execution; static unixctl_cb_func debug_status_execution; static unixctl_cb_func debug_dump_local_bindings; +static unixctl_cb_func debug_dump_conj_ids; static unixctl_cb_func lflow_cache_flush_cmd; static unixctl_cb_func lflow_cache_show_stats_cmd; static unixctl_cb_func debug_delay_nb_cfg_report; @@ -3428,6 +3429,10 @@ main(int argc, char *argv[]) debug_dump_local_bindings, &runtime_data->lbinding_data); + unixctl_command_register("debug/dump-conj-ids", "", 0, 0, + debug_dump_conj_ids, + &lflow_output_data->conj_ids); + unsigned int ovs_cond_seqno = UINT_MAX; unsigned int ovnsb_cond_seqno = UINT_MAX; unsigned int ovnsb_expected_cond_seqno = UINT_MAX; @@ -4256,3 +4261,13 @@ debug_dump_local_bindings(struct unixctl_conn *conn, int argc OVS_UNUSED, unixctl_command_reply(conn, ds_cstr(&binding_data)); ds_destroy(&binding_data); } + +static void +debug_dump_conj_ids(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *conj_ids) +{ + struct ds conj_ids_dump = DS_EMPTY_INITIALIZER; + lflow_conj_ids_dump(conj_ids, &conj_ids_dump); + unixctl_command_reply(conn, ds_cstr(&conj_ids_dump)); + ds_destroy(&conj_ids_dump); +} diff --git a/controller/test-lflow-conj-ids.c b/controller/test-lflow-conj-ids.c index 1273f9a4c..55eb3c7b6 100644 --- a/controller/test-lflow-conj-ids.c +++ b/controller/test-lflow-conj-ids.c @@ -106,6 +106,11 @@ test_conj_ids_operations(struct ovs_cmdl_context *ctx) goto done; } } + struct ds conj_ids_dump = DS_EMPTY_INITIALIZER; + lflow_conj_ids_dump(&conj_ids, &conj_ids_dump); + printf("%s", ds_cstr(&conj_ids_dump)); + ds_destroy(&conj_ids_dump); + done: lflow_conj_ids_destroy(&conj_ids); } diff --git a/tests/ovn-lflow-conj-ids.at b/tests/ovn-lflow-conj-ids.at index 818d67324..b5537c370 100644 --- a/tests/ovn-lflow-conj-ids.at +++ b/tests/ovn-lflow-conj-ids.at @@ -14,6 +14,12 @@ AT_CHECK( alloc(aaaaaaaa-1111-1111-1111-111111111111, 10): 0xaaaaaaaa alloc(bbbbbbbb-1111-1111-1111-111111111111, 10): 0xbbbbbbbb alloc(cccccccc-1111-1111-1111-111111111111, 10): 0xcccccccc +Conjunction IDs allocations: +lflow: cccccccc-1111-1111-1111-111111111111, start: 3435973836, n: 10 +lflow: aaaaaaaa-1111-1111-1111-111111111111, start: 2863311530, n: 10 +lflow: bbbbbbbb-1111-1111-1111-111111111111, start: 3149642683, n: 10 +--- +Total 30 IDs used. ]) AT_CLEANUP @@ -28,6 +34,11 @@ AT_CHECK( [0], [dnl alloc(aaaaaaaa-1111-1111-1111-111111111111, 1): 0xaaaaaaaa alloc(aaaaaaaa-2222-1111-1111-111111111111, 1): 0xaaaaaaab +Conjunction IDs allocations: +lflow: aaaaaaaa-1111-1111-1111-111111111111, start: 2863311530, n: 1 +lflow: aaaaaaaa-2222-1111-1111-111111111111, start: 2863311531, n: 1 (*) +--- +Total 2 IDs used. ]) # Conflict of the different prefix but overlapping range, the second allocation @@ -44,6 +55,11 @@ alloc(aaaaaaaa-1111-1111-1111-111111111111, 16): 0xaaaaaaaa alloc(aaaaaaab-1111-1111-1111-111111111111, 1): 0xaaaaaaba free(aaaaaaaa-1111-1111-1111-111111111111) alloc(aaaaaaab-2222-1111-1111-111111111111, 1): 0xaaaaaaab +Conjunction IDs allocations: +lflow: aaaaaaab-2222-1111-1111-111111111111, start: 2863311531, n: 1 +lflow: aaaaaaab-1111-1111-1111-111111111111, start: 2863311546, n: 1 (*) +--- +Total 2 IDs used. ]) # Conflict at the tail of the range. @@ -54,6 +70,11 @@ AT_CHECK( [0], [dnl alloc(aaaaaaaa-1111-1111-1111-111111111111, 1): 0xaaaaaaaa alloc(aaaaaaa0-1111-1111-1111-111111111111, 11): 0xaaaaaaab +Conjunction IDs allocations: +lflow: aaaaaaa0-1111-1111-1111-111111111111, start: 2863311531, n: 11 (*) +lflow: aaaaaaaa-1111-1111-1111-111111111111, start: 2863311530, n: 1 +--- +Total 12 IDs used. ]) # Realloc for the same lflow should get the same id, with the old allocations @@ -67,6 +88,11 @@ AT_CHECK( alloc(aaaaaaaa-1111-1111-1111-111111111111, 16): 0xaaaaaaaa alloc(aaaaaaaa-1111-1111-1111-111111111111, 1): 0xaaaaaaaa alloc(aaaaaaab-1111-1111-1111-111111111111, 1): 0xaaaaaaab +Conjunction IDs allocations: +lflow: aaaaaaaa-1111-1111-1111-111111111111, start: 2863311530, n: 1 +lflow: aaaaaaab-1111-1111-1111-111111111111, start: 2863311531, n: 1 +--- +Total 2 IDs used. ]) AT_CLEANUP @@ -82,6 +108,10 @@ AT_CHECK( alloc(ffffffff-1111-1111-1111-111111111111, 2): 0x1 free(ffffffff-1111-1111-1111-111111111111) alloc(00000000-2222-1111-1111-111111111111, 1): 0x1 +Conjunction IDs allocations: +lflow: 00000000-2222-1111-1111-111111111111, start: 1, n: 1 (*) +--- +Total 1 IDs used. ]) AT_CLEANUP @@ -99,6 +129,10 @@ alloc(00000001-1111-1111-1111-111111111111, 16): 0x1 alloc_specified(0000000a-1111-1111-1111-111111111111, 0xa, 1): false free(00000001-1111-1111-1111-111111111111) alloc_specified(0000000a-1111-1111-1111-111111111111, 0xa, 1): true +Conjunction IDs allocations: +lflow: 0000000a-1111-1111-1111-111111111111, start: 10, n: 1 +--- +Total 1 IDs used. ]) # alloc_specified for a range including 0 should always fail. @@ -107,6 +141,9 @@ AT_CHECK( alloc-specified fee1dead-1111-1111-1111-111111111111 0xffffffff 2], [0], [dnl alloc_specified(fee1dead-1111-1111-1111-111111111111, 0xffffffff, 2): false +Conjunction IDs allocations: +--- +Total 0 IDs used. ]) AT_CLEANUP