Skip to content

Commit

Permalink
mod_dropmon: use 0:0 datasource
Browse files Browse the repository at this point in the history
  • Loading branch information
sflow committed Jun 15, 2024
1 parent 364f11b commit 7ab3ab3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
5 changes: 3 additions & 2 deletions src/Linux/mod_dropmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -915,8 +915,9 @@ That would allow everything to stay on the stack as it does here, which has nice
discard.drops = mdata->noQuota;

// look up notifier
// TODO: consider having just one datasource for this (0:0)
SFLNotifier *notifier = getSFlowNotifier(mod, discard.input);
// We can just use one datasource for this (0:0) - especially since the
// input and output fields may not be limited stricting to phyical ports
SFLNotifier *notifier = getSFlowNotifier(mod, 0);

// enforce notifier limit on header size
if (hdrElem.flowType.header.header_length > notifier->sFlowEsMaximumHeaderSize)
Expand Down
23 changes: 5 additions & 18 deletions src/Linux/mod_sonic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2506,33 +2506,20 @@ extern "C" {
*/

static void evt_discard_sample(EVMod *mod, EVEvent *evt, void *data, size_t dataLen) {
HSP *sp = (HSP *)EVROOTDATA(mod);
HSPPendingEvtSample *ps = (HSPPendingEvtSample *)data;
// find and translate all ifIndex fields from the OS (Linux) ifIndex namespace to
// the SONiC ifIndex namespace.
HSPSonicIdxMap *idxm = NULL;
uint32_t dsClass = ps->discard->ds_class;
uint32_t osIndex = ps->discard->ds_index;
HSPSonicIdxMap *idxm = NULL;
uint32_t dsIndexAlias = 0;
if(dsClass == SFL_DSCLASS_IFINDEX
&& osIndex != 0) {
idxm = getIdxMapByOsIndex(mod, osIndex);
if(idxm == NULL
|| idxm->ifIndex == HSP_SONIC_IFINDEX_UNDEFINED) {
// for troubleshooting we can allow this through (untranslated) with:
// "sonic{suppressOther=off}"
if(!sp->sonic.suppressOther)
return;
// Rather than suppress useful discard events that were associated with interfaces
// that are not represented in the PORT_INDEX_TABLE, we will simply translate them
// as coming from dataSource 0:0 meaning "whole agent"
EVDebug(mod, 2, "received discard sample from non-sonic port (class=%u, osIndex=%u)", dsClass, osIndex);
// ps->suppress = YES;
}
dsIndexAlias = idxm ? idxm->ifIndex : 0;
// Note that if dsIndexAlias is 0 that means "no alias"
sfl_notifier_set_dsAlias(ps->notifier, dsIndexAlias);
}

uint32_t dsIndexAlias = idxm ? idxm->ifIndex : 0;
// fix datasource
sfl_notifier_set_dsAlias(ps->notifier, dsIndexAlias);
// fix in/out
if(ps->discard->input
&& ps->discard->input != SFL_INTERNAL_INTERFACE) {
Expand Down

0 comments on commit 7ab3ab3

Please sign in to comment.