Adapt SNMP for state_db mgmt_port_table entries - #380
rsh2prasad wants to merge 2 commits into
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
…ries too Signed-off-by: rakprasa <rsh2prasad@gmail.com>
7d394d0 to
dc7d57b
Compare
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
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
|
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
Hi @sonic-net/sonic-snmpagent-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks! ---Powered by SONiC BuildBot
|
7 similar comments
|
Hi @sonic-net/sonic-snmpagent-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks! ---Powered by SONiC BuildBot
|
|
Hi @sonic-net/sonic-snmpagent-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks! ---Powered by SONiC BuildBot
|
|
Hi @sonic-net/sonic-snmpagent-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks! ---Powered by SONiC BuildBot
|
|
Hi @sonic-net/sonic-snmpagent-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks! ---Powered by SONiC BuildBot
|
|
Hi @sonic-net/sonic-snmpagent-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks! ---Powered by SONiC BuildBot
|
|
Hi @sonic-net/sonic-snmpagent-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks! ---Powered by SONiC BuildBot
|
|
Hi @sonic-net/sonic-snmpagent-maintainer, this approved PR has workflow run(s) waiting for approval. Please help review. Thanks! ---Powered by SONiC BuildBot
|
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.