Skip to content

Commit 17e7871

Browse files
authored
[Multi-ASIC]:Update the template to add ipinip entry for Loopback4096 (#5235)
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com> 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
1 parent 8793814 commit 17e7871

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

dockers/docker-orchagent/ipinip.json.j2

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
{% set ipv6_addresses = [] %}
33
{% set ipv4_loopback_addresses = [] %}
44
{% set ipv6_loopback_addresses = [] %}
5+
{% if DEVICE_METADATA['localhost']['sub_role'] == 'FrontEnd' or DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd'%}
6+
{% set loopback_intf_names = ['Loopback0', 'Loopback4096'] %}
7+
{% else %}
8+
{% set loopback_intf_names = ['Loopback0'] %}
9+
{% endif %}
510
{% for (name, prefix) in LOOPBACK_INTERFACE|pfx_filter %}
6-
{%- if prefix | ipv4 and name == 'Loopback0' %}
11+
{%- if prefix | ipv4 and name in loopback_intf_names %}
712
{%- set ipv4_addresses = ipv4_addresses.append(prefix) %}
813
{%- set ipv4_loopback_addresses = ipv4_loopback_addresses.append(prefix) %}
914
{%- endif %}
10-
{%- if prefix | ipv6 and name == 'Loopback0' %}
15+
{%- if prefix | ipv6 and name in loopback_intf_names %}
1116
{%- set ipv6_addresses = ipv6_addresses.append(prefix) %}
1217
{%- set ipv6_loopback_addresses = ipv6_loopback_addresses.append(prefix) %}
1318
{%- endif %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[
2+
{
3+
"TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : {
4+
"tunnel_type":"IPINIP",
5+
"dst_ip":"10.1.0.32,8.0.0.0,10.0.0.0,10.1.0.1,10.1.0.3",
6+
"dscp_mode":"pipe",
7+
"ecn_mode":"copy_from_outer",
8+
"ttl_mode":"pipe"
9+
},
10+
"OP": "SET"
11+
}
12+
,
13+
{
14+
"TUNNEL_DECAP_TABLE:IPINIP_V6_TUNNEL" : {
15+
"tunnel_type":"IPINIP",
16+
"dst_ip":"fc00:1::32,fd00:1::32,fc00::1",
17+
"dscp_mode":"pipe",
18+
"ecn_mode":"copy_from_outer",
19+
"ttl_mode":"pipe"
20+
},
21+
"OP": "SET"
22+
}
23+
]

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

+10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def setUp(self):
1919
self.mlnx_port_config = os.path.join(self.test_dir, 'sample-port-config-mlnx.ini')
2020
self.dell6100_t0_minigraph = os.path.join(self.test_dir, 'sample-dell-6100-t0-minigraph.xml')
2121
self.arista7050_t0_minigraph = os.path.join(self.test_dir, 'sample-arista-7050-t0-minigraph.xml')
22+
self.multi_asic_minigraph = os.path.join(self.test_dir, 'multi_npu_data', 'sample-minigraph.xml')
23+
self.multi_asic_port_config = os.path.join(self.test_dir, 'multi_npu_data', 'sample_port_config-0.ini')
2224
self.output_file = os.path.join(self.test_dir, 'output')
2325

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

156+
def test_ipinip_multi_asic(self):
157+
ipinip_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent', 'ipinip.json.j2')
158+
argument = '-m ' + self.multi_asic_minigraph + ' -p ' + self.multi_asic_port_config + ' -t ' + ipinip_file + ' -n asic0 ' + ' > ' + self.output_file
159+
print(argument)
160+
self.run_script(argument)
161+
sample_output_file = os.path.join(self.test_dir, 'multi_npu_data', 'ipinip.json')
162+
assert filecmp.cmp(sample_output_file, self.output_file)
163+
154164
def tearDown(self):
155165
try:
156166
os.remove(self.output_file)

0 commit comments

Comments
 (0)