--- /dev/null
+module ietf-bgp {
+ yang-version 1.1;
+ namespace "urn:ietf:params:xml:ns:yang:ietf-bgp";
+ prefix bgp;
+
+ /*
+ * Import and Include
+ */
+
+ import ietf-routing {
+ prefix rt;
+ reference
+ "RFC 8349, A YANG Data Model for Routing Management
+ (NMDA Version)";
+ }
+ import ietf-routing-policy {
+ prefix rpol;
+ reference
+ "RFC ZZZZ, A YANG Data Model for Routing Policy Management";
+ }
+ import ietf-interfaces {
+ prefix if;
+ reference
+ "RFC 8343, A YANG Data Model for Interface Management.";
+ }
+ import ietf-bgp-types {
+ prefix bt;
+ reference
+ "RFC XXXX, BGP YANG Model for Service Provider Network.";
+ }
+ import ietf-bfd-types {
+ prefix bfd;
+ reference
+
+ "RFC BBBB, YANG Data Model for Bidirectional Forward Detection.";
+ }
+ import ietf-inet-types {
+ prefix inet;
+ reference
+ "RFC 6991: Common YANG Data Types.";
+ }
+ import ietf-yang-types {
+ prefix yang;
+ reference
+ "RFC 6991: Common YANG Data Types.";
+ }
+
+
+ include ietf-bgp-common;
+ include ietf-bgp-common-multiprotocol;
+ include ietf-bgp-common-structure;
+ include ietf-bgp-neighbor;
+ include ietf-bgp-peer-group;
+ include ietf-bgp-rib-types;
+ include ietf-bgp-rib;
+ include ietf-bgp-rib-ext;
+ include ietf-bgp-rib-attributes;
+ include ietf-bgp-rib-table-attributes;
+ include ietf-bgp-rib-tables;
+
+ organization
+ "IETF IDR Working Group";
+ contact
+ "WG Web: <http://tools.ietf.org/wg/idr>
+ WG List: <idr@ietf.org>
+
+ Authors: Mahesh Jethanandani (mjethanandani at gmail.com),
+ Keyur Patel (keyur at arrcus.com),
+ Susan Hares (shares at ndzh.com";
+ description
+ "This module describes a YANG model for BGP protocol
+ configuration. It is a limited subset of all of the configuration
+ parameters available in the variety of vendor implementations,
+ hence it is expected that it would be augmented with vendor-
+ specific configuration data as needed. Additional modules or
+ submodules to handle other aspects of BGP configuration,
+ including policy, VRFs, VPNs, and additional address families
+ are also expected.
+
+ This model supports the following BGP configuration level
+ hierarchy:
+
+ BGP
+ |
+ +-> [ global BGP configuration ]
+ +-> AFI / SAFI global
+ +-> peer group
+ +-> [ peer group config ]
+ +-> AFI / SAFI [ per-AFI overrides ]
+ +-> neighbor
+ +-> [ neighbor config ]
+ +-> [ optional pointer to peer-group ]
+ +-> AFI / SAFI [ per-AFI overrides ]";
+
+ revision 2019-06-13 {
+ description
+ "Initial Version";
+ reference
+ "RFC XXXX, BGP Model for Service Provider Network ";
+ }
+
+ /*
+ * Identity
+ */
+
+ identity bgp {
+ base rt:routing-protocol;
+ description
+ "BGP protocol.";
+ }
+
+ /*
+ * Feature(s)
+ */
+ feature clear-routes {
+ description
+ "Clearing of BGP routes is supported.";
+ }
+
+ feature clear-neighbors {
+ description
+ "Clearing of BGP neighbors is supported.";
+ }
+
+ feature clear-statistics {
+ description
+ "Clearing of BGP statistics is supported.";
+ }
+
+ /*
+
+ * Containers
+ */
+
+ augment "/rt:routing/rt:control-plane-protocols/"
+ + "rt:control-plane-protocol" {
+ when "derived-from-or-self(rt:type, 'bgp')" {
+ description
+ "This augmentation is valid for a routing protocol
+ instance of BGP.";
+ }
+ description
+ "BGP protocol augmentation of ietf-routing module
+ control-plane-protocol.";
+
+ container bgp {
+ description
+ "Top-level configuration for the BGP router";
+ container global {
+ presence "Enables global configuration of BGP";
+ description
+ "Global configuration for the BGP router";
+
+ leaf as {
+ type inet:as-number;
+ mandatory true;
+ description
+ "Local autonomous system number of the router. Uses
+ the 32-bit as-number type from the model in RFC 6991.";
+ }
+
+ leaf identifier {
+ type yang:dotted-quad;
+ description
+ "BGP Identifier of the router - an unsigned 32-bit,
+ non-zero integer that should be unique within an AS.
+ The value of the BGP Identifier for a BGP speaker is
+ determined upon startup and is the same for every local
+ interface and BGP peer.";
+ reference
+ "RFC 6286: AS-Wide Unique BGP ID for BGP-4. Section 2.1";
+ }
+
+ container default-route-distance {
+ description
+ "Administrative distance (or preference) assigned to
+ routes received from different sources
+ (external, internal, and local).";
+
+ leaf external-route-distance {
+ type uint8 {
+ range "1..255";
+ }
+ description
+ "Administrative distance for routes learned from
+ external BGP (eBGP).";
+ }
+ leaf internal-route-distance {
+ type uint8 {
+ range "1..255";
+ }
+ description
+ "Administrative distance for routes learned from
+ internal BGP (iBGP).";
+ }
+ }
+
+ container confederation {
+ description
+ "Configuration options specifying parameters when the
+ local router is within an autonomous system which is
+ part of a BGP confederation.";
+
+ leaf enabled {
+ type boolean;
+ description
+ "When this leaf is set to true it indicates that
+ the local-AS is part of a BGP confederation";
+ }
+
+ leaf identifier {
+ type inet:as-number;
+ description
+ "Confederation identifier for the autonomous system.";
+ }
+
+ leaf-list member-as {
+ type inet:as-number;
+ description
+ "Remote autonomous systems that are to be treated
+ as part of the local confederation.";
+ }
+ }
+
+ container graceful-restart {
+ description
+ "Parameters relating the graceful restart mechanism for
+
+ BGP";
+ uses graceful-restart-config;
+ }
+
+ uses global-group-use-multiple-paths;
+ uses route-selection-options;
+
+ container afi-safis {
+ description
+ "List of address-families associated with the BGP
+ instance";
+ list afi-safi {
+ key "afi-safi-name";
+
+ description
+ "AFI,SAFI configuration available for the
+ neighbour or group";
+
+ uses mp-afi-safi-config;
+ uses state;
+
+ container graceful-restart {
+ description
+ "Parameters relating to BGP graceful-restart";
+
+ uses mp-afi-safi-graceful-restart-config;
+ }
+
+ uses route-selection-options;
+ uses global-group-use-multiple-paths;
+ uses mp-all-afi-safi-list-contents;
+ }
+ }
+ uses rpol:apply-policy-group;
+ uses state;
+ }
+
+ container neighbors {
+ description
+ "Configuration for BGP neighbors";
+
+ list neighbor {
+ key "remote-address";
+
+ description
+ "List of BGP neighbors configured on the local system,
+ uniquely identified by remote IPv[46] address";
+
+ leaf local-address {
+ type inet:ip-address;
+ config false;
+ description
+ "The local IP address of this entry's BGP connection.";
+ }
+
+ leaf local-port {
+ type inet:port-number {
+ range "0..65535";
+ }
+ config false;
+ description
+ "The local port for the TCP connection between
+ the BGP peers.";
+ }
+
+ leaf peer-group {
+ type leafref {
+ path "../../../peer-groups/peer-group/peer-group-name";
+ }
+ description
+ "The peer-group with which this neighbor is associated";
+ }
+
+ leaf identifier {
+ type yang:dotted-quad;
+ config false;
+ description
+ "The BGP Identifier of this entry's BGP peer.
+ This entry MUST be 0.0.0.0 unless the
+ sessionstate is in the openconfirm or the
+ established state.";
+ reference
+ "RFC 4271, Section 4.2, 'BGP Identifier'.";
+ }
+
+ leaf remote-address {
+ type inet:ip-address;
+ description
+ "The remote IP address of this entry's BGP peer.";
+ }
+
+ leaf remote-port {
+ type inet:port-number {
+ range "0..65535";
+ }
+ config false;
+
+ description
+ "The remote port for the TCP connection
+ between the BGP peers. Note that the
+ objects local-addr, local-port, remote-addr, and
+ reemote-port provide the appropriate
+ reference to the standard MIB TCP
+ connection table.";
+ }
+
+ leaf remote-as {
+ type inet:as-number;
+ config false;
+ description
+ "The remote autonomous system number received in
+ the BGP OPEN message.";
+ reference
+ "RFC 4271, Section 4.2.";
+ }
+
+ leaf enabled {
+ type boolean;
+ default "true";
+ description
+ "Whether the BGP peer is enabled. In cases where the
+ enabled leaf is set to false, the local system should
+ not initiate connections to the neighbor, and should
+ not respond to TCP connections attempts from the
+ neighbor. If the state of the BGP session is
+ ESTABLISHED at the time that this leaf is set to false,
+ the BGP session should be ceased.
+
+ A transition from 'false' to 'true' will cause
+ the BGP Manual Start Event to be generated.
+ A transition from 'true' to 'false' will cause
+ the BGP Manual Stop Event to be generated.
+ This parameter can be used to restart BGP peer
+ connections. Care should be used in providing
+ write access to this object without adequate
+ authentication.";
+ reference
+ "RFC 4271, Section 8.1.2.";
+ }
+
+ uses neighbor-group-config;
+
+ leaf session-state {
+ type enumeration {
+ enum idle {
+
+ description
+ "Neighbor is down, and in the Idle state of the FSM";
+ }
+ enum connect {
+ description
+ "Neighbor is down, and the session is waiting for the
+ underlying transport session to be established";
+ }
+ enum active {
+ description
+ "Neighbor is down, and the local system is awaiting a
+ connection from the remote peer";
+ }
+ enum opensent {
+ description
+ "Neighbor is in the process of being established. The
+ local system has sent an OPEN message";
+ }
+ enum openconfirm {
+ description
+ "Neighbor is in the process of being established.
+ The local system is awaiting a NOTIFICATION or
+ KEEPALIVE message";
+ }
+ enum established {
+ description
+ "Neighbor is up - the BGP session with the peer is
+ established";
+ }
+ }
+ // notification does not like a non-config statement.
+ // config false;
+ description
+ "The BGP peer connection state.";
+ reference
+ "RFC 4271, Section 8.1.2.";
+ }
+
+ leaf last-established {
+ type uint64;
+ config false;
+ description
+ "This timestamp indicates the time that the BGP session
+ last transitioned in or out of the Established state.
+ The value is the timestamp in seconds relative to the
+ Unix Epoch (Jan 1, 1970 00:00:00 UTC).
+
+ The BGP session uptime can be computed by clients as
+
+ the difference between this value and the current time
+ in UTC (assuming the session is in the ESTABLISHED
+ state, per the session-state leaf).";
+ }
+
+ leaf-list supported-capabilities {
+ type identityref {
+ base bt:bgp-capability;
+ }
+ config false;
+ description
+ "BGP capabilities negotiated as supported with the peer";
+ }
+
+ leaf negotiated-hold-time {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ config false;
+ description
+ "The negotiated hold-time for the BGP session";
+ }
+
+ leaf last-error {
+ type binary {
+ length "2";
+ }
+ // notification does not like non-config statement.
+ // config false;
+ description
+ "The last error code and subcode seen by this
+ peer on this connection. If no error has
+ occurred, this field is zero. Otherwise, the
+ first byte of this two byte OCTET STRING
+ contains the error code, and the second byte
+ contains the subcode.";
+ reference
+ "RFC 4271, Section 4.5.";
+ }
+
+ leaf fsm-established-time {
+ type yang:gauge32;
+ units "seconds";
+ config false;
+ description
+ "This timer indicates how long (in
+ seconds) this peer has been in the
+ established state or how long
+
+ since this peer was last in the
+ established state. It is set to zero when
+ a new peer is configured or when the router is
+ booted.";
+ reference
+ "RFC 4271, Section 8.";
+ }
+
+ container timers {
+ description
+ "Timers related to a BGP neighbor";
+
+ uses neighbor-group-timers-config;
+
+ }
+
+ container transport {
+ description
+ "Transport session parameters for the BGP neighbor";
+
+ uses neighbor-group-transport-config;
+ }
+
+ leaf erroneous-update-messages {
+ type uint32;
+ config false;
+ description
+ "The number of BGP UPDATE messages for which the
+ treat-as-withdraw mechanism has been applied based on
+ erroneous message contents";
+ }
+
+ container graceful-restart {
+ description
+ "Parameters relating the graceful restart mechanism for
+ BGP";
+
+ uses graceful-restart-config;
+
+ leaf peer-restart-time {
+ type uint16 {
+ range "0..4096";
+ }
+ config false;
+ description
+ "The period of time (advertised by the peer) that the
+ peer expects a restart of a BGP session to take";
+ }
+
+ leaf peer-restarting {
+ type boolean;
+ config false;
+ description
+ "This flag indicates whether the remote neighbor is
+ currently in the process of restarting, and hence
+ received routes are currently stale";
+ }
+
+ leaf local-restarting {
+ type boolean;
+ config false;
+ description
+ "This flag indicates whether the local neighbor is
+ currently restarting. The flag is unset after all NLRI
+ have been advertised to the peer, and the End-of-RIB
+ (EOR) marker has been unset";
+ }
+
+ leaf mode {
+ type enumeration {
+ enum HELPER_ONLY {
+ description
+ "The local router is operating in helper-only
+ mode, and hence will not retain forwarding state
+ during a local session restart, but will do so
+ during a restart of the remote peer";
+ }
+ enum BILATERAL {
+ description
+ "The local router is operating in both helper
+ mode, and hence retains forwarding state during
+ a remote restart, and also maintains forwarding
+ state during local session restart";
+ }
+ enum REMOTE_HELPER {
+ description
+ "The local system is able to retain routes during
+ restart but the remote system is only able to
+ act as a helper";
+ }
+ }
+ config false;
+ description
+ "This leaf indicates the mode of operation of BGP
+ graceful restart with the peer";
+ }
+ }
+
+ uses structure-neighbor-group-ebgp-multihop;
+ uses structure-neighbor-group-route-reflector;
+ uses structure-neighbor-group-as-path-options;
+ uses structure-neighbor-group-add-paths;
+ uses bgp-neighbor-use-multiple-paths;
+ uses rpol:apply-policy-group;
+
+ container afi-safis {
+ description
+ "Per-address-family configuration parameters associated
+ with the neighbor";
+ uses bgp-neighbor-afi-safi-list;
+ }
+
+ container statistics {
+
+ leaf established-transitions {
+ type yang:counter64;
+ config false;
+ description
+ "Number of transitions to the Established state for the
+ neighbor session. This value is analogous to the
+ bgpPeerFsmEstablishedTransitions object from the standard
+ BGP-4 MIB";
+ reference
+ "RFC 4273 - Definitions of Managed Objects for BGP-4";
+ }
+
+ leaf fsm-established-transitions {
+ type yang:counter32;
+ config false;
+ description
+ "The total number of times the BGP FSM
+ transitioned into the established state
+ for this peer.";
+ reference
+ "RFC 4271, Section 8.";
+ }
+
+ container messages {
+ config false;
+ description
+ "Counters for BGP messages sent and received from the
+ neighbor";
+
+ leaf in-total-messages {
+ type yang:counter32;
+ config false;
+
+ description
+ "The total number of messages received
+ from the remote peer on this connection.";
+ reference
+ "RFC 4271, Section 4.";
+ }
+
+ leaf out-total-messages {
+ type yang:counter32;
+ config false;
+ description
+ "The total number of messages transmitted to
+ the remote peer on this connection.";
+ reference
+ "RFC 4271, Section 4.";
+ }
+
+ leaf in-update-elapsed-time {
+ type yang:gauge32;
+ units "seconds";
+ config false;
+ description
+ "Elapsed time (in seconds) since the last BGP
+ UPDATE message was received from the peer.
+ Each time in-updates is incremented,
+ the value of this object is set to zero (0).";
+ reference
+ "RFC 4271, Section 4.3.
+ RFC 4271, Section 8.2.2, Established state.";
+ }
+
+ container sent {
+ description
+ "Counters relating to BGP messages sent to the
+ neighbor";
+ uses bgp-neighbor-counters-message-types-state;
+ }
+
+ container received {
+ description
+ "Counters for BGP messages received from the
+ neighbor";
+ uses bgp-neighbor-counters-message-types-state;
+ }
+ }
+
+ container queues {
+ config false;
+
+ description
+ "Counters related to queued messages associated with
+ the BGP neighbor";
+
+ leaf input {
+ type uint32;
+ description
+ "The number of messages received from the peer
+ currently queued";
+ }
+
+ leaf output {
+ type uint32;
+ description
+ "The number of messages queued to be sent to the
+ peer";
+ }
+ }
+
+ container clear-statistics {
+ if-feature "clear-statistics";
+
+ action clear {
+ input {
+ leaf clear-at {
+ type yang:date-and-time;
+ description
+ "Time when the clear action needs to be
+ executed.";
+ }
+ }
+
+ output {
+ leaf clear-finished-at {
+ type yang:date-and-time;
+ description
+ "Time when the clear action command completed.";
+ }
+ }
+ }
+ description
+ "Clear statistics action command.";
+ }
+ description
+ "Statistics per neighbor.";
+ }
+ }
+
+ notification established {
+ description
+ "The established event is generated
+ when the BGP FSM enters the established state.";
+
+ leaf remote-address {
+ type leafref {
+ path "../../neighbor/remote-address";
+ }
+ description
+ "IP address of the neighbor that went into established
+ state.";
+ }
+
+ leaf last-error {
+ type leafref {
+ path "../../neighbor/last-error";
+ }
+ description
+ "The last error code and subcode seen by this
+ peer on this connection. If no error has
+ occurred, this field is zero. Otherwise, the
+ first byte of this two byte OCTET STRING
+ contains the error code, and the second byte
+ contains the subcode.";
+ reference
+ "RFC 4271, Section 4.5.";
+ }
+
+ leaf session-state {
+ type leafref {
+ path "../../neighbor/session-state";
+ }
+ description
+ "The BGP peer connection state.";
+ reference
+ "RFC 4271, Section 8.2.2.";
+ }
+ }
+
+ notification backward-transition {
+ description
+ "The backward-transition event is
+ generated when the BGP FSM moves from a higher
+ numbered state to a lower numbered state.";
+
+ leaf remote-addr {
+ type leafref {
+
+ path "../../neighbor/remote-address";
+ }
+ description
+ "IP address of the neighbor that went away from
+ established state.";
+ }
+
+ leaf last-error {
+ type leafref {
+ path "../../neighbor/last-error";
+ }
+ description
+ "The last error code and subcode seen by this
+ peer on this connection. If no error has
+ occurred, this field is zero. Otherwise, the
+ first byte of this two byte OCTET STRING
+ contains the error code, and the second byte
+ contains the subcode.";
+ reference
+ "RFC 4271, Section 4.5.";
+ }
+
+ leaf session-state {
+ type leafref {
+ path "../../neighbor/session-state";
+ }
+ description
+ "The BGP peer connection state.";
+ reference
+ "RFC 4271, Section 8.2.2.";
+ }
+ }
+
+ container clear-neighbors {
+ if-feature "clear-neighbors";
+
+ action clear {
+ input {
+ leaf clear-at {
+ type yang:date-and-time;
+ description
+ "Time when the clear action command needs to be
+ executed.";
+ }
+ }
+
+ output {
+ leaf clear-finished-at {
+
+ type yang:date-and-time;
+ description
+ "Time when the clear action command completed.";
+ }
+ }
+ }
+ description
+ "Clear neighbors action.";
+ }
+ }
+
+ container peer-groups {
+ description
+ "Configuration for BGP peer-groups";
+ uses bgp-peer-group-list;
+ }
+
+ container interfaces {
+ list interface {
+ key "name";
+
+ leaf name {
+ type if:interface-ref;
+ description
+ "Reference to the interface within the routing instance.";
+ }
+
+ container bfd {
+ if-feature "bt:bfd";
+
+ uses bfd:client-cfg-parms;
+ description
+ "BFD client configuration.";
+ reference
+ "RFC BBBB - YANG Data Model for Bidirectional Forwarding
+ Detection.";
+ }
+ description
+ "List of interfaces within the routing instance.";
+ }
+ description
+ "Interface specific parameters.";
+ }
+ uses rib;
+ }
+ }
+}