sonic-net / sonic-snmpagent

A net-snmpd agentx subagent for SONiC
Other
15 stars 113 forks source link

[ciscoPfcExtMIB]: Remove returning first intf index if subid is empty #322

Closed SuvarnaMeenakshi closed 3 months ago

SuvarnaMeenakshi commented 4 months ago

- What I did When querying for PFC counters MIB cpfcIfTable if there is no interface present on the device, then there is an exception while handing get_next as the implementation tries to return the first index of an empty list. This happens in case of VoQ chassis Supervisor where there are no interfaces present. Anytime a snmp query is made to cpfcIfTable 1.3.6.1.4.1.9.9.813.1.1, the exception message gets logged on the device.

- How I did it Currently if sub_id is None, if_range[0] is returned. IF if_range is empty array this can cause an Exception. Removed this check to avoid returning if_range[0]. The check "if not sub_id" is not required here. right = bisect_right(self.if_range, sub_id) will handle if the sub_id is empty or if the if_range is empty by returning 0 index.

- How to verify it Verified that no exception is logged upon query in VoQ chassis supervisor. Other platforms like Linecard, single-asic device - no Change in the SNMP result. - Description for the changelog

mssonicbld commented 2 months ago

Cherry-pick PR to 202405: https://github.com/sonic-net/sonic-snmpagent/pull/328