Skip to content

Commit

Permalink
sort the system port ID generation (sonic-net#20075)
Browse files Browse the repository at this point in the history
#### Why I did it
The system_port_id generation was based on the loop below

for interface in **interface_metadata.findall**(str(QName(ns1, "DeviceInterfaceMetadata"))):

"DeviceInterfaceMetadata" defined in the minigraph in DeviceInfo section, which is per interface and in this loop we increment the system_port_id++ so that each interface will have a unique ID. 

The for loop was based on interface_metadata list extracted by findall() API matching tag **"DeviceInterfaceMetadata"** [lxml.etree._Element](https://lxml.de/api/lxml.etree._Element-class.html). findall() doesn't guarantee document order. Hence the interface list and the corresponding system_port ids generated - has a possibility of not matching across config_db's in different linecards of a chassis.

When SYSTEM_PORT table entries hve mismatch across linecards, a few line cards behaving erratically, resulting in continuous pkt error interrupts getting fired and the IBGP sessions not getting established with other peer ASIC's in other line cards.

### How I did it
Add logic to do a sort of the system_ports dictionary based on the key (eg: "str-sonic-lc03|ASIC0|Ethernet120") and assign the system_port_id in an incremental way. 

This makes sure the system_port_ids in SYSTEM_PORT table in config_db matches in all linecards/asic

Thanks to @abdosi and @vmittal-msft in triaging and coming to this solution.

#### How to verify it

Verified by manually patching this logic in the minigraph parser in the sonic T2 chassis and make sure the dockers, interfaces, IBGP, EBGP comes up in all linecards across the chassis.
  • Loading branch information
judyjoseph authored Oct 3, 2024
1 parent 7ca784a commit e18cecb
Show file tree
Hide file tree
Showing 2 changed files with 1,149 additions and 1,144 deletions.
11 changes: 8 additions & 3 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,13 @@ def parse_chassis_deviceinfo_intf_metadata(device_info, chassis_linecards_info,
if linecard_name is not None:
key = "%s|%s" % (linecard_name, key)
system_ports[key] = {
"system_port_id": system_port_id,
"system_port_id": 0,
"switch_id": switch_id,
"core_index": core_id,
"core_port_index": core_port_id,
"speed": intf_speed,
"num_voq": num_voq
}
system_port_id += 1

chassis_port_alias.setdefault(slot_index, {}).update(
{(intf_sonic_name, intf_speed): intf_name})
Expand All @@ -363,8 +362,14 @@ def parse_chassis_deviceinfo_intf_metadata(device_info, chassis_linecards_info,
port_default_speed.setdefault(slot_index, {}).update(
{intf_sonic_name: intf_speed})

return system_ports, chassis_port_alias, port_default_speed
# The above loop with findall("DeviceInterfaceMetadata") was not giving interfaces from minigraph
# in document order. So doing an explict sort so that system_port_ids remain same across LCs
sorted_system_ports = { key:system_ports[key] for key in sorted(system_ports.keys()) }
for k,v in sorted_system_ports.items():
v["system_port_id"] = system_port_id
system_port_id += 1

return sorted_system_ports, chassis_port_alias, port_default_speed


def parse_chassis_deviceinfo_voq_int_intfs(device_info):
Expand Down
Loading

0 comments on commit e18cecb

Please sign in to comment.