BMP YANG Module
Camilo Cardona
NTT
164-168, Carrer de Numancia
Barcelona
08029
Spain
camilo@ntt.net
Paolo Lucente
NTT
Siriusdreef 70-72
Hoofddorp
2132
Netherlands
paolo@ntt.net
Thomas Graf
Swisscom
Binzring 17
Zurich 8045
Switzerland
thomas.graf@swisscom.com
Benoit Claise
Huawei
benoit.claise@huawei.com
OPS
GROW
This document proposes a YANG module for the configuration and monitoring of the BGP Monitoring Protocol (BMP).

Terminology
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 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.
Routing Information Bases, peers, monitoring stations, and initiation messages are defined in [RFC7854].

Model description
This document specifies a YANG module for configuring and monitoring the BGP Monitoring Protocol (BMP) [RFC7854]. The model provides parameters for configuring the session to BMP monitoring stations; the selection of the BGP Routing Information Bases (RIBs) for Route Monitoring Messages; provides operational metrics and enables resetting of BMP monitoring sessions.
The model is included in Section 3. In this section, we provide details and examples of each of its parts.
The BMP yang model is placed at the root of the YANG tree. At its upper level, the BMP model lists each monitoring station. Every monitoring station is identified by an ID, which is a string provided by the operator.

IP Connectivity
BMP allows for active and passive connections between the router and the BMP monitoring station as described in Section 3.2 of [RFC7854]. In an active connection, the router establishes the TCP connection to the monitoring station, while in a passive one, it is the monitoring station which initiates the connection. The BMP yang module provides options for both types of connection using a choice.
We describe each type of connection option next, and provide examples of their configuration.

Active connection
For an active connection, the IP address and port of the monitoring station, together with the local address MUST be provided. One can optionally provide the local port for establishing the connection. If the monitoring station is connected over a network-instance instead of the global one, this one must also be specified. An example of configuration is included in Figure 1.
Active connection example

<?xml version="1.0"?>
<bmp xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
  <bmp-monitoring-stations>
    <bmp-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-monitoring-station>
  </bmp-monitoring-stations>
</bmp>

Note in the example from Figure 1 that there is no network instance defined, so the connection is using the global network instance.

Passive connection
In a passive connection, the IP of the monitoring station, the local address and local port for the incoming connection must be specified. If the port of the monitoring station is provided, it MUST match the incoming connection. If the monitoring station is connected through a network-instance instead of the global one, this one MUST also be specified.
An incoming connection not matching a valid entry MUST be ignored by the router.
Passive connection example

<?xml version="1.0"?>
<bmp xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
  <bmp-monitoring-stations>
    <bmp-monitoring-station>
      <id>monitoring_station_two</id>
      <connection>
        <passive>
          <network-instance>test</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-monitoring-station>
  </bmp-monitoring-stations>
</bmp>

TCP Options
The BMP module allows tuning various parameters of the TCP connection supporting the BMP session:
- For configuring TCP keepalives, the connection container uses the tcp-common-grouping from [I-D.ietf-netconf-tcp-client-server]. Please see Section 2.1.3.1 of [I-D.ietf-netconf-tcp-client-server] for the explanation of each of its parameters. Note that for the configuration of these parameters, the device must have the feature "tcp-client-keepalives" enabled. See also Section 3.8.4 of [RFC9293]
- The maximum segment of the TCP connection. See Section 3.7.1 of [RFC9293].
- Enabling MTU discovery for the path. See Section 3.7.2 of [RFC9293].
- Session security. Provides options for authentication using AO and MD5. This part of the model was taken from the BGP yang model [I-D.ietf-idr-bgp-model].
Figures 3 and 4 include examples configuring the previous TCP parameters in the model.
Example of configuring basic TCP parameters

<?xml version="1.0"?>
<bmp xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
  <bmp-monitoring-stations>
    <bmp-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>
        <tcp-options>
          <keepalives>
            <idle-time>15</idle-time>
            <max-probes>3</max-probes>
            <probe-interval>30</probe-interval>
          </keepalives>
          <maximum-segment-size>1500</maximum-segment-size>
          <mtu-discovery>true</mtu-discovery>
        </tcp-options>
      </connection>
    </bmp-monitoring-station>
  </bmp-monitoring-stations>
</bmp>

Example of the Configuration of TCP session security.

=============== NOTE: '\' line wrapping per RFC 8792 ================

  <key-chains xmlns="urn:ietf:params:xml:ns:yang:ietf-key-chain">
    <key-chain>
      <name>bmp-key-chain</name>
      <description>An example of TCP-AO configuration for BMP</descr\
iption>
      <key>
        <key-id>55</key-id>
        <crypto-algorithm>aes-cmac-prf-128</crypto-algorithm>
        <lifetime>
          <send-lifetime>
            <start-date-time>2023-01-01T00:00:00+00:00</start-date-t\
ime>
            <end-date-time>2023-02-01T00:00:00+00:00</end-date-time>
          </send-lifetime>
          <accept-lifetime>
            <start-date-time>2023-01-01T00:00:00+00:00</start-date-t\
ime>
            <end-date-time>2023-02-01T00:00:00+00:00</end-date-time>
          </accept-lifetime>
        </lifetime>
        <key-string>
          <keystring>teststring</keystring>
        </key-string>
        <authentication xmlns="urn:ietf:params:xml:ns:yang:ietf-tcp">
          <keychain>bmp-key-chain</keychain>
          <ao>
            <send-id>65</send-id>
            <recv-id>87</recv-id>
          </ao>
        </authentication>
      </key>
      <key>
        <key-id>56</key-id>
        <crypto-algorithm>aes-cmac-prf-128</crypto-algorithm>
        <lifetime>
          <send-lifetime>
            <start-date-time>2023-01-01T00:00:00+00:00</start-date-t\
ime>
            <end-date-time>2023-02-01T00:00:00+00:00</end-date-time>
          </send-lifetime>
          <accept-lifetime>
            <start-date-time>2023-01-01T00:00:00+00:00</start-date-t\
ime>
            <end-date-time>2023-02-01T00:00:00+00:00</end-date-time>
          </accept-lifetime>
        </lifetime>
        <authentication xmlns="urn:ietf:params:xml:ns:yang:ietf-tcp">
          <keychain>bmp-key-chain</keychain>
          <ao>
            <send-id>65</send-id>
            <recv-id>87</recv-id>
          </ao>
        </authentication>
      </key>
    </key-chain>
  </key-chains>
  <bmp xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
    <bmp-monitoring-stations>
      <bmp-monitoring-station>
        <id>monitoring_station_one</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>
          <tcp-options>
            <secure-session-enable>true</secure-session-enable>
            <secure-session>
              <ao-keychain>bmp-key-chain</ao-keychain>
            </secure-session>
          </tcp-options>
        </connection>
      </bmp-monitoring-station>
    </bmp-monitoring-stations>
  </bmp>

Other BMP connectivity options
The model also includes the next options to configure the connection to the BMP monitoring station:
- Initial-delay: a value in seconds that the device must hold back before starting the connection to the station.
- Backoff time. Configuration of the backoff time strategy after failing to connect to the monitoring station. The model includes a basic exponential backoff with a default initial backoff of 30 seconds and a maximum of 720 seconds, as suggested in Section 3.2 of [RFC7854].
In the example in Figure 5, we configure an initial-delay of 10. Configuring an initial-backoff of 50 seconds and 600 of maximum-backoff.
Example of the initial-delay and simple exponential backoff.

<?xml version="1.0"?>
<bmp xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
  <bmp-monitoring-stations>
    <bmp-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>
        <initial-delay>10</initial-delay>
        <backoff>
            <simple-exponential>
                <initial-backoff>50</initial-backoff>
                <maximum-backoff>600</maximum-backoff>
            </simple-exponential>
        </backoff>
      </connection>
    </bmp-monitoring-station>
  </bmp-monitoring-stations>
</bmp>

