Skip to content

Commit

Permalink
Add subnet decap tunnels
Browse files Browse the repository at this point in the history
Signed-off-by: Longxiang Lyu <lolv@microsoft.com>
  • Loading branch information
lolyu committed May 31, 2024
1 parent d3cb0f2 commit bc80a53
Show file tree
Hide file tree
Showing 4 changed files with 295 additions and 2 deletions.
44 changes: 42 additions & 2 deletions dockers/docker-orchagent/ipinip.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
{%- set ipv6_loopback_addresses = ipv6_loopback_addresses.append(prefix) %}
{%- endif %}
{% endfor %}
{% set subnet_decap = namespace(enable=false) %}
{% for config in SUBNET_DECAP %}
{%- if SUBNET_DECAP[config].status == 'enable' %}
{%- set subnet_decap.enable = true %}
{%- endif %}
{% endfor %}
{% for (name, prefix) in INTERFACE|pfx_filter %}
{%- if prefix | ipv4 %}
{%- set ipv4_addresses = ipv4_addresses.append(prefix) %}
Expand All @@ -46,6 +52,21 @@
{% endfor %}
[
{% if ipv4_loopback_addresses %}
{% if subnet_decap.enable %}
{
"TUNNEL_DECAP_TABLE:IPINIP_SUBNET" : {
"tunnel_type":"IPINIP",
"dscp_mode":"uniform",
{% if "mlnx" in DEVICE_METADATA.localhost.platform %}
"ecn_mode":"standard",
{% else %}
"ecn_mode":"copy_from_outer",
{% endif %}
"ttl_mode":"pipe"
},
"OP": "SET"
},
{% endif %}
{
"TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : {
"tunnel_type":"IPINIP",
Expand All @@ -58,7 +79,9 @@
"ttl_mode":"pipe"
},
"OP": "SET"
}{% if ipv4_addresses %},
}
{%- if ipv4_addresses -%}
,
{% endif %}
{% for prefix in ipv4_addresses|sort %}
{
Expand All @@ -73,6 +96,21 @@
{% if ipv4_loopback_addresses and ipv6_loopback_addresses %},
{% endif %}
{% if ipv6_loopback_addresses %}
{% if subnet_decap.enable %}
{
"TUNNEL_DECAP_TABLE:IPINIP_SUBNET_V6" : {
"tunnel_type":"IPINIP",
"dscp_mode":"uniform",
{% if "mlnx" in DEVICE_METADATA.localhost.platform %}
"ecn_mode":"standard",
{% else %}
"ecn_mode":"copy_from_outer",
{% endif %}
"ttl_mode":"pipe"
},
"OP": "SET"
},
{% endif %}
{
"TUNNEL_DECAP_TABLE:IPINIP_V6_TUNNEL" : {
"tunnel_type":"IPINIP",
Expand All @@ -93,7 +131,9 @@
"term_type":"P2MP"
},
"OP": "SET"
}{% if not loop.last %},
}
{%- if not loop.last -%}
,
{% endif %}
{% endfor %}
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
[
{
"TUNNEL_DECAP_TABLE:IPINIP_SUBNET" : {
"tunnel_type":"IPINIP",
"dscp_mode":"uniform",
"ecn_mode":"copy_from_outer",
"ttl_mode":"pipe"
},
"OP": "SET"
},
{
"TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : {
"tunnel_type":"IPINIP",
"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_SUBNET_V6" : {
"tunnel_type":"IPINIP",
"dscp_mode":"uniform",
"ecn_mode":"copy_from_outer",
"ttl_mode":"pipe"
},
"OP": "SET"
},
{
"TUNNEL_DECAP_TABLE:IPINIP_V6_TUNNEL" : {
"tunnel_type":"IPINIP",
"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"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
[
{
"TUNNEL_DECAP_TABLE:IPINIP_SUBNET" : {
"tunnel_type":"IPINIP",
"dscp_mode":"uniform",
"ecn_mode":"copy_from_outer",
"ttl_mode":"pipe"
},
"OP": "SET"
},
{
"TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : {
"tunnel_type":"IPINIP",
"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_SUBNET_V6" : {
"tunnel_type":"IPINIP",
"dscp_mode":"uniform",
"ecn_mode":"copy_from_outer",
"ttl_mode":"pipe"
},
"OP": "SET"
},
{
"TUNNEL_DECAP_TABLE:IPINIP_V6_TUNNEL" : {
"tunnel_type":"IPINIP",
"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"
}
]
9 changes: 9 additions & 0 deletions src/sonic-config-engine/tests/test_j2files.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,15 @@ def test_ipinip(self):
sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'ipinip.json')
assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)

def test_ipinip_subnet_decap_enable(self):
ipinip_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent', 'ipinip.json.j2')
extra_data = {"SUBNET_DECAP": {"AZURE": {"status": "enable"}}}
argument = ['-m', self.t0_minigraph, '-p', self.t0_port_config, '-a', json.dumps(extra_data), '-t', ipinip_file]
self.run_script(argument, output_file=self.output_file)

sample_output_file = os.path.join(self.test_dir, 'sample_output', utils.PYvX_DIR, 'ipinip_subnet_decap_enable.json')
assert utils.cmp(sample_output_file, self.output_file), self.run_diff(sample_output_file, self.output_file)

def test_l2switch_template(self):
argument = ['-k', 'Mellanox-SN2700', '--preset', 'l2', '-p', self.t0_port_config]
output = self.run_script(argument)
Expand Down

0 comments on commit bc80a53

Please sign in to comment.