BGPCEP-781: Provide Add Path support for all AFI/SAFI
[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 2013-09-19; }
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 2017-12-07; }
12     import bmp-monitor { prefix bmp-mon; revision-date 2017-12-07; }
13     import bgp-message { prefix bgp-msg; revision-date 2017-12-07; }
14     import bgp-multiprotocol { prefix bgp-mp; revision-date 2017-12-07; }
15     import pmsi-tunnel { prefix pmsi; revision-date 2016-08-12; }
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 route-distinguisher {
227         leaf route-distinguisher {
228             type bgp-t:route-distinguisher;
229             mandatory true;
230         }
231     }
232
233     grouping ethernet-a-d-route {
234         container ethernet-a-d-route {
235             reference "https://tools.ietf.org/html/rfc7432#section-7.1";
236             description "Ethernet Auto-Discovery (A-D) route";
237
238             uses esi;
239             uses ethernet-tag-id;
240             leaf mpls-label {
241                 type netc:mpls-label;
242                 mandatory true;
243             }
244         }
245     }
246
247     grouping mac-ip-adv-route {
248         container mac-ip-adv-route {
249             reference "https://tools.ietf.org/html/rfc7432#section-7.2";
250             description "MAC/IP Advertisement route";
251
252             uses esi;
253             uses ethernet-tag-id;
254             leaf mac-address {
255                 type yang:mac-address;
256                 mandatory true;
257             }
258             leaf ip-address {
259                 type inet:ip-address;
260             }
261             leaf mpls-label1 {
262                 type netc:mpls-label;
263                 mandatory true;
264             }
265             leaf mpls-label2 {
266                 type netc:mpls-label;
267             }
268         }
269     }
270
271     grouping inc-multi-ethernet-tag-res {
272         container inc-multi-ethernet-tag-res {
273             reference "https://tools.ietf.org/html/rfc7432#section-7.3";
274             description "Inclusive Multicast Ethernet Tag route";
275
276             uses ethernet-tag-id;
277             leaf orig-route-ip {
278                 type inet:ip-address;
279             }
280         }
281     }
282
283     grouping es-route {
284         container es-route {
285             reference "https://tools.ietf.org/html/rfc7432#section-7.4";
286             description "Ethernet Segment route";
287
288             uses esi;
289             leaf orig-route-ip {
290                 type inet:ip-address;
291                 mandatory true;
292             }
293         }
294     }
295
296     grouping esi-label-extended-community {
297         container esi-label-extended-community {
298             reference "https://tools.ietf.org/html/rfc7432#section-7.5";
299             description "The ESI Label Extended Community is a transitive Extended
300                 Community that may be advertised along with Ethernet Auto-discovery
301                 routes, and it enables split-horizon procedures for multihomed sites";
302
303             leaf single-active-mode {
304                 type boolean;
305                 default false;
306             }
307             leaf esi-label {
308                 type netc:mpls-label;
309                 mandatory true;
310             }
311         }
312     }
313
314     grouping es-import-route-extended-community {
315         container es-import-route-extended-community {
316             reference "https://tools.ietf.org/html/rfc7432#section-7.6";
317             description
318                 "New transitive Route Target extended community carried with
319                 the Ethernet Segment route.  When used, it enables all the PEs
320                 connected to the same multihomed site to import the Ethernet Segment
321                 routes";
322
323             leaf es-import {
324                 type yang:mac-address;
325                 mandatory true;
326             }
327         }
328     }
329
330     grouping mac-mobility-extended-community {
331         container mac-mobility-extended-community {
332             reference "https://tools.ietf.org/html/rfc7432#section-7.7";
333             description
334                 "The MAC Mobility Extended Community is a transitive Extended Community
335                 that may be advertised along with MAC/IP Advertisement routes.";
336
337             leaf static {
338                 type boolean;
339                 default false;
340             }
341             leaf seq-number {
342                 type uint32;
343                 mandatory true;
344             }
345         }
346     }
347
348     grouping default-gateway-extended-community {
349         container default-gateway-extended-community {
350             presence
351                 "The Default Gateway community is an Extended Community of an
352                 Opaque Type";
353
354             reference "https://tools.ietf.org/html/rfc7432#section-7.8";
355
356             description
357                 "The Default Gateway community is an Extended Community of an
358                  Opaque Type ";
359         }
360     }
361
362     typedef operational-mode {
363         type enumeration {
364             enum vlan-aware-fxc {
365                 value 1;
366             }
367             enum vlan-unaware-fxc {
368                 value 2;
369             }
370         }
371     }
372
373     typedef normalization-type {
374         type enumeration {
375             enum single-vid {
376                 value 1;
377             }
378             enum double-vid {
379                 value 2;
380             }
381         }
382     }
383
384     grouping layer-2-attributes-extended-community {
385         container layer-2-attributes-extended-community {
386             reference "https://tools.ietf.org/html/draft-ietf-bess-evpn-vpws-02#section-3.1";
387             description
388                 "The EVPN Layer 2 attributes extended community is a extended community
389                 to be included with Ethernet A-D per EVI route.
390                 This attribute is mandatory if multihoming is enabled.";
391
392                 leaf primary-pe {
393                    type boolean;
394                    default false;
395                 }
396                 leaf backup-pe {
397                    type boolean;
398                    default false;
399                 }
400                 leaf control-word {
401                    type boolean;
402                    default false;
403                 }
404                 leaf mode-of-operation {
405                    reference "https://tools.ietf.org/html/draft-sajassi-bess-evpn-vpws-fxc-01#section-5";
406                    type operational-mode;
407                 }
408                 leaf operating-per {
409                    reference "https://tools.ietf.org/html/draft-sajassi-bess-evpn-vpws-fxc-01#section-5";
410                    type normalization-type;
411                 }
412                 leaf l2-mtu {
413                     type uint16;
414                     mandatory true;
415                 }
416         }
417     }
418
419     grouping evpn-destination {
420         list evpn-destination {
421             uses evpn;
422         }
423     }
424
425     grouping evpn-routes {
426         container evpn-routes {
427             list evpn-route {
428                 leaf route-key {
429                     type string;
430                 }
431                 key "route-key path-id";
432                 uses evpn;
433                 uses bgp-msg:path-id-grouping;
434                 uses bgp-rib:route {
435                     augment "attributes" {
436                         ext:augment-identifier pmsi-tunnel-augmentation;
437                         uses pmsi:pmsi-tunnel;
438                     }
439                     augment "attributes/extended-communities/extended-community" {
440                         case esi-label-extended-community-case {
441                             uses esi-label-extended-community;
442                         }
443                         case es-import-route-extended-community-case {
444                             uses es-import-route-extended-community;
445                         }
446                         case mac-mobility-extended-community-case {
447                             uses mac-mobility-extended-community;
448                         }
449                         case default-gateway-extended-community-case {
450                             uses default-gateway-extended-community;
451                         }
452                         case layer-2-attributes-extended-community-case {
453                             uses layer-2-attributes-extended-community;
454                         }
455                     }
456                 }
457             }
458         }
459     }
460
461     grouping evpn {
462         reference "https://tools.ietf.org/html/rfc7432#section-7";
463         description "The EVPN NLRI is carried in BGP [RFC4271] using BGP Multiprotocol
464             Extensions [RFC4760] with an Address Family Identifier (AFI) of 25 (L2VPN)
465             and a Subsequent Address Family Identifier (SAFI) of 70 (EVPN)";
466
467         choice evpn-choice {
468             case ethernet-a-d-route-case {
469                 uses ethernet-a-d-route;
470             }
471             case mac-ip-adv-route-case {
472                 uses mac-ip-adv-route;
473             }
474             case inc-multi-ethernet-tag-res-case {
475                 uses inc-multi-ethernet-tag-res;
476             }
477             case es-route-case {
478                 uses es-route;
479             }
480             mandatory true;
481         }
482
483         uses route-distinguisher;
484     }
485
486     augment "/bgp-msg:update/bgp-msg:attributes" {
487         uses pmsi:pmsi-tunnel;
488     }
489
490     augment "/bgp-msg:update/bgp-msg:attributes/bgp-mp:mp-reach-nlri/bgp-mp:advertized-routes/bgp-mp:destination-type" {
491         case destination-evpn-case {
492             container destination-evpn {
493                 uses evpn-destination;
494             }
495         }
496     }
497
498     augment "/bgp-msg:update/bgp-msg:attributes/bgp-mp:mp-unreach-nlri/bgp-mp:withdrawn-routes/bgp-mp:destination-type" {
499         case destination-evpn-case {
500             container destination-evpn {
501                 uses evpn-destination;
502             }
503         }
504     }
505
506     augment "/bgp-rib:application-rib/bgp-rib:tables/bgp-rib:routes" {
507         case evpn-routes-case {
508             uses evpn-routes;
509         }
510     }
511
512     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:loc-rib/bgp-rib:tables/bgp-rib:routes" {
513         case evpn-routes-case {
514             uses evpn-routes;
515         }
516     }
517
518     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:peer/bgp-rib:adj-rib-in/bgp-rib:tables/bgp-rib:routes" {
519         case evpn-routes-case {
520             uses evpn-routes;
521         }
522     }
523
524     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:peer/bgp-rib:effective-rib-in/bgp-rib:tables/bgp-rib:routes" {
525         case evpn-routes-case {
526             uses evpn-routes;
527         }
528     }
529
530     augment "/bgp-rib:bgp-rib/bgp-rib:rib/bgp-rib:peer/bgp-rib:adj-rib-out/bgp-rib:tables/bgp-rib:routes" {
531         case evpn-routes-case {
532             uses evpn-routes;
533         }
534     }
535
536     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" {
537         case evpn-routes-case {
538             uses evpn-routes;
539         }
540     }
541
542     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" {
543         case evpn-routes-case {
544             uses evpn-routes;
545         }
546     }
547
548     augment "/bgp-msg:update/bgp-msg:attributes/bgp-msg:extended-communities/bgp-msg:extended-community" {
549         case esi-label-extended-community-case {
550             uses esi-label-extended-community;
551         }
552         case es-import-route-extended-community-case {
553             uses es-import-route-extended-community;
554         }
555         case mac-mobility-extended-community-case {
556             uses mac-mobility-extended-community;
557         }
558         case default-gateway-extended-community-case {
559             uses default-gateway-extended-community;
560         }
561         case layer-2-attributes-extended-community-case {
562             uses layer-2-attributes-extended-community;
563         }
564     }
565 }