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.
No comments:
Post a Comment