Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[subnet_decap] Use new tunnel&&decap term db schema and add subnet decap tunnel to ipinip.json #18752

Merged
merged 5 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 62 additions & 3 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,10 +52,24 @@
{% 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",
"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",
Expand All @@ -60,14 +80,40 @@
},
"OP": "SET"
}
{%- if ipv4_addresses -%}
,
{% endif %}
{% 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 %} ,
{% if ipv4_loopback_addresses and ipv6_loopback_addresses %},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ipv4_loopback_addresses needs to be checked here?

Copy link
Contributor Author

@lolyu lolyu May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me list out all possible conditions:
if ipv4_loopback_addresses is empty, ipv6_loopback_addresses is empty: no tunnel && decap terms will be created, no need to add ,.
if ipv4_loopback_addresses is not empty, ipv6_loopback_addresses is empty: only IPv4 tunnel && decap terms will be created, no need to add ,.
if ipv4_loopback_addresses is empty, ipv6_loopback_addresses is not empty: only IPv6 tunnel && decap terms will be created, no need to add ,.
if ipv4_loopback_addresses is not empty, ipv6_loopback_addresses is not empty: both IPv4&&IPv6 tunnel && decap terms will be created, , will be added to inter-connect those two parts.

{% 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",
"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",
Expand All @@ -77,8 +123,21 @@
"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 %}

]
{% endif %}

53 changes: 49 additions & 4 deletions src/sonic-config-engine/tests/multi_npu_data/py2/ipinip.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
53 changes: 49 additions & 4 deletions src/sonic-config-engine/tests/multi_npu_data/py3/ipinip.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
89 changes: 85 additions & 4 deletions src/sonic-config-engine/tests/sample_output/py2/ipinip.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
Loading
Loading