Skip to content

Commit

Permalink
mod_sonic: allow Linux port lookup by name
Browse files Browse the repository at this point in the history
  • Loading branch information
sflow committed Jun 5, 2024
1 parent 8969b51 commit c4a107f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 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.1.04
Release: 4
Release: 5
License: http://sflow.net/license.html
Group: Applications/Internet
URL: http://sflow.net
Expand Down
2 changes: 1 addition & 1 deletion src/Linux/hsflowd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2314,7 +2314,7 @@ extern "C" {
SFL_MAX_OSRELEASE_CHARS);

// Helpful for version to be in every debug log.
myLog(LOG_INFO, "%s version %s\n", argv[0], STRINGIFY_DEF(HSP_VERSION));
myLog(LOG_INFO, "%s version %s", argv[0], STRINGIFY_DEF(HSP_VERSION));

// some modules can be triggered to load even if they are not
// explicitly in the config file - but do this before we read
Expand Down
18 changes: 13 additions & 5 deletions src/Linux/mod_sonic.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,14 @@ extern "C" {

static SFLAdaptor *portGetAdaptor(EVMod *mod, HSPSonicPort *prt) {
HSP *sp = (HSP *)EVROOTDATA(mod);
if(prt->osIndex == HSP_SONIC_IFINDEX_UNDEFINED)
return NULL;
return adaptorByIndex(sp, prt->osIndex);
//if(prt->osIndex == HSP_SONIC_IFINDEX_UNDEFINED)
// return NULL;
SFLAdaptor *adaptor = adaptorByIndex(sp, prt->osIndex);
if(adaptor == NULL)
adaptor = adaptorByName(sp, prt->portName);
if(adaptor == NULL)
adaptor = adaptorByAlias(sp, prt->portName);
return adaptor;
}

static bool portSyncToAdaptor(EVMod *mod, HSPSonicPort *prt, bool sync) {
Expand Down Expand Up @@ -997,7 +1002,7 @@ extern "C" {
HSPAdaptorNIO *nio = ADAPTOR_NIO(adaptor);
if(nio
&& (nio->switchPort != flag)) {
EVDebug(mod, 1, "setting port %s switchPort flag from %u to %u\n",
EVDebug(mod, 1, "setting port %s switchPort flag from %u to %u",
prt->portName,
nio->switchPort,
flag);
Expand Down Expand Up @@ -1346,7 +1351,10 @@ extern "C" {
redisReply *c_name = reply->element[ii];
redisReply *c_val = reply->element[ii + 1];
if(c_name->type == REDIS_REPLY_STRING) {
EVDebug(mod, 1, "portCounters: %s=%s", c_name->str, db_replyStr(c_val, db->replyBuf, YES));
EVDebug(mod, 2, "portCounters: %s %s=%s",
prt->portName,
c_name->str,
db_replyStr(c_val, db->replyBuf, YES));

if(my_strequal(c_name->str, HSP_SONIC_FIELD_IFIN_UCASTS))
prt->ctrs.pkts_in = db_getU32(c_val);
Expand Down

0 comments on commit c4a107f

Please sign in to comment.