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

[ipinip config] Add v6 ip and peering ip besides currect v4 loopback #2145

Merged
merged 3 commits into from
Oct 15, 2018
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
57 changes: 55 additions & 2 deletions dockers/docker-orchagent/ipinip.json.j2
Original file line number Diff line number Diff line change
@@ -1,16 +1,68 @@
{# only IPv4 decapsulation is supported #}
{% set ipv4_addresses = [] %}
{% set ipv6_addresses = [] %}
{% set ipv4_loopback_addresses = [] %}
{% set ipv6_loopback_addresses = [] %}
{% for (name, prefix) in LOOPBACK_INTERFACE %}
{%- if prefix | ipv4 and name == 'Loopback0' %}
{%- set ipv4_addresses = ipv4_addresses.append(prefix) %}
{%- set ipv4_loopback_addresses = ipv4_loopback_addresses.append(prefix) %}
{%- endif %}
{%- if prefix | ipv6 and name == 'Loopback0' %}
{%- set ipv6_addresses = ipv6_addresses.append(prefix) %}
{%- set ipv6_loopback_addresses = ipv6_loopback_addresses.append(prefix) %}
{%- endif %}
{% endfor %}
{% for (name, prefix) in INTERFACE %}
{%- if prefix | ipv4 %}
{%- set ipv4_addresses = ipv4_addresses.append(prefix) %}
{%- endif %}
{%- if prefix | ipv6 %}
{%- set ipv6_addresses = ipv6_addresses.append(prefix) %}
{%- endif %}
{% endfor %}
{% for (name, prefix) in PORTCHANNEL_INTERFACE %}
{%- if prefix | ipv4 %}
{%- set ipv4_addresses = ipv4_addresses.append(prefix) %}
{%- endif %}
{%- if prefix | ipv6 %}
{%- set ipv6_addresses = ipv6_addresses.append(prefix) %}
{%- endif %}
{% endfor %}
{% for (name, prefix) in VLAN_INTERFACE %}
{%- if prefix | ipv4 %}
{%- set ipv4_addresses = ipv4_addresses.append(prefix) %}
{%- endif %}
{%- if prefix | ipv6 %}
{%- set ipv6_addresses = ipv6_addresses.append(prefix) %}
{%- endif %}
{% endfor %}
[
{% if ipv4_loopback_addresses %}
{
"TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : {
"tunnel_type":"IPINIP",
"src_ip":"{{ ipv4_loopback_addresses | first | ip }}",
"dst_ip":"{% for prefix in ipv4_loopback_addresses %}{{ prefix | ip }}{% if not loop.last %},{% endif %}{% endfor %}",
"dst_ip":"{% for prefix in ipv4_addresses %}{{ prefix | ip }}{% if not loop.last %},{% endif %}{% endfor %}",
{% if "mlnx" in DEVICE_METADATA.localhost.platform %}
"dscp_mode":"uniform",
"ecn_mode":"standard",
{% else %}
"dscp_mode":"pipe",
"ecn_mode":"copy_from_outer",
{% endif %}
"ttl_mode":"pipe"
},
"OP": "SET"
}
{% endif %}
{% if ipv4_loopback_addresses and ipv6_loopback_addresses %} ,
Copy link
Contributor

@prsunny prsunny Oct 12, 2018

Choose a reason for hiding this comment

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

Why do we need this check? #Resolved

Copy link
Contributor Author

@taoyl-ms taoyl-ms Oct 13, 2018

Choose a reason for hiding this comment

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

Because the comma is only needed when both v4 and v6 tunnel needs to be constructed. #Closed

{% endif %}
{% if ipv6_loopback_addresses %}
{
"TUNNEL_DECAP_TABLE:IPINIP_V6_TUNNEL" : {
"tunnel_type":"IPINIP",
"src_ip":"{{ ipv6_loopback_addresses | first | ip }}",
"dst_ip":"{% for prefix in ipv6_addresses %}{{ prefix | ip }}{% if not loop.last %},{% endif %}{% endfor %}",
{% if "mlnx" in DEVICE_METADATA.localhost.platform %}
"dscp_mode":"uniform",
"ecn_mode":"standard",
Expand All @@ -22,4 +74,5 @@
},
"OP": "SET"
}
{% endif %}
]
14 changes: 13 additions & 1 deletion src/sonic-config-engine/tests/sample_output/ipinip.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@
"TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : {
"tunnel_type":"IPINIP",
"src_ip":"10.1.0.32",
"dst_ip":"10.1.0.32",
"dst_ip":"10.1.0.32,10.0.0.56,10.0.0.58,10.0.0.60,10.0.0.62,192.168.0.1",
"dscp_mode":"pipe",
"ecn_mode":"copy_from_outer",
"ttl_mode":"pipe"
},
"OP": "SET"
}
,
{
"TUNNEL_DECAP_TABLE:IPINIP_V6_TUNNEL" : {
"tunnel_type":"IPINIP",
"src_ip":"fc00:1::32",
"dst_ip":"fc00:1::32,fc00::71,fc00::75,fc00::79,fc00::7d",
"dscp_mode":"pipe",
"ecn_mode":"copy_from_outer",
"ttl_mode":"pipe"
Expand Down