SONiC
Module 3 · ASICs, Switching Pipelines, SAI & Forwarding

ASIC_DB Exploration

50 minLabObservationCorrelationVirtualOpen-source

Use targeted queries (SCAN, never KEYS *) to locate route- and next-hop-related objects in ASIC_DB, follow their OID references, translate virtual OIDs to real ones, and articulate which parts are human-readable versus implementation-oriented — reinforcing that ASIC_DB is a sync-path representation, not the silicon.

Safety: Safe

Non-disruptive. Safe to run in the virtual lab.

Read-only. Never SET/DEL ASIC_DB keys — you cannot 'program hardware' by editing this DB and you can desync state.

Prefer SCAN with COUNT and targeted MATCH over KEYS * on any system that matters.

Objective

  • Query ASIC_DB safely and precisely with SCAN and targeted MATCH patterns.
  • Locate route and next-hop objects and follow their references.
  • Distinguish human-readable content from implementation-oriented OIDs, and translate VID↔RID.

Starting state

  • VS up; a forwarding route exists; redis-cli available on the host.

Prerequisites: Lessons 3.3 and 3.4 complete. · At least one installed route with a resolved next hop.

Tasks

  1. 1

    Enumerate object types present (bounded, safe)

    Get a feel for what object types exist without dumping the whole DB.

    SONiC DBlist distinct object-type prefixes; SCAN, not KEYS *
    redis-cli -n 1 SCAN 0 MATCH 'ASIC_STATE:SAI_OBJECT_TYPE_*' COUNT 1000 | sed 's/:.*//' | sort -u
    Expected:
    • A list of SAI object types: ROUTE_ENTRY, NEXT_HOP, NEXT_HOP_GROUP, ROUTER_INTERFACE, NEIGHBOR_ENTRY, PORT, VLAN, FDB_ENTRY, etc.

    What happened internally: SCAN iterates in bounded chunks and does not block Redis the way KEYS * can. On a busy system this discipline matters.

  2. 2

    Locate route-related objects

    SONiC DB
    redis-cli -n 1 SCAN 0 MATCH 'ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY*' COUNT 500
    SONiC DBnote PACKET_ACTION and NEXT_HOP_ID
    redis-cli -n 1 HGETALL 'ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY:{...}'
    Expected:
    • Route entries with a human-readable destination prefix inside the key and an opaque next-hop OID attribute.

    What happened internally: The prefix in the key is human-readable; the next-hop reference is an implementation-oriented VID. Both live in the same object.

  3. 3

    Locate next-hop and next-hop-group objects

    SONiC DB
    redis-cli -n 1 SCAN 0 MATCH 'ASIC_STATE:SAI_OBJECT_TYPE_NEXT_HOP:*' COUNT 500
    SONiC DBpresent when ECMP is in use
    redis-cli -n 1 SCAN 0 MATCH 'ASIC_STATE:SAI_OBJECT_TYPE_NEXT_HOP_GROUP*' COUNT 500
    Expected:
    • Next-hop objects referencing a RIF and IP; next-hop-group objects (if ECMP) with members referencing next hops.

    What happened internally: Next-hop groups are the unit of ECMP. Their members reference individual next-hop objects — the fan-out point of the graph.

  4. 4

    Identify references and translate VID→RID

    SONiC DBvirtual → real OID (maintained by syncd)
    redis-cli -n 1 HGET VIDTORID oid:0x...
    SONiC DBhow many objects are mapped
    redis-cli -n 1 HLEN VIDTORID
    Expected:
    • A real OID returned for a given virtual OID; a count of mapped objects.

    What happened internally: VIDTORID/RIDTOVID are the abstraction boundary: ASIC_DB speaks in virtual IDs; syncd maps them to the vendor SAI's real handles.

  5. 5

    Classify human-readable vs implementation-oriented

    Write two short lists: (a) content a network engineer can read directly (prefixes, IPs, MACs, port names), and (b) content that is implementation-oriented (opaque OIDs, VID↔RID maps, internal attribute enums).

    Expected:
    • Two short lists that make the abstraction boundary explicit.

    What happened internally: This is the conceptual payoff: ASIC_DB is a faithful record of the SAI request/ack graph — part readable, part opaque — but still a database, not the transistors.

Troubleshooting branches

If: SCAN pattern returns nothing

Then: Key formats vary by version; broaden MATCH and confirm DB (-n 1). Ensure the route/next hop actually installed.

If: HGET VIDTORID returns nil

Then: Use an OID that actually appears as a value in an object attribute; not every OID you type will exist.

If: Tempted to run KEYS *

Then: Don't — it can block Redis and disrupt services. Always SCAN with COUNT and a targeted MATCH.

Cleanup / rollback
  • None — read-only. Do not write to ASIC_DB.

Lab evidence checklist

  • Distinct object-type list captured.
  • A route entry with its next-hop OID captured.
  • A next-hop (and, if present, next-hop-group) object captured.
  • One VID→RID translation captured.
  • The two-list human-readable vs implementation-oriented classification written.

Reflection

  • Which fields could you read directly, and which were opaque? What does that split reveal about SAI's abstraction?
  • Why is SCAN the correct tool here and KEYS * a hazard?
  • Explain, in one sentence, why finding an object in ASIC_DB is not the same as proving the packet forwards.
Lab notes & observations