Monday, 17 August 2026

SONiC Deep Dive: Intra-Switch Inter-VLAN Routing and Packet Forwarding

 

The title of this section might seem a little overwhelming, but it reflects the focus of the chapter. The SONiC Redis database programming pipeline is examined through the configuration of two Layer-2 VLANs, VLAN 10 and VLAN 20, together with their respective Layer-3 routing interfaces.

VLAN 10 and VLAN 20 represent two separate Layer-2 broadcast domains, with each VLAN associated with its own IP subnet. VLAN 10 uses the 10.0.10.0/24 subnet, while VLAN 20 uses the 10.0.20.0/24 subnet. Because the two hosts belong to different broadcast domains and IP subnets, communication between them requires Layer-3 routing. In this example, the routing is performed locally by Leaf-1 through the routing interfaces configured for the two VLANs.

Figure 5-15 depicts the basic building blocks and IP addressing scheme used in this example. PC1, with IP address 10.0.10.101/24, belongs to VLAN 10 and is connected to the Leaf-1 Ethernet0 interface. PC2, with IP address 10.0.20.101/24, belongs to VLAN 20 and is connected to the Leaf-1 Ethernet1 interface. The routing interfaces for VLAN 10 and VLAN 20 use IP addresses 10.0.10.1/24 and 10.0.20.1/24, respectively.

The configuration process is first examined from the database perspective. The changes made to CONFIG_DB, APPL_DB, and the config_db.json file are analyzed as the VLANs, and their routing interfaces are configured. This time, the sonic-cli is used instead of the SONiC Linux bash CLI.

The configuration is then traced further down the SONiC pipeline. The corresponding entries created in ASIC_DB are examined, including the relationships between the SAI objects representing the VLANs, routing interfaces, ports, and other required objects. The ASIC programming follows the same pipeline described earlier in this chapter, ultimately translating the configuration into SAI objects that are programmed into the hardware ASIC.



Figure 5-15: Vlans and Routing Interfaces - Topology.


Configuring VLANs and Routing Interfaces Using sonic-cli

 

The sonic-cli provides a traditional CLI-style switch configuration experience. From the administrator's perspective, VLANs, interfaces, IP addresses, and Layer-3 routing can be configured using commands like those found on traditional network switches. The complexity of the underlying SONiC configuration and ASIC programming pipeline is hidden behind this CLI.

Figure 5-16 illustrates the configuration of VLAN 20 and its Layer-3 routing interface. The interface Vlan 20 command is used to enter the VLAN interface configuration mode, after which the IP address 10.0.20.1/24 is assigned using the ip address 10.0.20.1/24 command. This IP address serves as the Layer-3 interface for the 10.0.20.0/24 subnet and provides the routing interface for the VLAN 20 broadcast domain.

The figure also shows how Ethernet1 is associated with VLAN 20. The interface configuration mode is entered with interface Ethernet 1, followed by switchport access vlan 20 to configure the interface as an access port belonging to VLAN 20. If interfaces are administratively disabled by default in the SONiC distribution, the interface is enabled with the no shutdown command.

From the configuration perspective, the process therefore resembles configuration on a traditional switch. However, the apparent simplicity of the CLI hides a considerably more complex set of operations inside SONiC. A single CLI configuration can result in changes to CONFIG_DB, updates to APPL_DB, creation of SAI objects in ASIC_DB, and, ultimately, programming of the hardware ASIC. These operations are performed by the SONiC components described earlier in this chapter; they are not exposed to the administrator through the sonic-cli interface.

Basic configuration verification can also be performed directly from the CLI. Commands such as show vlan, show ip interfaces, and show ip route provide a high-level view of the configured VLANs, Layer-3 interfaces, and routing information.

Figure 5-16: Configuring Routing Interface for VLAN 20.

 

CONFIG_DB, APPL_DB, and Config_db.json

 

Figure 5-17 shows what happens behind the scenes when a VLAN routing interface is configured using sonic-cli. As soon as Enter is pressed after each configuration command, the corresponding configuration is written to CONFIG_DB.

The configuration creates the VLAN_INTERFACE|Vlan20|10.0.20.1/24 entry. The VLAN interface name and IP prefix are encoded directly in the Redis key. The NULL/NULL value indicates that no additional field-value attributes are associated with this configuration entry.

The intfmgrd daemon, the SONiC interface manager, monitors the VLAN interface configuration in CONFIG_DB and translates it into the application-specific representation used by APPL_DB. In this example, the corresponding INTF_TABLE:Vlan20:10.0.20.1/24 entry contains attributes such as family, scope, and origin.

The family attribute identifies the address family as IPv4. The origin attribute indicates that the address is statically configured rather than learned dynamically from a routing protocol or another peer. The scope attribute is set to global, indicating that the address has global scope within the Linux networking model.

The configuration then continues through the normal SONiC programming pipeline, where the APPL_DB information is processed by the appropriate orchestration components and eventually results in the corresponding SAI objects being created in ASIC_DB. The ASIC programming then follows the same pipeline described earlier in this chapter, ultimately programming the configuration into the hardware ASIC.

