-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathipinip.json.j2
165 lines (163 loc) · 4.94 KB
/
ipinip.json.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
{% if DEVICE_METADATA['localhost']['switch_type'] == "dpu" %}
[]
{% 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'%}
{% set loopback_intf_names = ['Loopback0', 'Loopback4096'] %}
{% else %}
{% set loopback_intf_names = ['Loopback0', 'Loopback2', 'Loopback3'] %}
{% endif %}
{% for (name, prefix) in LOOPBACK_INTERFACE|pfx_filter %}
{%- if prefix | ipv4 and name in loopback_intf_names %}
{%- set ipv4_addresses = ipv4_addresses.append(prefix) %}
{%- set ipv4_loopback_addresses = ipv4_loopback_addresses.append(prefix) %}
{%- endif %}
{%- if prefix | ipv6 and name in loopback_intf_names %}
{%- set ipv6_addresses = ipv6_addresses.append(prefix) %}
{%- 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) %}
{%- endif %}
{%- if prefix | ipv6 %}
{%- set ipv6_addresses = ipv6_addresses.append(prefix) %}
{%- endif %}
{% endfor %}
{% for (name, prefix) in PORTCHANNEL_INTERFACE|pfx_filter %}
{%- 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|pfx_filter %}
{%- if prefix | ipv4 %}
{%- set ipv4_vlan_addresses = ipv4_vlan_addresses.append(prefix) %}
{%- endif %}
{%- if prefix | ipv6 %}
{%- 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 %}
{
"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"
},
{% 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" : {
"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"
}
{%- 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 %},
{% 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"
},
{% 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" : {
"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"
}{% 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 %}