BMP data
The bmp-data container defines the configuration parameters for the data that the device sends to the monitoring station using the various BMP messages. See Section 4 of [RFC7854].
The BMP model defines options for the initiation message, the statistics report, and the routing monitoring. The first two have simple configurations options and are shortly described next. The Routing monitoring is the most complex of all and it is detailed in Section 2.4.1.
- Initiation-message: Content for an information TLV type-0 for identification of the device. See 4.3 and Section 4.4 of [RFC7854]
- Statistics-interval: The statistics report is enabled by the presence of the bmp-statistics-report container. The statistics-interval is mandatory if the bmp-statistics-report container exists and defines the interval of the statistics report. See Section 4.8 of [RFC7854].
An example of configuring the previous options is included in Figure 6
Example of configuration of initiation-message and statistics report interval.

=============== NOTE: '\' line wrapping per RFC 8792 ================

<?xml version="1.0"?>
<bmp xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
  <bmp-monitoring-stations>
    <bmp-monitoring-station>
      <id>monitoring_station_one</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>
        <initiation-message>BMP device supporting the BMP yang modul\
e</initiation-message>
        <bmp-statistics-report>
          <statistics-interval>600</statistics-interval>
        </bmp-statistics-report>
      </bmp-data>
    </bmp-monitoring-station>
  </bmp-monitoring-stations>
</bmp>

BMP route monitoring
Route monitoring messages are used for synchronization of RIBs to the monitoring station. See Section 5 of [RFC7854].
The next 3 requirements were defined before designing this part of the model.
- Operators might not want to receive all routes from all RIBs in a network device. For instance, some devices contain a considerable amount of data that might overwhelm the monitoring station. In this cases, operators might want to only collect information from an arbitrary subset of RIBs, address families, peers.
- Operators might want to configure the route monitoring messages for different network instances differently. For example, they might want to receive different address families from the global network instance than in L3 VPN network instances.
- In contrast to the previous points. some operators might want a simple configuration that covers multiple cases (e.g. same config for all peers, or same config for all network instances). This would not only make configurations look smaller and concise, but will reduce the need for reconfiguring devices when you add a new peer or add a new network instance (which happens frequently on some type of networks).
Based on the previous points, the BMP yang model is designed to flexibly control the data sent through the BMP route monitoring packets, yet it provides options to facilitate configurations for simple cases, such as when the operator wants to receive all routes from a RIB.
The Routing monitoring configuration is divided in a 4 part hierarchy:
- Network Instance
- RIB Type (e.g. Adj-RIB-IN pre/post, local RIB)
- Address Family
- Peers
Absence of the routing monitoring container will disable the routing monitoring messages to the monitoring station.
We'll offer an introduction to these hierarchies before going over them with detail.
The number of RIB types (e.g. Adj-RIB-IN, etc/OUT and local RIB) and Address families is low, and their configuration should not change frequently. Therefore, they are configured explicitly in the model. That is, the model does not provide a way of providing a default configuration for these or configuring them in groups.
On the other hand, Network instances and peers require greater flexibility.
For network instances, the model should configure not only the "global" network instance (the main one configured under the /ietf-routing:routing), but also other network instances configured under the /ietf-network-instance:network-instances/. Also, network instances can change frequently in networks with customer connecting to Virtual Private Networks. To not force operators to change configuration at every change, the model provides methods for defining a "default" configuration for network instances. However, to provide control over the configuration, each network instance can be configured independently, if needed.
A situation is similar with peers for the Adj-RIB-IN and Adj-RIB-OUT RIBs. The model includes a way of configuring a default for all peers for simple cases, but one can provide configuration for type of peers, peergroups, or each peer individually.
We summarize the requirements stated on the previous two paragraphs next:
For network instances:
- The configuration should be simple for cases where only the "global" routing instance is enabled.
- The model should provide ways of configuring all Network instances (kind of a default config for any Network instance that is configured in the device).
- The model should provide a way of configuring network instances individually.
For peers:
- The model should provide ways of configuring all peers, kind of a default. This would be the most common case.
- The model should provide ways of configuring peergroups.
- The model should provide ways of configuring type of peers. For instance, only send routes from eBGP peers.
- The model should provide ways of configuring individual peers. For instance, turn a route-policy filtering prefix for a specific peer, or turning off a peer that is noisy yet not important.
To further control the route monitoring data, the peer/peer-type container includes a route-policy option in which the operator can further filter the data send to the BMP monitoring station.
We'll describe each of the 4 hierarchies, and provide examples for each, in the next sections.

Network instances
The routing monitoring configuration starts with the configuration of network instances. A network instance can be configured individual or it can be configured if it matches any of the selectors from the "bmp-ni-types" identity. We explain each next
The model currently defines two bmp-ni-types identities: "bmp-ni-types-all-ni" which selects all network instances, and "bmp-ni-types-non-global-ni" which selects all network instances, except the global one. The former can be used as a "default" configuration for simple cases.
The model offers two ways of configuring a network-instance individually. The main one is under container "bmp-data/bmp-monitoring-stations/" under the "routing/control-plane-protocols/control-plane-protocol/bgp". The second one is specifying the name under the "bmp/bmp-route-monitoring/network-instance". The former one is the prefered method, since it allows for better validation of the data. This method requires the support of schema-mount. The latter method does not validate some leafs, but it does not requires support for schema-mount by the device.
An empty configuration disables routing monitoring messages for the selected network-instances. Operators can also use the "enable" leaf to disable explicitly the routing messages for the network instance.
The route-monitoring data for a network instance can be configured by maximum one element of the network-instances list. There SHOULD be clear rules to which element to apply to a network instance in case multiple elements can select it. We provide rules and examples in the next part of the section.
- If the BGP container under the network-instance includes a BMP/Route monitoring container, it SHOULD be configured by it. Note that if the monitoring-station is not present in the container, the route monitoring will be disabled for this network instance.
- If the bmp-ni-types-global-ni exist, the global network instance / network instance SHOULD be configured using this element.
- If any /ni:network-instances/ni:network-instance/ is referenced, the network instance SHOULD be configured using this element.
- Any Network instance not referenced by any rule above SHOULD be configured using the bmp-ni-types-all-ni if one exists. If it does not exist, then the network instance is not configured (and therefore no route monitoring messages from the network instance are sent to the monitoring station).
Any extension of the bmp-ni-types SHOULD provide explanations of how to deal with case in which multiple elements select the same network instance.
We provide examples of configuring the network instance level next. For now, we will focus on the configuration using the BMP container (not the configuration under the BGP container). To focus on the network instance configuration, we mask the configuration under each instance using "Configuration X".
Examples of configuring the network instance level for Route Monitoring.

=============== NOTE: '\' line wrapping per RFC 8792 ================

<?xml version="1.0"?>
<bmp xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
  <bmp-monitoring-stations>
    <bmp-monitoring-station>
      <id>monitoring_station_one</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-instance-configuration>
            <network-instance>
              <network-instance-id>bmp-ni-types-all-ni</network-inst\
ance-id>
              <!-- Configuration A -->
            </network-instance>
            <network-instance>
              <network-instance-id>bmp-ni-types-global-ni</network-i\
nstance-id>
              <!-- Configuration B -->
            </network-instance>
            <network-instance>
              <network-instance-id>network-instance-two</network-ins\
tance-id>
              <!-- Configuration C -->
            </network-instance>
            <network-instance>
              <network-instance-id>network-instance-one</network-ins\
tance-id>
              <enabled>false</enabled>
            </network-instance>
          </network-instance-configuration>
        </bmp-route-monitoring>
      </bmp-data>
    </bmp-monitoring-station>
  </bmp-monitoring-stations>
</bmp>

In example from Figure 7, we have a "default" configuration (Configuration A) applied to any network instance without any explicit configuration. The global network instance and network-instance-two get Configuration B and Configuration C, respectively. The network-instance-one instance container disables the routing monitoring messages for that network instance.
Example of configuring all network instances.

=============== NOTE: '\' line wrapping per RFC 8792 ================

