From 702dd4e29189c40dd0dd130a644fc67997e70802 Mon Sep 17 00:00:00 2001 From: Longxiang Lyu <35479537+lolyu@users.noreply.github.com> Date: Fri, 13 Sep 2024 00:43:19 +0800 Subject: [PATCH] [subnet decap] Fix VLAN prefix decap term (#19229) Why I did it If subnet decap is enabled on T0, the subnet decap term should be created for VLAN prefixes. Work item tracking Microsoft ADO (number only): 28316828 How I did it For VLAN prefixes, if subnet decap is enabled, created MP2MP decap terms with subnet type vlan and under the subnet decap tunnels. Signed-off-by: Longxiang Lyu --- dockers/docker-orchagent/ipinip.json.j2 | 26 +++++++++++++++++-- .../py2/ipinip_subnet_decap_enable.json | 14 ++++++++++ .../py3/ipinip_subnet_decap_enable.json | 14 ++++++++++ 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/dockers/docker-orchagent/ipinip.json.j2 b/dockers/docker-orchagent/ipinip.json.j2 index f25f7d9fb695..478a19a8fe2b 100644 --- a/dockers/docker-orchagent/ipinip.json.j2 +++ b/dockers/docker-orchagent/ipinip.json.j2 @@ -3,6 +3,8 @@ {% else %} {% set ipv4_addresses = [] %} {% set ipv6_addresses = [] %} +{% set ipv4_vlan_addresses = [] %} +{% set ipv6_vlan_addresses = [] %} {% set ipv4_loopback_addresses = [] %} {% set ipv6_loopback_addresses = [] %} {% if DEVICE_METADATA['localhost']['sub_role'] == 'FrontEnd' or DEVICE_METADATA['localhost']['sub_role'] == 'BackEnd'%} @@ -44,12 +46,14 @@ {% endfor %} {% for (name, prefix) in VLAN_INTERFACE|pfx_filter %} {%- if prefix | ipv4 %} - {%- set ipv4_addresses = ipv4_addresses.append(prefix) %} + {%- set ipv4_vlan_addresses = ipv4_vlan_addresses.append(prefix) %} {%- endif %} {%- if prefix | ipv6 %} - {%- set ipv6_addresses = ipv6_addresses.append(prefix) %} + {%- set ipv6_vlan_addresses = ipv6_vlan_addresses.append(prefix) %} {%- endif %} {% endfor %} +{%- set ipv4_addresses = ipv4_addresses + ipv4_vlan_addresses %} +{%- set ipv6_addresses = ipv6_addresses + ipv6_vlan_addresses %} [ {% if ipv4_loopback_addresses %} {% if subnet_decap.enable %} @@ -66,6 +70,15 @@ }, "OP": "SET" }, +{% for prefix in ipv4_vlan_addresses|sort %} + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_SUBNET:{{ prefix | network }}/{{ prefix | prefixlen }}" : { + "term_type":"MP2MP", + "subnet_type": "vlan" + }, + "OP": "SET" + }, +{% endfor %} {% endif %} { "TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : { @@ -110,6 +123,15 @@ }, "OP": "SET" }, +{% for prefix in ipv6_vlan_addresses|sort %} + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_SUBNET_V6:{{ prefix | network }}/{{ prefix | prefixlen }}" : { + "term_type":"MP2MP", + "subnet_type": "vlan" + }, + "OP": "SET" + }, +{% endfor %} {% endif %} { "TUNNEL_DECAP_TABLE:IPINIP_V6_TUNNEL" : { diff --git a/src/sonic-config-engine/tests/sample_output/py2/ipinip_subnet_decap_enable.json b/src/sonic-config-engine/tests/sample_output/py2/ipinip_subnet_decap_enable.json index ad978b8865a7..abcfa56eaea9 100644 --- a/src/sonic-config-engine/tests/sample_output/py2/ipinip_subnet_decap_enable.json +++ b/src/sonic-config-engine/tests/sample_output/py2/ipinip_subnet_decap_enable.json @@ -8,6 +8,20 @@ }, "OP": "SET" }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_SUBNET:192.168.0.0/27" : { + "term_type":"MP2MP", + "subnet_type": "vlan" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_SUBNET:192.168.200.0/27" : { + "term_type":"MP2MP", + "subnet_type": "vlan" + }, + "OP": "SET" + }, { "TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : { "tunnel_type":"IPINIP", diff --git a/src/sonic-config-engine/tests/sample_output/py3/ipinip_subnet_decap_enable.json b/src/sonic-config-engine/tests/sample_output/py3/ipinip_subnet_decap_enable.json index ad978b8865a7..abcfa56eaea9 100644 --- a/src/sonic-config-engine/tests/sample_output/py3/ipinip_subnet_decap_enable.json +++ b/src/sonic-config-engine/tests/sample_output/py3/ipinip_subnet_decap_enable.json @@ -8,6 +8,20 @@ }, "OP": "SET" }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_SUBNET:192.168.0.0/27" : { + "term_type":"MP2MP", + "subnet_type": "vlan" + }, + "OP": "SET" + }, + { + "TUNNEL_DECAP_TERM_TABLE:IPINIP_SUBNET:192.168.200.0/27" : { + "term_type":"MP2MP", + "subnet_type": "vlan" + }, + "OP": "SET" + }, { "TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : { "tunnel_type":"IPINIP",