Skip to content

Fix early termination of SNMP walks when encountering None values#370

Open
spandan-nexthop wants to merge 1 commit intosonic-net:masterfrom
spandan-nexthop:spandan-nexthop.snmp-walk-fix
Open

Fix early termination of SNMP walks when encountering None values#370
spandan-nexthop wants to merge 1 commit intosonic-net:masterfrom
spandan-nexthop:spandan-nexthop.snmp-walk-fix

Conversation

@spandan-nexthop
Copy link
Copy Markdown

@spandan-nexthop spandan-nexthop commented Mar 31, 2026

Fixes: #369
Fixes: sonic-net/sonic-buildimage#26489
- What I did
Fix SNMP GETNEXT skipping valid entries after encountering interface with missing counters

When _get_nextvalue() encounters an interface whose counters are not present in COUNTERS_DB (returning None), it returns immediately instead of advancing to the next sub_id. This causes SNMP walks (GETNEXT operations) to jump to the next MIB subtree, silently skipping all remaining valid entries such as PortChannel interfaces and such that could come after the ports without counter support in the OID ordering.

- How I did it
Fix by looping through subsequent sub_ids when a None value is encountered, returning only once a valid value is found or all entries are exhausted.

- How to verify it
The steps to reproduce that are mentioned in the actual Issue linked above, can be re-run with this fix.

- Description for the changelog

Fix SNMP GETNEXT skipping valid entries after encountering interface with missing counters

When _get_nextvalue() encounters an interface whose counters are not
present in COUNTERS_DB (returning None), it returns immediately instead
of advancing to the next sub_id. This causes SNMP walks (GETNEXT
operations) to jump to the next MIB subtree, silently skipping all
remaining valid entries such as PortChannel interfaces and such that could
come after the ports without counter support in the OID ordering.

Fix by looping through subsequent sub_ids when a None value is
encountered, returning only once a valid value is found or all entries
are exhausted.

Signed-off-by: Spandan Chowdhury <spandan@nexthop.ai>
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@spandan-nexthop
Copy link
Copy Markdown
Author

cc: @anders-nexthop @bhouse-nexthop

@gechiang gechiang requested a review from qiluo-msft April 8, 2026 15:40
@gechiang
Copy link
Copy Markdown

gechiang commented Apr 8, 2026

Hi @qiluo-msft , can you or someone from your team help review this.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants