Mass-convert all compontents to use -no-zone addresses
[bgpcep.git] / bgp / extensions / evpn / src / main / yang / odl-bgp-evpn.yang
1 // vi: set smarttab et sw=4 tabstop=4:
2 module odl-bgp-evpn {
3     yang-version 1;
4     namespace "urn:opendaylight:params:xml:ns:yang:bgp-evpn";
5     prefix "bgp-evpn";
6
7     import bgp-types { prefix bgp-t; revision-date 2018-03-29; }
8     import ietf-inet-types { prefix inet; revision-date 2013-07-15; }
9     import ietf-yang-types {prefix yang; revision-date 2013-07-15;}
10     import network-concepts { prefix netc; revision-date 2013-11-25; }
11     import bgp-rib { prefix bgp-rib; revision-date 2018-03-29; }
12     import bmp-monitor { prefix bmp-mon; revision-date 2018-03-29; }
13     import bgp-message { prefix bgp-msg; revision-date 2018-03-29; }
14     import bgp-multiprotocol { prefix bgp-mp; revision-date 2018-03-29; }
15     import pmsi-tunnel { prefix pmsi; revision-date 2018-03-29; }
16     import odl-uint24 { prefix uint24; }
17
18     organization "Cisco Systems, Inc.";
19
20     contact "Claudio D. Gasparini <cgaspari@cisco.com>";
21
22     description
23         "This module contains the base data model of a BGP flow specification.
24         It rolls up the definitions contained in RFC7432.
25
26         Copyright (c)2016 Cisco Systems, Inc. All rights reserved.
27
28         This program and the accompanying materials are made available
29         under the terms of the Eclipse Public License v1.0 which
30         accompanies this distribution, and is available at
31         http://www.eclipse.org/legal/epl-v10.html";
32
33     revision "2018-03-29" {
34         description "Add support for add-path for all afi/safi.";
35     }
36
37     revision "2017-12-13" {
38         description "Support draft https://tools.ietf.org/html/draft-sajassi-bess-evpn-vpws-fxc-01";
39     }
40
41     revision "2017-12-07" {
42         description "Add support for add-path in base BGP NLRI.";
43     }
44
45     revision "2016-03-21" {
46          description
47              "Initial revision";
48          reference "https://tools.ietf.org/html/rfc7432";
49     }
50
51     identity l2vpn-address-family {
52         reference "https://tools.ietf.org/html/rfc7432#section-20";
53         base bgp-t:address-family;
54     }
55
56     identity evpn-subsequent-address-family {
57         reference "https://tools.ietf.org/html/rfc7432#section-20";
58         base bgp-t:subsequent-address-family;
59     }
60
61     typedef nlri-type {
62         reference "https://tools.ietf.org/html/rfc7432#section-7";
63         type enumeration {
64             enum eth-a-d-disc {
65                 value 1;
66             }
67             enum mac-ip-adv {
68                 value 2;
69             }
70             enum inc-mult-eth-tag {
71                 value 3;
72             }
73             enum eth-seg {
74                 value 4;
75             }
76         }
77     }
78
79     typedef esi-type {
80         reference "https://tools.ietf.org/html/rfc7432#section-5";
81         type enumeration {
82             enum arbitrary {
83                 value 0;
84             }
85             enum lacp-auto-generated {
86                 value 1;
87             }
88             enum lan-auto-generated {
89                 value 2;
90             }
91             enum mac-auto-generated {
92                 value 3;
93             }
94             enum router-id-generated {
95                 value 4;
96             }
97             enum as-generated {
98                 value 5;
99             }
100         }
101     }
102
103     grouping ethernet-tag-id {
104         reference "https://tools.ietf.org/html/rfc7432#section-7.1";
105         description "An Ethernet Tag ID is a 32-bit field containing either
106             a 12-bit or 24-bit identifier that identifies a particular
107             broadcast domain (e.g., a VLAN) in an EVPN instance";
108
109         container ethernet-tag-id {
110             leaf vlan-id {
111                 type uint32;
112                 mandatory true;
113             }
114         }
115     }
116
117     grouping local-discriminator {
118         leaf local-discriminator {
119             type uint32;
120             mandatory true;
121         }
122     }
123
124     grouping esi {
125         reference "https://tools.ietf.org/html/rfc7432#section-5";
126         description "Ethernet segment (ES) are identified by a unique non-zero identifier
127             called an Ethernet Segment Identifier (ESI). An ESI is encoded as a 10-octet
128             integer in line format with the most significant octet sent first";
129
130         choice esi {
131             mandatory true;
132             case arbitrary-case {
133                 container arbitrary {
134                     description "Type 0 indicates an arbitrary 9-octet ESI
135                         value, which is managed and configured by the operator";
136
137                     leaf arbitrary {
138                         type binary {
139                             length 9;
140                         }
141                         mandatory true;
142                     }
143                 }
144             }
145             case lacp-auto-generated-case {
146                 container lacp-auto-generated {
147                     description "When IEEE 802.1AX LACP is used between the PEs and CEs,
148                         ESI type 1 indicates an auto-generated ESI value determined from LACP";
149
150                     leaf ce-lacp-mac-address {
151                         type yang:mac-address;
152                         mandatory true;
153                     }
154                     leaf ce-lacp-port-key {
155                         type uint16;
156                         mandatory true;
157                     }
158                 }
159             }
160             case lan-auto-generated-case {
161                 container lan-auto-generated {
162                 description "Type 2 is used in the case of indirectly connected hosts via a bridged
163                     LAN between the CEs and the PEs. The ESI Value is auto-generated and determined
164                     based on the Layer 2 bridge protocol";
165
166                     leaf root-bridge-mac-address {
167                         type yang:mac-address;
168                         mandatory true;
169                     }
170                     leaf root-bridge-priority {
171                         type uint16;
172                         mandatory true;
173                     }
174                 }
175             }
176             case mac-auto-generated-case {
177                 container mac-auto-generated {
178                     description "Type 3 indicates a MAC-based ESI Value that
179                         can be auto-generated or configured by the operator.";
180
181                     leaf system-mac-address {
182                         type yang:mac-address;
183                         mandatory true;
184                     }
185                     leaf local-discriminator {
186                         type uint24:uint24;
187                         mandatory true;
188                     }
189                 }
190             }
191             case router-id-generated-case {
192                 container router-id-generated {
193                     description "Type 4 indicates a router-ID ESI Value that
194                      can be auto-generated or configured by the operator";
195
196                     leaf router-id {
197                         type inet:ipv4-address-no-zone;
198                         mandatory true;
199                     }
200                     uses local-discriminator;
201                 }
202             }
203             case as-generated-case {
204                 container as-generated {
205                     description "Type 5 indicates an Autonomous System (AS)-based ESI
206                     Value that can be auto-generated or configured by the operator";
207
208                     leaf as {
209                         type inet:as-number;
210                         mandatory true;
211                     }
212                     uses local-discriminator;
213                 }
214             }
215         }
216     }
217
218     grouping ethernet-a-d-route {
219         container ethernet-a-d-route {
220             reference "https://tools.ietf.org/html/rfc7432#section-7.1";
221             description "Ethernet Auto-Discovery (A-D) route";
222
223             uses esi;
224             uses ethernet-tag-id;
225             leaf mpls-label {
226                 type netc:mpls-label;
227                 mandatory true;
228             }
229         }
230     }
231
232     grouping mac-ip-adv-route {
233         container mac-ip-adv-route {
234             reference "https://tools.ietf.org/html/rfc7432#section-7.2";
235             description "MAC/IP Advertisement route";
236
237             uses esi;
238             uses ethernet-tag-id;
239             leaf mac-address {
240                 type yang:mac-address;
241                 mandatory true;
242             }
243             leaf ip-address {
244                 type inet:ip-address-no-zone;
245             }
246             leaf mpls-label1 {
247                 type netc:mpls-label;
248                 mandatory true;
249             }
250             leaf mpls-label2 {
251                 type netc:mpls-label;
252             }
253         }
254     }
255
256     grouping inc-multi-ethernet-tag-res {
257         container inc-multi-ethernet-tag-res {
258             reference "https://tools.ietf.org/html/rfc7432#section-7.3";
259             description "Inclusive Multicast Ethernet Tag route";
260
261             uses ethernet-tag-id;
262             uses bgp-t:orig-route-ip-grouping;
263         }
264     }
265
266     grouping es-route {
267         container es-route {
268             reference "https://tools.ietf.org/html/rfc7432#section-7.4";
269             description "Ethernet Segment route";
270
271             uses esi;
272             uses bgp-t:orig-route-ip-grouping;
273         }
274     }
275
276     grouping esi-label-extended-community {
277         container esi-label-extended-community {
278             reference "https://tools.ietf.org/html/rfc7432#section-7.5";
279             description "The ESI Label Extended Community is a transitive Extended
280                 Community that may be advertised along with Ethernet Auto-discovery
281                 routes, and it enables split-horizon procedures for multihomed sites";
282
283             leaf single-active-mode {
284                 type boolean;
285                 default false;
286             }
287             leaf esi-label {
288                 type netc:mpls-label;
289                 mandatory true;
290             }
291         }
292     }
293
294     grouping es-import-route-extended-community {
295         container es-import-route-extended-community {
296             reference "https://tools.ietf.org/html/rfc7432#section-7.6";
297             description
298                 "New transitive Route Target extended community carried with
299                 the Ethernet Segment route.  When used, it enables all the PEs
300                 connected to the same multihomed site to import the Ethernet Segment
301                 routes";
302
303             leaf es-import {
304                 type yang:mac-address;
305                 mandatory true;
306             }
307         }
308     }
309
310     grouping mac-mobility-extended-community {
311         container mac-mobility-extended-community {
312             reference "https://tools.ietf.org/html/rfc7432#section-7.7";
313             description
314                 "The MAC Mobility Extended Community is a transitive Extended Community
315                 that may be advertised along with MAC/IP Advertisement routes.";
316
317             leaf static {
318                 type boolean;
319                 default false;
320             }
321             leaf seq-number {
322                 type uint32;
323                 mandatory true;
324             }
325         }
326     }
327
328     grouping default-gateway-extended-community {
329         container default-gateway-extended-community {
330             presence
331                 "The Default Gateway community is an Extended Community of an
332                 Opaque Type";
333
334             reference "https://tools.ietf.org/html/rfc7432#section-7.8";
335
336             description
337                 "The Default Gateway community is an Extended Community of an
338                  Opaque Type ";
339         }
340     }
341
342     typedef operational-mode {
343         type enumeration {
344             enum vlan-aware-fxc {
345                 value 1;
346             }
347             enum vlan-unaware-fxc {
348                 value 2;
349             }
350         }
351     }
352
353     typedef normalization-type {
354         type enumeration {
355             enum single-vid {
356                 value 1;
357             }
358             enum double-vid {
359                 value 2;
360             }
361         }
362     }
363
364     grouping layer-2-attributes-extended-community {
365         container layer-2-attributes-extended-community {
366             reference "https://tools.ietf.org/html/draft-ietf-bess-evpn-vpws-02#section-3.1";
367             description
368                 "The EVPN Layer 2 attributes extended community is a extended community
369                 to be included with Ethernet A-D per EVI route.
370                 This attribute is mandatory if multihoming is enabled.";
371
372                 leaf primary-pe {
373                    type boolean;
374                    default false;
375                 }
376                 leaf backup-pe {
377                    type boolean;
378                    default false;
379                 }
380                 leaf control-word {
381                    type boolean;
382                    default false;
383                 }
384                 leaf mode-of-operation {
385                    reference "https://tools.ietf.org/html/draft-sajassi-bess-evpn-vpws-fxc-01#section-5";
386                    type operational-mode;
387                 }
388                 leaf operating-per {
389                    reference "https://tools.ietf.org/html/draft-sajassi-bess-evpn-vpws-fxc-01#section-5";
390                    type normalization-type;
391                 }
392                 leaf l2-mtu {
393                     type uint16;
394                     mandatory true;
395                 }
396         }
397     }
398
399     grouping evpn-destination {
400         list evpn-destination {
401             uses evpn;
402             uses bgp-msg:path-id-grouping;
403         }
404     }
405
406     grouping evpn-routes {
407         container evpn-routes {
408             list evpn-route {
409                 key "route-key path-id";
410                 uses evpn;
411                 uses pmsi:bgp-rib-route {
412                     augment "attributes/extended-communities/extended-community" {
413                         case esi-label-extended-community-case {
414                             uses esi-label-extended-community;
415                         }
416                         case es-import-route-extended-community-case {
417                             uses es-import-route-extended-community;
418                         }
419                         case mac-mobility-extended-community-case {
420                             uses mac-mobility-extended-community;
421                         }
422                         case default-gateway-extended-community-case {
423                             uses default-gateway-extended-community;
424                         }
425                         case layer-2-attributes-extended-community-case {
426                             uses layer-2-attributes-extended-community;
427                         }
428                     }
429                 }
430             }
431         }
432     }
433
434     grouping evpn {
435         reference "https://tools.ietf.org/html/rfc7432#section-7";
436         description "The EVPN NLRI is carried in BGP [RFC4271] using BGP Multiprotocol
437             Extensions [RFC4760] with an Address Family Identifier (AFI) of 25 (L2VPN)
438             and a Subsequent Address Family Identifier (SAFI) of 70 (EVPN)";
439
440         choice evpn-choice {
441             case ethernet-a-d-route-case {
442                 uses ethernet-a-d-route;
443             }
444             case mac-ip-adv-route-case {
445                 uses mac-ip-adv-route;
446             }
447             case inc-multi-ethernet-tag-res-case {
448                 uses inc-multi-ethernet-tag-res;
449             }
450             case es-route-case {
451                 uses es-route;
452             }
453             mandatory true;
454         }
455
456         uses bgp-t:route-distinguisher-grouping;
457     }
458
459     augment "/bgp-msg:update/bgp-msg:attributes/bgp-mp:mp-reach-nlri/bgp-mp:advertized-routes/bgp-mp:destination-type" {
460         case destination-evpn-case {
461             container destination-evpn {
462                 uses evpn-destination;
463             }
464         }
465     }
466
467     augment "/bgp-msg:update/bgp-msg:attributes/bgp-mp:mp-unreach-nlri/bgp-mp:withdrawn-routes/bgp-mp:destination-type" {
468         case destination-evpn-case {
469             container destination-evpn {
470                 uses evpn-destination;
471             }
472         }
473     }
474
475     augment "/bgp-rib:application-rib/bgp-rib:tables/bgp-rib:routes" {
476         case evpn-routes-case {
477             uses evpn-routes;
478         }
479     }
480
481     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:loc-rib/bgp-rib:tables/bgp-rib:routes" {
482         case evpn-routes-case {
483             uses evpn-routes;
484         }
485     }
486
487     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:peer/bgp-rib:adj-rib-in/bgp-rib:tables/bgp-rib:routes" {
488         case evpn-routes-case {
489             uses evpn-routes;
490         }
491     }
492
493     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:peer/bgp-rib:effective-rib-in/bgp-rib:tables/bgp-rib:routes" {
494         case evpn-routes-case {
495             uses evpn-routes;
496         }
497     }
498
499     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:peer/bgp-rib:adj-rib-out/bgp-rib:tables/bgp-rib:routes" {
500         case evpn-routes-case {
501             uses evpn-routes;
502         }
503     }
504
505     augment "/bmp-mon:bmp-monitor/bmp-mon:monitor/bmp-mon:router/bmp-mon:peer/bmp-mon:pre-policy-rib/bmp-mon:tables/bmp-mon:routes" {
506         case evpn-routes-case {
507             uses evpn-routes;
508         }
509     }
510
511     augment "/bmp-mon:bmp-monitor/bmp-mon:monitor/bmp-mon:router/bmp-mon:peer/bmp-mon:post-policy-rib/bmp-mon:tables/bmp-mon:routes" {
512         case evpn-routes-case {
513             uses evpn-routes;
514         }
515     }
516
517     augment "/bgp-msg:update/bgp-msg:attributes/bgp-msg:extended-communities/bgp-msg:extended-community" {
518         case esi-label-extended-community-case {
519             uses esi-label-extended-community;
520         }
521         case es-import-route-extended-community-case {
522             uses es-import-route-extended-community;
523         }
524         case mac-mobility-extended-community-case {
525             uses mac-mobility-extended-community;
526         }
527         case default-gateway-extended-community-case {
528             uses default-gateway-extended-community;
529         }
530         case layer-2-attributes-extended-community-case {
531             uses layer-2-attributes-extended-community;
532         }
533     }
534 }