Skip to content

Commit fd2831c

Browse files
arlakshmabdosi
authored andcommitted
[config]: Fix the device type and internal bgp session status for multi NPU platforms (#4600)
* The following changes for multi-npu platforms are done - Set the type in device_metadata for asic configuration to be same as host - Set the admin-status of internal bgp sessions as up Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
1 parent bb60e2b commit fd2831c

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

src/sonic-config-engine/minigraph.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,21 @@ def filter_acl_table_bindings(acls, neighbors, port_channels, sub_role):
749749

750750
return filter_acls
751751

752+
def enable_internal_bgp_session(bgp_sessions, filename, asic_name):
753+
'''
754+
In Multi-NPU session the internal sessions will always be up.
755+
So adding the admin-status 'up' configuration to bgp sessions
756+
BGP session between FrontEnd and BackEnd Asics are internal bgp sessions
757+
'''
758+
local_sub_role = parse_asic_sub_role(filename, asic_name)
759+
760+
for peer_ip in bgp_sessions.keys():
761+
peer_name = bgp_sessions[peer_ip]['name']
762+
peer_sub_role = parse_asic_sub_role(filename, peer_name)
763+
if ((local_sub_role == FRONTEND_ASIC_SUB_ROLE and peer_sub_role == BACKEND_ASIC_SUB_ROLE) or
764+
(local_sub_role == BACKEND_ASIC_SUB_ROLE and peer_sub_role == FRONTEND_ASIC_SUB_ROLE)):
765+
bgp_sessions[peer_ip].update({'admin_status': 'up'})
766+
752767
###############################################################################
753768
#
754769
# Main functions
@@ -842,6 +857,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None):
842857
(intfs, lo_intfs, mvrf, mgmt_intf, vlans, vlan_members, pcs, pc_members, acls, vni) = parse_dpg(child, asic_name)
843858
elif child.tag == str(QName(ns, "CpgDec")):
844859
(bgp_sessions, bgp_asn, bgp_peers_with_range, bgp_monitors) = parse_cpg(child, asic_name)
860+
enable_internal_bgp_session(bgp_sessions, filename, asic_name)
845861
elif child.tag == str(QName(ns, "PngDec")):
846862
(neighbors, devices, port_speed_png) = parse_asic_png(child, asic_name, hostname)
847863
elif child.tag == str(QName(ns, "MetadataDeclaration")):
@@ -851,6 +867,8 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None):
851867
elif child.tag == str(QName(ns, "DeviceInfos")):
852868
(port_speeds_default, port_descriptions) = parse_deviceinfo(child, hwsku)
853869

870+
# set the host device type in asic metadata also
871+
device_type = [devices[key]['type'] for key in devices if key.lower() == hostname.lower()][0]
854872
if asic_name is None:
855873
current_device = [devices[key] for key in devices if key.lower() == hostname.lower()][0]
856874
else:
@@ -864,7 +882,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None):
864882
'docker_routing_config_mode': docker_routing_config_mode,
865883
'hostname': hostname,
866884
'hwsku': hwsku,
867-
'type': current_device['type']
885+
'type': device_type
868886
}
869887
}
870888
# for this hostname, if sub_role is defined, add sub_role in

src/sonic-config-engine/tests/test_multinpu_cfggen.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
ASIC_SKU = 'multi-npu-asic'
1010
NUM_ASIC = 4
1111
HOSTNAME = 'multi_npu_platform_01'
12-
12+
DEVICE_TYPE = 'LeafRouter'
1313

1414
class TestMultiNpuCfgGen(TestCase):
1515

@@ -197,16 +197,16 @@ def test_frontend_bgp_neighbor(self):
197197
output = json.loads(self.run_script(argument))
198198
self.assertDictEqual(output, \
199199
{'10.0.0.1': {'rrclient': 0, 'name': '01T2', 'local_addr': '10.0.0.0', 'nhopself': 0, 'holdtime': '10', 'asn': '65200', 'keepalive': '3'},
200-
'10.1.0.0': {'rrclient': 0, 'name': 'ASIC2', 'local_addr': '10.1.0.1', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0'},
200+
'10.1.0.0': {'rrclient': 0, 'name': 'ASIC2', 'local_addr': '10.1.0.1', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0', 'admin_status': 'up'},
201201
'fc00::2': {'rrclient': 0, 'name': '01T2', 'local_addr': 'fc00::1', 'nhopself': 0, 'holdtime': '10', 'asn': '65200', 'keepalive': '3'},
202-
'10.1.0.2': {'rrclient': 0, 'name': 'ASIC3', 'local_addr': '10.1.0.3', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0'}})
202+
'10.1.0.2': {'rrclient': 0, 'name': 'ASIC3', 'local_addr': '10.1.0.3', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0', 'admin_status': 'up'}})
203203

204204
def test_backend_asic_bgp_neighbor(self):
205205
argument = "-m {} -p {} -n asic3 --var-json \"BGP_NEIGHBOR\"".format(self.sample_graph, self.port_config[3])
206206
output = json.loads(self.run_script(argument))
207207
self.assertDictEqual(output, \
208-
{'10.1.0.7': {'rrclient': 0, 'name': 'ASIC1', 'local_addr': '10.1.0.6', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0'},
209-
'10.1.0.3': {'rrclient': 0, 'name': 'ASIC0', 'local_addr': '10.1.0.2', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0'}})
208+
{'10.1.0.7': {'rrclient': 0, 'name': 'ASIC1', 'local_addr': '10.1.0.6', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0', 'admin_status': 'up'},
209+
'10.1.0.3': {'rrclient': 0, 'name': 'ASIC0', 'local_addr': '10.1.0.2', 'nhopself': 0, 'holdtime': '0', 'asn': '65100', 'keepalive': '0', 'admin_status': 'up'}})
210210

211211
def test_device_asic_metadata(self):
212212
argument = "-m {} --var-json DEVICE_METADATA".format(self.sample_graph)
@@ -215,7 +215,7 @@ def test_device_asic_metadata(self):
215215
asic_name = "asic{}".format(asic)
216216
self.assertEqual(output['localhost']['hostname'], 'multi_npu_platform_01')
217217
self.assertEqual(output['localhost']['asic_name'], asic_name)
218-
self.assertEqual(output['localhost']['type'], 'Asic')
218+
self.assertEqual(output['localhost']['type'], DEVICE_TYPE)
219219
if asic == 0 or asic == 1:
220220
self.assertEqual(output['localhost']['sub_role'], 'FrontEnd')
221221
else:

0 commit comments

Comments
 (0)