-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loopback Interface changes for multi ASIC devices #4825
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,13 +8,21 @@ | |
! TSA configuration | ||
! | ||
ip prefix-list PL_LoopbackV4 permit {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}/32 | ||
{% if multi_npu() == true %} | ||
ip prefix-list PL_LoopbackV4 permit {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback1") | ip }}/32 | ||
{% endif %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do you need it here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pavel-shirshov, I think this might be needed to support TSA for the multi-asic platforms. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @arlakshm I think you're not going to announce your internal loopbacks at all, right? This prefix-list is used to announce loopback only from the device in TSA mode. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed in the latest commit |
||
! | ||
{% if get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") != 'None' %} | ||
ipv6 prefix-list PL_LoopbackV6 permit {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | replace('/128', '/64') | ip_network }}/64 | ||
{% endif %} | ||
{% if multi_npu() == true %} | ||
{% if get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback1") != 'None' %} | ||
ipv6 prefix-list PL_LoopbackV6 permit {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback1") | replace('/128', '/64') | ip_network }}/64 | ||
{% endif %} | ||
{% endif %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need it here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pavel-shirshov, I think this might be needed to support TSA for the multi-asic platforms. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed in the latest commit |
||
! | ||
! | ||
{% if DEVICE_METADATA['localhost']['sub_role'] == 'FrontEnd' %} | ||
{% if multi_npu() == true %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is possible to write There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed in the latest commit |
||
route-map HIDE_INTERNAL permit 10 | ||
set community local-AS | ||
! | ||
|
@@ -37,16 +45,30 @@ router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} | |
{% endif %} | ||
! | ||
{# set router-id #} | ||
{% if multi_npu() == true %} | ||
bgp router-id {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback1") | ip }} | ||
{% else %} | ||
bgp router-id {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }} | ||
{% endif %} | ||
! | ||
{# advertise loopback #} | ||
network {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}/32 | ||
{% if multi_npu() == true %} | ||
network {{ get_ipv4_loopback_address(LOOPBACK_INTERFACE, "Loopback1") | ip }}/32 route-map HIDE_INTERNAL | ||
{% endif %} | ||
! | ||
{% if get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") != 'None' %} | ||
address-family ipv6 | ||
network {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback0") | ip }}/64 | ||
exit-address-family | ||
{% endif %} | ||
{% if multi_npu() == true %} | ||
{% if get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback1") != 'None' %} | ||
address-family ipv6 | ||
network {{ get_ipv6_loopback_address(LOOPBACK_INTERFACE, "Loopback1") | ip }}/64 route-map HIDE_INTERNAL | ||
exit-address-family | ||
{% endif %} | ||
{% endif %} | ||
{% endblock bgp_init %} | ||
! | ||
{% block vlan_advertisement %} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,6 +251,15 @@ def parse_asic_png(png, asic_name, hostname): | |
devices[name] = device_data | ||
return (neighbors, devices, port_speeds) | ||
|
||
def parse_loopback_intf(child): | ||
lointfs = child.find(str(QName(ns, "LoopbackIPInterfaces"))) | ||
lo_intfs = {} | ||
for lointf in lointfs.findall(str(QName(ns1, "LoopbackIPInterface"))): | ||
intfname = lointf.find(str(QName(ns, "AttachTo"))).text | ||
ipprefix = lointf.find(str(QName(ns1, "PrefixStr"))).text | ||
lo_intfs[(intfname, ipprefix)] = {} | ||
return lo_intfs | ||
|
||
def parse_dpg(dpg, hname): | ||
aclintfs = None | ||
mgmtintfs = None | ||
|
@@ -269,7 +278,6 @@ def parse_dpg(dpg, hname): | |
""" | ||
if mgmtintfs is None and child.find(str(QName(ns, "ManagementIPInterfaces"))) is not None: | ||
mgmtintfs = child.find(str(QName(ns, "ManagementIPInterfaces"))) | ||
|
||
hostname = child.find(str(QName(ns, "Hostname"))) | ||
if hostname.text.lower() != hname.lower(): | ||
continue | ||
|
@@ -290,12 +298,7 @@ def parse_dpg(dpg, hname): | |
ipprefix = ipintf.find(str(QName(ns, "Prefix"))).text | ||
intfs[(intfname, ipprefix)] = {} | ||
|
||
lointfs = child.find(str(QName(ns, "LoopbackIPInterfaces"))) | ||
lo_intfs = {} | ||
for lointf in lointfs.findall(str(QName(ns1, "LoopbackIPInterface"))): | ||
intfname = lointf.find(str(QName(ns, "AttachTo"))).text | ||
ipprefix = lointf.find(str(QName(ns1, "PrefixStr"))).text | ||
lo_intfs[(intfname, ipprefix)] = {} | ||
lo_intfs = parse_loopback_intf(child) | ||
|
||
mvrfConfigs = child.find(str(QName(ns, "MgmtVrfConfigs"))) | ||
mvrf = {} | ||
|
@@ -445,6 +448,13 @@ def parse_dpg(dpg, hname): | |
return intfs, lo_intfs, mvrf, mgmt_intf, vlans, vlan_members, pcs, pc_members, acls, vni | ||
return None, None, None, None, None, None, None, None, None, None | ||
|
||
def parse_host_loopback(dpg, hname): | ||
for child in dpg: | ||
hostname = child.find(str(QName(ns, "Hostname"))) | ||
if hostname.text.lower() != hname.lower(): | ||
continue | ||
lo_intfs = parse_loopback_intf(child) | ||
return lo_intfs | ||
|
||
def parse_cpg(cpg, hname): | ||
bgp_sessions = {} | ||
|
@@ -818,6 +828,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None): | |
cloudtype = None | ||
hostname = None | ||
linkmetas = {} | ||
host_lo_intfs = None | ||
|
||
# hostname is the asic_name, get the asic_id from the asic_name | ||
if asic_name is not None: | ||
|
@@ -859,6 +870,7 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None): | |
else: | ||
if child.tag == str(QName(ns, "DpgDec")): | ||
(intfs, lo_intfs, mvrf, mgmt_intf, vlans, vlan_members, pcs, pc_members, acls, vni) = parse_dpg(child, asic_name) | ||
host_lo_intfs = parse_host_loopback(child, hostname) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I get this change. As far as minigraph is concerned, it is yet another loopback interface, correct? Why do we need to have a special parsing for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In the multi ASIC minigraph, each ASIC is modeled as different device. The Loopback0 interface is in the DeviceDataPlaneInfo of the device or host, while the Loopback4096 is in the DeviceDataPlaneInfo of the ASIC. Here we are trying to get Loopback0 interface when generating the configuration of the ASIC. |
||
elif child.tag == str(QName(ns, "CpgDec")): | ||
(bgp_sessions, bgp_asn, bgp_peers_with_range, bgp_monitors) = parse_cpg(child, asic_name) | ||
enable_internal_bgp_session(bgp_sessions, filename, asic_name) | ||
|
@@ -922,6 +934,12 @@ def parse_xml(filename, platform=None, port_config_file=None, asic_name=None): | |
for lo_intf in lo_intfs: | ||
results['LOOPBACK_INTERFACE'][lo_intf] = lo_intfs[lo_intf] | ||
results['LOOPBACK_INTERFACE'][lo_intf[0]] = {} | ||
|
||
if host_lo_intfs is not None: | ||
for host_lo_intf in host_lo_intfs: | ||
results['LOOPBACK_INTERFACE'][host_lo_intf] = host_lo_intfs[host_lo_intf] | ||
results['LOOPBACK_INTERFACE'][host_lo_intf[0]] = {} | ||
|
||
results['MGMT_VRF_CONFIG'] = mvrf | ||
|
||
phyport_intfs = {} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are currently discussions on adding multiple loopback interfaces to Sonic and if there is a regular "Loopback1", say got added from previous config_db etc, it could result in some conflicts. My suggestion is, can we have it renamed to something specific?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prsunny , changed from Loopback1 to Loopback4096 for ASIC's loopback interface