Skip to content
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

[Multi-ASIC]:Update the template to add ipinip entry for Loopback4096 #5235

Merged
merged 2 commits into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions dockers/docker-orchagent/ipinip.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
{% set ipv6_addresses = [] %}
{% set ipv4_loopback_addresses = [] %}
{% set ipv6_loopback_addresses = [] %}
{% if DEVICE_METADATA['localhost']['sub_role'] == 'FrontEnd' or DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd'%}
{% set loopback_intf_names = ['Loopback0', 'Loopback4096'] %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this interface should be in if multi_asic() case right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add check to to add Loopback4096 is the device is either Frontend or Backend asic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor suggestion.. we can have it as below in case if we plan to add more loopbacks in future

set loopback_intf_names = ['Loopback0']
if FrontEnd or BackEnd
set loopback_intf_names = loopback_intf_names.append('Loopback4096')

{% else %}
{% set loopback_intf_names = ['Loopback0'] %}
{% endif %}
{% for (name, prefix) in LOOPBACK_INTERFACE|pfx_filter %}
{%- if prefix | ipv4 and name == 'Loopback0' %}
{%- if prefix | ipv4 and name in loopback_intf_names %}
{%- set ipv4_addresses = ipv4_addresses.append(prefix) %}
{%- set ipv4_loopback_addresses = ipv4_loopback_addresses.append(prefix) %}
{%- endif %}
{%- if prefix | ipv6 and name == 'Loopback0' %}
{%- if prefix | ipv6 and name in loopback_intf_names %}
{%- set ipv6_addresses = ipv6_addresses.append(prefix) %}
{%- set ipv6_loopback_addresses = ipv6_loopback_addresses.append(prefix) %}
{%- endif %}
Expand Down
23 changes: 23 additions & 0 deletions src/sonic-config-engine/tests/multi_npu_data/ipinip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[
{
"TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : {
"tunnel_type":"IPINIP",
"dst_ip":"10.1.0.32,8.0.0.0,10.0.0.0,10.1.0.1,10.1.0.3",
"dscp_mode":"pipe",
"ecn_mode":"copy_from_outer",
"ttl_mode":"pipe"
},
"OP": "SET"
}
,
{
"TUNNEL_DECAP_TABLE:IPINIP_V6_TUNNEL" : {
"tunnel_type":"IPINIP",
"dst_ip":"fc00:1::32,fd00:1::32,fc00::1",
"dscp_mode":"pipe",
"ecn_mode":"copy_from_outer",
"ttl_mode":"pipe"
},
"OP": "SET"
}
]
10 changes: 10 additions & 0 deletions src/sonic-config-engine/tests/test_j2files.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def setUp(self):
self.mlnx_port_config = os.path.join(self.test_dir, 'sample-port-config-mlnx.ini')
self.dell6100_t0_minigraph = os.path.join(self.test_dir, 'sample-dell-6100-t0-minigraph.xml')
self.arista7050_t0_minigraph = os.path.join(self.test_dir, 'sample-arista-7050-t0-minigraph.xml')
self.multi_asic_minigraph = os.path.join(self.test_dir, 'multi_npu_data', 'sample-minigraph.xml')
self.multi_asic_port_config = os.path.join(self.test_dir, 'multi_npu_data', 'sample_port_config-0.ini')
self.output_file = os.path.join(self.test_dir, 'output')

def run_script(self, argument):
Expand Down Expand Up @@ -151,6 +153,14 @@ def test_buffers_dell6100_render_template(self):
sample_output_file = os.path.join(self.test_dir, 'sample_output', 'buffers-dell6100.json')
assert filecmp.cmp(sample_output_file, self.output_file)

def test_ipinip_multi_asic(self):
ipinip_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent', 'ipinip.json.j2')
argument = '-m ' + self.multi_asic_minigraph + ' -p ' + self.multi_asic_port_config + ' -t ' + ipinip_file + ' -n asic0 ' + ' > ' + self.output_file
print(argument)
self.run_script(argument)
sample_output_file = os.path.join(self.test_dir, 'multi_npu_data', 'ipinip.json')
assert filecmp.cmp(sample_output_file, self.output_file)

def tearDown(self):
try:
os.remove(self.output_file)
Expand Down