summaryrefslogtreecommitdiffstats
path: root/yang/frr-route-map.yang
blob: 1e8c04bc6f9baf169911ed51ab7cd60d7bf686fc (plain)
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
module frr-route-map {
  yang-version 1.1;
  namespace "http://frrouting.org/yang/route-map";
  prefix frr-route-map;

  import ietf-inet-types {
    prefix inet;
  }

  import frr-filter {
    prefix filter;
  }

  import frr-interface {
    prefix frr-interface;
  }

  organization
    "FRRouting";
  contact
    "FRR Users List:       <mailto:frog@lists.frrouting.org>
     FRR Development List: <mailto:dev@lists.frrouting.org>";
  description
    "This module defines route map settings

     Copyright 2020 FRRouting

     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions
     are met:

     1. Redistributions of source code must retain the above copyright notice,
     this list of conditions and the following disclaimer.

     2. Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in the
     documentation and/or other materials provided with the distribution.

     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.";

  revision 2019-07-01 {
    description
      "Initial revision";
  }

  identity rmap-match-type {
    description
      "Base route-map match-condition";
  }

  identity interface {
    base rmap-match-type;
    description
      "Match interface";
  }

  identity ipv4-address-list {
    base rmap-match-type;
    description
      "Match an IPv4 access-list";
  }

  identity ipv4-prefix-list {
    base rmap-match-type;
    description
      "Match an IPv4 prefix-list";
  }

  identity ipv4-next-hop-list {
    base rmap-match-type;
    description
      "Match an IPv4 next-hop";
  }

  identity ipv4-next-hop-prefix-list {
    base rmap-match-type;
    description
      "Match an IPv4 next-hop prefix list";
  }

  identity ipv4-next-hop-type {
    base rmap-match-type;
    description
      "Match an IPv4 next-hop type";
  }

  identity ipv6-address-list {
    base rmap-match-type;
    description
      "Match an IPv6 access-list";
  }

  identity ipv6-prefix-list {
    base rmap-match-type;
    description
      "Match an IPv6 prefix-list";
  }

  identity ipv6-next-hop-list {
    base rmap-match-type;
    description
      "Match an IPv6 next-hop";
  }

  identity ipv6-next-hop-prefix-list {
    base rmap-match-type;
    description
      "Match an IPv6 next-hop prefix list";
  }

  identity ipv6-next-hop-type {
    base rmap-match-type;
    description
      "Match an IPv6 next-hop type";
  }

  identity match-metric {
    base rmap-match-type;
    description
      "Match a route metric";
  }

  identity match-tag {
    base rmap-match-type;
    description
      "Match a route tag";
  }

  identity rmap-set-type {
    description
      "Base route-map set-action";
  }

  identity ipv4-next-hop {
    base rmap-set-type;
    description
      "Set IPv4 address of the next hop";
  }

  identity ipv6-next-hop {
    base rmap-set-type;
    description
      "Set IPv6 address of the next hop";
  }

  identity set-metric {
    base rmap-set-type;
    description
      "Set prefix/route metric";
  }

  identity set-tag {
    base rmap-set-type;
    description
      "Set tag";
  }

  identity set-sr-te-color {
    base rmap-set-type;
    description
      "Set Color of the SR-TE";
  }

  typedef route-map-sequence {
    type uint16 {
      range "1..65535";
    }
    description
      "Route map valid sequence numbers";
  }

  typedef route-map-name {
    type string;
    description
      "Route map name format";
  }

  typedef route-map-ref {
    type leafref {
      path "/frr-route-map:lib/frr-route-map:route-map/frr-route-map:name";
      require-instance false;
    }
    description
      "Reference to a route-map.";
  }

  grouping rmap-match-condition {
    container rmap-match-condition {
      choice match-condition {
        description
          "Value to match (interpretation depends on condition type)";
        case interface {
          when "derived-from-or-self(../condition, 'interface')";
          leaf interface {
            type frr-interface:interface-ref;
          }
        }

        case list-name {
          when "derived-from-or-self(../condition, 'ipv4-address-list') or "
             + "derived-from-or-self(../condition, 'ipv4-prefix-list') or "
             + "derived-from-or-self(../condition, 'ipv4-next-hop-list') or "
             + "derived-from-or-self(../condition, 'ipv4-next-hop-prefix-list') or "
             + "derived-from-or-self(../condition, 'ipv6-address-list') or "
             + "derived-from-or-self(../condition, 'ipv6-next-hop-list') or "
             + "derived-from-or-self(../condition, 'ipv6-next-hop-prefix-list') or "
             + "derived-from-or-self(../condition, 'ipv6-prefix-list')";
          leaf list-name {
            type filter:access-list-name;
          }
        }

        case ipv4-next-hop-type {
          when "derived-from-or-self(../condition, 'ipv4-next-hop-type')";
          leaf ipv4-next-hop-type {
            type enumeration {
              enum "blackhole" {
                value 0;
              }
            }
          }
        }

        case ipv6-next-hop-type {
          when "derived-from-or-self(../condition, 'ipv6-next-hop-type')";
          leaf ipv6-next-hop-type {
            type enumeration {
              enum "blackhole" {
                value 0;
              }
            }
          }
        }

        case match-metric {
          when "derived-from-or-self(../condition, 'match-metric')";
          leaf metric {
            type uint32 {
              range "1..4294967295";
            }
          }
        }

        case match-tag {
          when "derived-from-or-self(../condition, 'match-tag')";
          leaf tag {
            type uint32 {
              range "1..4294967295";
            }
          }
        }
      }
    }
  }

  grouping rmap-set-action {
    container rmap-set-action {
      choice set-action {
        description
          "Value to set (interpretation depends on action-type)";
        case ipv4-address {
          when "derived-from-or-self(../action, 'ipv4-next-hop')";
          leaf ipv4-address {
            type inet:ipv4-address;
            description
              "IPv4 address";
          }
        }

        case ipv6-address {
          when "derived-from-or-self(../action, 'ipv6-next-hop')";
          leaf ipv6-address {
            type inet:ipv6-address;
            description
              "IPv6 address";
          }
        }

        case set-metric {
          when "derived-from-or-self(../action, 'set-metric')";
          choice metric-value {
            description
              "Metric to set or use";
            case value {
              leaf value {
                type uint32 {
                  range "0..4294967295";
                }
                description
                  "Use the following metric value";
              }
            }

            case add-metric {
              leaf add-metric {
                description "Add value to metric.";
                type uint32 {
                  range "0..4294967295";
                }
              }
            }

            case subtract-metric {
              leaf subtract-metric {
                description "Subtract value from metric.";
                type uint32 {
                  range "0..4294967295";
                }
              }
            }

            case use-round-trip-time {
              leaf use-round-trip-time {
                type boolean;
                description
                  "Use the round trip time as metric";
              }
            }

            case add-round-trip-time {
              leaf add-round-trip-time {
                type boolean;
                description
                  "Add round trip time to metric";
              }
            }

            case subtract-round-trip-time {
              leaf subtract-round-trip-time {
                type boolean;
                description
                  "Subtract round trip time to metric";
              }
            }
          }
        }

        case set-tag {
          when "derived-from-or-self(../action, 'set-tag')";
          leaf tag {
            type uint32 {
              range "0..4294967295";
            }
            description
              "Tag value";
          }
        }

        case set-sr-te-color {
          when "derived-from-or-self(../action, 'set-sr-te-color')";
          leaf policy {
            type string;
            description
              "Color of the SR-TE Policies to match with";
          }
        }
      }
    }
  }

  container lib {
    list route-map {
      key "name";
      description
        "Route map instance";
      leaf name {
        type route-map-name;
        description
          "Route map instance name";
      }
      leaf optimization-disabled {
        type boolean;
        default false;
        description "Disables or enables the optimization";
      }

      list entry {
        key "sequence";
        description
          "Route map entry";
        leaf sequence {
          type route-map-sequence;
          description
            "Route map instance priority (low number means higher priority)";
        }

        leaf description {
          type string;
          description
            "Route map description";
        }

        leaf action {
          type enumeration {
            enum "permit" {
              value 0;
              description
                "Executes configured action and permits the prefix/route
                 if the conditions matched. An alternative exit action can
                 be configured to continue processing the route map list
                 or jump to process another route map.";
            }
            enum "deny" {
              value 1;
              description
                "If all conditions are met the prefix/route is denied and
                 route map processing stops.";
            }
          }
          mandatory true;
          description
            "Route map actions: permit (executes action), deny (quits evaluation)";
        }

        leaf call {
          type route-map-name;
          description
            "Call another route map before calling `exit-policy`. If the
             called route map returns deny then this route map will also
             return deny";
        }

        leaf exit-policy {
          type enumeration {
            enum "permit-or-deny" {
              value 0;
              description
                "End route map evaluation and return";
            }
            enum "next" {
              value 1;
              description
                "Proceed evaluating next route map entry per sequence";
            }
            enum "goto" {
              value 2;
              description
                "Go to route map entry with the provided sequence number";
            }
          }
          default "permit-or-deny";
          description
            "What do to after route map successful match, set and call";
        }

        leaf goto-value {
          when "../exit-policy = 'goto'";
          type route-map-sequence;
          mandatory true;
          description
            "Sequence number to jump (when using `goto` exit policy)";
        }

        list match-condition {
          key "condition";
          description
            "Route map match conditions";
          leaf condition {
            type identityref {
              base rmap-match-type;
            }
            description
              "Match condition";
          }

          uses rmap-match-condition;
        }

        list set-action {
          key "action";
          description
            "Route map set actions";
          leaf action {
            type identityref {
              base rmap-set-type;
            }
            description
              "Action to do when the route map matches";
          }

          uses rmap-set-action;
        }
      }
    }
  }
}