<?xml version="1.0"?>
<bmp xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
  <bmp-monitoring-stations>
    <bmp-monitoring-station>
      <id>monitoring_station_one</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-instance-configuration>
            <network-instance>
              <network-instance-id>bmp-ni-types-all-ni</network-inst\
ance-id>
              <!-- Configuration D -->
            </network-instance>
        </network-instance-configuration>
        </bmp-route-monitoring>
      </bmp-data>
    </bmp-monitoring-station>
  </bmp-monitoring-stations>
</bmp>

The example in Figure 8 shows a "simple" configuration. In this case, all network instances would get "Configuration D". Note that `bmp-ni-types-all-ni` would also cover the global instance.
Another simple configuration would just involve configuring the global network instance. In this case, information of non-global network instances would not be sent to the monitoring station. This is depicted in Figure 9
Example of configuring only the global network instance.

=============== NOTE: '\' line wrapping per RFC 8792 ================

<?xml version="1.0"?>
<bmp xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
  <bmp-monitoring-stations>
    <bmp-monitoring-station>
      <id>monitoring_station_one</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-instance-configuration>
            <network-instance>
              <network-instance-id>bmp-ni-types-all-ni</network-inst\
ance-id>
              <!-- Configuration D -->
            </network-instance>
        </network-instance-configuration>
        </bmp-route-monitoring>
      </bmp-data>
    </bmp-monitoring-station>
  </bmp-monitoring-stations>
</bmp>

RIB Type
Alternatively to the configuration of Figure 9, one can configure directly the global instance, but using the BMP configuration under the BGP container
Each RIB type is configured explicitly in the model through a container. The model currently provides containers for adj-rib-out-pre, adj-rib-out-post, adj-rib-in-post, adj-rib-in-pre and local-rib.
An empty configuration or absence of a RIB-type container disables route-messages for it. Operators can also disable the RIB-type route monitoring messages by marking the "enabled" leaf as False.
We provide an example of this, together with address families, in the next section

Address families
Address families are configured explicitly within each RIB-TYPE using a list. The key is of type `ietf-bgp-types:afi-safi-type` without any further constraint.
An empty configuration or absence of an address family disables route-messages for it. Operators can also disable the address-family route monitoring messages by marking the "enabled" leaf as False.
We show a few examples of configuring RIB-Types and Address families next. We will mask further configurations of address families with "Configuration X" to focus on the covered parts.
Example of configuring RIBs and address families.

=============== NOTE: '\' line wrapping per RFC 8792 ================

<?xml version="1.0"?>
<bmp xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
  <bmp-monitoring-stations>
    <bmp-monitoring-station>
      <id>monitoring_station_one</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-instance-configuration>
            <network-instance>
              <network-instance-id>bmp-ni-types-all-ni</network-inst\
ance-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>
                    <!-- Configuration F -->
                  </address-family>
                  <address-family>
                    <address-family-id xmlns:bt="urn:ietf:params:xml\
:ns:yang:ietf-bgp-types">bt:ipv4-unicast</address-family-id>
                    <!-- Configuration G -->
                  </address-family>
                </address-families>
              </adj-rib-in-pre>
            </network-instance>
            <network-instance>
              <network-instance-id>bmp-ni-types-global-ni</network-i\
nstance-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>
                    <!-- Configuration H -->
                  </address-family>
                  <address-family>
                    <address-family-id xmlns:bt="urn:ietf:params:xml\
:ns:yang:ietf-bgp-types">bt:ipv4-unicast</address-family-id>
                    <!-- Configuration I -->
                  </address-family>
                </address-families>
              </adj-rib-in-pre>
              <adj-rib-in-post>
                <address-families>
                  <address-family>
                    <address-family-id xmlns:bt="urn:ietf:params:xml\
:ns:yang:ietf-bgp-types">bt:ipv6-unicast</address-family-id>
                    <!-- Configuration H -->
                  </address-family>
                  <address-family>
                    <address-family-id xmlns:bt="urn:ietf:params:xml\
:ns:yang:ietf-bgp-types">bt:ipv4-unicast</address-family-id>
                    <!-- Configuration I -->
                  </address-family>
                </address-families>
              </adj-rib-in-post>
            </network-instance>
            <network-instance>
              <network-instance-id>network-instance-one</network-ins\
tance-id>
              <enabled>false</enabled>
            </network-instance>
            <network-instance>
              <network-instance-id>network-instance-two</network-ins\
tance-id>
              <adj-rib-in-post>
                <address-families>
                  <address-family>
                    <address-family-id xmlns:bt="urn:ietf:params:xml\
:ns:yang:ietf-bgp-types">bt:ipv4-unicast</address-family-id>
                    <!-- Configuration L -->
                  </address-family>
                </address-families>
              </adj-rib-in-post>
            </network-instance>
          </network-instance-configuration>
        </bmp-route-monitoring>
      </bmp-data>
    </bmp-monitoring-station>
  </bmp-monitoring-stations>
</bmp>

In Figure 10, we expand previous sections examples with RIB-Type and address families configurations. The expected result of the previous configuration would be:
- For the global network instance, adj-rib-in-pre and adj-rib-in-post RIBs are enabled. In each of them IPv4 and IPv6 address families are configured. The configuration can be the same or not, depending on the requirements of the operators. Any other RIB and address families are disabled.
- Network instance one is disabled, meaning that routing monitoring messages are disabled for that network instance.
- Network instance "network-instance-two" has adj-rib-out-post enabled, but only address family ipv4-unicast is configured. The ipv6-unicast will not be configured for this instance.
- For all other network instances, adj-rib-in-pre with IPv4 and IPv6 address families are configured, thanks to the configuration of bmp-ni-types-all-ni
If an operator only wants to configure the IPv4/IPv6 of adj-rib-pre-in for the global instance, the configuration in Figure 11 plus the peer configuration (coming in next section) will be enough. We note again that even if the configuration of both address families is the same, they must be explicitly configured for each of them.
Example of configuring RIBs and address families.

=============== NOTE: '\' line wrapping per RFC 8792 ================

<?xml version="1.0"?>
<bmp xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
  <bmp-monitoring-stations>
    <bmp-monitoring-station>
      <id>monitoring_station_one</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-instance-configuration>
            <network-instance>
              <network-instance-id>bmp-ni-types-global-ni</network-i\
nstance-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>
                    <!-- Configuration for ipv6-uniceast -->
                  </address-family>
                  <address-family>
                    <address-family-id xmlns:bt="urn:ietf:params:xml\
:ns:yang:ietf-bgp-types">bt:ipv4-unicast</address-family-id>
                    <!-- Configuration for ipv4-unicast -->
                  </address-family>
                </address-families>
              </adj-rib-in-pre>
            </network-instance>
          </network-instance-configuration>
        </bmp-route-monitoring>
      </bmp-data>
    </bmp-monitoring-station>
  </bmp-monitoring-stations>
</bmp>

Peers
For adj-RIB-in and adj-RIB-out, both pre and post, the model requires the selection of peer's RIBs that will be transmitted to the monitoring station. The local-rib does not include this container.
Peers are a list indexed by a peer id, which can be one of the following:
- An individual peer, using a remote address. For the configuration under the "/bmp" tree, The model currently does not check if the remote address exists, that would be a responsibility of the device.
- Peergroups.
- A group of peers matching a BGP type. i.e. eBGP peers.
- One or more peers defined by an `bmp-peer-types` identity. The BMP model currently provides the `bmp-peer-types-all-peers` identity which select all peers. For simple cases, this is the value that would normally be considered.
Peers MUST be selected (configured) by maximum a single instance of the peers list. For the included keys in the BMP model, the process to select which instance to use is the next:
- If there is a peer address matching the peer, it should be configured using that instance.
- If the peer is of any BGP type listed in the peer list, it should be configured using this instance.
- If there is a peer instance identified with the `bmp-peer-types-all-peers`, it would be configured using this instance.
- Finally, if no instance covers the peer, the data from this peer should not be transmitted to the monitoring station.
An empty configuration of a peer type disables route-messages for it. Operators can also disable the address-family route monitoring messages by marking the "enabled" leaf as False.
Any additional bmp-peer-types identity created SHOULD describe how to unambiguously select a peer when there are conflicting options (multiple options covering the peer).
We'll provide examples of the peers configuration after describing the filter containers.