Once the configuration is complete, the write memory command saves the current configuration to config_db.json. This file serves as the persistent startup configuration and can be used to restore the configuration when SONiC is restarted.

The important point is that none of this database-level complexity is exposed to the administrator through the sonic-cli configuration commands. The CLI provides a traditional switch configuration interface, while SONiC internally translates the configuration through CONFIG_DB, APPL_DB, ASIC_DB, SAI, and finally the hardware ASIC.


Figure 5-17: Configuring Routing Interface for VLAN 20.

 

ASIC_DB

 

Figure 5-18 illustrates the relationships between the ASIC_DB objects created for inter-VLAN routing. The left side of the figure represents VLAN 10, while the right side represents VLAN 20. The middle of the figure contains objects shared by both VLANs, including the switch and virtual router objects.

Both VLAN routing interfaces are represented by SAI_OBJECT_TYPE_ ROUTER_INTERFACE objects and are associated with the same virtual router. For VLAN 10, the router interface is oid:0x6000000000a6a, while the router interface for VLAN 20 is oid:0x6000000000a6d. Both reference the same SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID, oid :0x300000000003a. This shared virtual router allows both VLAN interfaces to participate in the same Layer-3 routing context.

Each router interface is also associated with its corresponding VLAN object through SAI_ROUTER_INTERFACE_ATTR_VLAN_ID. The VLAN 10 router interface references VLAN object oid:0x26000000000a48, while the VLAN 20 router interface references VLAN object oid:0x26000000000a6c. Both router interfaces use the same source MAC address, 0C:9A:32:79:00:0A.

The routing table contains two route entries for each VLAN. The first entry represents the directly connected subnet. For VLAN 10, the route is 10.0.10.0/24, and for VLAN 20 it is 10.0.20.0/24. These routes reference the corresponding VLAN router interfaces through SAI_ROUTE_ENTRY_ ATTR_NEXT_HOP_ID. The 10.0.10.0/24 route therefore points to router interface oid:0x6000000000a6a, while the 10.0.20.0/24 route points to router interface oid:0x6000000000a6d.

The second route for each VLAN is a host route for the IP address configured on the VLAN routing interface itself: 10.0.10.1/32 and 10.0.20.1/32. Both entries use oid:0x1000000000001 as their NEXT_HOP_ID and specify SAI_PACKET_ACTION_FORWARD. These /32 routes represent the IP addresses owned by the switch. For example, when a packet destined for 10.0.20.1 is received, it is treated as local traffic rather than being forwarded toward another host. The packet is therefore delivered to the switch's control-plane networking stack, where it can be processed by the appropriate application, such as an FRR daemon.

A relationship can therefore be seen in the ASIC_DB representation: each VLAN has its own VLAN object and VLAN router interface, but both router interfaces share the same virtual router. The directly connected routes then point to their respective router interfaces, while the /32 routes for the switch's own IP addresses use a separate next-hop object for local handling.

The ASIC_DB route entries also contain the switch identifier oid:0x21000000000000 and the virtual router identifier oid:0x300000000003a as part of the route-entry key. These identifiers establish the switch and routing context to which each route belongs.

Figure 5-18 provides a view of how the high-level concept of two VLAN broadcast domains and their Layer-3 interfaces is represented as a collection of interrelated SAI objects in ASIC_DB. The relationships between the VLAN objects, router interfaces, virtual router, and route entries form the hardware-oriented representation of the inter-VLAN routing configuration.


Chapter Summary

 

This concludes Chapter 5, which examined how Layer-2 and Layer-3 connectivity is established between two hosts connected to the same SONiC switch. The chapter first showed how VLANs and host-facing interfaces are configured to provide intra-VLAN communication within the same Layer-2 broadcast domain. It then examined how routing interfaces are configured to enable inter-VLAN communication between different VLANs and IP subnets.

The configuration was followed through the SONiC programming pipeline, from the sonic-cli and CONFIG_DB, through APPL_DB and the SONiC orchestration components, to the SAI objects represented in ASIC_DB and ultimately the hardware ASIC. This demonstrated how a simple switch configuration command hides a sequence of database updates, daemon operations, SAI object creation, and hardware programming.

The result is a complete view of how SONiC provides both intra-VLAN and inter-VLAN connectivity for hosts connected to the same switch, and how the high-level configuration is translated into the objects and relationships required for packet forwarding.

Appendix Ch5-2

This appendix provides the configuration and Redis database outputs used to analyze the VLAN and inter-VLAN routing configuration presented in Chapter 5. The outputs show how the configuration is represented at different stages of the SONiC configuration pipeline, from the persistent config_db.json file and CONFIG_DB through APPL_DB to the SAI objects stored in ASIC_DB.

The examples focus primarily on VLAN 20, its routing interface 10.0.20.1/24, and the associated Ethernet1 interface. Additional CONFIG_DB entries, including device metadata, VLAN, and VLAN member configuration, are included to provide the necessary context for the relationships discussed in the chapter.

