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