Filtering route-monitoring messages
The local rib, and the peer containers within the rest of rib types, include a filter container. This container includes mechanisms to filter route-monitoring messages for the specific RIB.
The policy-filter can include a routing policy that, if existing, should be applied to the outgoing updates to the monitoring station, and would serve as a granular way of filtering the messages that the monitoring station receives.
Note that the policy-filter contains an `accept-route` default export policy. An operator can change it to a reject-route, if required.
The policies created with the routing-policy can perform a large variety of actions routes, and can filter them based on multiple characteristics. For the consistency of the data in the monitoring station, the route policies actions SHOULD be restricted to accepting or rejecting routes. Furthermore, the conditions SHOULD only match prefix sets.
We present examples of full configurations next.

Full examples of Route monitoring configurations

Example one
In the example configuration from Figure 12, address families IPv6 and IPv4 are configured to send all peers. This is an example of a simple configuration
Enabling Route monitoring for all peers; all network instances; IPv4/IPv6 Address families, in the adj-rib-in-pre RIB.

=============== NOTE: '\' line wrapping per RFC 8792 ================

<?xml version="1.0"?>
<bmp xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
  <bmp-monitoring-stations>
    <bmp-monitoring-station>
      <id>monitoring_station_one</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-instance-configuration>
            <network-instance>
              <network-instance-id>bmp-ni-types-global-ni</network-i\
nstance-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-configurations>
                      <bmp-peer-types>
                        <bmp-peer-type>
                            <peer-types-bmp>bmp-peer-types-all-peers\
</peer-types-bmp>
                        </bmp-peer-type>
                      </bmp-peer-types>
                  </peers-configurations>
                  </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-configurations>
                      <bmp-peer-types>
                        <bmp-peer-type>
                            <peer-types-bmp>bmp-peer-types-all-peers\
</peer-types-bmp>
                        </bmp-peer-type>
                      </bmp-peer-types>
                  </peers-configurations>
                  </address-family>
                </address-families>
              </adj-rib-in-pre>
            </network-instance>
          </network-instance-configuration>
        </bmp-route-monitoring>
      </bmp-data>
    </bmp-monitoring-station>
  </bmp-monitoring-stations>
</bmp>

Example two
In the example in Figure 13, the global network instance enables the adj-rib-in-pre. In this RIB, the IPv4 unicast address family is configured for all external peers. We assume peer 198.51.100.1 is external, but its BGP configuration is not shown in the snippet. Peer 198.51.100.1, however, has a specific configuration: it announces everything but prefixes matching the test_policy list. Note that there is a default accept-route default policy in the model.
Configuring address families differently for the global network instance

=============== NOTE: '\' line wrapping per RFC 8792 ================

<?xml version="1.0"?>
<routing-policy xmlns="urn:ietf:params:xml:ns:yang:ietf-routing-poli\
cy">
<policy-definitions>
  <policy-definition>
    <name>test_policy</name>
    <!-- Policy definition -->
  </policy-definition>
</policy-definitions>
</routing-policy>
<bmp xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
<bmp-monitoring-stations>
  <bmp-monitoring-station>
    <id>monitoring_station_one</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-instance-configuration>
          <network-instance>
            <network-instance-id>bmp-ni-types-global-ni</network-ins\
tance-id>
            <adj-rib-in-pre>
              <address-families>
                <address-family>
                  <address-family-id xmlns:bt="urn:ietf:params:xml:n\
s:yang:ietf-bgp-types">bt:ipv6-unicast</address-family-id>
                  <peers-configurations>
                    <bmp-peer-types>
                      <bmp-peer-type>
                        <peer-types-bmp>bmp-peer-types-all-peers</pe\
er-types-bmp>
                      </bmp-peer-type>
                    </bmp-peer-types>
                  </peers-configurations>
                </address-family>
                <address-family>
                  <address-family-id xmlns:bt="urn:ietf:params:xml:n\
s:yang:ietf-bgp-types">bt:ipv4-unicast</address-family-id>
                  <peers-configurations>
                    <peer-types>
                        <peer-type>
                            <peer-type-id>external</peer-type-id>
                        </peer-type>
                    </peer-types>
                    <peers>
                      <peer>
                        <peer-id-str>198.51.100.1</peer-id-str>
                        <filters>
                          <policy-filter>
                            <export-policy>test_policy</export-polic\
y>
                          </policy-filter>
                        </filters>
                      </peer>
                    </peers>
                  </peers-configurations>
                </address-family>
              </address-families>
            </adj-rib-in-pre>
          </network-instance>
        </network-instance-configuration>
      </bmp-route-monitoring>
    </bmp-data>
  </bmp-monitoring-station>
</bmp-monitoring-stations>
</bmp>

Example three
In the example from Figure 14, all network instances have adj-rib-in-pre with IPv6 and IPv4 configured receiving all peers. network-instance-one is disabled, and network-instance-two is announcing only the local-rib/IPv4 unicast routes.
Applying a general configuration to all network instances, except of two, which are configured specifically.

=============== NOTE: '\' line wrapping per RFC 8792 ================

<?xml version="1.0"?>
<bmp xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
  <bmp-monitoring-stations>
    <bmp-monitoring-station>
      <id>monitoring_station_one</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-instance-configuration>
            <network-instance>
              <network-instance-id>bmp-ni-types-all-ni</network-inst\
ance-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-configurations>
                      <bmp-peer-types>
                        <bmp-peer-type>
                        <peer-types-bmp>bmp-peer-types-all-peers</pe\
er-types-bmp>
                        </bmp-peer-type>
                      </bmp-peer-types>
                    </peers-configurations>
                  </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-configurations>
                      <bmp-peer-types>
                        <bmp-peer-type>
                        <peer-types-bmp>bmp-peer-types-all-peers</pe\
er-types-bmp>
                    </bmp-peer-type>
                      </bmp-peer-types>
                    </peers-configurations>
                  </address-family>
                </address-families>
              </adj-rib-in-pre>
            </network-instance>
            <network-instance>
              <network-instance-id>network-instance-one</network-ins\
tance-id>
              <enabled>false</enabled>
            </network-instance>
            <network-instance>
              <network-instance-id>network-instance-two</network-ins\
tance-id>
              <local-rib>
                <address-families>
                  <address-family>
                    <address-family-id xmlns:bt="urn:ietf:params:xml\
:ns:yang:ietf-bgp-types">bt:ipv4-unicast</address-family-id>
                  </address-family>
                </address-families>
              </local-rib>
            </network-instance>
          </network-instance-configuration>
        </bmp-route-monitoring>
      </bmp-data>
    </bmp-monitoring-station>
  </bmp-monitoring-stations>
</bmp>

Session stats
The non-configurable container "session-stats" includes various metrics for the session with the monitoring station.

Session reset action
The "session-reset" action resets a session with a monitoring station.

Base ietf-bmp YANG module

Tree View
The following tree diagram provides an overview of the ietf-bmp.yang data model.

=============== NOTE: '\' line wrapping per RFC 8792 ================

module: ietf-bmp
  +--rw bmp
     +--rw bmp-monitoring-stations
        +--rw bmp-monitoring-station* [id]
           +--rw id               string
           +--rw connection
           |  +--rw (passive-or-active)
           |  |  +--:(active)
           |  |  |  +--rw active
           |  |  |     +--rw network-instance?   string
           |  |  |     +--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?   string
           |  |        +--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-instance-configuration
           |        +--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-configurations
           |           |           +--rw peers
           |           |           |  +--rw peer* [peer-id-str]
           |           |           |     +--rw peer-id-str
           |           |           |     |       string
           |           |           |     +--rw enabled?
           |           |           |     |       boolean
           |           |           |     +--rw filters
           |           |           |        +--rw policy-filter
           |           |           |           +--rw export-policy*
           |           |           |           |       leafref
           |           |           |           +--rw default-export-\