The ASIC_DB output includes the router-interface objects and their object identifiers (OIDs), allowing the relationships between the VLAN interfaces, VLAN objects, and shared virtual router to be correlated with the explanations and figures in Chapter 5.

 

admin@sonic:~$ sonic-db-dump -n CONFIG_DB --pretty -k "VLAN_INTERFACE|Vlan20*"

{

  "VLAN_INTERFACE|Vlan20": {

    "expireat": 1786882177.7618697,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "NULL": "NULL"

    }

  },

  "VLAN_INTERFACE|Vlan20|10.0.20.1/24": {

    "expireat": 1786882177.7618823,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "NULL": "NULL"

    }

  }

}

 

admin@sonic:~$ sonic-db-dump -n APPL_DB --pretty -k "INTF_TABLE:Vlan20*"

{

  "INTF_TABLE:Vlan20": {

    "expireat": 1786882214.629678,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "NULL": "NULL"

    }

  },

  "INTF_TABLE:Vlan20:10.0.20.1/24": {

    "expireat": 1786882214.6296875,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "family": "IPv4",

      "origin": "STATIC",

      "scope": "global"

    }

  }

}

admin@sonic:~$

 

admin@sonic:~$ sonic-db-dump -n ASIC_DB --pretty -k "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:*"

{

  "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x60000000009c7": {

    "expireat": 1786882264.3216379,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "SAI_ROUTER_INTERFACE_ATTR_MTU": "9100",

      "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_LOOPBACK",

      "SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID": "oid:0x300000000003a"

    }

  },

  "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000a6a": {

    "expireat": 1786882264.3215926,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "SAI_ROUTER_INTERFACE_ATTR_MTU": "9100",

      "SAI_ROUTER_INTERFACE_ATTR_NAT_ZONE_ID": "0",

      "SAI_ROUTER_INTERFACE_ATTR_SRC_MAC_ADDRESS": "0C:9A:32:79:00:0A",

      "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_VLAN",

      "SAI_ROUTER_INTERFACE_ATTR_V4_MCAST_ENABLE": "false",

      "SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID": "oid:0x300000000003a",

      "SAI_ROUTER_INTERFACE_ATTR_VLAN_ID": "oid:0x26000000000a48"

    }

  },

  "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000a6d": {

    "expireat": 1786882264.3216293,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "SAI_ROUTER_INTERFACE_ATTR_MTU": "9100",

      "SAI_ROUTER_INTERFACE_ATTR_NAT_ZONE_ID": "0",

      "SAI_ROUTER_INTERFACE_ATTR_SRC_MAC_ADDRESS": "0C:9A:32:79:00:0A",

      "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_VLAN",

      "SAI_ROUTER_INTERFACE_ATTR_V4_MCAST_ENABLE": "false",

      "SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID": "oid:0x300000000003a",

      "SAI_ROUTER_INTERFACE_ATTR_VLAN_ID": "oid:0x26000000000a6c"

    }

  }

}admin@sonic:~$

 

admin@sonic:~$ sonic-db-dump -n CONFIG_DB --pretty -k 'DEVICE_METADATA|localhost'

{

  "DEVICE_METADATA|localhost": {

    "expireat": 1786882935.9643338,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "default_config_profile": "l3",

      "frr_mgmt_framework_config": "true",

      "hostname": "Leaf-1",

      "hwsku": "DellEMC-S5248f-P-25G-DPB",

      "mac": "0c:9a:32:79:00:0a",

      "platform": "x86_64-kvm_x86_64-r0",

      "type": "LeafRouter"

    }

  }

}

admin@sonic:~$

 

}admin@sonic:~$sonic-db-dump -n CONFIG_DB --pretty -k 'PORT|Ethernet1''

{

  "PORT|Ethernet1": {

    "expireat": 1786883135.760981,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "NULL": "NULL",

      "access_vlan": "20",

      "admin_status": "up",

      "adv_speeds": "all",

      "alias": "Eth1/2",

      "autoneg": "off",

      "description": "**PC2**",

      "fec": "none",

      "index": "2",

      "lanes": "50",

      "link_training": "off",

      "mtu": "9100",

      "speed": "25000",

      "unreliable_los": "auto"

    }

  }

}

admin@sonic:~$

 

dmin@sonic:~$ sudo cat /etc/sonic/config_db.json

"DEVICE_METADATA": {

        "localhost": {

            "default_config_profile": "l3",

            "frr_mgmt_framework_config": "true",

            "hostname": "Leaf-1",

            "hwsku": "DellEMC-S5248f-P-25G-DPB",

            "mac": "0c:9a:32:79:00:0a",

            "platform": "x86_64-kvm_x86_64-r0",

            "type": "LeafRouter"

        }

    },

