BUG-4931: Simple routing policy
[bgpcep.git] / bgp / rib-impl / src / main / yang / odl-bgp-rib-impl-cfg.yang
1 // vi: set smarttab et sw=4 tabstop=4:
2 module odl-bgp-rib-impl-cfg {
3     yang-version 1;
4     namespace "urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl";
5     prefix "bgprib-impl";
6
7     import bgp-multiprotocol { prefix bgp-mp; revision-date 2013-09-19; }
8     import bgp-rib { prefix rib; revision-date 2013-09-25; }
9     import bgp-types { prefix bgp-t; revision-date 2013-09-19; }
10     import odl-bgp-rib-cfg { prefix bgprib; revision-date 2013-07-01; }
11     import odl-bgp-parser-spi-cfg { prefix bgpspi; revision-date 2013-11-15; }
12     import odl-bgp-rib-spi-cfg { prefix ribspi; revision-date 2013-11-15; }
13     import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
14     import opendaylight-md-sal-binding {prefix mdsb; revision-date 2013-10-28; }
15     import opendaylight-md-sal-dom {prefix sal; revision-date 2013-10-28; }
16     import netty { prefix netty; revision-date 2013-11-19; }
17     import config { prefix config; revision-date 2013-04-05; }
18     import odl-tcpmd5-cfg { prefix tcpmd5; revision-date 2014-04-27; }
19     import odl-tcpmd5-netty-cfg { prefix tcpmd5n; revision-date 2014-04-27; }
20     import rpc-context { prefix rpcx; revision-date 2013-06-17; }
21     import odl-bgp-openconfig-spi-cfg { prefix bgp-oc-spi; revision-date 2015-09-25; }
22     import odl-bgp-path-selection-mode { prefix bps; revision-date 2016-03-01;}
23
24     organization "Cisco Systems, Inc.";
25
26     contact "Robert Varga <rovarga@cisco.com>";
27
28     description
29         "This module contains the base YANG definitions for
30          BGP listener implementation.
31
32         Copyright (c)2013 Cisco Systems, Inc. All rights reserved.;
33
34         This program and the accompanying materials are made available
35         under the terms of the Eclipse Public License v1.0 which
36         accompanies this distribution, and is available at
37         http://www.eclipse.org/legal/epl-v10.html";
38
39     revision "2016-03-30" {
40         description
41             "Updated to simplify reconnection strategy.";
42     }
43     revision "2013-04-09" {
44         description
45             "Initial revision";
46     }
47
48     identity base-bgp-parser {
49         base config:module-type;
50         config:java-name-prefix BaseBGPParser;
51         config:provided-service bgpspi:extension;
52     }
53
54     augment "/config:modules/config:module/config:configuration" {
55         case base-bgp-parser {
56             when "/config:modules/config:module/config:type = 'base-bgp-parser'";
57         }
58     }
59
60     identity bgp-dispatcher {
61         description
62             "Service representing a BGP Dispatcher.";
63
64         base "config:service-type";
65         config:java-class "org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher";
66     }
67
68     identity bgp-dispatcher-impl {
69         base config:module-type;
70         config:provided-service bgp-dispatcher;
71         config:java-name-prefix BGPDispatcherImpl;
72     }
73
74     augment "/config:modules/config:module/config:configuration" {
75         case bgp-dispatcher-impl {
76             when "/config:modules/config:module/config:type = 'bgp-dispatcher-impl'";
77
78             container bgp-extensions {
79                 uses config:service-ref {
80                     refine type {
81                         mandatory true;
82                         config:required-identity bgpspi:consumer-extensions;
83                     }
84                 }
85             }
86
87             container boss-group {
88                 uses config:service-ref {
89                     refine type {
90                         mandatory true;
91                         config:required-identity netty:netty-threadgroup;
92                     }
93                 }
94             }
95
96             container worker-group {
97                 uses config:service-ref {
98                     refine type {
99                         mandatory true;
100                         config:required-identity netty:netty-threadgroup;
101                     }
102                 }
103             }
104
105             container md5-channel-factory {
106                 uses config:service-ref {
107                     refine type {
108                         mandatory false;
109                         config:required-identity tcpmd5n:md5-channel-factory;
110                     }
111                 }
112             }
113
114             container md5-server-channel-factory {
115                 uses config:service-ref {
116                     refine type {
117                         mandatory false;
118                         config:required-identity tcpmd5n:md5-server-channel-factory;
119                     }
120                 }
121             }
122         }
123     }
124
125     identity base-bgp-rib {
126         base config:module-type;
127         config:provided-service ribspi:extension;
128         config:java-name-prefix BaseBGPRIB;
129     }
130
131     augment "/config:modules/config:module/config:configuration" {
132         case base-bgp-rib {
133             when "/config:modules/config:module/config:type = 'base-bgp-rib'";
134         }
135     }
136
137     identity rib-instance {
138         description
139             "Service representing a RIB instance";
140
141         base "config:service-type";
142         config:java-class "org.opendaylight.protocol.bgp.rib.impl.spi.RIB";
143     }
144
145     identity bgp-peer-registry {
146         description
147             "Registry of BGP peers. Every new BGP in/out connection looks for peers to handle bgp messages in this registry";
148
149         base "config:service-type";
150         config:java-class "org.opendaylight.protocol.bgp.rib.impl.spi.BGPPeerRegistry";
151     }
152
153     identity strict-bgp-peer-registry {
154         description
155             "Registry of BGP peers that allows only one connection per 2 peers. Uses IP address for Peer identification and BGP Ids to resolve duplicate connections";
156
157         config:provided-service bgp-peer-registry;
158         base config:module-type;
159         config:java-name-prefix StrictBgpPeerRegistry;
160     }
161
162
163     augment "/config:modules/config:module/config:configuration" {
164         case strict-bgp-peer-registry {
165             when "/config:modules/config:module/config:type = 'strict-bgp-peer-registry'";
166         }
167     }
168
169     identity bgp-peer {
170         description
171             "BGP peer instance.";
172
173         base config:module-type;
174         config:java-name-prefix BGPPeer;
175     }
176
177     identity bgp-peer-acceptor {
178         description
179             "BGP peer acceptor that handles incoming bgp connections. Uses BGP peer registry to accept or decline incoming connections";
180
181         base config:module-type;
182         config:java-name-prefix BGPPeerAcceptor;
183     }
184
185     augment "/config:modules/config:module/config:configuration" {
186         case bgp-peer-acceptor {
187             when "/config:modules/config:module/config:type = 'bgp-peer-acceptor'";
188
189             leaf binding-address {
190                 description "IP address to bind to";
191                 type inet:ip-address;
192                 default "0.0.0.0";
193             }
194
195             leaf binding-port {
196                 description "Port to bind to";
197                 type inet:port-number;
198                 default "179";
199             }
200
201             container accepting-bgp-dispatcher {
202                 uses config:service-ref {
203                     refine type {
204                         mandatory true;
205                         config:required-identity bgp-dispatcher;
206                     }
207                 }
208             }
209
210             container accepting-peer-registry {
211                 uses config:service-ref {
212                     refine type {
213                         mandatory true;
214                         config:required-identity bgp-peer-registry;
215                     }
216                 }
217             }
218         }
219     }
220
221     identity bgp-application-peer {
222         description
223             "Application peer handler which handles translation from custom RIB into local RIB";
224
225         base config:module-type;
226         config:java-name-prefix BGPApplicationPeer;
227     }
228
229     augment "/config:modules/config:module/config:configuration" {
230         case bgp-application-peer {
231             when "/config:modules/config:module/config:type = 'bgp-application-peer'";
232
233             container data-broker {
234                 uses config:service-ref {
235                     refine type {
236                         mandatory true;
237                         config:required-identity sal:dom-async-data-broker;
238                     }
239                 }
240             }
241
242             container target-rib {
243                 uses config:service-ref {
244                     refine type {
245                         mandatory true;
246                         config:required-identity rib-instance;
247                     }
248                 }
249             }
250
251             container bgp-peer-registry {
252                 description "BGP peer registry where current instance of BGP peer will be registered.";
253                 uses config:service-ref {
254                     refine type {
255                         // FIXME backwards compatibility. If not configured, GLOBAL instance is used
256                         mandatory false;
257                         config:required-identity bgp-peer-registry;
258                     }
259                 }
260             }
261
262             leaf application-rib-id {
263                 type rib:application-rib-id;
264                 mandatory true;
265             }
266
267             leaf bgp-peer-id {
268                 type inet:ipv4-address;
269                 mandatory true;
270             }
271         }
272     }
273
274     identity bgp-table-type {
275         description
276             "Service representing a AFI/SAFI pair";
277
278         base "config:service-type";
279         config:java-class "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.BgpTableType";
280     }
281
282     identity add-path {
283         base "config:service-type";
284         config:java-class "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.mp.capabilities.add.path.capability.AddressFamilies";
285     }
286
287     identity add-path-impl {
288         config:provided-service add-path;
289         base config:module-type;
290         config:java-name-prefix AddPathImpl;
291     }
292
293     identity bgp-table-type-impl {
294         description
295             "Simple provider for bgp-table-type.";
296
297         config:provided-service bgp-table-type;
298         base config:module-type;
299         config:java-name-prefix BGPTableTypeImpl;
300     }
301
302     augment "/config:modules/config:module/config:configuration" {
303         case bgp-table-type-impl {
304             when "/config:modules/config:module/config:type = 'bgp-table-type-impl'";
305
306             leaf afi {
307                 type identityref {
308                     base bgp-t:address-family;
309                 }
310                 mandatory true;
311             }
312             leaf safi {
313                 type identityref {
314                     base bgp-t:subsequent-address-family;
315                 }
316                 mandatory true;
317             }
318         }
319     }
320
321     augment "/config:modules/config:module/config:configuration" {
322         case add-path-impl {
323             when "/config:modules/config:module/config:type = 'add-path-impl'";
324             container address-family {
325                 uses config:service-ref {
326                     refine type {
327                         mandatory true;
328                         config:required-identity bgp-table-type;
329                     }
330                 }
331             }
332             leaf send-receive {
333                 type bgp-mp:send-receive;
334                 mandatory true;
335             }
336         }
337     }
338
339     augment "/config:modules/config:module/config:configuration" {
340         case bgp-peer {
341             when "/config:modules/config:module/config:type = 'bgp-peer'";
342
343             leaf host {
344                 description "Remote host IP address";
345                 type inet:ip-address;
346                 mandatory true;
347             }
348
349             leaf port {
350                 description "Remote host port";
351                 type inet:port-number;
352                 default 179;
353             }
354
355             leaf holdtimer {
356                 type int16;
357                 default 180;
358             }
359
360             leaf retrytimer {
361                 type int16;
362                 default 10;
363             }
364
365             leaf peer-role {
366                 type rib:peer-role;
367                 default ibgp;
368             }
369
370             leaf simple-routing-policy {
371                 type rib:simple-routing-policy;
372             }
373
374             leaf initiate-connection {
375                 description "If true, connection will be initiated right away from current device.
376                     If not, the peer will only be registered to peer registry and available for incomming bgp connections.";
377                 type boolean;
378                 default true;
379             }
380
381             list advertized-table {
382                 key "type name";
383                 uses config:service-ref {
384                     refine type {
385                         mandatory true;
386                         config:required-identity bgp-table-type;
387                     }
388                 }
389             }
390
391             list add-path {
392                 key "type name";
393                 uses config:service-ref {
394                     refine type {
395                         config:required-identity add-path;
396                     }
397                 }
398             }
399
400             leaf route-refresh {
401                 type boolean;
402                 default "true";
403             }
404
405             leaf remote-as {
406                 description
407                     "Expected remote AS number. If not present, it is assumed
408                     to be the same as our local AS number.";
409                 type uint32;
410             }
411
412             leaf password {
413                 type tcpmd5:rfc2385-key;
414                 description "RFC2385 shared secret";
415             }
416
417             container rib {
418                 uses config:service-ref {
419                     refine type {
420                         mandatory true;
421                         config:required-identity rib-instance;
422                     }
423                 }
424             }
425
426             container peer-registry {
427                 description "BGP peer registry where current instance of BGP peer will be registered.";
428                 uses config:service-ref {
429                     refine type {
430                         // FIXME backwards compatibility. If not configured, GLOBAL instance is used
431                         mandatory false;
432                         config:required-identity bgp-peer-registry;
433                     }
434                 }
435             }
436             container rpc-registry {
437                 uses config:service-ref {
438                     refine type {
439                         mandatory false;
440                         config:required-identity mdsb:binding-rpc-registry;
441                     }
442                 }
443             }
444         }
445     }
446
447     grouping message-state {
448         leaf count {
449             description "Total number of BGP messages.";
450             type uint32;
451             default 0;
452         }
453
454         leaf timestamp {
455             description "The BGP message timestamp (seconds).";
456             type uint32;
457             default 0;
458         }
459     }
460
461     grouping message-stats {
462         container received {
463             description "The received BGP messages statistics.";
464             uses message-state;
465         }
466
467         container sent {
468             description "The sent BGP messages statistics.";
469             uses message-state;
470         }
471     }
472
473     grouping error {
474         leaf code {
475             description "The BGP error code.";
476             type uint8;
477             default 0;
478         }
479
480         leaf sub-code {
481             description "The BGP error sub-code.";
482             type uint8;
483             default 0;
484         }
485     }
486
487     grouping afi-safi {
488         leaf afi {
489             description "Address Family Identifier.";
490             type string;
491             default "";
492         }
493         leaf safi {
494             description "Subsequent Address Family Identifier.";
495             type string;
496             default "";
497         }
498     }
499
500     grouping preferences {
501         leaf bgp-id {
502             description "The BGP Identifier.";
503             type string;
504             default "";
505         }
506
507         leaf address {
508             description "The IP address of BGP connection.";
509             type string;
510             default "";
511         }
512
513         leaf port {
514             description "The port for connection between the BGP peers.";
515             type uint16;
516             default 0;
517         }
518
519         leaf as {
520             description "Autonomous system number.";
521             type uint32;
522             default 0;
523         }
524
525         leaf holdtime {
526             description "Time interval (in seconds) for HoldTimer proposed by the peer.";
527             type uint16;
528             default 0;
529         }
530
531         leaf four-octet-as-capability {
532             description "The BGP peer 4 byte AS numbers support capability.";
533             type boolean;
534             default "false";
535         }
536
537         leaf bgp-extended-message-capability {
538             description "The bgp extended message support capability.";
539             type boolean;
540             default "false";
541         }
542
543         leaf gr-capability {
544             description "BGP graceful restart support capability.";
545             type boolean;
546             default "false";
547         }
548
549         leaf add-path-capability {
550             type boolean;
551             default "false";
552         }
553
554         leaf route-refresh-capability {
555             reference "https://tools.ietf.org/html/rfc2918";
556             type boolean;
557             default "false";
558         }
559
560         list advertized-table-types {
561             description "The BGP Table-type capabilities advertized by the BGP peer.";
562             uses afi-safi;
563         }
564
565         list advertised-add-path-table-types {
566             description "The BGP Table-type capabilities advertized by the BGP peer.";
567             uses afi-safi;
568             leaf send-receive {
569                 description "Send Receive Add Path Configuration.";
570                 type string;
571                 default "";
572             }
573         }
574     }
575
576     identity peer-rpc;
577
578     augment "/config:modules/config:module/config:state" {
579         case bgp-peer {
580             when "/config:modules/config:module/config:type = 'bgp-peer'";
581
582             rpcx:rpc-context-instance "peer-rpc";
583
584             container bgp-peer-state {
585                 list route-table {
586
587                     leaf table-type {
588                         description "The table name - composed of AFI and SAFI.";
589                         type string;
590                     }
591
592                     leaf routes-count {
593                         description "The total number of routes in table.";
594                         type uint32;
595                         default 0;
596                     }
597                 }
598
599                 leaf session-established-count {
600                     description "The total number of time the BGP session was transitioned to Up state.";
601                     type uint32;
602                     default 0;
603                 }
604             }
605
606             container bgp-session-state {
607
608                 leaf session-state {
609                     description "The BGP peer connection state.";
610                     type string;
611                 }
612
613                 leaf session-duration {
614                     description "The session duration (time formated d:HH:mm:ss).";
615                     type string;
616                 }
617
618                 leaf holdtime-current {
619                     description "Time interval (in seconds) for HoldTimer established with the peer.";
620                     type uint16;
621                     default 0;
622                 }
623
624                 leaf keepalive-current {
625                     description "Time interval (in seconds) for KeepAlive established with the peer.";
626                     type uint16;
627                     default 0;
628                 }
629
630                 container speaker-preferences {
631                     description "The BGP speaker preferences, to which this BGP peer is connected.";
632                     uses preferences;
633                 }
634
635                 container peer-preferences {
636                     description "The BGP peer preferences.";
637                     uses preferences;
638                 }
639
640                 container messages-stats {
641                     description "The BGP messages statistics.";
642                     container total-msgs {
643                         description "The statistics for all received/sent BGP messages.";
644                         uses message-stats;
645                     }
646
647                     container keep-alive-msgs {
648                         description "The statistics for received/sent BGP Keep-Alive messages.";
649                         uses message-stats;
650                     }
651
652                     container update-msgs {
653                         description "The statistics for received/sent BGP Update messages.";
654                         uses message-stats;
655                     }
656
657                     container route-refresh-msgs {
658                         description "The statistics for received/sent BGP Route Refresh messages.";
659                         uses message-stats;
660                     }
661
662                     container error-msgs {
663                         container error-received {
664                             description "The received BGP Error (notification) messages statistics.";
665                             uses message-state;
666                             uses error;
667                         }
668
669                         container error-sent {
670                             description "The sent BGP Error (notification) messages statistics.";
671                             uses message-state;
672                             uses error;
673                         }
674                     }
675                 }
676             }
677         }
678     }
679
680     rpc reset-session {
681         description "Restart the session between BGP peers";
682         input {
683             uses rpcx:rpc-context-ref {
684                 refine context-instance {
685                     rpcx:rpc-context-instance peer-rpc;
686                 }
687             }
688         }
689      }
690
691      rpc reset-stats {
692         description "Reset the BGP peer statistics.";
693         input {
694             uses rpcx:rpc-context-ref {
695                 refine context-instance {
696                     rpcx:rpc-context-instance peer-rpc;
697                 }
698             }
699         }
700      }
701
702     identity bgp-path-selection-mode {
703         description
704             "Service representing an address family + path selection mode.";
705
706         base "config:service-type";
707         config:java-class "org.opendaylight.protocol.bgp.rib.impl.spi.BGPBestPathSelection";
708     }
709
710     identity bgp-psm-impl {
711         base config:module-type;
712         config:provided-service bgp-path-selection-mode;
713         config:java-name-prefix BGPPSMImpl;
714     }
715
716     augment "/config:modules/config:module/config:configuration" {
717         case bgp-psm-impl {
718             when "/config:modules/config:module/config:type = 'bgp-psm-impl'";
719             container path-address-family {
720                 uses config:service-ref {
721                     refine type {
722                         mandatory true;
723                         config:required-identity bgp-table-type;
724                     }
725                 }
726             }
727             container path-selection-mode {
728                 uses config:service-ref {
729                     refine type {
730                         mandatory true;
731                         config:required-identity bps:path-selection-mode-factory;
732                     }
733                 }
734             }
735         }
736     }
737
738     identity rib-impl {
739         base config:module-type;
740         config:provided-service bgprib:rib;
741         config:provided-service rib-instance;
742         config:java-name-prefix RIBImpl;
743     }
744
745     augment "/config:modules/config:module/config:configuration" {
746         case rib-impl {
747             when "/config:modules/config:module/config:type = 'rib-impl'";
748
749             container extensions {
750                 uses config:service-ref {
751                     refine type {
752                         mandatory true;
753                         config:required-identity ribspi:consumer-extensions;
754                     }
755                 }
756             }
757
758             container bgp-dispatcher {
759                 uses config:service-ref {
760                     refine type {
761                         mandatory true;
762                         config:required-identity bgp-dispatcher;
763                     }
764                 }
765             }
766
767             container data-provider {
768                 uses config:service-ref {
769                     refine type {
770                         mandatory true;
771                         config:required-identity mdsb:binding-async-data-broker;
772                     }
773                 }
774             }
775
776             container codec-tree-factory {
777                 uses config:service-ref {
778                     refine type {
779                         mandatory true;
780                         config:required-identity mdsb:binding-codec-tree-factory;
781                     }
782                 }
783             }
784
785             container dom-data-provider {
786                 uses config:service-ref {
787                     refine type {
788                         mandatory true;
789                         config:required-identity sal:dom-async-data-broker;
790                     }
791                 }
792             }
793
794             container openconfig-provider {
795                 uses config:service-ref {
796                     refine type {
797                         mandatory false;
798                         config:required-identity bgp-oc-spi:bgp-openconfig-provider;
799                     }
800                 }
801             }
802
803             leaf local-as {
804                 description "Our local AS number. Needed by best selection path attribute.";
805                 type uint32;
806                 mandatory true;
807             }
808
809             leaf bgp-rib-id {
810                 description "Our local BGP identifier. Needed by best selection path attribute.";
811                 mandatory true;
812                 type inet:ipv4-address;
813             }
814
815             list local-table {
816                 uses config:service-ref {
817                     refine type {
818                         mandatory true;
819                         config:required-identity bgp-table-type;
820                     }
821                 }
822             }
823
824             leaf rib-id {
825                 description "Identifier of this RIB in local data store.";
826                 type rib:rib-id;
827                 mandatory true;
828             }
829
830             leaf cluster-id {
831                 description "IBGP identifier. Needed by route reflection.";
832                 reference "https://tools.ietf.org/html/rfc4456#section-7";
833                 type inet:ipv4-address;
834             }
835
836             list rib-path-selection-mode {
837                 uses config:service-ref {
838                     refine type {
839                         config:required-identity bgp-path-selection-mode;
840                     }
841                 }
842             }
843         }
844     }
845 }
846