policy?
           |           |           |                   rt-pol:defaul\
t-policy-type
           |           |           +--rw peer-groups
           |           |           |  +--rw peer-group*
           |           |           |          [peer-group-id-str]
           |           |           |     +--rw peer-group-id-str
           |           |           |     |       string
           |           |           |     +--rw enabled?
           |           |           |     |       boolean
           |           |           |     +--rw filters
           |           |           |        +--rw policy-filter
           |           |           |           +--rw export-policy*
           |           |           |           |       leafref
           |           |           |           +--rw default-export-\
policy?
           |           |           |                   rt-pol:defaul\
t-policy-type
           |           |           +--rw bmp-peer-types
           |           |           |  +--rw bmp-peer-type*
           |           |           |          [peer-types-bmp]
           |           |           |     +--rw peer-types-bmp
           |           |           |     |       identityref
           |           |           |     +--rw enabled?
           |           |           |     |       boolean
           |           |           |     +--rw filters
           |           |           |        +--rw policy-filter
           |           |           |           +--rw export-policy*
           |           |           |           |       leafref
           |           |           |           +--rw default-export-\
policy?
           |           |           |                   rt-pol:defaul\
t-policy-type
           |           |           +--rw peer-types
           |           |              +--rw peer-type*
           |           |              |       [peer-type-id]
           |           |              |  +--rw peer-type-id
           |           |              |          bt:peer-type
           |           |              +--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-configurations
           |           |           +--rw peers
           |           |           |  +--rw peer* [peer-id-str]
           |           |           |     +--rw peer-id-str
           |           |           |     |       string
           |           |           |     +--rw enabled?
           |           |           |     |       boolean
           |           |           |     +--rw filters
           |           |           |        +--rw policy-filter
           |           |           |           +--rw export-policy*
           |           |           |           |       leafref
           |           |           |           +--rw default-export-\
policy?
           |           |           |                   rt-pol:defaul\
t-policy-type
           |           |           +--rw peer-groups
           |           |           |  +--rw peer-group*
           |           |           |          [peer-group-id-str]
           |           |           |     +--rw peer-group-id-str
           |           |           |     |       string
           |           |           |     +--rw enabled?
           |           |           |     |       boolean
           |           |           |     +--rw filters
           |           |           |        +--rw policy-filter
           |           |           |           +--rw export-policy*
           |           |           |           |       leafref
           |           |           |           +--rw default-export-\
policy?
           |           |           |                   rt-pol:defaul\
t-policy-type
           |           |           +--rw bmp-peer-types
           |           |           |  +--rw bmp-peer-type*
           |           |           |          [peer-types-bmp]
           |           |           |     +--rw peer-types-bmp
           |           |           |     |       identityref
           |           |           |     +--rw enabled?
           |           |           |     |       boolean
           |           |           |     +--rw filters
           |           |           |        +--rw policy-filter
           |           |           |           +--rw export-policy*
           |           |           |           |       leafref
           |           |           |           +--rw default-export-\
policy?
           |           |           |                   rt-pol:defaul\
t-policy-type
           |           |           +--rw peer-types
           |           |              +--rw peer-type*
           |           |              |       [peer-type-id]
           |           |              |  +--rw peer-type-id
           |           |              |          bt:peer-type
           |           |              +--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-configurations
           |           |           +--rw peers
           |           |           |  +--rw peer* [peer-id-str]
           |           |           |     +--rw peer-id-str
           |           |           |     |       string
           |           |           |     +--rw enabled?
           |           |           |     |       boolean
           |           |           |     +--rw filters
           |           |           |        +--rw policy-filter
           |           |           |           +--rw export-policy*
           |           |           |           |       leafref
           |           |           |           +--rw default-export-\
policy?
           |           |           |                   rt-pol:defaul\
t-policy-type
           |           |           +--rw peer-groups
           |           |           |  +--rw peer-group*
           |           |           |          [peer-group-id-str]
           |           |           |     +--rw peer-group-id-str
           |           |           |     |       string
           |           |           |     +--rw enabled?
           |           |           |     |       boolean
           |           |           |     +--rw filters
           |           |           |        +--rw policy-filter
           |           |           |           +--rw export-policy*
           |           |           |           |       leafref
           |           |           |           +--rw default-export-\
policy?
           |           |           |                   rt-pol:defaul\
t-policy-type
           |           |           +--rw bmp-peer-types
           |           |           |  +--rw bmp-peer-type*
           |           |           |          [peer-types-bmp]
           |           |           |     +--rw peer-types-bmp
           |           |           |     |       identityref
           |           |           |     +--rw enabled?
           |           |           |     |       boolean
           |           |           |     +--rw filters
           |           |           |        +--rw policy-filter
           |           |           |           +--rw export-policy*
           |           |           |           |       leafref
           |           |           |           +--rw default-export-\
policy?
           |           |           |                   rt-pol:defaul\
t-policy-type
           |           |           +--rw peer-types
           |           |              +--rw peer-type*
           |           |              |       [peer-type-id]
           |           |              |  +--rw peer-type-id
           |           |              |          bt:peer-type
           |           |              +--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-configurations
           |                       +--rw peers
           |                       |  +--rw peer* [peer-id-str]
           |                       |     +--rw peer-id-str
           |                       |     |       string
           |                       |     +--rw enabled?
           |                       |     |       boolean
           |                       |     +--rw filters
           |                       |        +--rw policy-filter
           |                       |           +--rw export-policy*
           |                       |           |       leafref
           |                       |           +--rw default-export-\
policy?
           |                       |                   rt-pol:defaul\
t-policy-type
           |                       +--rw peer-groups
           |                       |  +--rw peer-group*
           |                       |          [peer-group-id-str]
           |                       |     +--rw peer-group-id-str
           |                       |     |       string
           |                       |     +--rw enabled?
           |                       |     |       boolean
           |                       |     +--rw filters
           |                       |        +--rw policy-filter
           |                       |           +--rw export-policy*
           |                       |           |       leafref
           |                       |           +--rw default-export-\
policy?
           |                       |                   rt-pol:defaul\
t-policy-type
           |                       +--rw bmp-peer-types
           |                       |  +--rw bmp-peer-type*
           |                       |          [peer-types-bmp]
           |                       |     +--rw peer-types-bmp
           |                       |     |       identityref
           |                       |     +--rw enabled?
           |                       |     |       boolean
           |                       |     +--rw filters
           |                       |        +--rw policy-filter
           |                       |           +--rw export-policy*
           |                       |           |       leafref
           |                       |           +--rw default-export-\
policy?
           |                       |                   rt-pol:defaul\
t-policy-type
           |                       +--rw peer-types
           |                          +--rw peer-type*
           |                          |       [peer-type-id]
           |                          |  +--rw peer-type-id
           |                          |          bt:peer-type
           |                          +--rw enabled?     boolean
           |                          +--rw filters
           |                             +--rw policy-filter
           |                                +--rw export-policy*
           |                                |       leafref
           |                                +--rw default-export-pol\
icy?
           |                                        rt-pol:default-p\
olicy-type
           +--ro session-stats
           |  +--ro 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

  augment /rt:routing/rt:control-plane-protocols
            /rt:control-plane-protocol/bgp:bgp:
    +--rw bmp-data
       +--rw bmp-monitoring-stations!
          +--rw bmp-monitoring-station* [id]
             +--rw id                      string
             +--rw bmp-route-monitoring!
                +--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-configurations
                |           +--rw bmp-peer-types
                |           |  +--rw bmp-peer-type*
                |           |          [peer-types-bmp]
                |           |     +--rw peer-types-bmp
                |           |     |       identityref
                |           |     +--rw enabled?          boolean
                |           |     +--rw filters
                |           |        +--rw policy-filter
                |           |           +--rw export-policy*
                |           |           |       leafref
                |           |           +--rw default-export-policy?
                |           |                   rt-pol:default-polic\