"Ethernet1": {

            "access_vlan": "20",

            "admin_status": "up",

            "adv_speeds": "all",

            "alias": "Eth1/2",

            "autoneg": "off",

            "description": "**PC2**",

            "fec": "none",

            "index": "2",

            "lanes": "50",

            "link_training": "off",

            "mtu": "9100",

            "speed": "25000",

            "unreliable_los": "auto"

        },

 

  "VLAN": {

        "Vlan10": {

            "members": [

                "Ethernet0"

            ],

            "vlanid": "10"

        },

        "Vlan20": {

            "admin_status": "up",

            "autostate": "enable",

            "description": "second_vlan",

            "members": [

                "Ethernet1"

            ],

            "vlanid": "20"

        }

    },

    "VLAN_INTERFACE": {

        "Vlan10": {},

        "Vlan10|10.0.10.1/24": {},

        "Vlan20": {},

        "Vlan20|10.0.20.1/24": {}

    },

    "VLAN_MEMBER": {

        "Vlan10|Ethernet0": {

            "tagging_mode": "untagged"

        },

        "Vlan20|Ethernet1": {

            "tagging_mode": "untagged"

        }

    },

 


Saturday, 15 August 2026

SONiC Deep Dive: Binding Interface to Vlan

Step 3: Associate Ethernet0 to VLAN 10

After configuring VLAN 10 and bringing up interface Ethernet0, the next step is to make Ethernet0 an untagged member of VLAN 10.

GONFIG_DB and APPL_DB

Figure 5-11 gives a conceptual view of the Redis database updates resulting from the SONiC command:

sudo config vlan member add 10 Ethernet0 --untagged

The command defines our intent: Ethernet0 should participate in VLAN 10 as an untagged (access) port. For an untagged VLAN member, frames received from the host arrive without an 802.1Q tag and are associated with VLAN 10 based on the port's VLAN membership. In the opposite direction, frames transmitted from VLAN 10 toward Ethernet0 are sent without an 802.1Q tag.

The command updates several related entries in CONFIG_DB. The PORT|Ethernet0 entry contains the port's access VLAN configuration:

PORT|Ethernet0

    access_vlan = 10

 

The VLAN|Vlan10 entry represents the VLAN itself and contains a members@ field that records Ethernet0 as a member:

 

VLAN|Vlan10

   members@ = Ethernet0   

   vlanid = 10

 

The @ character in members@ is part of the SONiC CONFIG_DB schema convention. The members@ value is a configuration representation of the relationship between the VLAN and its members.

The VLAN membership is also represented explicitly by a separate CONFIG_DB entry:

VLAN_MEMBER|Vlan10|Ethernet0

    tagging_mode = untagged

 

This VLAN_MEMBER entry represents the relationship between VLAN 10 and Ethernet0 and specifies the VLAN tagging mode.

The configuration changes in CONFIG_DB are consumed by the SONiC configuration management processes, which update the appropriate tables in APPL_DB. The resulting application-level state is then consumed by orchagent, which uses the SAI API to create or update the required SAI objects.

The VLAN itself and the VLAN-to-port relationship are represented separately in APPL_DB. VLAN_TABLE:Vlan10 represents the VLAN, while VLAN_MEMBER_TABLE represents the membership of Ethernet0 in VLAN 10. Therefore, the Ethernet0 membership does not need to appear as a members@ field in VLAN_TABLE in APPL_DB. 

Figure 5-11: Ethernet0-to-Vlan10 Association: CONFIG_DB and APPL_DB.

 

ASIC_DB

Figure 5-12 depicts the SAI object representations in ASIC_DB that bind Ethernet0 to VLAN 10. The SAI_OBJECT_TYPE_BRIDGE object (oid:0x3900000000098e) represents the switch's default 802.1Q VLAN-aware Layer-2 bridge. The 802.1Q bridge provides the common Layer-2 switching context in which multiple VLANs can exist. The same 1Q bridge can provide the Layer-2 switching context for VLAN 10, VLAN 20, and other VLANs configured on the switch.

The SAI_OBJECT_TYPE_VLAN object (oid:0x26000000000a65) represents VLAN 10.

The SAI_OBJECT_TYPE_VLAN_MEMBER object (oid:0x27000000000a6b) establishes the membership relationship between VLAN 10 and the bridge port associated with Ethernet0. Its SAI_VLAN_MEMBER_ATTR _VLAN_ID attribute references the VLAN object, while SAI_VLAN_ MEMBER_ATTR_BRIDGE_PORT_ID references the SAI_OBJECT_TYPE _BRIDGE_ PORT object (oid:0x3a000000000a6a).

The bridge-port is an SAI abstraction that represents a switch port as a participant in the Layer-2 bridging system. It separates the physical or logical port represented by SAI_OBJECT_TYPE_PORT from its participation in Layer-2 bridging. In this example, the SAI_BRIDGE_PORT_ATTR_ PORT_ID attribute of the SAI_OBJECT_ TYPE_BRIDGE_PORT references the SAI_OBJECT_TYPE_ PORT object (oid:0x1000000000002), which represents Ethernet0.

Because Ethernet0 was configured as an untagged interface, the VLAN_MEMBER object also contains the VLAN tagging mode:

