From 2e22e186fc873c4a35fd11f4cb758c0743c09fb5 Mon Sep 17 00:00:00 2001 From: Longxiang Lyu Date: Tue, 23 Apr 2024 03:31:22 +0000 Subject: [PATCH] [decap] Enhance `ipinip.json.j2` template to use new db schema Signed-off-by: Longxiang Lyu --- dockers/docker-orchagent/ipinip.json.j2 | 29 ++++-- .../tests/multi_npu_data/py2/ipinip.json | 53 ++++++++++- .../tests/multi_npu_data/py3/ipinip.json | 53 ++++++++++- .../multi_npu_data/sample_port_config-0.ini | 1 + .../tests/sample_output/py2/ipinip.json | 89 ++++++++++++++++++- .../tests/sample_output/py3/ipinip.json | 89 ++++++++++++++++++- 6 files changed, 293 insertions(+), 21 deletions(-) diff --git a/dockers/docker-orchagent/ipinip.json.j2 b/dockers/docker-orchagent/ipinip.json.j2 index 9cdf6857bddd..2c9c12947367 100644 --- a/dockers/docker-orchagent/ipinip.json.j2 +++ b/dockers/docker-orchagent/ipinip.json.j2 @@ -46,7 +46,6 @@ { "TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : { "tunnel_type":"IPINIP", - "dst_ip":"{% for prefix in ipv4_addresses|sort %}{{ prefix | ip }}{% if not loop.last %},{% endif %}{% endfor %}", "dscp_mode":"uniform", {% if "mlnx" in DEVICE_METADATA.localhost.platform %} "ecn_mode":"standard", @@ -56,15 +55,24 @@ "ttl_mode":"pipe" }, "OP": "SET" - } + }{% if ipv4_addresses %}, {% endif %} -{% if ipv4_loopback_addresses and ipv6_loopback_addresses %} , +{% for prefix in ipv4_addresses|sort %} + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:{{ prefix | ip }}" : { + "term_type":"P2MP" + }, + "OP": "SET" + }{% if not loop.last %}, +{% endif %} +{% endfor %} +{% endif %} +{% if ipv4_loopback_addresses and ipv6_loopback_addresses %}, {% endif %} {% if ipv6_loopback_addresses %} { "TUNNEL_DECAP_TABLE:IPINIP_V6_TUNNEL" : { "tunnel_type":"IPINIP", - "dst_ip":"{% for prefix in ipv6_addresses|sort %}{{ prefix | ip }}{% if not loop.last %},{% endif %}{% endfor %}", "dscp_mode":"uniform", {% if "mlnx" in DEVICE_METADATA.localhost.platform %} "ecn_mode":"standard", @@ -74,6 +82,17 @@ "ttl_mode":"pipe" }, "OP": "SET" - } + }{% if ipv6_addresses %}, +{% endif %} +{% for prefix in ipv6_addresses|sort %} + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_V6_TUNNEL:{{ prefix | ip }}" : { + "term_type":"P2MP" + }, + "OP": "SET" + }{% if not loop.last %}, +{% endif %} +{% endfor %} {% endif %} + ] diff --git a/src/sonic-config-engine/tests/multi_npu_data/py2/ipinip.json b/src/sonic-config-engine/tests/multi_npu_data/py2/ipinip.json index 82d583de6078..94196a0a4878 100644 --- a/src/sonic-config-engine/tests/multi_npu_data/py2/ipinip.json +++ b/src/sonic-config-engine/tests/multi_npu_data/py2/ipinip.json @@ -2,22 +2,67 @@ { "TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : { "tunnel_type":"IPINIP", - "dst_ip":"10.0.0.0,10.1.0.1,10.1.0.3,10.1.0.32,8.0.0.0", "dscp_mode":"uniform", "ecn_mode":"copy_from_outer", "ttl_mode":"pipe" }, "OP": "SET" - } - , + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.0.0.0" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.1.0.1" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.1.0.3" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.1.0.32" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:8.0.0.0" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, { "TUNNEL_DECAP_TABLE:IPINIP_V6_TUNNEL" : { "tunnel_type":"IPINIP", - "dst_ip":"fc00:1::32,fc00::1,fd00:1::32", "dscp_mode":"uniform", "ecn_mode":"copy_from_outer", "ttl_mode":"pipe" }, "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_V6_TUNNEL:fc00:1::32" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_V6_TUNNEL:fc00::1" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_V6_TUNNEL:fd00:1::32" : { + "term_type":"P2MP" + }, + "OP": "SET" } ] diff --git a/src/sonic-config-engine/tests/multi_npu_data/py3/ipinip.json b/src/sonic-config-engine/tests/multi_npu_data/py3/ipinip.json index 82d583de6078..94196a0a4878 100644 --- a/src/sonic-config-engine/tests/multi_npu_data/py3/ipinip.json +++ b/src/sonic-config-engine/tests/multi_npu_data/py3/ipinip.json @@ -2,22 +2,67 @@ { "TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : { "tunnel_type":"IPINIP", - "dst_ip":"10.0.0.0,10.1.0.1,10.1.0.3,10.1.0.32,8.0.0.0", "dscp_mode":"uniform", "ecn_mode":"copy_from_outer", "ttl_mode":"pipe" }, "OP": "SET" - } - , + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.0.0.0" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.1.0.1" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.1.0.3" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.1.0.32" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:8.0.0.0" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, { "TUNNEL_DECAP_TABLE:IPINIP_V6_TUNNEL" : { "tunnel_type":"IPINIP", - "dst_ip":"fc00:1::32,fc00::1,fd00:1::32", "dscp_mode":"uniform", "ecn_mode":"copy_from_outer", "ttl_mode":"pipe" }, "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_V6_TUNNEL:fc00:1::32" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_V6_TUNNEL:fc00::1" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_V6_TUNNEL:fd00:1::32" : { + "term_type":"P2MP" + }, + "OP": "SET" } ] diff --git a/src/sonic-config-engine/tests/multi_npu_data/sample_port_config-0.ini b/src/sonic-config-engine/tests/multi_npu_data/sample_port_config-0.ini index 2e932da6c1fc..f5064386c00a 100644 --- a/src/sonic-config-engine/tests/multi_npu_data/sample_port_config-0.ini +++ b/src/sonic-config-engine/tests/multi_npu_data/sample_port_config-0.ini @@ -3,6 +3,7 @@ Ethernet0 33,34,35,36 Ethernet1/1 0 Eth0-ASIC0 Ext Ethernet4 29,30,31,32 Ethernet1/2 1 Eth1-ASIC0 Ext Ethernet8 41,42,43,44 Ethernet1/3 2 Eth2-ASIC0 Ext Ethernet12 37,38,39,40 Ethernet1/4 3 Eth3-ASIC0 Ext + Ethernet-BP0 13,14,15,16 Eth4-ASIC0 0 Eth4-ASIC0 Int Ethernet-BP4 17,18,19,20 Eth5-ASIC0 1 Eth5-ASIC0 Int Ethernet-BP8 21,22,23,24 Eth6-ASIC0 2 Eth6-ASIC0 Int diff --git a/src/sonic-config-engine/tests/sample_output/py2/ipinip.json b/src/sonic-config-engine/tests/sample_output/py2/ipinip.json index 0a01058463bd..755e954cfb59 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/ipinip.json +++ b/src/sonic-config-engine/tests/sample_output/py2/ipinip.json @@ -2,22 +2,103 @@ { "TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : { "tunnel_type":"IPINIP", - "dst_ip":"10.0.0.56,10.0.0.58,10.0.0.60,10.0.0.62,10.1.0.32,10.21.0.64,10.21.64.2,192.168.0.1,192.168.200.1", "dscp_mode":"uniform", "ecn_mode":"copy_from_outer", "ttl_mode":"pipe" }, "OP": "SET" - } - , + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.0.0.56" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.0.0.58" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.0.0.60" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.0.0.62" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.1.0.32" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.21.0.64" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.21.64.2" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:192.168.0.1" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:192.168.200.1" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, { "TUNNEL_DECAP_TABLE:IPINIP_V6_TUNNEL" : { "tunnel_type":"IPINIP", - "dst_ip":"fc00:1::32,fc00::71,fc00::75,fc00::79,fc00::7d", "dscp_mode":"uniform", "ecn_mode":"copy_from_outer", "ttl_mode":"pipe" }, "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_V6_TUNNEL:fc00:1::32" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_V6_TUNNEL:fc00::71" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_V6_TUNNEL:fc00::75" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_V6_TUNNEL:fc00::79" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_V6_TUNNEL:fc00::7d" : { + "term_type":"P2MP" + }, + "OP": "SET" } ] diff --git a/src/sonic-config-engine/tests/sample_output/py3/ipinip.json b/src/sonic-config-engine/tests/sample_output/py3/ipinip.json index 0a01058463bd..755e954cfb59 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/ipinip.json +++ b/src/sonic-config-engine/tests/sample_output/py3/ipinip.json @@ -2,22 +2,103 @@ { "TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : { "tunnel_type":"IPINIP", - "dst_ip":"10.0.0.56,10.0.0.58,10.0.0.60,10.0.0.62,10.1.0.32,10.21.0.64,10.21.64.2,192.168.0.1,192.168.200.1", "dscp_mode":"uniform", "ecn_mode":"copy_from_outer", "ttl_mode":"pipe" }, "OP": "SET" - } - , + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.0.0.56" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.0.0.58" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.0.0.60" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.0.0.62" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.1.0.32" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.21.0.64" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:10.21.64.2" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:192.168.0.1" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_TUNNEL:192.168.200.1" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, { "TUNNEL_DECAP_TABLE:IPINIP_V6_TUNNEL" : { "tunnel_type":"IPINIP", - "dst_ip":"fc00:1::32,fc00::71,fc00::75,fc00::79,fc00::7d", "dscp_mode":"uniform", "ecn_mode":"copy_from_outer", "ttl_mode":"pipe" }, "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_V6_TUNNEL:fc00:1::32" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_V6_TUNNEL:fc00::71" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_V6_TUNNEL:fc00::75" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_V6_TUNNEL:fc00::79" : { + "term_type":"P2MP" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_V6_TUNNEL:fc00::7d" : { + "term_type":"P2MP" + }, + "OP": "SET" } ]