y-type
                |           +--rw peer-types
                |           |  +--rw peer-type* [peer-type-id]
                |           |  |  +--rw peer-type-id
                |           |  |          bt:peer-type
                |           |  +--rw enabled?     boolean
                |           |  +--rw filters
                |           |     +--rw policy-filter
                |           |        +--rw export-policy*
                |           |        |       leafref
                |           |        +--rw default-export-policy?
                |           |                rt-pol:default-policy-t\
ype
                |           +--rw peer-groups
                |           |  +--rw peer-group* [peer-id]
                |           |     +--rw peer-id    leafref
                |           |     +--rw enabled?   boolean
                |           |     +--rw filters
                |           |        +--rw policy-filter
                |           |           +--rw export-policy*
                |           |           |       leafref
                |           |           +--rw default-export-policy?
                |           |                   rt-pol:default-polic\
y-type
                |           +--rw peers
                |              +--rw peer* [peer-id]
                |                 +--rw peer-id    leafref
                |                 +--rw enabled?   boolean
                |                 +--rw filters
                |                    +--rw policy-filter
                |                       +--rw export-policy*
                |                       |       leafref
                |                       +--rw default-export-policy?
                |                               rt-pol:default-polic\
y-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-configurations
                |           +--rw bmp-peer-types
                |           |  +--rw bmp-peer-type*
                |           |          [peer-types-bmp]
                |           |     +--rw peer-types-bmp
                |           |     |       identityref
                |           |     +--rw enabled?          boolean
                |           |     +--rw filters
                |           |        +--rw policy-filter
                |           |           +--rw export-policy*
                |           |           |       leafref
                |           |           +--rw default-export-policy?
                |           |                   rt-pol:default-polic\
y-type
                |           +--rw peer-types
                |           |  +--rw peer-type* [peer-type-id]
                |           |  |  +--rw peer-type-id
                |           |  |          bt:peer-type
                |           |  +--rw enabled?     boolean
                |           |  +--rw filters
                |           |     +--rw policy-filter
                |           |        +--rw export-policy*
                |           |        |       leafref
                |           |        +--rw default-export-policy?
                |           |                rt-pol:default-policy-t\
ype
                |           +--rw peer-groups
                |           |  +--rw peer-group* [peer-id]
                |           |     +--rw peer-id    leafref
                |           |     +--rw enabled?   boolean
                |           |     +--rw filters
                |           |        +--rw policy-filter
                |           |           +--rw export-policy*
                |           |           |       leafref
                |           |           +--rw default-export-policy?
                |           |                   rt-pol:default-polic\
y-type
                |           +--rw peers
                |              +--rw peer* [peer-id]
                |                 +--rw peer-id    leafref
                |                 +--rw enabled?   boolean
                |                 +--rw filters
                |                    +--rw policy-filter
                |                       +--rw export-policy*
                |                       |       leafref
                |                       +--rw default-export-policy?
                |                               rt-pol:default-polic\
y-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-configurations
                |           +--rw bmp-peer-types
                |           |  +--rw bmp-peer-type*
                |           |          [peer-types-bmp]
                |           |     +--rw peer-types-bmp
                |           |     |       identityref
                |           |     +--rw enabled?          boolean
                |           |     +--rw filters
                |           |        +--rw policy-filter
                |           |           +--rw export-policy*
                |           |           |       leafref
                |           |           +--rw default-export-policy?
                |           |                   rt-pol:default-polic\
y-type
                |           +--rw peer-types
                |           |  +--rw peer-type* [peer-type-id]
                |           |  |  +--rw peer-type-id
                |           |  |          bt:peer-type
                |           |  +--rw enabled?     boolean
                |           |  +--rw filters
                |           |     +--rw policy-filter
                |           |        +--rw export-policy*
                |           |        |       leafref
                |           |        +--rw default-export-policy?
                |           |                rt-pol:default-policy-t\
ype
                |           +--rw peer-groups
                |           |  +--rw peer-group* [peer-id]
                |           |     +--rw peer-id    leafref
                |           |     +--rw enabled?   boolean
                |           |     +--rw filters
                |           |        +--rw policy-filter
                |           |           +--rw export-policy*
                |           |           |       leafref
                |           |           +--rw default-export-policy?
                |           |                   rt-pol:default-polic\
y-type
                |           +--rw peers
                |              +--rw peer* [peer-id]
                |                 +--rw peer-id    leafref
                |                 +--rw enabled?   boolean
                |                 +--rw filters
                |                    +--rw policy-filter
                |                       +--rw export-policy*
                |                       |       leafref
                |                       +--rw default-export-policy?
                |                               rt-pol:default-polic\
y-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-configurations
                            +--rw bmp-peer-types
                            |  +--rw bmp-peer-type*
                            |          [peer-types-bmp]
                            |     +--rw peer-types-bmp
                            |     |       identityref
                            |     +--rw enabled?          boolean
                            |     +--rw filters
                            |        +--rw policy-filter
                            |           +--rw export-policy*
                            |           |       leafref
                            |           +--rw default-export-policy?
                            |                   rt-pol:default-polic\
y-type
                            +--rw peer-types
                            |  +--rw peer-type* [peer-type-id]
                            |  |  +--rw peer-type-id
                            |  |          bt:peer-type
                            |  +--rw enabled?     boolean
                            |  +--rw filters
                            |     +--rw policy-filter
                            |        +--rw export-policy*
                            |        |       leafref
                            |        +--rw default-export-policy?
                            |                rt-pol:default-policy-t\
ype
                            +--rw peer-groups
                            |  +--rw peer-group* [peer-id]
                            |     +--rw peer-id    leafref
                            |     +--rw enabled?   boolean
                            |     +--rw filters
                            |        +--rw policy-filter
                            |           +--rw export-policy*
                            |           |       leafref
                            |           +--rw default-export-policy?
                            |                   rt-pol:default-polic\
y-type
                            +--rw peers
                               +--rw peer* [peer-id]
                                  +--rw peer-id    leafref
                                  +--rw enabled?   boolean
                                  +--rw filters
                                     +--rw policy-filter
                                        +--rw export-policy*
                                        |       leafref
                                        +--rw default-export-policy?
                                                rt-pol:default-polic\
y-type