SAI_VLAN_MEMBER_ATTR_VLAN_TAGGING_MODE = SAI_VLAN_TAGGING_MODE_UNTAGGED

This specifies that Ethernet0 is an untagged member of VLAN 10. Frames transmitted from VLAN 10 toward Ethernet0 are sent without an 802.1Q VLAN tag, while untagged frames received from Ethernet0 are associated with VLAN 10.

The subsequent ASIC programming follows the same SAI-to-ASIC process described in the previous sections and is therefore omitted from Figure 5-12.

ASIC MAC Address Learning - Forwarding Database (FDB)

The BRIDGE_PORT object also defines how the port participates in Layer-2 frame forwarding. In this example, the relevant attribute is:

SAI_BRIDGE_PORT_ATTR_FDB_LEARNING_MODE:SAI_BRIDGE_PORT_FDB_LEARNING_MODE_HW

The SAI_BRIDGE_PORT_FDB_LEARNING_MODE_HW setting tells the ASIC to perform MAC-address learning in hardware. The ASIC learns source MAC addresses and associates them with the corresponding bridge ports, allowing subsequent frames to known destination MAC addresses to be forwarded directly to the appropriate port. No software-based MAC learning process is required for this operation.

The BRIDGE_PORT abstraction therefore does more than connect a PORT to the Layer-2 bridging system. It also provides a place to configure Layer-2 behavior associated with the port, such as FDB learning and bridge-port administrative state.


Figure 5-12: Ethernet0-to-Vlan10 Association: ASIC_DB.

 

Host Connectivity

At this phase, we have created Layer-2 VLAN 10, enabled the Ethernet0 and Ethernet1 interfaces, and bound both interfaces to VLAN 10. For testing, we connect hosts PC-1 (IP address: 10.0.10.101/24) and PC-2 (IP address: 10.0.10.102/24) to the SONiC switch interfaces Eth1/1 and Eth1/2, as shown in Figure 5-13. We then ping the IP address of PC-2 from PC-1 and vice versa, as shown in Examples 5-7 and 5-8.


Figure 5-13: Host Connectivity Setup.

 

PC1> ping 10.0.10.102 -c 3

 

84 bytes from 10.0.10.102 icmp_seq=1 ttl=64 time=9.855 ms

84 bytes from 10.0.10.102 icmp_seq=2 ttl=64 time=10.754 ms

84 bytes from 10.0.10.102 icmp_seq=3 ttl=64 time=6.991 ms

Example 5-7: Ping From PC1 to PC2.

 

PC2> ping 10.0.10.101 -c 3

 

84 bytes from 10.0.10.101 icmp_seq=1 ttl=64 time=29.778 ms

84 bytes from 10.0.10.101 icmp_seq=2 ttl=64 time=3.044 ms

84 bytes from 10.0.10.101 icmp_seq=3 ttl=64 time=3.629 ms

Example 5-8: Pinging From PC2 to PC1.

Summary

This chapter has explained what happens behind the scenes when we configure a VLAN and bind interfaces to it. In daily operations, however, most network administrators do not necessarily need to know which daemon, running in which container, participates in the ASIC programming pipeline, what each daemon does, or how the different processes communicate with each other.

The SONiC configuration and processing flow shown in Figure 5-14 is not unique to SONiC. The individual components may differ between network operating systems, but the basic concept of taking a configuration from the user, processing it through the operating system, and eventually programming the hardware can be similar.

Understanding these details becomes particularly useful when troubleshooting a network device. Instead of looking only at the final configuration or operational state, we can follow the configuration through the different layers and determine where the expected state is no longer being reflected. Knowing which daemon is responsible for each step, which database contains the information, and how the processes communicate can help identify where the configuration pipeline has stopped or where an unexpected state has been introduced.


Figure 5-14: Summary.

Appendix A.

This appendix starts by showing scripts that print VLAN, VLAN-member, and port-specific information from the config_db.json file and the corresponding keys from the CONFIG_DB tables. It then shows similar comparisons between CONFIG_DB and APPL_DB, as well as between APPL_DB and ASIC_DB, where database tables are compared with the corresponding SAI objects.

 

Config_db.json and CONFIG_DB

 

VLAN

printf '%s\n' '========== Config_db.json =========='

sudo jq '.VLAN' /etc/sonic/config_db.json

 

printf '\n%s\n' '============ CONFIG_DB ============'

sudo sonic-db-dump -n CONFIG_DB --pretty -k 'VLAN|Vlan10'

========== Config_db.json ==========

{

  "Vlan10": {

    "members": [

      "Ethernet0",

      "Ethernet1"

    ],

    "vlanid": "10"

  }

}

 

============ CONFIG_DB ============

{

  "VLAN|Vlan10": {

    "expireat": 1786775174.6650724,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "members@": "Ethernet0,Ethernet1",

      "vlanid": "10"

    }

  }

}

admin@sonic:~$

Example A-1: Config_db.json & CONFIG_DB - VLAN.

VLAN_MEMBER

