Skip to content

Commit

Permalink
remove global rate-limiting on notifier events (each module should ra…
Browse files Browse the repository at this point in the history
…te-limit separately)
  • Loading branch information
sflow committed Aug 6, 2020
1 parent b47944e commit 3ce3e31
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
2 changes: 1 addition & 1 deletion hsflowd.spec
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 3 additions & 7 deletions src/sflow/sflow_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
15 changes: 0 additions & 15 deletions src/sflow/sflow_notifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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 */
Expand Down

0 comments on commit 3ce3e31

Please sign in to comment.