From 1f071563701ee24a95b21327785bb6b3cf08bca4 Mon Sep 17 00:00:00 2001 From: Shu0T1an ChenG Date: Thu, 28 Sep 2017 16:39:55 -0700 Subject: [PATCH] [swss]: Update the ipinip.j2 template to specify the IPv4 loopback address Use ipv4_loopback_addresses variable to store all IPv4 loopback addresses. The source IP for encapsulation is chosen from one of the addresses. The destination IPs for decapsulation is the list of the addresses. Signed-off-by: Shu0T1an ChenG --- dockers/docker-orchagent/ipinip.json.j2 | 12 +++++++++--- .../tests/sample_output/ipinip.json | 1 - 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dockers/docker-orchagent/ipinip.json.j2 b/dockers/docker-orchagent/ipinip.json.j2 index 2f411b088e6d..2554755c701d 100644 --- a/dockers/docker-orchagent/ipinip.json.j2 +++ b/dockers/docker-orchagent/ipinip.json.j2 @@ -1,9 +1,16 @@ +{# only IPv4 decapsulation is supported #} +{% set ipv4_loopback_addresses = [] %} +{% for (name, prefix) in LOOPBACK_INTERFACE %} + {%- if prefix | ipv4 %} + {%- set ipv4_loopback_addresses = ipv4_loopback_addresses.append(prefix) %} + {%- endif %} +{% endfor %} [ { "TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : { "tunnel_type":"IPINIP", - "src_ip":"{{ LOOPBACK_INTERFACE.keys()[0][1] | ip }}", - "dst_ip":"{{ LOOPBACK_INTERFACE.keys()[0][1] | ip }}", + "src_ip":"{{ ipv4_loopback_addresses | first | ip }}", + "dst_ip":"{% for prefix in ipv4_loopback_addresses %}{{ prefix | ip }}{% if not loop.last %},{% endif %}{% endfor %}", {% if onie_switch_asic == "mlnx" %} "dscp_mode":"uniform", "ecn_mode":"standard", @@ -16,4 +23,3 @@ "OP": "SET" } ] - diff --git a/src/sonic-config-engine/tests/sample_output/ipinip.json b/src/sonic-config-engine/tests/sample_output/ipinip.json index 00862a379281..5a7ac1b6063b 100644 --- a/src/sonic-config-engine/tests/sample_output/ipinip.json +++ b/src/sonic-config-engine/tests/sample_output/ipinip.json @@ -11,4 +11,3 @@ "OP": "SET" } ] -