printf '%s\n' '========== Config_db.json =========='

sudo jq '.VLAN_MEMBER | with_entries(select(.key | startswith("Vlan10|")))' /etc/sonic/config_db.json

 

printf '\n%s\n' '============ CONFIG_DB ============'

sudo sonic-db-dump -n CONFIG_DB --pretty -k 'VLAN_MEMBER|Vlan10|*'

========== Config_db.json ==========

{

  "Vlan10|Ethernet0": {

    "tagging_mode": "untagged"

  },

  "Vlan10|Ethernet1": {

    "tagging_mode": "untagged"

  }

}

 

============ CONFIG_DB ============

{

  "VLAN_MEMBER|Vlan10|Ethernet0": {

    "expireat": 1786775238.5690634,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "tagging_mode": "untagged"

    }

  },

  "VLAN_MEMBER|Vlan10|Ethernet1": {

    "expireat": 1786775238.5690591,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "tagging_mode": "untagged"

    }

  }

}

admin@sonic:~$

Example A-2: Config_db.json & CONFIG_DB - VLAN_MEMBER.


 

PORT

printf '%s\n' '========== Config_db.json =========='

sudo jq '.PORT | with_entries(

  select(.key == "Ethernet0" or .key == "Ethernet1")

)' /etc/sonic/config_db.json

 

printf '\n%s\n' '============ CONFIG_DB ============'

sudo sonic-db-dump -n CONFIG_DB --pretty -k 'PORT|Ethernet0'

sudo sonic-db-dump -n CONFIG_DB --pretty -k 'PORT|Ethernet1'

========== Config_db.json ==========

{

  "Ethernet0": {

    "admin_status": "up",

    "adv_speeds": "all",

    "alias": "Eth1/1",

    "autoneg": "off",

    "fec": "none",

    "index": "1",

    "lanes": "49",

    "link_training": "off",

    "mtu": "9100",

    "speed": "25000",

    "unreliable_los": "auto"

  },

  "Ethernet1": {

    "admin_status": "up",

    "adv_speeds": "all",

    "alias": "Eth1/2",

    "autoneg": "off",

    "fec": "none",

    "index": "2",

    "lanes": "50",

    "link_training": "off",

    "mtu": "9100",

    "speed": "25000",

    "unreliable_los": "auto"

  }

}

 

============ CONFIG_DB ============

{

  "PORT|Ethernet0": {

    "expireat": 1786775324.9049945,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "admin_status": "up",

      "adv_speeds": "all",

      "alias": "Eth1/1",

      "autoneg": "off",

      "fec": "none",

      "index": "1",

      "lanes": "49",

      "link_training": "off",

      "mtu": "9100",

      "speed": "25000",

      "unreliable_los": "auto"

    }

  }

}{

  "PORT|Ethernet1": {

    "expireat": 1786775325.4135427,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "admin_status": "up",

      "adv_speeds": "all",

      "alias": "Eth1/2",

      "autoneg": "off",

      "fec": "none",

      "index": "2",

      "lanes": "50",

      "link_training": "off",

      "mtu": "9100",

      "speed": "25000",

      "unreliable_los": "auto"

    }

  }

}

admin@sonic:~$

Example A-3: Config_db.json & CONFIG_DB - PORT.


 

CONFIG_DB and APPL_DB

 

VLAN

 

printf '%s\n' '============ CONFIG_DB ============'

sudo sonic-db-dump -n CONFIG_DB --pretty -k 'VLAN|Vlan10'

 

printf '\n%s\n' '============== APPL_DB =============='

sudo sonic-db-dump -n APPL_DB --pretty -k 'VLAN_TABLE:Vlan10'

============ CONFIG_DB ============

{

  "VLAN|Vlan10": {

    "expireat": 1786775377.0510554,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "members@": "Ethernet0,Ethernet1",

      "vlanid": "10"

    }

  }

}

============== APPL_DB ==============

{

  "VLAN_TABLE:Vlan10": {

    "expireat": 1786775377.5195205,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "admin_status": "up",

      "last_change": "1786774681",

      "mac": "0c:9a:32:79:00:0a",

      "mtu": "9100",

      "oper_mtu": "9100",

      "oper_status": "up"

    }

  }

}

admin@sonic:~$

Example A-4: CONFIG_DB & APPL_DB - VLAN.

VLAN_MEMBER

printf '%s\n' '============ CONFIG_DB ============'

sudo sonic-db-dump -n CONFIG_DB --pretty -k 'VLAN_MEMBER|Vlan10|Ethernet0'

sudo sonic-db-dump -n CONFIG_DB --pretty -k 'VLAN_MEMBER|Vlan10|Ethernet1'

 

printf '\n%s\n' '============== APPL_DB =============='

sudo sonic-db-dump -n APPL_DB --pretty -k 'VLAN_MEMBER_TABLE:Vlan10:Ethernet0'

sudo sonic-db-dump -n APPL_DB --pretty -k 'VLAN_MEMBER_TABLE:Vlan10:Ethernet1'

============ CONFIG_DB ============

