From 3ce3e317291aaadd17ae9c11b89704fb5c4549f2 Mon Sep 17 00:00:00 2001 From: Neil McKee Date: Thu, 6 Aug 2020 01:17:06 +0000 Subject: [PATCH] remove global rate-limiting on notifier events (each module should rate-limit separately) --- hsflowd.spec | 2 +- src/sflow/sflow_api.h | 10 +++------- src/sflow/sflow_notifier.c | 15 --------------- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/hsflowd.spec b/hsflowd.spec index a345729b..e9ea2b99 100644 --- a/hsflowd.spec +++ b/hsflowd.spec @@ -1,7 +1,7 @@ Summary: host sFlow daemon Name: hsflowd Version: 2.0.29 -Release: 5 +Release: 6 License: http://sflow.net/license.html Group: Applications/Internet URL: http://sflow.net diff --git a/src/sflow/sflow_api.h b/src/sflow/sflow_api.h index ea92ab73..361da218 100644 --- a/src/sflow/sflow_api.h +++ b/src/sflow/sflow_api.h @@ -203,11 +203,8 @@ typedef struct _SFLNotifier { /* private fields */ SFLReceiver *myReceiver; uint32_t seqNo; - /* rate limiting */ - uint32_t nThisTick; uint32_t nLastTick; - uint32_t rateLimit; - uint32_t rateQuota; + uint32_t nThisTick; /* optional alias datasource index */ uint32_t ds_alias; } SFLNotifier; @@ -324,9 +321,8 @@ uint32_t sfl_notifier_get_sFlowEsReceiver(SFLNotifier *notifier); void sfl_notifier_set_sFlowEsReceiver(SFLNotifier *notifier, uint32_t sFlowEsReceiver); uint32_t sfl_notifier_get_sFlowEsMaximumHeaderSize(SFLNotifier *notifier); void sfl_notifier_set_sFlowEsMaximumHeaderSize(SFLNotifier *notifier, uint32_t sFlowEsMaximumHeaderSize); -void sfl_notifier_set_rateLimit(SFLNotifier *notifier, uint32_t nPerSecond); -uint32_t sfl_notifier_get_rateLimit(SFLNotifier *notifier); - +uint32_t sfl_notifier_get_nLastTick(SFLNotifier *notifier); + /* call this to indicate a discontinuity with a counter like samplePool so that the sflow collector will ignore the next delta */ void sfl_sampler_resetFlowSeqNo(SFLSampler *sampler); diff --git a/src/sflow/sflow_notifier.c b/src/sflow/sflow_notifier.c index df6a0674..2e7ec7a0 100644 --- a/src/sflow/sflow_notifier.c +++ b/src/sflow/sflow_notifier.c @@ -29,7 +29,6 @@ void sfl_notifier_init(SFLNotifier *notifier, SFLAgent *agent, SFLDataSource_ins notifier->dsi = dsi; /* set defaults */ - notifier->rateQuota = 100; // TOOD: define in sflow_api.h notifier->sFlowEsMaximumHeaderSize = SFL_DEFAULT_HEADER_SIZE; } @@ -71,16 +70,6 @@ void sfl_notifier_set_sFlowEsMaximumHeaderSize(SFLNotifier *notifier, uint32_t s notifier->sFlowEsMaximumHeaderSize = sFlowEsMaximumHeaderSize; } -/* call this to set a maximum notifications-per-second rate. */ - -void sfl_notifier_set_rateLimit(SFLNotifier *notifier, uint32_t nPerSecond) { - notifier->rateLimit = nPerSecond; -} - -uint32_t sfl_notifier_get_rateLimit(SFLNotifier *notifier) { - return notifier->rateLimit; -} - uint32_t sfl_notifier_get_nLastTick(SFLNotifier *notifier) { return notifier->nLastTick; } @@ -107,7 +96,6 @@ void sfl_notifier_set_dsAlias(SFLNotifier *notifier, uint32_t ds_alias) { notifi void sfl_notifier_tick(SFLNotifier *notifier, time_t now) { - notifier->rateQuota = notifier->rateLimit ? notifier->rateLimit : (uint32_t)-1; notifier->nLastTick = notifier->nThisTick; notifier->nThisTick = 0; } @@ -121,9 +109,6 @@ void sfl_notifier_writeEventSample(SFLNotifier *notifier, SFLEvent_discarded_pac { if(es == NULL) return; notifier->nThisTick++; - if(notifier->rateQuota == 0) - return; // no more this tick - --notifier->rateQuota; /* increment the sequence number */ es->sequence_number = ++notifier->seqNo; /* copy the other header fields in - event samples always use expanded form */