Skip to content

Commit

Permalink
[Multi-ASIC]:Update the template to add ipinip entry for Loopback4096 (
Browse files Browse the repository at this point in the history
…#5235)

Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <[email protected]>
The following changes are done. 
- Multi asic platform have 2 Loopback interfaces, Loopback0 and Loopback4096. IPinIP decap entries need to be added for both of them. Update the ipinip.json.j2 template to add decap entries for Loopback4096.
- Add corressponding unit test
  • Loading branch information
arlakshm authored Sep 1, 2020
1 parent 8793814 commit 17e7871
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
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'] %}
{% 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

0 comments on commit 17e7871

Please sign in to comment.