{

  "VLAN_MEMBER|Vlan10|Ethernet0": {

    "expireat": 1786775471.0865471,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "tagging_mode": "untagged"

    }

  }

}{

  "VLAN_MEMBER|Vlan10|Ethernet1": {

    "expireat": 1786775471.6284318,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "tagging_mode": "untagged"

    }

  }

}

============== APPL_DB ==============

{

  "VLAN_MEMBER_TABLE:Vlan10:Ethernet0": {

    "expireat": 1786775472.1512458,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "dynamic": "no",

      "tagging_mode": "untagged"

    }

  }

}{

  "VLAN_MEMBER_TABLE:Vlan10:Ethernet1": {

    "expireat": 1786775472.6109993,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "dynamic": "no",

      "tagging_mode": "untagged"

    }

  }

}

admin@sonic:~$

Example A-5: CONFIG_DB & APPL_DB - VLAN_MEMBER.

 

PORT

printf '%s\n' '============ CONFIG_DB ============'

sudo sonic-db-dump -n CONFIG_DB --pretty -k 'PORT|Ethernet0'

sudo sonic-db-dump -n CONFIG_DB --pretty -k 'PORT|Ethernet1'

 

printf '\n%s\n' '============== APPL_DB =============='

sudo sonic-db-dump -n APPL_DB --pretty -k 'PORT_TABLE:Ethernet0'

sudo sonic-db-dump -n APPL_DB --pretty -k 'PORT_TABLE:Ethernet1'

============ CONFIG_DB ============

{

  "PORT|Ethernet0": {

    "expireat": 1786775497.705537,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "admin_status": "up",

      "adv_speeds": "all",

      "alias": "Eth1/1",

      "autoneg": "off",

      "fec": "none",

      "index": "1",

      "lanes": "49",

      "link_training": "off",

      "mtu": "9100",

      "speed": "25000",

      "unreliable_los": "auto"

    }

  }

}{

  "PORT|Ethernet1": {

    "expireat": 1786775498.2250605,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "admin_status": "up",

      "adv_speeds": "all",

      "alias": "Eth1/2",

      "autoneg": "off",

      "fec": "none",

      "index": "2",

      "lanes": "50",

      "link_training": "off",

      "mtu": "9100",

      "speed": "25000",

      "unreliable_los": "auto"

    }

  }

}

============== APPL_DB ==============

{

  "PORT_TABLE:Ethernet0": {

    "expireat": 1786775498.6911356,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "admin_status": "up",

      "adv_speeds": "all",

      "alias": "Eth1/1",

      "autoneg": "off",

      "description": "",

      "fec": "none",

      "index": "1",

      "lanes": "49",

      "last_change": "1786774679",

      "link_training": "off",

      "mtu": "9100",

      "oper_speed": "25000",

      "oper_status": "up",

      "oper_status_change_uptime": "119",

      "port_load_interval": "10",

      "reason": "OPER_UP",

      "speed": "25000",

      "unreliable_los": "auto"

    }

  }

}{

  "PORT_TABLE:Ethernet1": {

    "expireat": 1786775499.1984518,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "admin_status": "up",

      "adv_speeds": "all",

      "alias": "Eth1/2",

      "autoneg": "off",

      "description": "",

      "fec": "none",

      "index": "2",

      "lanes": "50",

      "last_change": "1786774679",

      "link_training": "off",

      "mtu": "9100",

      "oper_speed": "25000",

      "oper_status": "up",

      "oper_status_change_uptime": "119",

      "port_load_interval": "10",

      "reason": "OPER_UP",

      "speed": "25000",

      "unreliable_los": "auto"

    }

  }

}

admin@sonic:~$

Example A-6: CONFIG_DB & APPL_DB - PORT.

 


 

APPL_DB and ASIC_DB

VLAN

printf '%s\n' '============== APPL_DB =============='

sudo sonic-db-dump -n APPL_DB --pretty -k 'VLAN_TABLE:Vlan10'

 

printf '\n%s\n' '============== ASIC_DB =============='

sudo sonic-db-dump -n ASIC_DB --pretty -k 'ASIC_STATE:SAI_OBJECT_TYPE_VLAN:*'

============== APPL_DB ==============

{

  "VLAN_TABLE:Vlan10": {

    "expireat": 1786775601.3179913,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "admin_status": "up",

      "last_change": "1786774681",

      "mac": "0c:9a:32:79:00:0a",

      "mtu": "9100",

      "oper_mtu": "9100",

      "oper_status": "up"

    }

  }

}

============== ASIC_DB ==============

{

  "ASIC_STATE:SAI_OBJECT_TYPE_VLAN:oid:0x26000000000955": {

    "expireat": 1786775601.8435838,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "NULL": "NULL",

      "SAI_VLAN_ATTR_VLAN_ID": "1"

    }

  },

  "ASIC_STATE:SAI_OBJECT_TYPE_VLAN:oid:0x26000000000a48": {

    "expireat": 1786775601.8435814,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "SAI_VLAN_ATTR_VLAN_ID": "10"

    }

  },

  "ASIC_STATE:SAI_OBJECT_TYPE_VLAN:oid:0x26000000000a69": {

    "expireat": 1786775601.8435771,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "SAI_VLAN_ATTR_VLAN_ID": "3967"

    }

  }

}