YANG Module
<CODE BEGINS> file "ietf-bmp@2022-01-27.yang"

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-routing {
    prefix rt;
    reference
      "RFC 8349: A YANG Data Model for Routing Management
       (NMDA Version).";
  }
  import ietf-bgp {
    prefix bgp;
    reference
      "I-D.draft-ietf-idr-bgp-model-17:
       BGP YANG module for Service Provider Network.";
  }
  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-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 2024-04-03 {
    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 selecting peers";
  }

  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
      "Configuring the global one";
  }

  identity bmp-ni-types-non-global-ni {
    base bmp-ni-types;
    description
      "The identify is an explicit way
       of selecting all network instances, except th e global-one.";
  }

  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.
         In the absence of this container, the system
         would select the maximum segment size for this
         connection";
    }
    // Taken from the bgp yang module
    leaf mtu-discovery {
      type boolean;
      default "true";
      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 {
        mandatory true;
        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 {
      mandatory true;
      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 {
            // TODO:This will not be supported for
            // implementations not supporting schema-mount.
            // Should just leave it as a string?
            // type leafref {
            //   path "/ni:network-instances/ni:network-instance/"
            //      + "ni:name";
            // }
            type string;
            description
              "If present, specifies the network instance
               used to reach the monitoring station.
               If not provided, the global network
               instance is used.";
          }
          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 {
            // TODO:This will not be supported for
            // implementations not supporting schema-mount.
            // Should just leave it as a string?
            // type leafref {
            //   path "/ni:network-instances/ni:network-instance/"
            //      + "ni:name";
            // }
            type string;
            description
              "If present, specifies the network instance
               used to reach the monitoring station.
               If not provided, the global network
               instance is used.";
          }
          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-ni-peer-ribs-filter {
    description
      "Leaves for configuring RIBs where under the BGP
       container.";
    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.";
        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-configurations {
          description
            "Every peer under the configured network instance can be
            at most configured by one of the next containers.  If the
            peer is not covered by any, then no BMP message should
            include information from/to that peer.  If the peer is
            covered by more than one, then the priority is:
             1. peers
             2. peer-groups
             3. peer-type
             4. bmp-peer-types

             New child containers or new bmp-peer-types instances
             SHOULD provide a way of unambiguislly selecting which
             configuration container should be selected for a peer in
             case mutiple matches.
            ";
          container bmp-peer-types {
            description
              "Generic identification of peers to configure.";
            list bmp-peer-type {
              key "peer-types-bmp";
              description
                "Identification of peers
                 for which we send BMP data to the collector
                 using a peer type defined using a peer-types-bmp.
                 For instance, to create a default for all
                 peers use bmp-peer-types-all-peers";
              leaf peer-types-bmp {
                type identityref {
                  base bmp-peer-types;
                }
                description
                  "Peer type to configure";
              }
              leaf enabled {
                type boolean;
                default "true";
                description
                  "Enables routing monitoring messages
                   for the peer(s).";
              }
              uses bmp-source-configuration;
            }
          }
          container peer-types {
            description
              "Generic identification of peers to configure.";
            list peer-type {
              key "peer-type-id";
              description
                "Identification of peers
                 for which we send BMP data to the collector
                 using BGP peer-type (e.g. internal, external)
                ";
              leaf peer-type-id {
                type bt:peer-type;
                description
                  "BGP Peer type to configure";
              }
            }
            leaf enabled {
              type boolean;
              default "true";
              description
                "Enables routing monitoring messages
                 for the peer(s).";
            }
            uses bmp-source-configuration;
          }
          container peer-groups {
            description
              "Identification of peer-groups
               to configure";
            list peer-group {
              key "peer-id";
              description
                "Identification of peer-groups
                 for which we send BMP data to the collector";
              leaf peer-id {
                type leafref {
                  path "../../../../../../../../../../../"
                     + "bgp:peer-groups/bgp:peer-group/"
                     + "bgp:name";
                }
                description
                  "Peergroup to configure";
              }
              leaf enabled {
                type boolean;
                default "true";
                description
                  "Enables routing monitoring messages
                   for the peer-group(s).";
              }
              uses bmp-source-configuration;
            }
          }
          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 leafref {
                  path "../../../../../../../../../../../"
                     + "bgp:neighbors/bgp:neighbor/"
                     + "bgp:remote-address";
                }
                description
                  "Peer to configure";
              }
              leaf enabled {
                type boolean;
                default "true";
                description
                  "Enables routing monitoring messages
                   for the peer(s).";
              }
              uses bmp-source-configuration;
            }
          }
        }
      }
    }
  }

  grouping bmp-peer-ribs-filter {
    description
      "Leaves for configuring RIBs
       under the main BMP container";
    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.";
        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-configurations {
          description
            "Every peer under this BGP instance
             can be at most configured by one of the next containers.
             If the peer is not covered by any, then no BMP
             message should include information from/to that peer.
             If the peer is covered by more than one, then the
             priority is:
             1. peer
             2. peer-groups
             3. peer-type
             4. bmp-peer-types

             New child containers or new bmp-peer-types instances
             SHOULD provide a way of unambiguislly selecting which
             configuration container should be selected for a peer in
             case mutiple matches.
            ";
          container peers {
            description
              "Generic identification of peers to configure.";
            list peer {
              key "peer-id-str";
              description
                "Identification of the peer. It is up to the
                implementation to define what to do if no peer
                matches this key.";
              leaf peer-id-str {
                type string;
                description
                  "Peer to configure";
              }
              leaf enabled {
                type boolean;
                default "true";
                description
                  "Enables routing monitoring messages
                   for the peer(s).";
              }
              uses bmp-source-configuration;
            }
          }
          container peer-groups {
            description
              "Generic identification of peers to configure.";
            list peer-group {
              key "peer-group-id-str";
              description
                "Identification of the peer-group. It is up to the
                implementation to define what to do if no peer-group
                with this name exists.";
              leaf peer-group-id-str {
                type string;
                description
                  "Peer-group to configure";
              }
              leaf enabled {
                type boolean;
                default "true";
                description
                  "Enables routing monitoring messages
                   for the peer(s).";
              }
              uses bmp-source-configuration;
            }
          }
          container bmp-peer-types {
            description
              "Generic identification of peers to configure.";
            list bmp-peer-type {
              key "peer-types-bmp";
              description
                "Identification of peers
                 for which we send BMP data to the collector
                 using a peer type defined using a peer-types-bmp.
                 For instance, to create a default for all
                 peers use bmp-peer-types-all-peers";
              leaf peer-types-bmp {
                type identityref {
                  base bmp-peer-types;
                }
                description
                  "Peer type to configure";
              }
              leaf enabled {
                type boolean;
                default "true";
                description
                  "Enables routing monitoring messages
                   for the peer(s).";
              }
              uses bmp-source-configuration;
            }
          }
          container peer-types {
            description
              "Generic identification of peers to configure.";
            list peer-type {
              key "peer-type-id";
              description
                "Identification of peers
                 for which we send BMP data to the collector
                 using BGP peer-type (e.g. internal, external)
                ";
              leaf peer-type-id {
                type bt:peer-type;
                description
                  "BGP peer-type to configure";
              }
            }
            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-instance-configuration {
      description
        "This container offers various options for configuring BMP
         route-monitoring messages for each network instance.
         Additionally, network instances can be configured under the
         bmp-data container that this module includes under the
         /rt:routing/rt:control-plane-protocols/
         rt:control-plane-protocol/bgp:bgp container.

         This container also holds a way of configuring the network
         instance directly. This is redundant , and unfavoured to the
         configuration under the bgp container, but it might be used
         for implementation not yet supporting schema-mount since
         that is required for adding control-plane infromation using
         the ietf-network-instance module.

         This container also provides a way of configuring
         network-instances by 'bmp-ni-types'. It currently holds two
         instances:  bmp-ni-types-all-ni to configure all network
         instances (serving as a default), and
         bmp-ni-types-non-global-ni that configures all non-global
         network instances: i.e. providing a default for all  network
         instances under the ietf-network-instance module.

         A single configuration container Network MUST
         be applied to a network instance.  If not containe matches a
         network instance, the BMP route monitoring messages SHOULD
         be disabled for that network instance.  If more than one
         container matches a network-instance  the order of
         preference is:
         1. The configuration under the BGP container
         2. The Network-instance under this container
         3. bmp-ni-types: bmp-ni-types-non-global-ni (if it matches).
         4. bmp-ni-types: bmp-ni-types-all-ni

         New identities under bmp-ni-types or augmentations of this
         container in the future SHOULD provide a clear way of
         selecting the configuration container for a network-instance
         without ambiguity.";
      list network-instance {
        key "network-instance-id";
        description
          "Network instance to monitory using BMP.";
        leaf network-instance-id {
          type union {
            type identityref {
              base bmp-ni-types;
            }
            // TODO:This will not be supported for
            // implementations not supporting schema-mount.
            // Should just leave it as a string to be useful without
            // schema-mount??
            //type leafref {
            //  path "/ni:network-instances/ni:network-instance/"
            //     + "ni:name";
            //}
            type string;
          }
          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 bmp-monitoring-stations {
      description
        "Container for the list of BMP monitoring stations";
      list bmp-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 {
          config false;
          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;
            description
              "Value indicating if the session is currently
               established";
          }
          leaf total-route-monitoring-messages {
            type uint64;
            description
              "Number of route-monitoring messages sent since last
               successful connection";
          }
          leaf total-statistics-messages {
            type uint64;
            description
              "Number of statistics messages sent since last
               successful connection";
          }
          leaf total-peer-down-messages {
            type uint64;
            description
              "Number of peer-down messages sent since last
               successful connection";
          }
          leaf total-peer-up-messages {
            type uint64;
            description
              "Number of peer-up messages sent since last successful
               connection";
          }
          leaf total-initiation-messages {
            type uint64;
            description
              "Number of initiation messages sent since last
               successful connection";
          }
          leaf total-route-mirroring-messages {
            type uint64;
            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";
                }
              }
            }
          }
        }
      }
    }
  }

  // Augment the BGP module to include data for network instances

  augment "/rt:routing/rt:control-plane-protocols/"
        + "rt:control-plane-protocol/bgp:bgp" {
    description
      "Augments the BGP container under control-plane-protocol.  It
       can be used to configure the global BGP instance, but also the
       network-instances under the module ietf-network-instance";
    container bmp-data {
      description
        "Container for the configuration of BMP data
         related to this BGP instance";
      container bmp-monitoring-stations {
        presence
          "If this container exists, the network instance must be
          configured using this";
        description
          "Container for the configuration of BMP data
           related to this BGP instance";
        list bmp-monitoring-station {
          key "id";
          description
            "Container for the configuration of BMP data for this
             monitoring-station related to this BGP instance";
          leaf id {
            // TODO: We have not been able to configure
            // the schema mount to recognize this yet.
            // Until we solve it, we will keep it as
            //type leafref {
            //  path "/bmp:bmp/bmp:bmp-monitoring-stations/"
            //        + "bmp:bmp-monitoring-station/bmp:id";
            //}
            type string;
            description
              "Identification string for the monitoring station";
          }
          container bmp-route-monitoring {
            presence "The presence of this container means the
                      Network instance it contains MUST
                      be configured using it";
            description
              "Configuration of the data sources for
               route-monitoring messages for this network-instance";
            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-ni-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-ni-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-ni-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-ni-peer-ribs-filter;
              reference
                "RFC8671: Support for Adj-RIB-Out in the BGP
                 Monitoring Protocol (BMP) , Section 3.";
            }
          }
        }
      }
    }
  }
}

