From patchwork Mon Dec 19 16:18:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Adri=C3=A1n_Moreno?= X-Patchwork-Id: 1717475 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.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=YjhQtiFB; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NbQ0319Thz1ydb for ; Tue, 20 Dec 2022 03:19:47 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 6B0A240351; Mon, 19 Dec 2022 16:19:45 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 6B0A240351 Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YjhQtiFB X-Virus-Scanned: amavisd-new at osuosl.org 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 l7hmuqFjISzT; Mon, 19 Dec 2022 16:19:44 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id C38EC4033D; Mon, 19 Dec 2022 16:19:42 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C38EC4033D Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 126DEC00C7; Mon, 19 Dec 2022 16:19:42 +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 817EEC0078 for ; Mon, 19 Dec 2022 16:19:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C2EF88109A for ; Mon, 19 Dec 2022 16:18:32 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org C2EF88109A Authentication-Results: smtp1.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YjhQtiFB 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 0CXfRRYt-hfR for ; Mon, 19 Dec 2022 16:18:32 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org DAD36812C5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id DAD36812C5 for ; Mon, 19 Dec 2022 16:18:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671466710; 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=ZMDy9czskT6JYXxskXqGVw0ZINAJvKfjwtXKhzH2iic=; b=YjhQtiFBCY5qQw/B+Jnh1laZciSi/dYMXBKyz92LxFqJosR8SIFYQ6sGmbY0lKfhQlTgDa 3fibCed7uOWNFdrJw166Aj0OUzCrk/nE3hEN4TffT5GprLFUVt1HnwTBRGgraCMGAORQzM DVQP2UqRZtAz/pTmD+dC5kmlTXalEfc= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-329-73juxkPNOpm3zTy7nrZYyg-1; Mon, 19 Dec 2022 11:18:29 -0500 X-MC-Unique: 73juxkPNOpm3zTy7nrZYyg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6B75D3C0F23A for ; Mon, 19 Dec 2022 16:18:29 +0000 (UTC) Received: from antares.redhat.com (unknown [10.39.192.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC1D62026D4B; Mon, 19 Dec 2022 16:18:28 +0000 (UTC) From: Adrian Moreno To: dev@openvswitch.org Date: Mon, 19 Dec 2022 17:18:14 +0100 Message-Id: <20221219161814.55422-7-amorenoz@redhat.com> In-Reply-To: <20221219161814.55422-1-amorenoz@redhat.com> References: <20221219161814.55422-1-amorenoz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 6/6] controller: only sample pflow if Collector Set exists 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" Make physical (pflow) engine node also depend on Flow_Sample_Collector_Set table and only enable flow sampling if the right collector set exists. Signed-off-by: Adrian Moreno Acked-by: Mark Michelson --- controller/ovn-controller.c | 104 ++++++++++++++++++++++++++---------- 1 file changed, 75 insertions(+), 29 deletions(-) diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 09f843541..b2af0298d 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -3127,6 +3127,64 @@ lflow_output_flow_sample_collector_set_handler(struct engine_node *node, return true; } +static void +pflow_output_get_debug(struct engine_node *node, struct physical_debug *debug) +{ + const struct ovsrec_open_vswitch_table *ovs_table = + EN_OVSDB_GET(engine_get_input("OVS_open_vswitch", node)); + const struct ovsrec_bridge_table *bridge_table = + EN_OVSDB_GET(engine_get_input("OVS_bridge", node)); + const struct sbrec_sb_global_table *sb_global_table = + EN_OVSDB_GET(engine_get_input("SB_sb_global", node)); + const struct sbrec_sb_global *sb_global = + sbrec_sb_global_table_first(sb_global_table); + + if (!debug) { + return; + } + debug->collector_set_id = 0; + debug->obs_domain_id = 0; + + const struct ovsrec_open_vswitch *ovs_cfg = + ovsrec_open_vswitch_table_first(ovs_table); + if (!ovs_cfg) { + return; + } + + const struct ovsrec_bridge *br_int; + br_int = get_bridge(bridge_table, br_int_name(ovs_cfg)); + if (!br_int) { + return; + } + + const uint32_t debug_collector_set = + smap_get_uint(&sb_global->options, "debug_drop_collector_set", 0); + if (!debug_collector_set) { + return; + } + + struct ovsdb_idl_index *ovsrec_flow_sample_collector_set_by_id = + engine_ovsdb_node_get_index( + engine_get_input("OVS_flow_sample_collector_set", node), "id"); + + struct ovsrec_flow_sample_collector_set *s = + ovsrec_flow_sample_collector_set_index_init_row( + ovsrec_flow_sample_collector_set_by_id); + + ovsrec_flow_sample_collector_set_index_set_id(s, debug_collector_set); + ovsrec_flow_sample_collector_set_index_set_bridge(s, br_int); + if (!ovsrec_flow_sample_collector_set_index_find( + ovsrec_flow_sample_collector_set_by_id, s)) { + ovsrec_flow_sample_collector_set_index_destroy_row(s); + return; + } + ovsrec_flow_sample_collector_set_index_destroy_row(s); + + debug->collector_set_id = debug_collector_set; + debug->obs_domain_id = smap_get_uint(&sb_global->options, + "debug_drop_domain_id", 0); +} + static bool lflow_output_sb_mac_binding_handler(struct engine_node *node, void *data) { @@ -3577,11 +3635,6 @@ static void init_physical_ctx(struct engine_node *node, chassis = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id); } - const struct sbrec_sb_global_table *sb_global_table = - EN_OVSDB_GET(engine_get_input("SB_sb_global", node)); - const struct sbrec_sb_global *sb_global = - sbrec_sb_global_table_first(sb_global_table); - ovs_assert(br_int && chassis); struct ed_type_ct_zones *ct_zones_data = @@ -3603,13 +3656,8 @@ static void init_physical_ctx(struct engine_node *node, p_ctx->local_bindings = &rt_data->lbinding_data.bindings; p_ctx->patch_ofports = &non_vif_data->patch_ofports; p_ctx->chassis_tunnels = &non_vif_data->chassis_tunnels; - p_ctx->debug.collector_set_id = smap_get_uint(&sb_global->options, - "debug_drop_collector_set", - 0); - p_ctx->debug.obs_domain_id = smap_get_uint(&sb_global->options, - "debug_drop_domain_id", - 0); + pflow_output_get_debug(node, &p_ctx->debug); } static void * @@ -3813,26 +3861,16 @@ pflow_output_activated_ports_handler(struct engine_node *node, void *data) } static bool -pflow_output_sb_sb_global_handler(struct engine_node *node, void *data) +pflow_output_debug_handler(struct engine_node *node, void *data) { - const struct sbrec_sb_global_table *sb_global_table = - EN_OVSDB_GET(engine_get_input("SB_sb_global", node)); - const struct sbrec_sb_global *sb_global = - sbrec_sb_global_table_first(sb_global_table); - struct ed_type_pflow_output *pfo = data; + struct physical_debug debug; + + pflow_output_get_debug(node, &debug); - uint32_t collector_set_id = smap_get_uint(&sb_global->options, - "debug_drop_collector_set", - 0); - uint32_t obs_domain_id = smap_get_uint(&sb_global->options, - "debug_drop_domain_id", - 0); - - if (pfo->debug.collector_set_id != collector_set_id || - pfo->debug.obs_domain_id != obs_domain_id) { - pfo->debug.collector_set_id = collector_set_id; - pfo->debug.obs_domain_id = obs_domain_id; + if (pfo->debug.collector_set_id != debug.collector_set_id || + pfo->debug.obs_domain_id != debug.obs_domain_id) { + pfo->debug = debug; return false; } engine_set_node_state(node, EN_UPDATED); @@ -3989,6 +4027,10 @@ main(int argc, char *argv[]) struct ovsdb_idl_index *ovsrec_port_by_interfaces = ovsdb_idl_index_create1(ovs_idl_loop.idl, &ovsrec_port_col_interfaces); + struct ovsdb_idl_index *ovsrec_flow_sample_collector_set_by_id + = ovsdb_idl_index_create2(ovs_idl_loop.idl, + &ovsrec_flow_sample_collector_set_col_bridge, + &ovsrec_flow_sample_collector_set_col_id); ovsdb_idl_get_initial_snapshot(ovs_idl_loop.idl); @@ -4189,8 +4231,10 @@ main(int argc, char *argv[]) engine_add_input(&en_pflow_output, &en_mff_ovn_geneve, NULL); engine_add_input(&en_pflow_output, &en_ovs_open_vswitch, NULL); engine_add_input(&en_pflow_output, &en_ovs_bridge, NULL); + engine_add_input(&en_pflow_output, &en_ovs_flow_sample_collector_set, + pflow_output_debug_handler); engine_add_input(&en_pflow_output, &en_sb_sb_global, - pflow_output_sb_sb_global_handler); + pflow_output_debug_handler); engine_add_input(&en_northd_options, &en_sb_sb_global, en_northd_options_sb_sb_global_handler); @@ -4327,6 +4371,8 @@ main(int argc, char *argv[]) sbrec_static_mac_binding_by_datapath); engine_ovsdb_node_add_index(&en_sb_chassis_template_var, "chassis", sbrec_chassis_template_var_index_by_chassis); + engine_ovsdb_node_add_index(&en_ovs_flow_sample_collector_set, "id", + ovsrec_flow_sample_collector_set_by_id); struct ed_type_lflow_output *lflow_output_data = engine_get_internal_data(&en_lflow_output);