a14cc8deeb64009d5d9f9ecb69109eb3ff1807d4
[bgpcep.git] / bgp / 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 yang-ext { prefix ext; revision-date 2013-07-09; }
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     typedef uint24 {
104         type uint32 {
105             range "0 .. 16777215";
106         }
107         description
108             "24-bit unsigned integer.";
109     }
110
111     grouping ethernet-tag-id {
112         reference "https://tools.ietf.org/html/rfc7432#section-7.1";
113         description "An Ethernet Tag ID is a 32-bit field containing either
114             a 12-bit or 24-bit identifier that identifies a particular
115             broadcast domain (e.g., a VLAN) in an EVPN instance";
116
117         container ethernet-tag-id {
118             leaf vlan-id {
119                 type uint32;
120                 mandatory true;
121             }
122         }
123     }
124
125     grouping local-discriminator {
126         leaf local-discriminator {
127             type uint32;
128             mandatory true;
129         }
130     }
131
132     grouping esi {
133         reference "https://tools.ietf.org/html/rfc7432#section-5";
134         description "Ethernet segment (ES) are identified by a unique non-zero identifier
135             called an Ethernet Segment Identifier (ESI). An ESI is encoded as a 10-octet
136             integer in line format with the most significant octet sent first";
137
138         choice esi {
139             mandatory true;
140             case arbitrary-case {
141                 container arbitrary {
142                     description "Type 0 indicates an arbitrary 9-octet ESI
143                         value, which is managed and configured by the operator";
144
145                     leaf arbitrary {
146                         type binary {
147                             length 9;
148                         }
149                         mandatory true;
150                     }
151                 }
152             }
153             case lacp-auto-generated-case {
154                 container lacp-auto-generated {
155                     description "When IEEE 802.1AX LACP is used between the PEs and CEs,
156                         ESI type 1 indicates an auto-generated ESI value determined from LACP";
157
158                     leaf ce-lacp-mac-address {
159                         type yang:mac-address;
160                         mandatory true;
161                     }
162                     leaf ce-lacp-port-key {
163                         type uint16;
164                         mandatory true;
165                     }
166                 }
167             }
168             case lan-auto-generated-case {
169                 container lan-auto-generated {
170                 description "Type 2 is used in the case of indirectly connected hosts via a bridged
171                     LAN between the CEs and the PEs. The ESI Value is auto-generated and determined
172                     based on the Layer 2 bridge protocol";
173
174                     leaf root-bridge-mac-address {
175                         type yang:mac-address;
176                         mandatory true;
177                     }
178                     leaf root-bridge-priority {
179                         type uint16;
180                         mandatory true;
181                     }
182                 }
183             }
184             case mac-auto-generated-case {
185                 container mac-auto-generated {
186                     description "Type 3 indicates a MAC-based ESI Value that
187                         can be auto-generated or configured by the operator.";
188
189                     leaf system-mac-address {
190                         type yang:mac-address;
191                         mandatory true;
192                     }
193                     leaf local-discriminator {
194                         type uint24;
195                         mandatory true;
196                     }
197                 }
198             }
199             case router-id-generated-case {
200                 container router-id-generated {
201                     description "Type 4 indicates a router-ID ESI Value that
202                      can be auto-generated or configured by the operator";
203
204                     leaf router-id {
205                         type inet:ipv4-address;
206                         mandatory true;
207                     }
208                     uses local-discriminator;
209                 }
210             }
211             case as-generated-case {
212                 container as-generated {
213                     description "Type 5 indicates an Autonomous System (AS)-based ESI
214                     Value that can be auto-generated or configured by the operator";
215
216                     leaf as {
217                         type inet:as-number;
218                         mandatory true;
219                     }
220                     uses local-discriminator;
221                 }
222             }
223         }
224     }
225
226     grouping ethernet-a-d-route {
227         container ethernet-a-d-route {
228             reference "https://tools.ietf.org/html/rfc7432#section-7.1";
229             description "Ethernet Auto-Discovery (A-D) route";
230
231             uses esi;
232             uses ethernet-tag-id;
233             leaf mpls-label {
234                 type netc:mpls-label;
235                 mandatory true;
236             }
237         }
238     }
239
240     grouping mac-ip-adv-route {
241         container mac-ip-adv-route {
242             reference "https://tools.ietf.org/html/rfc7432#section-7.2";
243             description "MAC/IP Advertisement route";
244
245             uses esi;
246             uses ethernet-tag-id;
247             leaf mac-address {
248                 type yang:mac-address;
249                 mandatory true;
250             }
251             leaf ip-address {
252                 type inet:ip-address;
253             }
254             leaf mpls-label1 {
255                 type netc:mpls-label;
256                 mandatory true;
257             }
258             leaf mpls-label2 {
259                 type netc:mpls-label;
260             }
261         }
262     }
263
264     grouping inc-multi-ethernet-tag-res {
265         container inc-multi-ethernet-tag-res {
266             reference "https://tools.ietf.org/html/rfc7432#section-7.3";
267             description "Inclusive Multicast Ethernet Tag route";
268
269             uses ethernet-tag-id;
270             uses bgp-t:orig-route-ip-grouping;
271         }
272     }
273
274     grouping es-route {
275         container es-route {
276             reference "https://tools.ietf.org/html/rfc7432#section-7.4";
277             description "Ethernet Segment route";
278
279             uses esi;
280             uses bgp-t:orig-route-ip-grouping;
281         }
282     }
283
284     grouping esi-label-extended-community {
285         container esi-label-extended-community {
286             reference "https://tools.ietf.org/html/rfc7432#section-7.5";
287             description "The ESI Label Extended Community is a transitive Extended
288                 Community that may be advertised along with Ethernet Auto-discovery
289                 routes, and it enables split-horizon procedures for multihomed sites";
290
291             leaf single-active-mode {
292                 type boolean;
293                 default false;
294             }
295             leaf esi-label {
296                 type netc:mpls-label;
297                 mandatory true;
298             }
299         }
300     }
301
302     grouping es-import-route-extended-community {
303         container es-import-route-extended-community {
304             reference "https://tools.ietf.org/html/rfc7432#section-7.6";
305             description
306                 "New transitive Route Target extended community carried with
307                 the Ethernet Segment route.  When used, it enables all the PEs
308                 connected to the same multihomed site to import the Ethernet Segment
309                 routes";
310
311             leaf es-import {
312                 type yang:mac-address;
313                 mandatory true;
314             }
315         }
316     }
317
318     grouping mac-mobility-extended-community {
319         container mac-mobility-extended-community {
320             reference "https://tools.ietf.org/html/rfc7432#section-7.7";
321             description
322                 "The MAC Mobility Extended Community is a transitive Extended Community
323                 that may be advertised along with MAC/IP Advertisement routes.";
324
325             leaf static {
326                 type boolean;
327                 default false;
328             }
329             leaf seq-number {
330                 type uint32;
331                 mandatory true;
332             }
333         }
334     }
335
336     grouping default-gateway-extended-community {
337         container default-gateway-extended-community {
338             presence
339                 "The Default Gateway community is an Extended Community of an
340                 Opaque Type";
341
342             reference "https://tools.ietf.org/html/rfc7432#section-7.8";
343
344             description
345                 "The Default Gateway community is an Extended Community of an
346                  Opaque Type ";
347         }
348     }
349
350     typedef operational-mode {
351         type enumeration {
352             enum vlan-aware-fxc {
353                 value 1;
354             }
355             enum vlan-unaware-fxc {
356                 value 2;
357             }
358         }
359     }
360
361     typedef normalization-type {
362         type enumeration {
363             enum single-vid {
364                 value 1;
365             }
366             enum double-vid {
367                 value 2;
368             }
369         }
370     }
371
372     grouping layer-2-attributes-extended-community {
373         container layer-2-attributes-extended-community {
374             reference "https://tools.ietf.org/html/draft-ietf-bess-evpn-vpws-02#section-3.1";
375             description
376                 "The EVPN Layer 2 attributes extended community is a extended community
377                 to be included with Ethernet A-D per EVI route.
378                 This attribute is mandatory if multihoming is enabled.";
379
380                 leaf primary-pe {
381                    type boolean;
382                    default false;
383                 }
384                 leaf backup-pe {
385                    type boolean;
386                    default false;
387                 }
388                 leaf control-word {
389                    type boolean;
390                    default false;
391                 }
392                 leaf mode-of-operation {
393                    reference "https://tools.ietf.org/html/draft-sajassi-bess-evpn-vpws-fxc-01#section-5";
394                    type operational-mode;
395                 }
396                 leaf operating-per {
397                    reference "https://tools.ietf.org/html/draft-sajassi-bess-evpn-vpws-fxc-01#section-5";
398                    type normalization-type;
399                 }
400                 leaf l2-mtu {
401                     type uint16;
402                     mandatory true;
403                 }
404         }
405     }
406
407     grouping evpn-destination {
408         list evpn-destination {
409             uses evpn;
410             uses bgp-msg:path-id-grouping;
411         }
412     }
413
414     grouping evpn-routes {
415         container evpn-routes {
416             list evpn-route {
417                 key "route-key path-id";
418                 uses evpn;
419                 uses pmsi:bgp-rib-route {
420                     augment "attributes/extended-communities/extended-community" {
421                         case esi-label-extended-community-case {
422                             uses esi-label-extended-community;
423                         }
424                         case es-import-route-extended-community-case {
425                             uses es-import-route-extended-community;
426                         }
427                         case mac-mobility-extended-community-case {
428                             uses mac-mobility-extended-community;
429                         }
430                         case default-gateway-extended-community-case {
431                             uses default-gateway-extended-community;
432                         }
433                         case layer-2-attributes-extended-community-case {
434                             uses layer-2-attributes-extended-community;
435                         }
436                     }
437                 }
438             }
439         }
440     }
441
442     grouping evpn {
443         reference "https://tools.ietf.org/html/rfc7432#section-7";
444         description "The EVPN NLRI is carried in BGP [RFC4271] using BGP Multiprotocol
445             Extensions [RFC4760] with an Address Family Identifier (AFI) of 25 (L2VPN)
446             and a Subsequent Address Family Identifier (SAFI) of 70 (EVPN)";
447
448         choice evpn-choice {
449             case ethernet-a-d-route-case {
450                 uses ethernet-a-d-route;
451             }
452             case mac-ip-adv-route-case {
453                 uses mac-ip-adv-route;
454             }
455             case inc-multi-ethernet-tag-res-case {
456                 uses inc-multi-ethernet-tag-res;
457             }
458             case es-route-case {
459                 uses es-route;
460             }
461             mandatory true;
462         }
463
464         uses bgp-t:route-distinguisher-grouping;
465     }
466
467     augment "/bgp-msg:update/bgp-msg:attributes/bgp-mp:mp-reach-nlri/bgp-mp:advertized-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-msg:update/bgp-msg:attributes/bgp-mp:mp-unreach-nlri/bgp-mp:withdrawn-routes/bgp-mp:destination-type" {
476         case destination-evpn-case {
477             container destination-evpn {
478                 uses evpn-destination;
479             }
480         }
481     }
482
483     augment "/bgp-rib:application-rib/bgp-rib:tables/bgp-rib:routes" {
484         case evpn-routes-case {
485             uses evpn-routes;
486         }
487     }
488
489     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:loc-rib/bgp-rib:tables/bgp-rib:routes" {
490         case evpn-routes-case {
491             uses evpn-routes;
492         }
493     }
494
495     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:peer/bgp-rib:adj-rib-in/bgp-rib:tables/bgp-rib:routes" {
496         case evpn-routes-case {
497             uses evpn-routes;
498         }
499     }
500
501     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:peer/bgp-rib:effective-rib-in/bgp-rib:tables/bgp-rib:routes" {
502         case evpn-routes-case {
503             uses evpn-routes;
504         }
505     }
506
507     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:peer/bgp-rib:adj-rib-out/bgp-rib:tables/bgp-rib:routes" {
508         case evpn-routes-case {
509             uses evpn-routes;
510         }
511     }
512
513     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" {
514         case evpn-routes-case {
515             uses evpn-routes;
516         }
517     }
518
519     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" {
520         case evpn-routes-case {
521             uses evpn-routes;
522         }
523     }
524
525     augment "/bgp-msg:update/bgp-msg:attributes/bgp-msg:extended-communities/bgp-msg:extended-community" {
526         case esi-label-extended-community-case {
527             uses esi-label-extended-community;
528         }
529         case es-import-route-extended-community-case {
530             uses es-import-route-extended-community;
531         }
532         case mac-mobility-extended-community-case {
533             uses mac-mobility-extended-community;
534         }
535         case default-gateway-extended-community-case {
536             uses default-gateway-extended-community;
537         }
538         case layer-2-attributes-extended-community-case {
539             uses layer-2-attributes-extended-community;
540         }
541     }
542 }