Skip to content

Commit

Permalink
request ifIndex remap when port OID changes (see pull request #66)
Browse files Browse the repository at this point in the history
  • Loading branch information
sflow committed Apr 1, 2024
1 parent 7597707 commit 306cacc
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/Linux/mod_sonic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,15 @@ extern "C" {
}
}

static void requestPortIfIndexDiscovery(EVMod *mod, HSPSonicPort *prt) {
HSP_mod_SONIC *mdata = (HSP_mod_SONIC *)mod->data;
if(prt->unmappedPort == NO) {
// queue it for ifIndex discovery
UTArrayPush(mdata->unmappedPorts, prt);
prt->unmappedPort = YES;
}
}

static void db_portNamesCB(redisAsyncContext *ctx, void *magic, void *req_magic)
{
HSPSonicDBClient *db = (HSPSonicDBClient *)ctx->ev.data;
Expand Down Expand Up @@ -1106,14 +1115,18 @@ extern "C" {
else if(!my_strequal(prt->oid, p_oid->str)) {
// OID changed under our feet
setStr(&prt->oid, p_oid->str);
// osIndex for this port-name may have changed too. Ask for it to be remapped.
// This happens on interface breakout,
// as described in pull request #66 (https://github.com/sflow/host-sflow/pull/66).
// A port such as "Ethernet40" can break out into 4 new ports with new oids, speeds,
// and osIndex (Linux ifIndex) numbers.... but the first of these new ports still
// bears the name "Ethernet40".
requestPortIfIndexDiscovery(mod, prt);
signalCounterDiscontinuity(mod, prt);
}
if(prt->osIndex == HSP_SONIC_IFINDEX_UNDEFINED) {
if(prt->unmappedPort == NO) {
// queue it for ifIndex discovery
UTArrayPush(mdata->unmappedPorts, prt);
prt->unmappedPort = YES;
}
// queue it for ifIndex discovery
requestPortIfIndexDiscovery(mod, prt);
}
prt->mark = NO;
}
Expand Down

0 comments on commit 306cacc

Please sign in to comment.