﻿<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="4"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<rfc category="std" ipr="trust200902" docName="draft-ietf-grow-bmp-yang-01">
  <front>
    <title abbrev="BMP YANG Module">BMP YANG Module</title>
    <author fullname="Camilo Cardona" initials="C" surname="Cardona ">
      <organization>NTT</organization>
      <address>
        <postal>
          <street>164-168, Carrer de Numancia</street>

          <city>Barcelona</city>

          <code>08029</code>

          <country>Spain</country>
        </postal>

        <email>camilo@ntt.net</email>
      </address>
    </author>
    <author fullname="Paolo Lucente" initials="P." surname="Lucente">
      <organization>NTT</organization>
      <address>
        <postal>
          <street>Siriusdreef 70-72</street>
          <city>Hoofddorp</city>
          <region>WT</region>
          <code>2132</code>
          <country>Netherlands</country>
        </postal>
        <email>paolo@ntt.net</email>
      </address>
    </author>
    <author fullname="Thomas Graf" initials="T." surname="Graf">
      <organization>Swisscom</organization>
      <address>
        <postal>
          <street>Binzring 17</street>
          <city>Zurich 8045</city>
          <country>Switzerland</country>
        </postal>
        <email>thomas.graf@swisscom.com</email>
      </address>
    </author>     
    <author fullname="Benoit Claise" initials="B" surname="Claise">
      <organization>Huawei</organization>
      <address>
        <email>benoit.claise@huawei.com</email>
      </address>
    </author> 
    <date/>
    <area>OPS</area>
    <workgroup>GROW</workgroup>
    <abstract>
      <t> 
        This document proposes a YANG module for BMP (BGP Monitoring Protocol) configuration and monitoring.
        A complementary RPC triggers a refresh of the session of a BMP monitoring station.
      </t>
    </abstract>
  </front>

  <middle>
    <section title="Terminology" anchor="terminology">
       <t>
         The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
         NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED",
         "MAY", and "OPTIONAL" in this document are to be interpreted as
         described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/>
         when, and only when, they appear in all capitals, as shown here.
      </t>    
       <t>
           Routing Information Bases, peers, monitoring stations, and
           initiation messages are defined in <xref target="RFC7854"/>.
      </t>    
    </section>   
    <section title="Introduction" anchor="introduction">
       <t>
              This document specifies a YANG module for configuring and
           monitoring the BGP Monitoring Protocol (BMP)  <xref target="RFC7854"/>.  The model
           provides parameters for defining sessions to BMP monitoring stations; the
           selection of the BGP Routing Information Bases (RIBs) for Route Monitoring Messages; provides
           operational metrics  and enables reseting of BMP monitoring sessions.
       </t> 
    </section>  

    <section title="Model summary" anchor="model_summary">
       <t>
           The BMP YANG model provides the methods for managing BMP monitoring stations. It includes:
      </t>     
      <t> 
        <list style="symbols">
          <t> 
              Connectivity parameters, including monitoring station IP
              address(es) and destination port(s).
          </t>
          <t> 
              BMP session parameters, such as defining the BMP initiation message
              or the interval for statistics messages.
          </t>
          <t> 
              BGP data sources for Route Monitoring Messages.  
              The model requires the explicit configuration
              of the network instance, RIBs, and address family to send to each
              monitoring station over Route Monitoring Messages.
              For Adj-RIB-in and Adj-RIB-out, both pre and post policy,
              the model also requires to reference the peer.
              In those RIBs, the identity "bmp-peer-types-all-peers" can be used if the
              operators desire to receive data of all peers.
          </t>
          <t> 
              Per BMP station status and statistics, such as established status, number 
              of route-monitoring messages, number of route-mirroring messages, number 
              of peer-down and peer-up messages, number of initiation messages.
          </t>
          <t> 
              BMP session reset RPC action.
          </t>
        </list>
      </t>     
    </section>

    <section title="Base ietf-bmp YANG module">
      <section title="Tree View" anchor="ietf-bmp-tree-view">
        <t>
        The following tree diagram provides an overview of the ietf-bmp.yang
            data model.
        </t>
        <t>
          <figure>
            <artwork><![CDATA[
=============== NOTE: '\\' line wrapping per RFC 8792 ===============

module: ietf-bmp
  +--rw bmp
     +--rw monitoring-stations
        +--rw monitoring-station* [id]
           +--rw id               string
           +--rw connection
           |  +--rw (passive-or-active)?
           |  |  +--:(active)
           |  |  |  +--rw active
           |  |  |     +--rw network-instance?   leafref
           |  |  |     +--rw station-address     inet:ip-address
           |  |  |     +--rw station-port        inet:port-number
           |  |  |     +--rw local-address       inet:ip-address
           |  |  |     +--rw local-port?         inet:port-number
           |  |  +--:(passive)
           |  |     +--rw passive
           |  |        +--rw network-instance?   leafref
           |  |        +--rw station-address     inet:ip-address
           |  |        +--rw station-port?       inet:port-number
           |  |        +--rw local-address       inet:ip-address
           |  |        +--rw local-port          inet:port-number
           |  +--rw tcp-options
           |  |  +--rw maximum-segment-size?    uint16
           |  |  +--rw mtu-discovery?           boolean
           |  |  +--rw keepalives! {keepalives-supported}?
           |  |  |  +--rw idle-time         uint16
           |  |  |  +--rw max-probes        uint16
           |  |  |  +--rw probe-interval    uint16
           |  |  +--rw secure-session-enable?   boolean
           |  |  +--rw secure-session
           |  |     +--rw (authentication)?
           |  |        +--:(ao)
           |  |        |  +--rw ao-keychain?
           |  |        |          key-chain:key-chain-ref
           |  |        +--:(md5)
           |  |           +--rw md5-keychain?
           |  |                   key-chain:key-chain-ref
           |  +--rw initial-delay?   uint32
           |  +--rw backoff
           |     +--rw (backoff-options)?
           |        +--:(simple-exponential)
           |           +--rw simple-exponential
           |              +--rw initial-backoff?   uint32
           |              +--rw maximum-backoff?   uint32
           +--rw bmp-data
           |  +--rw initiation-message?      string
           |  +--rw bmp-statistics-report!
           |  |  +--rw statistics-interval    uint32
           |  +--rw bmp-route-monitoring
           |     +--rw network-instances
           |        +--rw network-instance* [network-instance-id]
           |           +--rw network-instance-id    union
           |           +--rw enabled?               boolean
           |           +--rw adj-rib-in-pre
           |           |  +--rw address-families
           |           |     +--rw address-family*
           |           |             [address-family-id]
           |           |        +--rw address-family-id
           |           |        |       identityref
           |           |        +--rw enabled?
           |           |        |       boolean
           |           |        +--rw peers
           |           |           +--rw peer* [peer-id]
           |           |              +--rw peer-id    union
           |           |              +--rw enabled?   boolean
           |           |              +--rw filters
           |           |                 +--rw policy-filter
           |           |                    +--rw export-policy*    \
\       leafref
           |           |                    +--rw default-export-pol\
\icy?
           |           |                            rt-pol:default-p\
\olicy-type
           |           +--rw adj-rib-in-post
           |           |  +--rw address-families
           |           |     +--rw address-family*
           |           |             [address-family-id]
           |           |        +--rw address-family-id
           |           |        |       identityref
           |           |        +--rw enabled?
           |           |        |       boolean
           |           |        +--rw peers
           |           |           +--rw peer* [peer-id]
           |           |              +--rw peer-id    union
           |           |              +--rw enabled?   boolean
           |           |              +--rw filters
           |           |                 +--rw policy-filter
           |           |                    +--rw export-policy*    \
\       leafref
           |           |                    +--rw default-export-pol\
\icy?
           |           |                            rt-pol:default-p\
\olicy-type
           |           +--rw local-rib
           |           |  +--rw address-families
           |           |     +--rw address-family*
           |           |             [address-family-id]
           |           |        +--rw address-family-id
           |           |        |       identityref
           |           |        +--rw filters
           |           |           +--rw policy-filter
           |           |              +--rw export-policy*          \
\ leafref
           |           |              +--rw default-export-policy?
           |           |                      rt-pol:default-policy-\
\type
           |           +--rw adj-rib-out-pre
           |           |  +--rw address-families
           |           |     +--rw address-family*
           |           |             [address-family-id]
           |           |        +--rw address-family-id
           |           |        |       identityref
           |           |        +--rw enabled?
           |           |        |       boolean
           |           |        +--rw peers
           |           |           +--rw peer* [peer-id]
           |           |              +--rw peer-id    union
           |           |              +--rw enabled?   boolean
           |           |              +--rw filters
           |           |                 +--rw policy-filter
           |           |                    +--rw export-policy*    \
\       leafref
           |           |                    +--rw default-export-pol\
\icy?
           |           |                            rt-pol:default-p\
\olicy-type
           |           +--rw adj-rib-out-post
           |              +--rw address-families
           |                 +--rw address-family*
           |                         [address-family-id]
           |                    +--rw address-family-id
           |                    |       identityref
           |                    +--rw enabled?
           |                    |       boolean
           |                    +--rw peers
           |                       +--rw peer* [peer-id]
           |                          +--rw peer-id    union
           |                          +--rw enabled?   boolean
           |                          +--rw filters
           |                             +--rw policy-filter
           |                                +--rw export-policy*    \
\       leafref
           |                                +--rw default-export-pol\
\icy?
           |                                        rt-pol:default-p\
\olicy-type
           +--rw session-stats
           |  +--rw discontinuity-time
           |  |       yang:date-and-time
           |  +--ro established-session?               boolean
           |  +--ro total-route-monitoring-messages?   uint64
           |  +--ro total-statistics-messages?         uint64
           |  +--ro total-peer-down-messages?          uint64
           |  +--ro total-peer-up-messages?            uint64
           |  +--ro total-initiation-messages?         uint64
           |  +--ro total-route-mirroring-messages?    uint64
           +--rw actions
              +---x session-reset
                 +--ro output
                    +--ro (outcome)?
                       +--:(success)
                       |  +--ro success?   empty
                       +--:(failure)
                          +--ro failure?   string
           ]]></artwork>
          </figure>
        </t> 
      </section>    

      <section title="YANG Module" anchor="ietf-bmp">
        <t>&lt;CODE BEGINS> file "ietf-bmp@2022-01-27.yang"</t>
          <figure>
            <artwork><![CDATA[
module ietf-bmp {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-bmp";
  prefix bmp;

  import ietf-yang-types {
     prefix yang;
   }

  import ietf-inet-types {
    prefix inet;
    reference
      "RFC 6991: Common YANG Data Types";
  }

  import ietf-bgp-types {
    prefix bt;
    reference
      "RFC AAAA: BGP YANG module for Service Provider Network.
       RFC-EDITOR: please update XXX with the RFC ID assigned 
       to I-D.ietf-idr-bgp-model";
  }

  import ietf-netconf-acm {
    prefix nacm;
    reference
      "RFC 8341: Network Configuration Access Control Model";
  }

  import ietf-tcp-common {
    prefix "tcpcmn";
    reference
      "I-D.ietf-netconf-tcp-client-server: YANG Groupings for TCP
       Clients and TCP Servers.";
  }

  import ietf-network-instance {
    prefix "ni";
    reference
    "RFC 8529: YANG Data Model for Network Instances";
  }

  import ietf-routing-policy {
    prefix "rt-pol";
    reference
    "RFC 9067: A YANG Data Model for Routing Policy";

  }

  import ietf-key-chain {
       prefix key-chain;
       reference
         "RFC 8177: YANG Key Chain.";
  }

  organization
    "IETF GROW Working Group";
  contact
    "WG Web:   <https://datatracker.ietf.org/wg/grow/>
     WG List:  <mailto:grow@ietf.org>

     Author:  Camilo Cardona
        <mailto:camilo@ntt.net>

     Author:  Paolo Lucente
        <mailto:cpaolo@ntt.net>

     Author:  Thomas Graf
        <mailto:thomas.graf@swisscom.com>

     Author:  Benoit Claise
        <mailto:benoit.claise@huawei.com>";
  description
    "This module specifies a structure for BMP
     (BGP Monitoring Protocol) configuration and monitoring.

     The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL',
     'SHALL NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED',
     'NOT RECOMMENDED', 'MAY', and 'OPTIONAL' in this document
     are to be interpreted as described in BCP 14 (RFC 2119)
     (RFC 8174) when, and only when, they appear in all
     capitals, as shown here.

     Copyright (c) 2022 IETF Trust and the persons identified as
     authors of the code.  All rights reserved.

     Redistribution and use in source and binary forms, with or
     without modification, is permitted pursuant to, and subject to
     the license terms contained in, the Revised BSD License set
     forth in Section 4.c of the IETF Trust's Legal Provisions
     Relating to IETF Documents
     (https://trustee.ietf.org/license-info).

     This version of this YANG module is part of RFC 9196
     (https://www.rfc-editor.org/info/rfc9196); see the RFC itself
     for full legal notices.";

  revision 2022-10-18 {
    description
      "initial version";
    reference
      "RFC YYYY: BMP YANG Module
      RFC-EDITOR: please update YYYY with this RFC ID";
  }

  identity bmp-peer-types {
    description 
    "Enum values for multiple selecting peer's 
    Routing Information Bases (RIB) for configuration.";
  }
  
  identity bmp-peer-types-all-peers {
    base bmp-peer-types;
    description 
    "This identity selects all peer's RIBs. 
    When used, it act as a 'default' configuration."; 
  }

  identity bmp-ni-types {
    description "Enum values for selecting multiple Network instances
    for configuration";
  }
  
  identity bmp-ni-types-all-ni {
    base bmp-ni-types;
    description "The identify is an explicit way 
      of selecting all network instances."; 
  }

  identity bmp-ni-types-global-ni {
    base bmp-ni-types;
    description "Selects the global network instance"; 
  }

  grouping bmp-tcp-options {
    description 
      "TCP options for the connection to the station";
    leaf maximum-segment-size {
      type uint16;
      description
        "Maximum segment size for the TCP connections.";
    }

    // Taken from the bgp yang module
    leaf mtu-discovery {
        type boolean;
        description
          "Turns path mtu discovery for the  TCP sessions 
          on (true) or off (false).";
        reference
          "RFC 1191: Path MTU discovery.";
      }
    uses tcpcmn:tcp-common-grouping;

    // taken from the bgp yang module
    leaf secure-session-enable {
       type boolean;
       default "false";
       description
         "Does this session need to be secured?";
    }

   container secure-session {
     when "../secure-session-enable = 'true'";
     description
       "Container for describing how a particular BMP session
        is to be secured.";

      choice authentication {
       case ao {
         leaf ao-keychain {
           type key-chain:key-chain-ref;
           description
             "Reference to the key chain that will be used by
              this model. Applicable for TCP-AO and TCP-MD5
              only";
           reference
             "RFC 8177: YANG Key Chain.";
         }
         description
           "Uses TCP-AO to secure the session. Parameters for
            those are defined as a grouping in the TCP YANG
            model.";
         reference
           "RFC 5925 - The TCP Authentication Option.";
      }

       case md5 {
         leaf md5-keychain {
           type key-chain:key-chain-ref;
           description
             "Reference to the key chain that will be used by
              this model. Applicable for TCP-AO and TCP-MD5
              only";
           reference
             "RFC 8177: YANG Key Chain.";
         }
         description
           "Uses TCP-MD5 to secure the session. Parameters for
            those are defined as a grouping in the TCP YANG
            model.";
         reference
           "RFC 5925: The TCP Authentication Option.";
       }
       description
         "Choice of TCP authentication.";
      }
   }


  }

  grouping bmp-ip-connection {
    description
      "common elements for defining connectivity
       to a BMP monitoring station";
    choice passive-or-active {
      description
        "Choice for active or passive connection as described
        in section 3.2 of RFC 7854";
      case active {
        description
          "The device starts the connection to the monitoring 
          station";
        container active {
          description
            "The device starts the connection to 
            the monitoring station";
          leaf network-instance {
            type leafref {
              path "/ni:network-instances/ni:network-instance/"
                 + "ni:name";
            }
            description 
              "If present, specifies the network instance 
              used to reach the monitoring station.";
          }
          leaf station-address {
            type inet:ip-address;
            mandatory true;
            description
              "Destination IP address of monitoring station";
          }
          leaf station-port {
            type inet:port-number;
            mandatory true;
            description
              "Destination port of the station";
          }
          leaf local-address {
            type inet:ip-address;
            mandatory true;
            description
              "Local IP address to source active connection";
          }
          leaf local-port {
            type inet:port-number;
            description
              "Optional Local port for active connection";
          }

        }

      }

      case passive {
        description
          "The device waits for the connection 
          in a local endpoint";
        container passive {
          description
            "The device waits for the connection 
            in a local endpoint";
          leaf network-instance {
            type leafref {
              path "/ni:network-instances/ni:network-instance/"
                 + "ni:name";
            }
            description 
              "If present, specifies the network instance 
              used to reach the monitoring station.";
          }
          leaf station-address {
            type inet:ip-address;
            mandatory true;
            description
              "address of the station";
          }
          leaf station-port {
            type inet:port-number;
            description
              "Optional value identifying the origin port of 
              the connection, if provided it MUST match";
          }
          leaf local-address {
            type inet:ip-address;
            mandatory true;
            description
              "Local IP address to wait for the connection";
          }
          leaf local-port {
            type inet:port-number;
            mandatory true;
            description
              "Local port to wait for the connection";
          }

        }

      }
    }
  }

  grouping bmp-source-configuration {
    description
    "Group containing some general characteristics for configuring
    a BMP source";

    container filters {
      description 
      "Includes containers specifying filters for deciding 
      which routes to export to the station";
      container policy-filter {
          description
          "Filter routes based on a policy.
          The policy SHOULD not perform any action besides
          filtering routes.
          The policy SHOULD only contain accept and reject 
          routes, and the matching conditions SHOULD only 
          match prefix sets.";
          leaf-list export-policy {
           type leafref {
             path "/rt-pol:routing-policy/"
                + "rt-pol:policy-definitions/"
                + "rt-pol:policy-definition/rt-pol:name";
             require-instance true;
           }
           ordered-by user;
           description
              "List of policy names in sequence used to select
              routes to be exported to station.";
         }
         leaf default-export-policy {
           type rt-pol:default-policy-type;
           default "accept-route";
           description
             "Explicitly set a default policy if no policy 
             definition in the export policy chain 
             is satisfied.";
         }
      }
    }
  }

  grouping bmp-peer-ribs-filter {
    description
      "Leaves for configuring RIBs where
       origin/destination peers are defined.";

    container address-families {
      description
        "container for lists of address-families";
      list address-family {
        key "address-family-id";
        description
          "List of address families.
           The name of the address family, as defined
           in the BGP model is used for keying.";

        // If we knew the network instance,
        // we could list the AF directly from the configured
        // ones, as we for instance show next for the global one.
        // leaf name {
        //   type leafref {
        //     path "/rt:routing/rt:control-plane-protocols/"
        //        + "rt:control-plane-protocol/bgp:bgp/"
        //        + "bgp:global/bgp:afi-safis/bgp:afi-safi/bgp:name";
        //   }
        //   description
        //     "Name of the address family";
        // }
        // However, since is not aware if we are doing global, 
        // and individual NT or a default, we cannot 
        // contraint it to this.
        leaf address-family-id {
          type identityref {
            base bt:afi-safi-type;
          }
          description
          "Address family id to configure";
        }

        leaf enabled {
          type boolean;
          default true;
          description
            "Enables route monitoring messages 
            for the address family";
        }

        container peers {
          description
          "Identification of peers 
          for which we send BMP data to the collector";
          list peer {
            key "peer-id";
            description
            "Identification of peers 
            for which we send BMP data to the collector";
            leaf peer-id {
              type union {
                // inet:ip-address reflects a neighbor
                // but since the model is not aware of 
                // the ni, it doesn not know from where to get it
                // e.g. if we knew were were referencing 
                //      the global instance, we could do:
                // type leafref {
                //   path "/rt:routing/rt:control-plane-protocols/"
                //   + "rt:control-plane-protocol/bgp:bgp/"
                //   + "bgp:neighbors/bgp:neighbor/"
                //   + "bgp:remote-address";
                // }
                type inet:ip-address;
                type bt:peer-type;
                type identityref {
                  base bmp-peer-types;
                }
              }
              description
                "Peers can be identified by a remote-address,
                 by the bgp type of the peers,
                 or by an enum value corresponding to groups 
                 of peers.  This way an operator can 
                 select, for example, all external peers, 
                 all internal peers, or all peers.";
            }

            leaf enabled {
              type boolean;
              default true;
              description
                "Enables routing monitoring messages 
                for the peer(s).";
            }
            uses bmp-source-configuration;

          }
        }
      }
    }
  }

  grouping bmp-route-monitoring-sources {
    description
      "Route monitoring sources";
    reference "RFC7854:  BGP Monitoring Protocol, Section 5.";

    container network-instances {
      description
      "container for lists of network-instances";
      list network-instance {
        key "network-instance-id";
        description
          "Network instance to monitory using BMP.";

        leaf network-instance-id {
          type union {
            type leafref {
              path "/ni:network-instances/ni:network-instance/"
                 + "ni:name";
            }
            type identityref {
              base bmp-ni-types;
            }
          }
          description 
            "Identification of a network-instance.
            Network instances can be identified
            directly by their path or use an identity to 
            identify one or a group of them 
            (e.g. bmp-ni-types-all-ni for all of them)";
            
        }


        leaf enabled {
          type boolean;
          default true;
          description
            "Enables routing monitoring 
            messages for the network instance.";
        }

        container adj-rib-in-pre {
          description
            "Configuration for the adj-rib-in pre-policy";
          reference 
            "RFC7854: BGP Monitoring Protocol (BMP), Section 2.";
          uses bmp-peer-ribs-filter;
        }
        container adj-rib-in-post {
          description
            "Configuration for the adj-rib-in post-policy";
          reference 
            "RFC7854: BGP Monitoring Protocol (BMP), Section 2.";
          uses bmp-peer-ribs-filter;
        }
        container local-rib {
          description
            "Configuration for the local-rib";
          reference 
            "RFC9069: Support for Local RIB in the BGP Monitoring
            Protocol (BMP), Section 3.";

          container address-families {
            description
              "List of address families to enable for
               local-rib.";
            list address-family {
              key "address-family-id";
              description
               "Address family to enable for local-rib";
              leaf address-family-id {
                type identityref {
                  base bt:afi-safi-type;
                }
                description
                "Address family id to enable for local-rib";
              }
              uses bmp-source-configuration;
            }
          }
        }
        container adj-rib-out-pre {
          description
            "Configuration for the adj-rib-out pre-policy";
          uses bmp-peer-ribs-filter;
          reference 
            "RFC8671: Support for Adj-RIB-Out in the BGP Monitoring
            Protocol (BMP) , Section 3.";
        }
        container adj-rib-out-post {
          description
            "Configuration for the adj-rib-out post-policy";
          uses bmp-peer-ribs-filter;
          reference 
            "RFC8671: Support for Adj-RIB-Out in the BGP Monitoring
            Protocol (BMP) , Section 3.";
        }

      }

    }

  }


  container bmp {
    description
      "Main level for BMP configuration ";
    container monitoring-stations {
      description
        "Container for the list of BMP monitoring stations";
      list monitoring-station {
        key "id";
        description
          "Configuration for a BMP monitoring station.";
        leaf id {
          type string;
          description
            "Identification string for the monitoring station";
        }
        // Connection, missing tcp tuning params 
        // like keep-alives, segment sizes, etc.
        container connection {
          description
            "Connection details for the monitoring station";
          uses bmp-ip-connection;

          container tcp-options {
            description
             "TCP options for the connection to the monitoring 
             station";
            uses bmp-tcp-options;
          }

          leaf initial-delay {
            type uint32;
            units "seconds";
            default 0;
            description
              "Initial delay of the connection to the station";
          }

          container backoff {
            description
              "Configures the backoff strategy after a connection 
              retry";
            reference "RFC7854 Section 3.2";
            choice backoff-options {
              description
                "Options for backoff strategies";
              reference "RFC7854 Section 3.2";
              case simple-exponential {
                description 
                  "Simple exponential backoff with limits.";
                container simple-exponential {
                  description 
                    "Simple exponential backoff with limits. 
                    Starts with the initial backoff and doubles
                    the backoff of every retry until reaching the 
                    maximum backoff";
                  leaf initial-backoff {
                    type uint32;
                    units "seconds";
                    default 30;
                    description
                      "Initial backoff time";
                  }
                  leaf maximum-backoff {
                    type uint32;
                    units "seconds";
                    default 720;
                    description
                      "Maximum backoff time";
                  }
                }
              }
            }
          }
        }

        container bmp-data {
          description
            "Configuration of BMP data";

          leaf initiation-message {
            type string;
            description
              "User defined message to append to the
               initiation message";
            reference "RFC7854:  BGP Monitoring Protocol, 
              Section 4.3 and 4.4";
          }

          container bmp-statistics-report  {
            presence "Enables the BMP statistics report";

            description "Configuration of the statistics report";
            reference "RFC7854:  BGP Monitoring Protocol, 
              Section 4.8";


            leaf statistics-interval {
              type uint32;
              units "seconds";
              mandatory true;
              description
                "Interval for statistic report message.";
            }

          }

          container bmp-route-monitoring {
            description
              "Configuration of the data sources for 
              route-monitoring messages";
            uses bmp-route-monitoring-sources;
          }
        }

        container session-stats {
          description
            "stats and operational values for the station";

          leaf discontinuity-time {
             type yang:date-and-time;
             mandatory true;
             description
               "The time on the most recent occasion at which any
               one or more of this station's counters suffered a
               discontinuity.  If no such discontinuities have
               occurred since the last re-initialization of the
               local management subsystem, then this node contains
               the time the local management subsystem
               re-initialized itself.";
           }

          leaf established-session {
            type boolean;
            config false;
            description
              "Value indicating if the session is currently
               established";
          }
          leaf total-route-monitoring-messages {
            type uint64;
            config false;
            description
              "Number of route-monitoring messages sent since last
               successful connection";
          }
          leaf total-statistics-messages {
            type uint64;
            config false;
            description
              "Number of statistics messages sent since last
               successful connection";
          }
          leaf total-peer-down-messages {
            type uint64;
            config false;
            description
              "Number of peer-down messages sent since last
               successful connection";
          }
          leaf total-peer-up-messages {
            type uint64;
            config false;
            description
              "Number of peer-up messages sent since last successful
               connection";
          }
          leaf total-initiation-messages {
            type uint64;
            config false;
            description
              "Number of initiation messages sent since last
               successful connection";
          }
          leaf total-route-mirroring-messages {
            type uint64;
            config false;
            description
              "Number of route-mirroring messages sent since last
               successful connection";
          }
        }


        container actions {
          nacm:default-deny-all;
          description
            "Container with the actions for the BMP operation";
          action session-reset {
            description
              "Resets the session for a station.";
            output {
              choice outcome {
                description
                  "Output of the reset operation. Either a success or
                   failure. For the latter, the reason for the 
                   error is provided.";
                leaf success {
                  type empty;
                  description
                    "Reset successful";
                }
                leaf failure {
                  type string;
                  description
                    "Reset could not be performed. 
                    Reason is included in the field";
                }
              }
            }
          }
        }

      }



    }


  }
}
            ]]></artwork>
          </figure>
        <t>&lt;CODE ENDS></t>
      </section> 
    </section>  
                    
    <section title="Security Considerations" anchor="security-considerations">
      <t> 
         The YANG module specified in this document defines a schema for data
          that is designed to be accessed via network management protocols such
          as NETCONF <xref target="RFC6241"/> or RESTCONF <xref
          target="RFC8040"/>. The lowest NETCONF layer is the secure transport
          layer, and the mandatory-to-implement secure transport is Secure
          Shell (SSH) <xref target="RFC6242"/>. The lowest RESTCONF layer is
          HTTPS, and the mandatory-to-implement secure transport is TLS <xref
          target="RFC8446"/>. The NETCONF Access Control Model (NACM) <xref
              target="RFC8341"/> provides the means to restrict access for
          NETCONF or RESTCONF users to a preconfigured subset of all
          available NETCONF or RESTCONF protocol operations and content. 
      </t>
      <t>
         BGP data is sensible for security considerations. The model described
          in this document could be used to send BGP information to malicious
          BMP stations. Write access to this model SHOULD therefore be
          properly protected. 
      </t>
      <t>
          The session-reset action can demand considerable amount of resources
          from network elements. It SHOULD thus be protected from illegal access.
      </t>
    </section>

    <section title="IANA Considerations" anchor="iana-considerations">
      <section title="The IETF XML Registry">
      	<t>
      	   This document registers a URIs in the IETF XML 
      	   registry <xref target="RFC3688"/>.  Following the format in 
           <xref target="RFC3688"/>, the following registrations are
           requested:</t>
        <t>
          <figure>
          	<artwork>
   URI: urn:ietf:params:xml:ns:yang:ietf-bmp
   Registrant Contact: The IESG.
   XML: N/A, the requested URI is an XML namespace.
             </artwork>
           </figure>
         </t>
      </section>
      <section title="The YANG Module Name Registration">
        <t>
           This document registers the following YANG module in the "
           YANG Module Names" registry  
           registry <xref target="RFC6020"/>:</t>
        <t>
          <figure>
            <artwork>
   Name: ietf-bmp
   Namespace: urn:ietf:params:xml:ns:yang:ietf-bmp
   Prefix: bmp
   Reference: [This RFC-to-be]
             </artwork>
           </figure>
         </t>
      </section>
    </section>

    <section title="Open Issues">
      <t>
        <list counter="a">
          <t>The security considerations section will have to be aligned with 
              https://trac.ietf.org/trac/ops/wiki/yang-security-guidelines</t>
        </list>
      </t>
    </section>
  </middle>

  <back>
    <references title="Normative References"> 
      <?rfc include="reference.RFC.2119"?>
      <?rfc include="reference.RFC.3688"?>
      <?rfc include="reference.RFC.6241"?>
      <?rfc include="reference.RFC.6242"?>
      <?rfc include="reference.RFC.6991"?>
      <?rfc include="reference.RFC.7854"?>
      <?rfc include="reference.RFC.8671"?>
      <?rfc include="reference.RFC.9069"?>
      <?rfc include="reference.RFC.8040"?>
      <?rfc include="reference.RFC.8174"?>
      <?rfc include="reference.RFC.8349"?>
      <?rfc include="reference.RFC.8446"?>
      <?rfc include="reference.RFC.8341"?>
      <?rfc include="reference.RFC.6020"?>
      <?rfc include="reference.RFC.8529"?>
      <?rfc include="reference.RFC.1191"?>
      <?rfc include="reference.RFC.8177"?>
      <?rfc include='reference.I-D.ietf-idr-bgp-model'?>
      <?rfc include='reference.I-D.ietf-netconf-tcp-client-server'?>
    </references>
<!--
    <references title="Informative References">
    </references>
        -->
    <?rfc needLines="100"?>

<!--   
    <section title="Changes between revisions">
      </t>   
      <t>v00 - v01
        <list style="symbols">
          <t>Placeholder: xxx</t>
          <t>Placeholder: yyy</t>
        </list>
      </t>
    </section>    
  -->

    <section title="Examples">
        <t>This sections shows some examples of BMP configuration using the
            model.</t>
        <section title="Example one">
            <t>In this example, the device connects to a monitoring station
            using an active connection. 
            The devices sends route monitoring messages for the global
            instance, the adj-rib-out-pre RIB, the IPv4/IPv6 address family,
            and external peers.
            </t>
        <t><figure>
            <artwork><![CDATA[
=============== NOTE: '\' line wrapping per RFC 8792 ================

<bmp xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
<monitoring-stations>
  <monitoring-station>
    <id>1</id>
    <connection>
      <active>
        <station-address>192.0.2.1</station-address>
        <station-port>57992</station-port>
        <local-address>192.0.2.2</local-address>
      </active>
    </connection>
    <bmp-data>
      <bmp-route-monitoring>
        <network-instances>
          <network-instance>
              <network-instance-id>
                      bmp-ni-types-global-ni</network-instance-id>
            <adj-rib-in-pre>
              <address-families>
                <address-family>
                    <address-family-id 
                xmlns:bt="urn:ietf:params:xml:ns:yang:ietf-bgp-types\
">
                            bt:ipv6-unicast</address-family-id>
                  <peers>
                    <peer>
                      <peer-id>external</peer-id>
                    </peer>
                  </peers>
                </address-family>
                <address-family>
                    <address-family-id 
               xmlns:bt="urn:ietf:params:xml:ns:yang:ietf-bgp-types">
                            bt:ipv4-unicast</address-family-id>
                  <peers>
                    <peer>
                      <peer-id>external</peer-id>
                    </peer>
                  </peers>
                </address-family>
              </address-families>
            </adj-rib-in-pre>
          </network-instance>
        </network-instances>
      </bmp-route-monitoring>
    </bmp-data>
  </monitoring-station>
</monitoring-stations>
</bmp>
]]></artwork>         
    </figure></t>
    </section>
        <section title="Example two">
            <t>In the next example, the device connects to a monitoring station
            using a passive connection, over the network-instance monitoring.
            The configuration of route monitoring messages is more complex than
            in the previous example.  It shows how to combine the configuration
            of general identities of network instances and peers (e.g.
            bmp-ni-types-all-ni for NI, external for peers), and individual
            configurations to support a more complex requirement. This is what
                the example expects to configure:</t>
        <t>
        <list style="symbols">
            <t> For the global network instance,
            the device sends updates for adj-rib-in-pre, address families IPv4
            and IPv6. It sends updates for all external peers except peer
            128.66.1.1, which is disabled.</t>
        <t>Network instance monitoring is disabled for route monitoring messages. </t>
        <t>For the rest of network
            instances, we are enabling messages from adj-rib-in-pre, address
                families IPv4/IPv6, and for all peers.</t>
        </list>
        </t>
        <t><figure>
            <artwork><![CDATA[
=============== NOTE: '\' line wrapping per RFC 8792 ================

<bmp xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
    <monitoring-stations>
      <monitoring-station>
        <id>2</id>
        <connection>
          <passive>
            <network-instance>monitoring</network-instance>
            <station-address>192.0.2.1</station-address>
            <local-address>192.0.2.2</local-address>
            <local-port>57993</local-port>
          </passive>
        </connection>
        <bmp-data>
          <bmp-route-monitoring>
            <network-instances>
              <network-instance>
                  <network-instance-id>
                          bmp-ni-types-all-ni</network-instance-id>
                <adj-rib-in-pre>
                  <address-families>
                    <address-family>
                        <address-family-id 
                  xmlns:bt="urn:ietf:params:xml:ns:yang:ietf-bgp-typ\
es">
                                bt:ipv6-unicast</address-family-id>
                      <peers>
                        <peer>
                          <peer-id>bmp-peer-types-all-peers</peer-id>
                        </peer>
                      </peers>
                    </address-family>
                    <address-family>
                        <address-family-id 
                  xmlns:bt="urn:ietf:params:xml:ns:yang:ietf-bgp-typ\
es">
                                bt:ipv4-unicast</address-family-id>
                      <peers>
                        <peer>
                          <peer-id>bmp-peer-types-all-peers</peer-id>
                        </peer>
                      </peers>
                    </address-family>
                  </address-families>
                </adj-rib-in-pre>
              </network-instance>
              <network-instance>
                  <network-instance-id>
                          bmp-ni-types-global-ni</network-instance-i\
d>
                <adj-rib-in-pre>
                  <address-families>
                    <address-family>
                        <address-family-id 
                 xmlns:bt="urn:ietf:params:xml:ns:yang:ietf-bgp-type\
s">
                                bt:ipv6-unicast</address-family-id>
                      <peers>
                        <peer>
                          <peer-id>128.66.1.1</peer-id>
                          <enabled>false</enabled>
                        </peer>
                        <peer>
                          <peer-id>external</peer-id>
                        </peer>
                      </peers>
                    </address-family>
                    <address-family>
                        <address-family-id 
                xmlns:bt="urn:ietf:params:xml:ns:yang:ietf-bgp-types\
">
                                bt:ipv4-unicast</address-family-id>
                      <peers>
                        <peer>
                          <peer-id>128.66.1.1</peer-id>
                          <enabled>false</enabled>
                        </peer>
                        <peer>
                          <peer-id>external</peer-id>
                        </peer>
                      </peers>
                    </address-family>
                  </address-families>
                </adj-rib-in-pre>
              </network-instance>
              <network-instance>
                <network-instance-id>monitoring</network-instance-id>
                <enabled>false</enabled>
              </network-instance>
            </network-instances>
          </bmp-route-monitoring>
        </bmp-data>
      </monitoring-station>
    </monitoring-stations>
  </bmp>
]]></artwork>         
    </figure></t>
    </section>
    </section>

    <section title="Acknowledgements" numbered="no">
        <t>
          The authors would like to thank Yimin Shen, Jeff Haas, Pierre Vander
            Vorst, and Tom Petch for their review and feedback.
        </t>
    </section>

  </back>
</rfc>
<!-- Local Variables: -->
<!-- fill-column:72 -->
<!-- End: -->

