]> git.proxmox.com Git - mirror_frr.git/blob - yang/frr-route-map.yang
Merge pull request #6882 from vishaldhingra/static
[mirror_frr.git] / yang / frr-route-map.yang
1 module frr-route-map {
2 yang-version 1.1;
3 namespace "http://frrouting.org/yang/route-map";
4 prefix frr-route-map;
5
6 import ietf-inet-types {
7 prefix inet;
8 }
9
10 import frr-filter {
11 prefix filter;
12 }
13
14 import frr-interface {
15 prefix frr-interface;
16 }
17
18 organization
19 "FRRouting";
20 contact
21 "FRR Users List: <mailto:frog@lists.frrouting.org>
22 FRR Development List: <mailto:dev@lists.frrouting.org>";
23 description
24 "This module defines route map settings
25
26 Copyright 2020 FRRouting
27
28 Redistribution and use in source and binary forms, with or without
29 modification, are permitted provided that the following conditions
30 are met:
31
32 1. Redistributions of source code must retain the above copyright notice,
33 this list of conditions and the following disclaimer.
34
35 2. Redistributions in binary form must reproduce the above copyright
36 notice, this list of conditions and the following disclaimer in the
37 documentation and/or other materials provided with the distribution.
38
39 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
40 \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
41 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
42 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
43 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
45 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
46 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
47 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
48 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
49 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.";
50
51 revision 2019-07-01 {
52 description
53 "Initial revision";
54 }
55
56 /*
57 * Types.
58 */
59 typedef route-map-sequence {
60 type uint16 {
61 range "1..65535";
62 }
63 description
64 "Route map valid sequence numbers.";
65 }
66
67 typedef route-map-name {
68 type string;
69 description
70 "Route map name format.";
71 }
72
73 typedef route-map-ref {
74 type leafref {
75 path "/frr-route-map:lib/frr-route-map:route-map/frr-route-map:name";
76 require-instance false;
77 }
78 description
79 "Reference to a route-map.";
80 }
81
82 /*
83 * Operational data.
84 */
85 container lib {
86 list route-map {
87 key "name";
88 description
89 "Route map instance.";
90 leaf name {
91 type route-map-name;
92 description
93 "Route map instance name.";
94 }
95
96 list entry {
97 key "sequence";
98 description
99 "Route map entry.";
100 leaf sequence {
101 description
102 "Route map instance priority (low number means higher priority).";
103 type route-map-sequence;
104 }
105
106 leaf description {
107 description "Route map description.";
108 type string;
109 }
110
111 leaf action {
112 description
113 "Route map actions: permit (executes action), deny (quits evaluation).";
114 mandatory true;
115 type enumeration {
116 enum permit {
117 description
118 "Executes configured action and permits the prefix/route
119 if the conditions matched. An alternative exit action can
120 be configured to continue processing the route map list
121 or jump to process another route map.";
122 value 0;
123 }
124 enum deny {
125 description
126 "If all conditions are met the prefix/route is denied and
127 route map processing stops.";
128 value 1;
129 }
130 }
131 }
132
133 leaf call {
134 description
135 "Call another route map before calling `exit-policy`. If the
136 called route map returns deny then this route map will also
137 return deny.";
138 type route-map-name;
139 }
140
141 leaf exit-policy {
142 description "What do to after route map successful match, set and call.";
143 type enumeration {
144 enum permit-or-deny {
145 description "End route map evaluation and return.";
146 value 0;
147 }
148 enum next {
149 description
150 "Proceed evaluating next route map entry per sequence.";
151 value 1;
152 }
153 enum goto {
154 description
155 "Go to route map entry with the provided sequence number.";
156 value 2;
157 }
158 }
159 default "permit-or-deny";
160 }
161
162 leaf goto-value {
163 when "../exit-policy = 'goto'";
164 description
165 "Sequence number to jump (when using `goto` exit policy).";
166 mandatory true;
167 type route-map-sequence;
168 }
169
170 list match-condition {
171 key "condition";
172 description
173 "Route map match conditions.";
174 leaf condition {
175 description "Match condition.";
176 type enumeration {
177 enum interface {
178 description "Match interface.";
179 value 0;
180 }
181 enum ipv4-address-list {
182 description "Match an IPv4 access-list.";
183 value 1;
184 }
185 enum ipv4-prefix-list {
186 description "Match an IPv4 prefix-list.";
187 value 2;
188 }
189 enum ipv4-next-hop-list {
190 description "Match an IPv4 next-hop.";
191 value 3;
192 }
193 enum ipv4-next-hop-prefix-list {
194 description "Match an IPv4 next-hop prefix list.";
195 value 4;
196 }
197 enum ipv4-next-hop-type {
198 description "Match an IPv4 next-hop type.";
199 value 5;
200 }
201 enum ipv6-address-list {
202 description "Match an IPv6 access-list.";
203 value 6;
204 }
205 enum ipv6-prefix-list {
206 description "Match an IPv6 prefix-list.";
207 value 7;
208 }
209 enum ipv6-next-hop-type {
210 description "Match an IPv6 next-hop type.";
211 value 8;
212 }
213 enum metric {
214 description "Match a route metric.";
215 value 9;
216 }
217 enum tag {
218 description "Match a route tag.";
219 value 10;
220 }
221 /* zebra specific conditions. */
222 enum ipv4-prefix-length {
223 description "Match IPv4 prefix length.";
224 value 100;
225 }
226 enum ipv6-prefix-length {
227 description "Match IPv6 prefix length.";
228 value 101;
229 }
230 enum ipv4-next-hop-prefix-length {
231 description "Match next-hop prefix length.";
232 value 102;
233 }
234 enum source-protocol {
235 description "Match source protocol.";
236 value 103;
237 }
238 enum source-instance {
239 description "Match source protocol instance.";
240 value 104;
241 }
242 }
243 }
244
245 choice condition-value {
246 description
247 "Value to match (interpretation depends on condition type).";
248 mandatory true;
249 case interface {
250 when "./condition = 'interface'";
251 leaf interface {
252 type frr-interface:interface-ref;
253 }
254 }
255
256 case list-name {
257 when "./condition = 'ipv4-address-list' or
258 ./condition = 'ipv4-prefix-list' or
259 ./condition = 'ipv4-next-hop-list' or
260 ./condition = 'ipv4-next-hop-prefix-list' or
261 ./condition = 'ipv6-address-list' or
262 ./condition = 'ipv6-prefix-list'";
263 leaf list-name {
264 type filter:access-list-name;
265 }
266 }
267
268 case ipv4-next-hop-type {
269 when "./condition = 'ipv4-next-hop-type'";
270 leaf ipv4-next-hop-type {
271 type enumeration {
272 enum blackhole {
273 value 0;
274 }
275 }
276 }
277 }
278
279 case ipv6-next-hop-type {
280 when "./condition = 'ipv6-next-hop-type'";
281 leaf ipv6-next-hop-type {
282 type enumeration {
283 enum blackhole {
284 value 0;
285 }
286 }
287 }
288 }
289
290 case metric {
291 when "./condition = 'metric'";
292 leaf metric {
293 type uint32 {
294 range "1..4294967295";
295 }
296 }
297 }
298
299 case tag {
300 when "./condition = 'tag'";
301 leaf tag {
302 type uint32 {
303 range "1..4294967295";
304 }
305 }
306 }
307 }
308 }
309
310 list set-action {
311 description "Route map set actions.";
312
313 key "action";
314
315 leaf action {
316 description "Action to do when the route map matches.";
317 type enumeration {
318 enum ipv4-next-hop {
319 description "Set IPv4 address of the next hop.";
320 value 0;
321 }
322 enum ipv6-next-hop {
323 description "Set IPv6 address of the next hop.";
324 value 1;
325 }
326 enum metric {
327 description "Set prefix/route metric.";
328 value 2;
329 }
330 enum tag {
331 description "Set tag.";
332 value 3;
333 }
334 /* zebra specific conditions. */
335 enum source {
336 description "Set source address for route.";
337 value 100;
338 }
339 }
340 }
341
342 choice action-value {
343 description
344 "Value to set (interpretation depends on action-type).";
345 case ipv4-address {
346 when "./action = 'ipv4-next-hop'";
347 leaf ipv4-address {
348 description "IPv4 address.";
349 type inet:ipv4-address;
350 }
351 }
352
353 case ipv6-address {
354 when "./action = 'ipv6-next-hop'";
355 leaf ipv6-address {
356 description "IPv6 address.";
357 type inet:ipv6-address;
358 }
359 }
360
361 case metric {
362 when "./action = 'metric'";
363 choice metric-value {
364 description "Metric to set or use.";
365 case value {
366 leaf value {
367 description "Use the following metric value.";
368 type uint32 {
369 range "0..4294967295";
370 }
371 }
372 }
373
374 case add-metric {
375 leaf add-metric {
376 description "Add value to metric.";
377 type uint32 {
378 range "0..4294967295";
379 }
380 }
381 }
382
383 case subtract-metric {
384 leaf subtract-metric {
385 description "Subtract value from metric.";
386 type uint32 {
387 range "0..4294967295";
388 }
389 }
390 }
391
392 case use-round-trip-time {
393 leaf use-round-trip-time {
394 description "Use the round trip time as metric.";
395 type boolean;
396 }
397 }
398
399 case add-round-trip-time {
400 leaf add-round-trip-time {
401 description "Add round trip time to metric.";
402 type boolean;
403 }
404 }
405
406 case subtract-round-trip-time {
407 leaf subtract-round-trip-time {
408 description "Subtract round trip time to metric.";
409 type boolean;
410 }
411 }
412 }
413 }
414
415 case tag {
416 when "./action = 'tag'";
417 leaf tag {
418 description "Tag value.";
419 type uint32 {
420 range "0..4294967295";
421 }
422 }
423 }
424 }
425 }
426 }
427 }
428 }
429 }