From patchwork Mon Apr 25 11:17:24 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: 1621878 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=LZ9yMIlE; dkim-atps=neutral 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=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4Kn2YM2PV3z9s0B for ; Mon, 25 Apr 2022 21:17:43 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 246F6405AD; Mon, 25 Apr 2022 11:17:39 +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 idilvfEYdDio; Mon, 25 Apr 2022 11:17:37 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id B6BFB40492; Mon, 25 Apr 2022 11:17:36 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8A043C007B; Mon, 25 Apr 2022 11:17:36 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8E059C007F for ; Mon, 25 Apr 2022 11:17:35 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 52306404EF for ; Mon, 25 Apr 2022 11:17:35 +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 pf01rbjGPqor for ; Mon, 25 Apr 2022 11:17:34 +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 smtp2.osuosl.org (Postfix) with ESMTPS id 7F69C4031F for ; Mon, 25 Apr 2022 11:17:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650885453; 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=rQ3gKhYrrGBJs/3g5d6ZUv28o5l7fgJpmD6sM8tqtbQ=; b=LZ9yMIlEpFjiiIAxXw97tenrsDkiEUZJb2pdtjMOpAZ05d1gWlI2wYpEScT1cyDabeXQQt XSiB2+XJYVR+mRGk2nYec6eTrDq1RcGtLbvQaUBaSp7g9Nzbv/f60od5LsFaOFoNtl97xF 9nf/oNappDwQK7WEoj6d+qk3DcufhGE= 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-464-fV3_RVzMOd29E2_q0bThNQ-1; Mon, 25 Apr 2022 07:17:31 -0400 X-MC-Unique: fV3_RVzMOd29E2_q0bThNQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 99D981E10B50 for ; Mon, 25 Apr 2022 11:17:31 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (unknown [10.39.194.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98E17145BEEE; Mon, 25 Apr 2022 11:17:30 +0000 (UTC) From: Adrian Moreno To: dev@openvswitch.org Date: Mon, 25 Apr 2022 13:17:24 +0200 Message-Id: <20220425111724.2981776-4-amorenoz@redhat.com> In-Reply-To: <20220425111724.2981776-1-amorenoz@redhat.com> References: <20220425111724.2981776-1-amorenoz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=amorenoz@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: trozet@redhat.com, dceara@redhat.com Subject: [ovs-dev] [RFC PATCH ovn 3/3] debug: add sampling of drop actions 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" Two new options are added to NB_Global table allowing to enable drop sampling specifying the collector_set_id and the obs_domain_id of the sample actions added to all drop flows. The obs_point_id is set to the flow cookie to be able to correlate it. Signed-off-by: Adrian Moreno --- northd/debug.c | 79 ++++++++++++++++++++++++++++++++++++++++++++----- northd/debug.h | 6 ++++ northd/northd.c | 1 + ovn-nb.xml | 21 +++++++++++++ 4 files changed, 99 insertions(+), 8 deletions(-) diff --git a/northd/debug.c b/northd/debug.c index 5dc40e8ce..21da9055d 100644 --- a/northd/debug.c +++ b/northd/debug.c @@ -4,32 +4,95 @@ #include "debug.h" +#include "openvswitch/dynamic-string.h" +#include "openvswitch/vlog.h" #include "smap.h" +VLOG_DEFINE_THIS_MODULE(debug) + static struct debug_config config; +bool +debug_enabled(void) +{ + return config.enabled; +} + +bool debug_sampling_enabled(void) +{ + return config.collector_set_id != 0; +} + void init_debug_config(const struct nbrec_nb_global *nb) { const struct smap *options = &nb->options; - config.enabled = smap_get_bool(options, "debug_drop_mode", false); + bool enabled = smap_get_bool(options, "debug_drop_mode", false); + uint32_t collector_set_id = smap_get_uint(options, + "debug_drop_collector_set", + 0); + + uint32_t observation_domain_id = smap_get_uint(options, + "debug_drop_domain_id", + 0); + + if (enabled != config.enabled || + collector_set_id != config.collector_set_id || + observation_domain_id != config.observation_domain_id || + !config.drop_action.string) { + + if (!enabled && collector_set_id) { + VLOG_WARN("Debug collection set configured, " + "assuming debug_drop_mode"); + enabled = true; + } + + config.enabled = enabled; + config.collector_set_id = collector_set_id; + config.observation_domain_id = observation_domain_id; + + ds_clear(&config.drop_action); + + if (debug_sampling_enabled()) { + ds_put_format(&config.drop_action, + "sample(probability=65535," + "collector_set=%d," + "obs_domain=%d," + "obs_point=$cookie); ", + config.collector_set_id, + config.observation_domain_id); + + ds_put_format(&config.drop_action, "/* drop */"); + VLOG_INFO("Debug drop sampling enabled"); + } + } } -bool -debug_enabled(void) +void +destroy_debug_config(void) { - return config.enabled; + if (config.drop_action.string) { + ds_destroy(&config.drop_action); + ds_init(&config.drop_action); + } } const char * -debug_drop_action(void) -{ - return "drop;"; +debug_drop_action(void) { + if (OVS_UNLIKELY(debug_sampling_enabled())) { + return ds_cstr_ro(&config.drop_action); + } else { + return "drop;"; + } } const char * debug_implicit_drop_action(void) { - return "/* drop */"; + if (OVS_UNLIKELY(debug_sampling_enabled())) { + return ds_cstr_ro(&config.drop_action); + } else { + return "/* drop */"; + } } diff --git a/northd/debug.h b/northd/debug.h index 0e83b4ca2..9a1c02986 100644 --- a/northd/debug.h +++ b/northd/debug.h @@ -19,14 +19,20 @@ #include #include "lib/ovn-nb-idl.h" +#include "openvswitch/dynamic-string.h" struct debug_config { bool enabled; + uint32_t collector_set_id; + uint32_t observation_domain_id; + struct ds drop_action; }; void init_debug_config(const struct nbrec_nb_global *nb); +void destroy_debug_config(void); bool debug_enabled(void); +bool debug_sampling_enabled(void); const char *debug_drop_action(void); const char *debug_implicit_drop_action(void); diff --git a/northd/northd.c b/northd/northd.c index 56d16d719..88b4d47bb 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -15268,6 +15268,7 @@ northd_destroy(struct northd_data *data) destroy_datapaths_and_ports(&data->datapaths, &data->ports, &data->lr_list); + destroy_debug_config(); } static void diff --git a/ovn-nb.xml b/ovn-nb.xml index 76b6bab17..b28607585 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -263,6 +263,27 @@

+ +

+ If set to a 32-bit number and if + debug_drop_collection_set is also configured, + ovn-northd will add a sample action to + every logical flow that contains a 'drop' action. + IPFIX samples will have the specified value in the + observation_domain_id field. +

+
+ + +

+ If set to a 32-bit number ovn-northd will add a + sample action to every logical flow that contains a + 'drop' action. The sample action will have the specified + collection_set_id. The value must match that of the local OVS + configuration as described in ovs-actions(7). +

+
+

These options control how routes are advertised between OVN