From e36bf4a37f813ef003b5c941371e02db217dacbd Mon Sep 17 00:00:00 2001 From: Vladimir Jigulin Date: Fri, 15 Mar 2024 12:07:15 +0100 Subject: [PATCH] [CENNSO-1852] Throttle ipfix error messages (#396) To avoid lags because of warnings spam --- upf/upf_ipfix.c | 9 +++++++-- upf/upf_ipfix.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/upf/upf_ipfix.c b/upf/upf_ipfix.c index 5693a06..716540b 100644 --- a/upf/upf_ipfix.c +++ b/upf/upf_ipfix.c @@ -690,8 +690,10 @@ upf_ipfix_ensure_context (const upf_ipfix_context_key_t *key) &context->template_id, key->is_ip4, true); if (rv) { - clib_warning ("couldn't add IPFIX report, perhaps " - "the exporter has been deleted?"); + vlib_log_err ( + fm->log_failure_class, + "IPFIX report add reason %U, exporter misconfigured or deleted", + format_vnet_api_errno, rv); pool_put (fm->contexts, context); return ~0; } @@ -718,6 +720,9 @@ upf_ipfix_init (vlib_main_t *vm) /* Set up time reference pair */ fm->vlib_time_0 = (u32) vlib_time_now (vm); + fm->log_failure_class = + vlib_log_register_class_rate_limit ("ipfix", "failure", 1); + /* initialize the IP/TEID hash's */ clib_bihash_init_24_8 (&fm->context_by_key, "context_by_key", UPF_IPFIX_MAPPING_BUCKETS, diff --git a/upf/upf_ipfix.h b/upf/upf_ipfix.h index 27d22e2..6078142 100644 --- a/upf/upf_ipfix.h +++ b/upf/upf_ipfix.h @@ -70,6 +70,8 @@ typedef struct u16 template_id; u32 vlib_time_0; + vlib_log_class_t log_failure_class; // rate limited log class + /** convenience vlib_main_t pointer */ vlib_main_t *vlib_main; } upf_ipfix_main_t;