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 <[email protected]> --- 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 <stdbool.h> #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 @@ </p> </column> + <column name="options" key="debug_drop_domain_id"> + <p> + If set to a 32-bit number and if + <code>debug_drop_collection_set</code> is also configured, + <code>ovn-northd</code> will add a <code>sample</code> action to + every logical flow that contains a 'drop' action. + IPFIX samples will have the specified value in the + observation_domain_id field. + </p> + </column> + + <column name="options" key="debug_drop_collection_set"> + <p> + If set to a 32-bit number <code>ovn-northd</code> will add a + <code>sample</code> 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). + </p> + </column> + <group title="Options for configuring interconnection route advertisement"> <p> These options control how routes are advertised between OVN -- 2.35.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