admin@sonic:~$

Example A-7: APPL_DB & ASIC_DB- VLAN.

VLAN_MEMBER

 

printf '%s\n' '============== APPL_DB =============='

sudo sonic-db-dump -n APPL_DB --pretty -k 'VLAN_MEMBER_TABLE:Vlan10:Ethernet0'

sudo sonic-db-dump -n APPL_DB --pretty -k 'VLAN_MEMBER_TABLE:Vlan10:Ethernet1'

 

printf '\n%s\n' '============== ASIC_DB =============='

sudo sonic-db-dump -n ASIC_DB --pretty -k 'ASIC_STATE:SAI_OBJECT_TYPE_VLAN_MEMBER:*'

 

sudo sonic-db-dump -n APPL_DB --pretty -k 'VLAN_MEMBER_TABLE:Vlan10:Ethernet0'

sudo sonic-db-dump -n APPL_DB --pretty -k 'VLAN_MEMBER_TABLE:Vlan10:Ethernet1'

============== APPL_DB ==============y -k 'ASIC_STATE:SAI_OBJECT_TYPE_VLAN_MEMBER:*'

{

  "VLAN_MEMBER_TABLE:Vlan10:Ethernet0": {

    "expireat": 1786775663.2531705,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "dynamic": "no",

      "tagging_mode": "untagged"

    }

  }

}{

  "VLAN_MEMBER_TABLE:Vlan10:Ethernet1": {

    "expireat": 1786775663.7200844,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "dynamic": "no",

      "tagging_mode": "untagged"

    }

  }

}

============== ASIC_DB ==============

{

  "ASIC_STATE:SAI_OBJECT_TYPE_VLAN_MEMBER:oid:0x27000000000a4a": {

    "expireat": 1786775664.2388985,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "SAI_VLAN_MEMBER_ATTR_BRIDGE_PORT_ID": "oid:0x3a000000000a49",

      "SAI_VLAN_MEMBER_ATTR_VLAN_ID": "oid:0x26000000000a48",

      "SAI_VLAN_MEMBER_ATTR_VLAN_TAGGING_MODE": "SAI_VLAN_TAGGING_MODE_UNTAGGED"

    }

  },

  "ASIC_STATE:SAI_OBJECT_TYPE_VLAN_MEMBER:oid:0x27000000000a4c": {

    "expireat": 1786775664.2389033,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "SAI_VLAN_MEMBER_ATTR_BRIDGE_PORT_ID": "oid:0x3a000000000a4b",

      "SAI_VLAN_MEMBER_ATTR_VLAN_ID": "oid:0x26000000000a48",

      "SAI_VLAN_MEMBER_ATTR_VLAN_TAGGING_MODE": "SAI_VLAN_TAGGING_MODE_UNTAGGED"

    }

  }

}

admin@sonic:~$

Example A-8: APPL_DB & ASIC_DB- VLAN_MEMBER.

 


 

PORT

sudo sonic-db-dump -n APPL_DB --pretty -k 'PORT_TABLE:Ethernet0'==='

sudo sonic-db-dump -n APPL_DB --pretty -k 'PORT_TABLE:Ethernet0'

printf '\n%s\n' '============== ASIC_DB =============='

sudo sonic-db-dump -n ASIC_DB --pretty -k 'ASIC_STATE:SAI_OBJECT_TYPE_PORT:oid:0x1000000000002'

============== APPL_DB ==============

{

  "PORT_TABLE:Ethernet0": {

    "expireat": 1786775776.5472891,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "admin_status": "up",

      "adv_speeds": "all",

      "alias": "Eth1/1",

      "autoneg": "off",

      "description": "",

      "fec": "none",

      "index": "1",

      "lanes": "49",

      "last_change": "1786774679",

      "link_training": "off",

      "mtu": "9100",

      "oper_speed": "25000",

      "oper_status": "up",

      "oper_status_change_uptime": "119",

      "port_load_interval": "10",

      "reason": "OPER_UP",

      "speed": "25000",

      "unreliable_los": "auto"

    }

  }

}

============== ASIC_DB ==============

{

  "ASIC_STATE:SAI_OBJECT_TYPE_PORT:oid:0x1000000000002": {

    "expireat": 1786775777.0333235,

    "ttl": -0.001,

    "type": "hash",

    "value": {

      "NULL": "NULL",

      "SAI_PORT_ATTR_ADMIN_STATE": "true",

      "SAI_PORT_ATTR_MTU": "9122",

      "SAI_PORT_ATTR_PORT_VLAN_ID": "10",

      "SAI_PORT_ATTR_SPEED": "25000"

    }

  }

}

admin@sonic:~$

Example A-9: APPL_DB & ASIC_DB - PORT.