-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 all commits
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 |
---|---|---|
|
@@ -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.
@pavel-shirshov , do we need to add this in the bgpcfgd unit test?
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.
@lguohan yes. when it is ready.
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.
are we advertising this loopback 4096 to the outside world?
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.
@lguohan, the route-map HIDE_INTERNAL will prevent advertising Loopback4096 to the external devices.