Adapt SNMP for state_db mgmt_port_table entries#380
Open
rsh2prasad wants to merge 1 commit into
Open
Conversation
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
…ries too Signed-off-by: rakprasa <rsh2prasad@gmail.com>
7d394d0 to
dc7d57b
Compare
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Collaborator
|
Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks! ---Powered by SONiC BuildBot
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why I did it
ifHighSpeed(ifMIB.ifXTable.ifHighSpeed, OID.1.3.6.1.2.1.31.1.1.1.15) returns0(or the40000default) for management interfaces in setups where the operational speed of the mgmt port is published inSTATE_DBrather thanCONFIG_DB.Today
InterfaceMIBUpdater._get_if_entry()looks up management ports underMGMT_PORT|<name>in CONFIG_DB only. On platforms where the mgmt driver writes the live link speed (and other operational fields) intoSTATE_DB'sMGMT_PORT_TABLE|<name>, the CONFIG_DB row may not carry aspeedfield at all, soifHighSpeedfalls back to the hard-coded default and SNMP polling shows the wrong management-port speed.rfc1213.pyalready has the same two-tier lookup helper (mgmt_if_entry_table_state_db) forifSpeed. This PR bringsrfc2863.py(ifXTable) in line with that behavior soifHighSpeedreflects reality on those platforms.What I did
InterfaceMIBUpdater._get_if_entry_state_db()helper insrc/sonic_ax_impl/mibs/ietf/rfc2863.py. For an OID that maps to a management port, it reads the entry fromSTATE_DBvia the existingmibs.mgmt_if_entry_table_state_db(name)table builder (MGMT_PORT_TABLE|<name>), usingNamespace.dbs_get_all(..., blocking=False)so a missing key returnsNoneinstead of stalling the SNMP request.get_high_speed()so that when the queried OID is a management port, it pulls the entry fromSTATE_DB(via the new helper); for all other interface types (physical ports, LAGs, VLANs) the existingCONFIG_DB/APPL_DB-based_get_if_entry()path is unchanged.int(entry.get("speed", 40000))still applies ifSTATE_DBhas nospeedfield — so the default fallback is preserved.Files changed
src/sonic_ax_impl/mibs/ietf/rfc2863.py— new_get_if_entry_state_db()and updatedget_high_speed().tests/test_hc_interfaces.py— four new unit tests covering:GETNEXTwalks overifXTableend up at the mgmt-port row (proves mgmt port is reachable in the MIB).GET ifHighSpeedon a mgmt port returns the value sourced fromSTATE_DB(e.g.2000).GETNEXT ifHighSpeedon the prior OID lands on the mgmt port with the correct speed.GETNEXTpast the last mgmt port returnsEND_OF_MIB_VIEW.tests/mock_tables/state_db.json,tests/mock_tables/global_db/state_db.json,tests/mock_tables/asic0/state_db.json,tests/mock_tables/asic1/state_db.json— extendedMGMT_PORT_TABLEmocks withdescription,alias,admin_status,speed, etc., including aNotExistInStateDBcase to exercise the missing-row path. Multi-asic mocks (asic0/asic1) use theMGMT_PORT_TABLE:<name>colon-separated form to match how multi-asic STATE_DB serializes keys.