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