Skip to content

Adapt SNMP for state_db mgmt_port_table entries#380

Open
rsh2prasad wants to merge 1 commit into
sonic-net:masterfrom
rsh2prasad:rakprasa/snmp_mgmt_speed
Open

Adapt SNMP for state_db mgmt_port_table entries#380
rsh2prasad wants to merge 1 commit into
sonic-net:masterfrom
rsh2prasad:rakprasa/snmp_mgmt_speed

Conversation

@rsh2prasad

@rsh2prasad rsh2prasad commented Jun 15, 2026

Copy link
Copy Markdown

Why I did it

ifHighSpeed (ifMIB.ifXTable.ifHighSpeed, OID .1.3.6.1.2.1.31.1.1.1.15) returns 0 (or the 40000 default) for management interfaces in setups where the operational speed of the mgmt port is published in STATE_DB rather than CONFIG_DB.

Today InterfaceMIBUpdater._get_if_entry() looks up management ports under MGMT_PORT|<name> in CONFIG_DB only. On platforms where the mgmt driver writes the live link speed (and other operational fields) into STATE_DB's MGMT_PORT_TABLE|<name>, the CONFIG_DB row may not carry a speed field at all, so ifHighSpeed falls back to the hard-coded default and SNMP polling shows the wrong management-port speed.

rfc1213.py already has the same two-tier lookup helper (mgmt_if_entry_table_state_db) for ifSpeed. This PR brings rfc2863.py (ifXTable) in line with that behavior so ifHighSpeed reflects reality on those platforms.

What I did

  • Added a new InterfaceMIBUpdater._get_if_entry_state_db() helper in src/sonic_ax_impl/mibs/ietf/rfc2863.py. For an OID that maps to a management port, it reads the entry from STATE_DB via the existing mibs.mgmt_if_entry_table_state_db(name) table builder (MGMT_PORT_TABLE|<name>), using Namespace.dbs_get_all(..., blocking=False) so a missing key returns None instead of stalling the SNMP request.
  • Updated get_high_speed() so that when the queried OID is a management port, it pulls the entry from STATE_DB (via the new helper); for all other interface types (physical ports, LAGs, VLANs) the existing CONFIG_DB/APPL_DB-based _get_if_entry() path is unchanged.
  • Behavior is purely additive: existing flows for non-mgmt ports are untouched, and int(entry.get("speed", 40000)) still applies if STATE_DB has no speed field — so the default fallback is preserved.

Files changed

  • src/sonic_ax_impl/mibs/ietf/rfc2863.py — new _get_if_entry_state_db() and updated get_high_speed().
  • tests/test_hc_interfaces.py — four new unit tests covering:
    • GETNEXT walks over ifXTable end up at the mgmt-port row (proves mgmt port is reachable in the MIB).
    • GET ifHighSpeed on a mgmt port returns the value sourced from STATE_DB (e.g. 2000).
    • GETNEXT ifHighSpeed on the prior OID lands on the mgmt port with the correct speed.
    • GETNEXT past the last mgmt port returns END_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 — extended MGMT_PORT_TABLE mocks with description, alias, admin_status, speed, etc., including a NotExistInStateDB case to exercise the missing-row path. Multi-asic mocks (asic0 / asic1) use the MGMT_PORT_TABLE:<name> colon-separated form to match how multi-asic STATE_DB serializes keys.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@rsh2prasad rsh2prasad changed the title Add support for snmp to looking into state_db for mgmt_port_table ent… Adapt SNMP for state_db mgmt_port_table entries Jun 15, 2026
@rsh2prasad rsh2prasad marked this pull request as ready for review June 15, 2026 20:58
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

…ries too

Signed-off-by: rakprasa <rsh2prasad@gmail.com>
@rsh2prasad rsh2prasad force-pushed the rakprasa/snmp_mgmt_speed branch from 7d394d0 to dc7d57b Compare June 15, 2026 22:14
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld

Copy link
Copy Markdown
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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants