summaryrefslogtreecommitdiffstats
path: root/yang/frr-nexthop.yang
blob: 175487d78b57411f1d4c564a5dce5e67d5eb3f87 (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
// SPDX-License-Identifier: BSD-2-Clause
module frr-nexthop {
  yang-version 1.1;
  namespace "http://frrouting.org/yang/nexthop";
  prefix frr-nexthop;

  import ietf-inet-types {
    prefix inet;
  }

  import ietf-routing-types {
    prefix rt-types;
  }

  import frr-interface {
    prefix frr-interface;
  }

  import frr-vrf {
    prefix frr-vrf;
  }

  organization
    "FRRouting";
  contact
    "FRR Users List: <mailto:frog@lists.frrouting.org>
     FRR Development List: <mailto:dev@lists.frrouting.org>";
  description
    "This module defines a model for managing FRR nexthop information.

     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-08-15 {
    description
      "Initial revision.";
  }

  typedef optional-ip-address {
    type union {
      type inet:ip-address;
      type string {
        length "0";
      }
    }
  }

  /*
   * Nexthop types.
   */
  typedef nexthop-type {
    type enumeration {
      enum "ifindex" {
        value 1;
        description
          "Specific interface.";
      }
      enum "ip4" {
        value 2;
        description
          "IPv4 address.";
      }
      enum "ip4-ifindex" {
        value 3;
        description
          "IPv4 address and interface.";
      }
      enum "ip6" {
        value 4;
        description
          "IPv6 address.";
      }
      enum "ip6-ifindex" {
        value 5;
        description
          "IPv6 address and interface.";
      }
      enum "blackhole" {
        value 6;
        description
          "Unreachable or prohibited.";
      }
    }
    description
      "Nexthop types.";
  }

  /*
   * Blockhole nexthop type.
   */
  typedef blackhole-type {
    type enumeration {
      enum "unspec" {
        value 0;
        description
          "Generic unreachable.";
      }
      enum "null" {
        value 1;
        description
          "Null type.";
      }
      enum "reject" {
        value 2;
        description
          "ICMP unreachable.";
      }
      enum "prohibited" {
        value 3;
        description
          "ICMP admin-prohibited.";
      }
    }
    default "null";
    description
      "Nexthop blackhole types.";
  }

  typedef nexthop-group-ref {
    type leafref {
      path "/frr-nexthop:frr-nexthop-group/frr-nexthop:nexthop-groups/frr-nexthop:name";
      require-instance false;
    }
  }

  /*
   * Common nexthop attributes grouping.
   */
  grouping frr-nexthop-attributes {
    leaf nh-type {
      type nexthop-type;
      mandatory true;
      description
        "The nexthop type.";
    }

    leaf vrf {
      type frr-vrf:vrf-ref;
      description
        "The nexthop vrf name, if different from the route.";
    }

    leaf gateway {
      type frr-nexthop:optional-ip-address;
      description
        "The nexthop gateway address.";
    }

    leaf interface {
      type frr-interface:interface-ref;
      description
        "The nexthop egress interface.";
    }

    leaf bh-type {
      type blackhole-type;
      description
        "A blackhole sub-type, if the nexthop is a blackhole type.";
    }

    leaf onlink {
      type boolean;
      default "false";
      description
        "Nexthop is directly connected.";
    }

    leaf srte-color {
      when "../nh-type = 'ip4' or
            ../nh-type = 'ip6' or
            ../nh-type = 'ip4-ifindex' or
            ../nh-type = 'ip6-ifindex'";
      type uint32;
      description
        "The nexthop SR-TE color";
    }

    uses rt-types:mpls-label-stack {
      description
        "Nexthop's MPLS label stack.";
    }

    uses srv6-segs-stack {
      description
        "Nexthop's SRv6 segs SIDs stack.";
    }
  }

  /*
   * operational common attributes for nexthop
   */
  grouping frr-nexthop-operational {
    leaf duplicate {
      type empty;
      config false;
      description
        "Duplicate nexthop";
    }

    leaf recursive {
      type empty;
      config false;
      description
        "Nexthop resolved through another gateway.";
    }

    leaf active {
      type empty;
      config false;
      description
        "Nexthop is active.";
    }

    leaf fib {
      type empty;
      config false;
      description
        "Nexthop is installed in fib.";
    }

    leaf weight {
      type uint8;
      config false;
      description
        "Weight to be used by the nexthop for purposes of ECMP";
    }
  }

  grouping nexthop-grouping {
    list nexthop {
      key "nh-type vrf gateway interface";
      min-elements 1;
      description
        "A list of nexthop objects.";
      uses frr-nexthop-attributes;
    }
  }

  /*
   * Single nexthop grouping.
   */
  grouping frr-nexthop {
    container frr-nexthops {
      description
        "FRR nexthop object.";
      uses nexthop-grouping;
    }
  }


  /*
   * Container for FRR nexthop group.
   */
  grouping frr-nexthop-grouping {
    list nexthop-groups {
      key "name";
      description
        "List of nexthop groups, each contains group of nexthops";
      leaf name {
        type string;
        description
          "The nexthop-group name.";
      }

      uses frr-nexthop;
    }
  }

  /* Operational nexthop-group */
  grouping frr-nexthop-group-operational {
    container nexthop-group {
      description
        "A group of nexthops.";
      leaf id {
        type uint32;
        description
          "The nexthop-group id.";
      }

      uses nexthop-grouping;
    }
  }

  /* Contaner for SRv6 segs SIDs */
  grouping srv6-segs-stack {
    description
      "This grouping specifies an SRv6 segs SIDs stack. The segs
      SIDs stack is encoded as a list of SID entries. The
      list key is an identifier that indicates the relative
      ordering of each entry.";
      container srv6-segs-stack {
        description
          "Container for a list of SRv6 segs SIDs entries.";
          list entry {
            key "id";
            description
              "List of SRv6 segs SIDs entries.";
	    leaf id {
              type uint8;
              description
              "Identifies the entry in a sequence of SRv6 segs SIDs
              entries.";
            }
            leaf seg {
                type inet:ipv6-address;
            }
          }
      }
  }
  container frr-nexthop-group {
    description
      "A nexthop-group, represented as a list of nexthop objects.";
    uses frr-nexthop-grouping;
  }

  /*
   * Augment weight attributes to nexthop group.
   */
  augment "/frr-nexthop-group/nexthop-groups/frr-nexthops/nexthop" {
    leaf weight {
      type uint8;
      description
        "Weight to be used by the nexthop for purposes of ECMP";
    }
  }
}