From 2a581bd5b5d7b432ddd0d2454a9418134f2d4022 Mon Sep 17 00:00:00 2001 From: Spandan Chowdhury Date: Tue, 31 Mar 2026 11:09:05 -0700 Subject: [PATCH] Fix early termination of SNMP walks when encountering None values 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 --- src/ax_interface/mib.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/ax_interface/mib.py b/src/ax_interface/mib.py index 5cfd39e2c..c7c2e7cc1 100644 --- a/src/ax_interface/mib.py +++ b/src/ax_interface/mib.py @@ -365,15 +365,16 @@ def _get_value(self, mib_entry, oid_key): def _get_nextvalue(self, mib_entry, oid_key): sub_id = mib_entry.get_sub_id(oid_key) key1 = mib_entry.get_next(sub_id) - if key1 is None: - return None - val1 = mib_entry(key1) - if val1 is None: - return None - oid1 = mib_entry.replace_sub_id(oid_key, key1) - # OID found, call the OIDEntry - vr = ValueRepresentation.from_typecast(mib_entry.value_type, oid1, val1) - return vr + while key1 is not None: + val1 = mib_entry(key1) + if val1 is not None: + oid1 = mib_entry.replace_sub_id(oid_key, key1) + # OID found, call the OIDEntry + vr = ValueRepresentation.from_typecast(mib_entry.value_type, oid1, val1) + return vr + # Value is None, continue to the next sub_id + key1 = mib_entry.get_next(key1) + return None def get(self, sr, d=None): oid_key = sr.start.to_tuple()