Skip to content

Commit f8da3e4

Browse files
lguohanqiluo-msft
authored andcommitted
Revert "[config]: Loopback Interface changes for multi ASIC devices (sonic-net#4825)"
This reverts commit cae65a4.
1 parent 7c30949 commit f8da3e4

File tree

6 files changed

+16
-120
lines changed

6 files changed

+16
-120
lines changed

dockers/docker-fpm-frr/frr/bgpd/bgpd.main.conf.j2

+1-15
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ipv6 prefix-list PL_LoopbackV6 permit {{ get_ipv6_loopback_address(LOOPBACK_INTE
1515
{% endif %}
1616
!
1717
!
18-
{% if multi_asic() %}
18+
{% if DEVICE_METADATA['localhost']['sub_role'] == 'FrontEnd' %}
1919
route-map HIDE_INTERNAL permit 10
2020
set community local-AS
2121
!
@@ -38,30 +38,16 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
3838
{% endif %}
3939
!
4040
{# set router-id #}
41-
{% if multi_asic() %}
42-
bgp router-id {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") | ip }}
43-
{% else %}
4441
bgp router-id {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}
45-
{% endif %}
4642
!
4743
{# advertise loopback #}
4844
network {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}/32
49-
{% if multi_asic() %}
50-
network {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") | ip }}/32 route-map HIDE_INTERNAL
51-
{% endif %}
5245
!
5346
{% if get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") != 'None' %}
5447
address-family ipv6
5548
network {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}/64
5649
exit-address-family
5750
{% endif %}
58-
{% if multi_asic() %}
59-
{% if get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") != 'None' %}
60-
address-family ipv6
61-
network {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback4096") | ip }}/64 route-map HIDE_INTERNAL
62-
exit-address-family
63-
{% endif %}
64-
{% endif %}
6551
{% endblock bgp_init %}
6652
!
6753
{% block vlan_advertisement %}

src/sonic-config-engine/minigraph.py

+7-25
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,6 @@ def parse_asic_png(png, asic_name, hostname):
251251
devices[name] = device_data
252252
return (neighbors, devices, port_speeds)
253253

254-
def parse_loopback_intf(child):
255-
lointfs = child.find(str(QName(ns, "LoopbackIPInterfaces")))
256-
lo_intfs = {}
257-
for lointf in lointfs.findall(str(QName(ns1, "LoopbackIPInterface"))):
258-
intfname = lointf.find(str(QName(ns, "AttachTo"))).text
259-
ipprefix = lointf.find(str(QName(ns1, "PrefixStr"))).text
260-
lo_intfs[(intfname, ipprefix)] = {}
261-
return lo_intfs
262-
263254
def parse_dpg(dpg, hname):
264255
aclintfs = None
265256
mgmtintfs = None
@@ -278,6 +269,7 @@ def parse_dpg(dpg, hname):
278269
"""
279270
if mgmtintfs is None and child.find(str(QName(ns, "ManagementIPInterfaces"))) is not None:
280271
mgmtintfs = child.find(str(QName(ns, "ManagementIPInterfaces")))
272+
281273
hostname = child.find(str(QName(ns, "Hostname")))
282274
if hostname.text.lower() != hname.lower():
283275
continue
@@ -298,7 +290,12 @@ def parse_dpg(dpg, hname):
298290
ipprefix = ipintf.find(str(QName(ns, "Prefix"))).text
299291
intfs[(intfname, ipprefix)] = {}
300292

301-
lo_intfs = parse_loopback_intf(child)
293+
lointfs = child.find(str(QName(ns, "LoopbackIPInterfaces")))
294+
lo_intfs = {}
295+
for lointf in lointfs.findall(str(QName(ns1, "LoopbackIPInterface"))):
296+
intfname = lointf.find(str(QName(ns, "AttachTo"))).text
297+
ipprefix = lointf.find(str(QName(ns1, "PrefixStr"))).text
298+
lo_intfs[(intfname, ipprefix)] = {}
302299

303300
mvrfConfigs = child.find(str(QName(ns, "MgmtVrfConfigs")))
304301
mvrf = {}
@@ -455,13 +452,6 @@ def parse_dpg(dpg, hname):
455452
return intfs, lo_intfs, mvrf, mgmt_intf, vlans, vlan_members, pcs, pc_members, acls, vni
456453
return None, None, None, None, None, None, None, None, None, None
457454

458-
def parse_host_loopback(dpg, hname):
459-
for child in dpg:
460-
hostname = child.find(str(QName(ns, "Hostname")))
461-
if hostname.text.lower() != hname.lower():
462-
continue
463-
lo_intfs = parse_loopback_intf(child)
464-
return lo_intfs
465455

466456
def parse_cpg(cpg, hname):
467457
bgp_sessions = {}
@@ -836,7 +826,6 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
836826
cloudtype = None
837827
hostname = None
838828
linkmetas = {}
839-
host_lo_intfs = None
840829

841830
# hostname is the asic_name, get the asic_id from the asic_name
842831
if asic_name is not None:
@@ -878,7 +867,6 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
878867
else:
879868
if child.tag == str(QName(ns, "DpgDec")):
880869
(intfs, lo_intfs, mvrf, mgmt_intf, vlans, vlan_members, pcs, pc_members, acls, vni) = parse_dpg(child, asic_name)
881-
host_lo_intfs = parse_host_loopback(child, hostname)
882870
elif child.tag == str(QName(ns, "CpgDec")):
883871
(bgp_sessions, bgp_asn, bgp_peers_with_range, bgp_monitors) = parse_cpg(child, asic_name)
884872
enable_internal_bgp_session(bgp_sessions, filename, asic_name)
@@ -942,12 +930,6 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None, hw
942930
for lo_intf in lo_intfs:
943931
results['LOOPBACK_INTERFACE'][lo_intf] = lo_intfs[lo_intf]
944932
results['LOOPBACK_INTERFACE'][lo_intf[0]] = {}
945-
946-
if host_lo_intfs is not None:
947-
for host_lo_intf in host_lo_intfs:
948-
results['LOOPBACK_INTERFACE'][host_lo_intf] = host_lo_intfs[host_lo_intf]
949-
results['LOOPBACK_INTERFACE'][host_lo_intf[0]] = {}
950-
951933
results['MGMT_VRF_CONFIG'] = mvrf
952934

953935
phyport_intfs = {}

src/sonic-config-engine/sonic-cfggen

-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ from sonic_device_util import get_machine_info
4545
from sonic_device_util import get_platform_info
4646
from sonic_device_util import get_system_mac
4747
from sonic_device_util import get_npu_id_from_name
48-
from sonic_device_util import is_multi_npu
4948
from config_samples import generate_sample_config
5049
from config_samples import get_available_config
5150
from swsssdk import SonicV2Connector, ConfigDBConnector, SonicDBConfig
@@ -345,8 +344,6 @@ def main():
345344
env.filters['ip_network'] = ip_network
346345
for attr in ['ip', 'network', 'prefixlen', 'netmask', 'broadcast']:
347346
env.filters[attr] = partial(prefix_attr, attr)
348-
# Pass the is_multi_npu function as global
349-
env.globals['multi_asic'] = is_multi_npu
350347
template = env.get_template(template_file)
351348
print(template.render(sort_data(data)))
352349

src/sonic-config-engine/sonic_device_util.py

+4-12
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,12 @@ def get_npu_id_from_name(npu_name):
4444
else:
4545
return None
4646

47-
def get_asic_conf_file_path(platform):
48-
asic_conf_path_candidates = []
49-
asic_conf_path_candidates.append(os.path.join('/usr/share/sonic/platform', ASIC_CONF_FILENAME))
50-
if platform is not None:
51-
asic_conf_path_candidates.append(os.path.join(SONIC_DEVICE_PATH, platform, ASIC_CONF_FILENAME))
52-
for asic_conf_file_path in asic_conf_path_candidates:
53-
if os.path.isfile(asic_conf_file_path):
54-
return asic_conf_file_path
55-
return None
56-
5747
def get_num_npus():
5848
platform = get_platform_info(get_machine_info())
59-
asic_conf_file_path = get_asic_conf_file_path(platform)
60-
if asic_conf_file_path is None:
49+
if not platform:
50+
return 1
51+
asic_conf_file_path = os.path.join(SONIC_DEVICE_PATH, platform, ASIC_CONF_FILENAME)
52+
if not os.path.isfile(asic_conf_file_path):
6153
return 1
6254
with open(asic_conf_file_path) as asic_conf_file:
6355
for line in asic_conf_file:

src/sonic-config-engine/tests/multi_npu_data/sample-minigraph.xml

+4-36
Original file line numberDiff line numberDiff line change
@@ -387,20 +387,12 @@
387387
<a:LoopbackIPInterface>
388388
<ElementType>LoopbackInterface</ElementType>
389389
<Name>HostIP</Name>
390-
<AttachTo>Loopback4096</AttachTo>
390+
<AttachTo>Loopback0</AttachTo>
391391
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.NetMux">
392392
<b:IPPrefix>8.0.0.0/32</b:IPPrefix>
393393
</a:Prefix>
394394
<a:PrefixStr>8.0.0.0/32</a:PrefixStr>
395395
</a:LoopbackIPInterface>
396-
<a:LoopbackIPInterface>
397-
<Name>HostIP1</Name>
398-
<AttachTo>Loopback4096</AttachTo>
399-
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.Evolution">
400-
<b:IPPrefix>FD00:1::32/128</b:IPPrefix>
401-
</a:Prefix>
402-
<a:PrefixStr>FD00:1::32/128</a:PrefixStr>
403-
</a:LoopbackIPInterface>
404396
</LoopbackIPInterfaces>
405397
<ManagementIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
406398
<ManagementVIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
@@ -465,20 +457,12 @@
465457
<a:LoopbackIPInterface>
466458
<ElementType>LoopbackInterface</ElementType>
467459
<Name>HostIP</Name>
468-
<AttachTo>Loopback4096</AttachTo>
460+
<AttachTo>Loopback0</AttachTo>
469461
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.NetMux">
470462
<b:IPPrefix>8.0.0.1/32</b:IPPrefix>
471463
</a:Prefix>
472464
<a:PrefixStr>8.0.0.1/32</a:PrefixStr>
473465
</a:LoopbackIPInterface>
474-
<a:LoopbackIPInterface>
475-
<Name>HostIP1</Name>
476-
<AttachTo>Loopback4096</AttachTo>
477-
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.Evolution">
478-
<b:IPPrefix>FD00:2::32/128</b:IPPrefix>
479-
</a:Prefix>
480-
<a:PrefixStr>FD00:2::32/128</a:PrefixStr>
481-
</a:LoopbackIPInterface>
482466
</LoopbackIPInterfaces>
483467
<ManagementIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
484468
<ManagementVIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
@@ -542,20 +526,12 @@
542526
<a:LoopbackIPInterface>
543527
<ElementType>LoopbackInterface</ElementType>
544528
<Name>HostIP</Name>
545-
<AttachTo>Loopback4096</AttachTo>
529+
<AttachTo>Loopback0</AttachTo>
546530
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.NetMux">
547531
<b:IPPrefix>8.0.0.4/32</b:IPPrefix>
548532
</a:Prefix>
549533
<a:PrefixStr>8.0.0.4/32</a:PrefixStr>
550534
</a:LoopbackIPInterface>
551-
<a:LoopbackIPInterface>
552-
<Name>HostIP1</Name>
553-
<AttachTo>Loopback4096</AttachTo>
554-
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.Evolution">
555-
<b:IPPrefix>FD00:3::32/128</b:IPPrefix>
556-
</a:Prefix>
557-
<a:PrefixStr>FD00:3::32/128</a:PrefixStr>
558-
</a:LoopbackIPInterface>
559535
</LoopbackIPInterfaces>
560536
<ManagementIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
561537
<ManagementVIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
@@ -604,20 +580,12 @@
604580
<a:LoopbackIPInterface>
605581
<ElementType>LoopbackInterface</ElementType>
606582
<Name>HostIP</Name>
607-
<AttachTo>Loopback4096</AttachTo>
583+
<AttachTo>Loopback0</AttachTo>
608584
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.NetMux">
609585
<b:IPPrefix>8.0.0.5/32</b:IPPrefix>
610586
</a:Prefix>
611587
<a:PrefixStr>8.0.0.5/32</a:PrefixStr>
612588
</a:LoopbackIPInterface>
613-
<a:LoopbackIPInterface>
614-
<Name>HostIP1</Name>
615-
<AttachTo>Loopback4096</AttachTo>
616-
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.Evolution">
617-
<b:IPPrefix>FD00:4::32/128</b:IPPrefix>
618-
</a:Prefix>
619-
<a:PrefixStr>FD00:4::32/128</a:PrefixStr>
620-
</a:LoopbackIPInterface>
621589
</LoopbackIPInterfaces>
622590
<ManagementIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
623591
<ManagementVIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>

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

-29
Original file line numberDiff line numberDiff line change
@@ -245,32 +245,3 @@ def test_back_end_asic_acl(self):
245245
argument = "-m {} -p {} -n asic3 --var-json \"ACL_TABLE\"".format(self.sample_graph, self.port_config[3])
246246
output = json.loads(self.run_script(argument))
247247
self.assertDictEqual(output, {})
248-
249-
def test_loopback_intfs(self):
250-
argument = "-m {} --var-json \"LOOPBACK_INTERFACE\"".format(self.sample_graph)
251-
output = json.loads(self.run_script(argument))
252-
self.assertDictEqual(output, {\
253-
"Loopback0": {},
254-
"Loopback0|10.1.0.32/32": {},
255-
"Loopback0|FC00:1::32/128": {}})
256-
257-
# The asic configuration should have 2 loopback interfaces
258-
argument = "-m {} -n asic0 --var-json \"LOOPBACK_INTERFACE\"".format(self.sample_graph)
259-
output = json.loads(self.run_script(argument))
260-
self.assertDictEqual(output, { \
261-
"Loopback0": {},
262-
"Loopback4096": {},
263-
"Loopback0|10.1.0.32/32": {},
264-
"Loopback0|FC00:1::32/128": {},
265-
"Loopback4096|8.0.0.0/32": {},
266-
"Loopback4096|FD00:1::32/128": {}})
267-
268-
argument = "-m {} -n asic3 --var-json \"LOOPBACK_INTERFACE\"".format(self.sample_graph)
269-
output = json.loads(self.run_script(argument))
270-
self.assertDictEqual(output, {\
271-
"Loopback0": {},
272-
"Loopback4096": {},
273-
"Loopback0|10.1.0.32/32": {},
274-
"Loopback0|FC00:1::32/128": {},
275-
"Loopback4096|8.0.0.5/32": {},
276-
"Loopback4096|FD00:4::32/128": {}})

0 commit comments

Comments
 (0)