<CODE ENDS>

Security Considerations
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 [RFC6241] or RESTCONF [RFC8040]. The lowest NETCONF layer is the secure transport layer, and the mandatory-to-implement secure transport is Secure Shell (SSH) [RFC6242]. The lowest RESTCONF layer is HTTPS, and the mandatory-to-implement secure transport is TLS [RFC8446]. The NETCONF Access Control Model (NACM) [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.
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.
The session-reset action can demand considerable amount of resources from network elements. It SHOULD thus be protected from illegal access.

IANA Considerations

The IETF XML Registry
This document registers a URIs in the IETF XML registry [RFC3688]. Following the format in [RFC3688], the following registrations are requested:

   URI: urn:ietf:params:xml:ns:yang:ietf-bmp
   Registrant Contact: The IESG.
   XML: N/A, the requested URI is an XML namespace.

The YANG Module Name Registration
This document registers the following YANG module in the " YANG Module Names" registry registry [RFC6020]:

   Name: ietf-bmp
   Namespace: urn:ietf:params:xml:ns:yang:ietf-bmp
   Prefix: bmp
   Reference: [This RFC-to-be]

Open Issues
The security considerations section will have to be aligned with https://trac.ietf.org/trac/ops/wiki/yang-security-guidelines

Normative References
[RFC2119]
[RFC8174]
[RFC7854]
[I-D.ietf-netconf-tcp-client-server]
[RFC9293]
[I-D.ietf-idr-bgp-model]
[RFC6241]
[RFC8040]
[RFC6242]
[RFC8446]
[RFC8341]
[RFC3688]
[RFC6020]

Examples
This sections shows some examples of BMP configuration using the model.

Example one
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.

=============== NOTE: '\' line wrapping per RFC 8792 ================

<bmp xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
  <bmp-monitoring-stations>
    <bmp-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-instance-configuration>
            <network-instance>
              <network-instance-id>bmp-ni-types-all-ni</network-inst\
ance-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-configurations>
                      <peer-types>
                        <peer-type>
                          <peer-type-id>external</peer-type-id>
                        </peer-type>
                      </peer-types>
                    </peers-configurations>
                  </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-configurations>
                      <peer-types>
                        <peer-type>
                          <peer-type-id>external</peer-type-id>
                        </peer-type>
                      </peer-types>
                    </peers-configurations>
                  </address-family>
                </address-families>
              </adj-rib-in-pre>
            </network-instance>
          </network-instance-configuration>
        </bmp-route-monitoring>
      </bmp-data>
    </bmp-monitoring-station>
  </bmp-monitoring-stations>
</bmp>

Example two
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:
- 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.
- Network instance monitoring is disabled for route monitoring messages.
- For the rest of network instances, we are enabling messages from adj-rib-in-pre, address families IPv4/IPv6, and for all peers.

=============== NOTE: '\' line wrapping per RFC 8792 ================

<routing xmlns="urn:ietf:params:xml:ns:yang:ietf-routing">
  <control-plane-protocols>
    <control-plane-protocol>
      <type xmlns:bgp="urn:ietf:params:xml:ns:yang:ietf-bgp">bgp:bgp\
</type>
      <name>BGP</name>
      <bgp xmlns="urn:ietf:params:xml:ns:yang:ietf-bgp">
        <global>
          <as>64496</as>
          <identifier>192.0.2.1</identifier>
        </global>
        <neighbors>
          <neighbor>
            <!-- Neighbor-specific configuration parameters -->
            <remote-address>128.66.1.1</remote-address>
            <peer-as>64497</peer-as>
          </neighbor>
          <!-- Additional neighbors if needed -->
        </neighbors>
        <!-- Additional BGP configuration elements -->
        <bmp-data xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
            <bmp-monitoring-stations>
            <bmp-monitoring-station>
                <id>2</id>
                <bmp-route-monitoring>
                <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-configurations>
                      <peers>
                        <peer>
                          <peer-id>128.66.1.1</peer-id>
                          <enabled>false</enabled>
                        </peer>
                      </peers>
                        <peer-types>
                        <peer-type>
                          <peer-type-id>external</peer-type-id>
                        </peer-type>
                        </peer-types>
                  </peers-configurations>
                    </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-configurations>
                      <peers>
                        <peer>
                          <peer-id>128.66.1.1</peer-id>
                          <enabled>false</enabled>
                        </peer>
                      </peers>
                        <peer-types>
                        <peer-type>
                          <peer-type-id>external</peer-type-id>
                        </peer-type>
                        </peer-types>
                  </peers-configurations>
                    </address-family>
                  </address-families>
                </adj-rib-in-pre>
                </bmp-route-monitoring>
            </bmp-monitoring-station>
            </bmp-monitoring-stations>
        </bmp-data>
      </bgp>
    </control-plane-protocol>
  </control-plane-protocols>
</routing>
<bmp xmlns="urn:ietf:params:xml:ns:yang:ietf-bmp">
    <bmp-monitoring-stations>
      <bmp-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-instance-configuration>
              <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-types">bt:ipv6-unicast</address-family-id>
                      <peers-configurations>
                          <bmp-peer-types>
                        <bmp-peer-type>
                          <peer-types-bmp>bmp-peer-types-all-peers</\
peer-types-bmp>
                        </bmp-peer-type>
                      </bmp-peer-types>
                  </peers-configurations>
                    </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-configurations>
                    <bmp-peer-types>
                        <bmp-peer-type>
                          <peer-types-bmp>bmp-peer-types-all-peers</\
peer-types-bmp>
                        </bmp-peer-type>
                    </bmp-peer-types>
                      </peers-configurations>
                    </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-instance-configuration>
          </bmp-route-monitoring>
        </bmp-data>
      </bmp-monitoring-station>
    </bmp-monitoring-stations>
  </bmp>

Acknowledgements
The authors would like to thank Yimin Shen, Jeff Haas, Pierre Vander Vorst, and Tom Petch for their review and feedback.