From 7ab3ab30396781f0252024812f3e6e3b7e6b672d Mon Sep 17 00:00:00 2001 From: Neil McKee Date: Sat, 15 Jun 2024 11:48:08 -0700 Subject: [PATCH] mod_dropmon: use 0:0 datasource --- src/Linux/mod_dropmon.c | 5 +++-- src/Linux/mod_sonic.c | 23 +++++------------------ 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/Linux/mod_dropmon.c b/src/Linux/mod_dropmon.c index 255d657..37c30b8 100644 --- a/src/Linux/mod_dropmon.c +++ b/src/Linux/mod_dropmon.c @@ -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) diff --git a/src/Linux/mod_sonic.c b/src/Linux/mod_sonic.c index 43d30f2..2cb4613 100644 --- a/src/Linux/mod_sonic.c +++ b/src/Linux/mod_sonic.c @@ -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) {