Bug-5023: Simplify client re-connection strategies
[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 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 initiate-connection {
371                 description "If true, connection will be initiated right away from current device.
372                     If not, the peer will only be registered to peer registry and available for incomming bgp connections.";
373                 type boolean;
374                 default true;
375             }
376
377             list advertized-table {
378                 key "type name";
379                 uses config:service-ref {
380                     refine type {
381                         mandatory true;
382                         config:required-identity bgp-table-type;
383                     }
384                 }
385             }
386
387             list add-path {
388                 key "type name";
389                 uses config:service-ref {
390                     refine type {
391                         config:required-identity add-path;
392                     }
393                 }
394             }
395
396             leaf route-refresh {
397                 type boolean;
398                 default "true";
399             }
400
401             leaf remote-as {
402                 description
403                     "Expected remote AS number. If not present, it is assumed
404                     to be the same as our local AS number.";
405                 type uint32;
406             }
407
408             leaf password {
409                 type tcpmd5:rfc2385-key;
410                 description "RFC2385 shared secret";
411             }
412
413             container rib {
414                 uses config:service-ref {
415                     refine type {
416                         mandatory true;
417                         config:required-identity rib-instance;
418                     }
419                 }
420             }
421
422             container peer-registry {
423                 description "BGP peer registry where current instance of BGP peer will be registered.";
424                 uses config:service-ref {
425                     refine type {
426                         // FIXME backwards compatibility. If not configured, GLOBAL instance is used
427                         mandatory false;
428                         config:required-identity bgp-peer-registry;
429                     }
430                 }
431             }
432         }
433     }
434
435     grouping message-state {
436         leaf count {
437             description "Total number of BGP messages.";
438             type uint32;
439             default 0;
440         }
441
442         leaf timestamp {
443             description "The BGP message timestamp (seconds).";
444             type uint32;
445             default 0;
446         }
447     }
448
449     grouping message-stats {
450         container received {
451             description "The received BGP messages statistics.";
452             uses message-state;
453         }
454
455         container sent {
456             description "The sent BGP messages statistics.";
457             uses message-state;
458         }
459     }
460
461     grouping error {
462         leaf code {
463             description "The BGP error code.";
464             type uint8;
465             default 0;
466         }
467
468         leaf sub-code {
469             description "The BGP error sub-code.";
470             type uint8;
471             default 0;
472         }
473     }
474
475     grouping afi-safi {
476         leaf afi {
477             description "Address Family Identifier.";
478             type string;
479             default "";
480         }
481         leaf safi {
482             description "Subsequent Address Family Identifier.";
483             type string;
484             default "";
485         }
486     }
487
488     grouping preferences {
489         leaf bgp-id {
490             description "The BGP Identifier.";
491             type string;
492             default "";
493         }
494
495         leaf address {
496             description "The IP address of BGP connection.";
497             type string;
498             default "";
499         }
500
501         leaf port {
502             description "The port for connection between the BGP peers.";
503             type uint16;
504             default 0;
505         }
506
507         leaf as {
508             description "Autonomous system number.";
509             type uint32;
510             default 0;
511         }
512
513         leaf holdtime {
514             description "Time interval (in seconds) for HoldTimer proposed by the peer.";
515             type uint16;
516             default 0;
517         }
518
519         leaf four-octet-as-capability {
520             description "The BGP peer 4 byte AS numbers support capability.";
521             type boolean;
522             default "false";
523         }
524
525         leaf bgp-extended-message-capability {
526             description "The bgp extended message support capability.";
527             type boolean;
528             default "false";
529         }
530
531         leaf gr-capability {
532             description "BGP graceful restart support capability.";
533             type boolean;
534             default "false";
535         }
536
537         leaf add-path-capability {
538             type boolean;
539             default "false";
540         }
541
542         leaf route-refresh-capability {
543             reference "https://tools.ietf.org/html/rfc2918";
544             type boolean;
545             default "false";
546         }
547
548         list advertized-table-types {
549             description "The BGP Table-type capabilities advertized by the BGP peer.";
550             uses afi-safi;
551         }
552
553         list advertised-add-path-table-types {
554             description "The BGP Table-type capabilities advertized by the BGP peer.";
555             uses afi-safi;
556             leaf send-receive {
557                 description "Send Receive Add Path Configuration.";
558                 type string;
559                 default "";
560             }
561         }
562     }
563
564     identity peer-rpc;
565
566     augment "/config:modules/config:module/config:state" {
567         case bgp-peer {
568             when "/config:modules/config:module/config:type = 'bgp-peer'";
569
570             rpcx:rpc-context-instance "peer-rpc";
571
572             container bgp-peer-state {
573                 list route-table {
574
575                     leaf table-type {
576                         description "The table name - composed of AFI and SAFI.";
577                         type string;
578                     }
579
580                     leaf routes-count {
581                         description "The total number of routes in table.";
582                         type uint32;
583                         default 0;
584                     }
585                 }
586
587                 leaf session-established-count {
588                     description "The total number of time the BGP session was transitioned to Up state.";
589                     type uint32;
590                     default 0;
591                 }
592             }
593
594             container bgp-session-state {
595
596                 leaf session-state {
597                     description "The BGP peer connection state.";
598                     type string;
599                 }
600
601                 leaf session-duration {
602                     description "The session duration (time formated d:HH:mm:ss).";
603                     type string;
604                 }
605
606                 leaf holdtime-current {
607                     description "Time interval (in seconds) for HoldTimer established with the peer.";
608                     type uint16;
609                     default 0;
610                 }
611
612                 leaf keepalive-current {
613                     description "Time interval (in seconds) for KeepAlive established with the peer.";
614                     type uint16;
615                     default 0;
616                 }
617
618                 container speaker-preferences {
619                     description "The BGP speaker preferences, to which this BGP peer is connected.";
620                     uses preferences;
621                 }
622
623                 container peer-preferences {
624                     description "The BGP peer preferences.";
625                     uses preferences;
626                 }
627
628                 container messages-stats {
629                     description "The BGP messages statistics.";
630                     container total-msgs {
631                         description "The statistics for all received/sent BGP messages.";
632                         uses message-stats;
633                     }
634
635                     container keep-alive-msgs {
636                         description "The statistics for received/sent BGP Keep-Alive messages.";
637                         uses message-stats;
638                     }
639
640                     container update-msgs {
641                         description "The statistics for received/sent BGP Update messages.";
642                         uses message-stats;
643                     }
644
645                     container route-refresh-msgs {
646                         description "The statistics for received/sent BGP Route Refresh messages.";
647                         uses message-stats;
648                     }
649
650                     container error-msgs {
651                         container error-received {
652                             description "The received BGP Error (notification) messages statistics.";
653                             uses message-state;
654                             uses error;
655                         }
656
657                         container error-sent {
658                             description "The sent BGP Error (notification) messages statistics.";
659                             uses message-state;
660                             uses error;
661                         }
662                     }
663                 }
664             }
665         }
666     }
667
668     rpc reset-session {
669         description "Restart the session between BGP peers";
670         input {
671             uses rpcx:rpc-context-ref {
672                 refine context-instance {
673                     rpcx:rpc-context-instance peer-rpc;
674                 }
675             }
676         }
677      }
678
679      rpc reset-stats {
680         description "Reset the BGP peer statistics.";
681         input {
682             uses rpcx:rpc-context-ref {
683                 refine context-instance {
684                     rpcx:rpc-context-instance peer-rpc;
685                 }
686             }
687         }
688      }
689
690     identity bgp-path-selection-mode {
691         description
692             "Service representing an address family + path selection mode.";
693
694         base "config:service-type";
695         config:java-class "org.opendaylight.protocol.bgp.rib.impl.spi.BGPBestPathSelection";
696     }
697
698     identity bgp-psm-impl {
699         base config:module-type;
700         config:provided-service bgp-path-selection-mode;
701         config:java-name-prefix BGPPSMImpl;
702     }
703
704     augment "/config:modules/config:module/config:configuration" {
705         case bgp-psm-impl {
706             when "/config:modules/config:module/config:type = 'bgp-psm-impl'";
707             container path-address-family {
708                 uses config:service-ref {
709                     refine type {
710                         mandatory true;
711                         config:required-identity bgp-table-type;
712                     }
713                 }
714             }
715             container path-selection-mode {
716                 uses config:service-ref {
717                     refine type {
718                         mandatory true;
719                         config:required-identity bps:path-selection-mode-factory;
720                     }
721                 }
722             }
723         }
724     }
725
726     identity rib-impl {
727         base config:module-type;
728         config:provided-service bgprib:rib;
729         config:provided-service rib-instance;
730         config:java-name-prefix RIBImpl;
731     }
732
733     augment "/config:modules/config:module/config:configuration" {
734         case rib-impl {
735             when "/config:modules/config:module/config:type = 'rib-impl'";
736
737             container extensions {
738                 uses config:service-ref {
739                     refine type {
740                         mandatory true;
741                         config:required-identity ribspi:consumer-extensions;
742                     }
743                 }
744             }
745
746             container bgp-dispatcher {
747                 uses config:service-ref {
748                     refine type {
749                         mandatory true;
750                         config:required-identity bgp-dispatcher;
751                     }
752                 }
753             }
754
755             container data-provider {
756                 uses config:service-ref {
757                     refine type {
758                         mandatory true;
759                         config:required-identity mdsb:binding-async-data-broker;
760                     }
761                 }
762             }
763
764             container codec-tree-factory {
765                 uses config:service-ref {
766                     refine type {
767                         mandatory true;
768                         config:required-identity mdsb:binding-codec-tree-factory;
769                     }
770                 }
771             }
772
773             container dom-data-provider {
774                 uses config:service-ref {
775                     refine type {
776                         mandatory true;
777                         config:required-identity sal:dom-async-data-broker;
778                     }
779                 }
780             }
781
782             container openconfig-provider {
783                 uses config:service-ref {
784                     refine type {
785                         mandatory false;
786                         config:required-identity bgp-oc-spi:bgp-openconfig-provider;
787                     }
788                 }
789             }
790
791             leaf local-as {
792                 description "Our local AS number. Needed by best selection path attribute.";
793                 type uint32;
794                 mandatory true;
795             }
796
797             leaf bgp-rib-id {
798                 description "Our local BGP identifier. Needed by best selection path attribute.";
799                 mandatory true;
800                 type inet:ipv4-address;
801             }
802
803             list local-table {
804                 uses config:service-ref {
805                     refine type {
806                         mandatory true;
807                         config:required-identity bgp-table-type;
808                     }
809                 }
810             }
811
812             leaf rib-id {
813                 description "Identifier of this RIB in local data store.";
814                 type rib:rib-id;
815                 mandatory true;
816             }
817
818             leaf cluster-id {
819                 description "IBGP identifier. Needed by route reflection.";
820                 reference "https://tools.ietf.org/html/rfc4456#section-7";
821                 type inet:ipv4-address;
822             }
823
824             list path-selection-mode {
825                 uses config:service-ref {
826                     refine type {
827                         config:required-identity bgp-path-selection-mode;
828                     }
829                 }
830             }
831         }
832     }
833 }
834