<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC2234 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2234.xml">
<!ENTITY RFC2629 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2629.xml">
<!ENTITY RFC4234 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4234.xml">
<!ENTITY nbsp    "&#160;">
]>

<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>

<?rfc strict="yes" ?>
<?rfc comments="no" ?>
<?rfc inline="no" ?>
<?rfc editing="no" ?>
<?rfc toc="yes" ?>
<?rfc tocompact="yes" ?>
<?rfc tocdepth="3" ?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="yes" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>

<rfc category="std"
    ipr="trust200902"
    docName="draft-sas-idr-maxprefix-outbound-02"
    updates="4271"
    submissionType="IETF">

<front>

	<title abbrev="BGP Maximum Prefix Limits Outbound">
		Revised BGP Maximum Prefix Limits Outbound
	</title>

	<author fullname="Melchior Aelmans" initials="M." surname="Aelmans">
		<organization>Juniper Networks</organization>

		<address>
			<postal>
				<street>Boeing Avenue 240</street>
				<code>1119 PZ</code>
				<city>Schiphol-Rijk</city>
				<country>Netherlands</country>
			</postal>

			<email>maelmans@juniper.net</email>
		</address>
	</author>

	<author fullname="Massimiliano Stucchi" initials="M." surname="Stucchi">
		<organization>Independent</organization>
		<address>
			<email>max@stucchi.ch</email>
		</address>
	</author>

	<author fullname="Job Snijders" initials="J." surname="Snijders">
		<organization>Fastly</organization>
		<address>
			<postal>
				<street />
				<code />
				<city>Amsterdam</city>
				<country>Netherlands</country>
			</postal>
			<email>job@fastly.com</email>
		</address>
	</author>

	<date />
	<area>Routing</area>
	<workgroup>Inter-Domain Routing</workgroup>

	<keyword>BGP</keyword>
	<keyword>Prefix</keyword>

	<abstract>
		<t>
			This document updates RFC4271 by adding a control mechanism which limits the negative impact of outbound route leaks (RFC7908) in order to prevent resource exhaustion in Border Gateway Protocol (BGP) implementations.
		</t>
	</abstract>
	<note title="Requirements Language">
		<t>
			The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they appear in all capitals, as shown here.
		</t>
	</note>
</front>
<middle>
	<section title="Introduction">
		<t>
			This document updates <xref target="RFC4271" /> by adding a control mechanism which limits the negative impact of outbound <xref target="RFC7908">route leaks</xref> in order to prevent resource exhaustion in Border Gateway Protocol (BGP) implementations.
			<xref target="RFC4271" /> describes methods to tear down BGP sessions or discard UPDATES after certain inbound thresholds are exceeded. In addition to "inbound maximum prefix limits", this document introduces a specification for "outbound maximum prefix limits".
			<xref target="I-D.sas-idr-maxprefix-inbound" /> updates sections in <xref target="RFC4271" /> to clarify "inbound maximum prefix limits". This documents updates those sections again to add "outbound maximum prefix limits".
		</t>
	</section>

        <!--
            <section title="Application of Control Theory to BGP Operations">
            <t>
            </t>
            </section>
        -->

        <section title="Changes to RFC4271 Section 6">
            <t>
                This section updates <xref target="RFC4271" /> to specify what events can result in AutomaticStop (Event 8) in the BGP FSM.
            </t>
            <t>
                The following paragraph replaces the second paragraph of Section 6.7 (Cease), which starts with "A BGP speaker MAY support" and ends with "The speaker MAY also log this locally.":
            </t>
            <t>
                <list style="empty">
                    <t>
                        A BGP speaker MAY support the ability to impose a locally-configured, upper bound on the number of address prefixes the speaker is willing to accept from a neighbor (inbound maximum prefix limit) or send to a neighbor (outbound prefix limit).
                        The limit on the prefixes accepted from a neighbor can be applied before policy processing (Pre-Policy) or after policy processing (Post-Policy).
                        Outbound prefix limits MUST be measured after policy, since the Policy (even a policy of "send all") is run before determining what can be sent.
                        When the upper bound is reached, the speaker, under control of local configuration, either:
                        <list style="letters">
                            <t><!-- option a -->
                                Discards new address prefixes being sent to the neighbor while maintaining the BGP connection with the neighbor. As these prefixes are discared and their reachability information is not sent to the neighbor it might lead to inconsistent routing behaviour;
                            </t>
			    <t> <!-- Option b -->
				Sent all prefixes exceeding the threshold and generates a log;
														</t>
                            <t> <!-- option c -->
				Terminates the BGP session with the neighbor.  This should be done using a Hard Reset according to <xref target="RFC8538" />.
                            </t>
                        </list>
                        <!-- OLD : If the BGP speaker decides to terminate its BGP connection with a neighbor because the number of address prefixes received from the neighbor exceeds the locally-configured, upper bound, then the speaker MUST send the neighbor a NOTIFICATION message with the Error Code Cease. -->
                            If the BGP speaker uses option (b), where the limit causes a CEASE Notification, then the CEASE error codes should use:
                    </t>
                </list>
            </t>
            <texttable>
                <ttcol>Subcode</ttcol><ttcol>Symbolic Name</ttcol>
                <c>1</c><c>Threshold exceeded: Maximum Number of Prefixes Received</c>
                <c>TBD</c><c>Threshold exceeded: Maximum Number of Prefixes Sent</c>
            </texttable>
            <t>
                <list style="empty">
                    <t>
                        The speaker MAY also log the event locally.
                    </t>
                </list>
            </t>
        </section>

        <section title="Changes to RFC4271 Section 8">
            <t>
                This section updates <xref target="RFC4271">Section 8</xref>, the paragraph that starts with "One reason for an AutomaticStop event is" and ends with "The local system automatically disconnects the peer." is replaced with:
            </t>
            <t>
                <list style="empty">
                    <t>
                        Possible reasons for an AutomaticStop event are: A BGP speaker receives an UPDATE messages with a number of prefixes for a given peer such that the total prefixes received exceeds the maximum number of prefixes configured (either "Pre-Policy" or "Post-Policy"), or announces more prefixes than through local configuration allowed to.
                        The local system automatically disconnects the peer.
                    </t>
                </list>
            </t>
        </section>

        <section title="Changes to RFC4271 Section 9">
            <t>
                This section updates <xref target="RFC4271" /> by adding a subsection after Section 9.4 (Originating BGP routes) to specify various events that can lead up to an AutomaticStop (Event 8) in the BGP FSM.
            </t>
            <t>
                <list style="empty">
                    <t>
                        9.5 Maximum Prefix Limits
                    </t>
                    <t>
                        9.5.1 Pre-Policy Inbound Maximum Prefix Limits
                    </t>
                    <t>
                        <list style="empty">
                            <t>
                                The Adj-RIBs-In stores routing information learned from inbound UPDATE messages that were received from another BGP speaker <xref target="RFC4271">Section 3.2</xref>.
                                The pre-policy limit uses the number of NLRIs per Address Family Identifier (AFI) per Subsequent Address Family Identifier (SAFI) as input into its threshold comparisons.
                                For example, when an operator configures the pre-policy limit for IPv4 Unicast to be 50 on a given EBGP session, and the other BGP speaker announces its 51st IPv4 Unicast NLRI, the session MUST be terminated.
                            </t>
                            <t>
                                Pre-policy limits are particularly useful to help dampen the effects of full table route leaks and memory exhaustion when the implementation stores rejected routes.
                            </t>
                        </list>
                    </t>
                    <t>
                        9.5.2 Post-Policy Inbound Maximum Prefix Limits
                    </t>
                    <t>
                        <list style="empty">
                            <t>
															<xref target="RFC4271" /> describes a Policy Information Base (PIB) that contains local policies that can be applied to the information in the Routing Information Base (RIB).
                                The post-policy limit uses the number of NLRIs per Address Family Identifier (AFI) per Subsequent Address Family Identifier (SAFI), after application of the Import Policy as input into its threshold comparisons.
                                For example, when an operator configures the post-policy limit for IPv4 Unicast to be 50 on a given EBGP session, and the other BGP speaker announces a hundred IPv4 Unicast routes of which none are accepted as a result of the local import policy (and thus not considered for the Loc-RIB by the local BGP speaker), the session is not terminated.
                            </t>
                            <t>
                                Post-policy limits are useful to help prevent FIB exhaustion and prevent accidental BGP session teardown due to prefixes not accepted by policy anyway.
                            </t>
                        </list>
                    </t>
                    <t>
                        9.5.3 Outbound Maximum Prefix Limits
                    </t>
                    <t>
                        <list style="empty">
                            <t>
                                An operator MAY configure a BGP speaker to terminate its BGP session with a neighbor when the number of address prefixes to be advertised to that neighbor exceeds a locally configured post-policy upper limit.
                                The BGP speaker then MUST send the neighbor a NOTIFICATION message with the Error Code "Cease" and the Error Subcode "Threshold reached: Maximum Number of Prefixes Sent". Implementations MAY support additional actions.
                                The Hard Cease action is defined in <xref target="RFC8538" />.
                            </t>
                            <t>
                                Reporting when thresholds have been exceeded is an implementation specific consideration, but SHOULD include methods such as Syslog <xref target="RFC5424"/>.
                                By definition, Outbound Maximum Prefix Limits are Post-Policy.
                            </t>
                            <t>
                                The Adj-RIBs-Out stores information selected by the local BGP speaker for advertisement to its neighbors.
                                The routing information stored in the Adj-RIBs-Out will be carried in the local BGP speaker's UPDATE messages and advertised to its neighbors <xref target="RFC4271">Section 3.2</xref>.
                                The Outbound Maximum Prefix Limit uses the number of NLRIs per Address Family Identifier (AFI) per Subsequent Address Family Identifier (SAFI), after application of the Export Policy, as input into its threshold comparisons.
                                For example, when an operator configures the Outbound Maximum Prefix Limit for IPv4 Unicast to be 50 on a given EBGP session, and were about to announce its 51st IPv4 Unicast NLRI to the other BGP speaker as a result of the local export policy, the session MUST be terminated.
                            </t>
                            <t>
                                Outbound Maximum Prefix Limits are useful to help dampen the negative effects of a misconfiguration in local policy.
                                In many cases, it would be more desirable to tear down a BGP session rather than causing or propagating a route leak.
                            </t>
                        </list>
                    </t>
                </list>
            </t>
        </section>
	
	<section title="Use cases">
	    <t>
		    Egress maximum prefix limits are usefull in a variety of cases. Some of those are outlined in this section.
            </t>
		    <section title="Internet use case">
			    <t>
				    In order to prevent the BGP speaker from leaking a full routing table to its neighbor operators should 
				    implement proper routing policy and preferably RFC8212. However, even when implementing both measurements 
				    an operator could still (accidentaly) announce more routes than intended. Setting a maximum prefix outbound
				    value prevents this.
			    </t>
		    </section>
		    <section title="CE protection">
			    <t>
				    Residential and many business customers connected to the internet using a 'simple' CPE and connected to a single 
				    Service Provider only needs to accept a single default route and not the full internet table. In order to prevent
				    overloading the CPE Control Plane, maximum outbound limits should be applied on the session on the PE router.
			    </t>
		    </section>
		    <section title="PE-CE BGP session from operator side">
			    <t>
				    -- Change this so it explains that it's extra protection towards the PE so it won't kill the BGP session due to max prefix inbound --
				    Internet providers PE side gateway PE-CE connections would would generally set maximum prefix  to disconnect 
				    if maximum prefix is reached. This is a secondary protection mechanism as the primary is prefix length and AS path checks. 
			    </t>
		    </section>
	</section>

        <section title="Security Considerations">
            <t>
				  Maximum Prefix Limits are an essential tool for routing operations and SHOULD be used to increase stability.  They provide a first-line mechanism to avoid route leaks and to avoid unintended routing suggestions to happen between neighbors.  Implementing this measures is only one of the building blocks you need to provide full security, but it is important to build a modular defense system.
	    </t>
						<t>
							Stability for the routing table is also an important aspect for implementing the measures included in this draft.  Ensuring that neighbors will not receive an amount of routes that would overload their routing platform contributes to the stability of interconnections and of the Internet as a whole.
						</t>
        </section>

        <section title="IANA Considerations">
            <t>
                <!-- TDB, find better names? -->
                This memo requests that IANA assigns a new subcode named "Threshold exceeded: Maximum Number of Prefixes Sent" in the "Cease NOTIFICATION message subcodes" registry under the "Border Gateway Protocol (BGP) Parameters" group.
            </t>
        </section>

        <section title="Acknowledgments">
            <t>
                The authors would like to thank Saku Ytti and John Heasley (NTT Ltd.), Jeff Haas, Colby Barth and John Scudder (Juniper Networks), Martijn Schmidt (i3D.net), Teun Vink (BIT), Sabri Berisha (eBay), Martin Pels (Quanza), Steven Bakker (AMS-IX), Aftab Siddiqui (ISOC), Yu Tianpeng, Ruediger Volk (Deutsche Telekom), Robert Raszuk (Bloomberg), Jakob Heitz (Cisco), Warren Kumari (Google), Ben Maddison (Workonline), Randy Bush, Brian Dickson and Gyan Mishra (Verizon) for their support, insightful reviews, and comments.
            </t>
        </section>
	
        <section title="Implementation status - RFC EDITOR: REMOVE BEFORE PUBLICATION">
            <t>
                This section records the status of known implementations of the
                protocol defined by this specification at the time of posting of
                this Internet-Draft, and is based on a proposal described in
                RFC7942. The description of implementations in this
                section is intended to assist the IETF in its decision processes in
                progressing drafts to RFCs.  Please note that the listing of any
                individual implementation here does not imply endorsement by the
                IETF. Furthermore, no effort has been spent to verify the
                information presented here that was supplied by IETF contributors.
                This is not intended as, and must not be construed to be, a catalog
                of available implementations or their features. Readers are advised
                to note that other implementations may exist.
            </t>
            <t>
                The table below provides an overview (as of the moment of writing) of which vendors have produced implementations of inbound or outbound maximum prefix limits.
                Each table cell shows the applicable configuration keywords if the vendor implemented the feature.
            </t>
            <texttable anchor="table_ex" title="Maximum prefix limits capabilities per implementation" style="all">
                <ttcol align="center" width="20%">Vendor</ttcol>
                <ttcol align="center">Inbound Pre-Policy</ttcol>
                <ttcol align="center">Inbound Post-Policy</ttcol>
                <ttcol align="center">Outbound</ttcol>
                <c>Cisco IOS XR</c><c></c><c>maximum-prefix</c><c></c>
                <c>Cisco IOS XE</c><c></c><c>maximum-prefix</c><c></c>
                <c>Juniper Junos OS</c><c>prefix-limit</c><c>accepted-prefix-limit, or prefix-limit combined with 'keep none'</c><c>advertise-prefix-limit *</c>
                <c>Nokia SR OS</c><c>prefix-limit</c><c></c><c></c>
                <c>NIC.CZ BIRD</c><c>'import keep filtered' combined with 'receive limit'</c><c>'import limit' or 'receive limit'</c><c>export limit</c>
                <c>OpenBSD OpenBGPD</c><c>max-prefix</c><c></c><c></c>
                <c>Arista EOS</c><c>maximum-routes</c><c>maximum-accepted-routes</c><c></c>
                <c>Huawei VRPv5</c><c>peer route-limit</c><c></c><c></c>
                <c>Huawei VRPv8</c><c>peer route-limit</c><c>peer route-limit accept-prefix</c><c></c>
                <postamble>First presented by Job Snijders at <xref target="RIPE77"/></postamble>
            </texttable>
            <t>
                  *In testing stage
           </t>
        </section>

    </middle>
    <back>
        <references title="Normative References">
					<?rfc include="reference.RFC.2119.xml"?>
            <?rfc include="reference.RFC.8174.xml"?>
            <?rfc include="reference.RFC.4271.xml"?>
					<?rfc include="reference.RFC.8538.xml"?>
					<?rfc include="reference.I-D.sas-idr-maxprefix-inbound.xml"?>
        </references>
        <references title="Informative References">
            <?rfc include="reference.I-D.ietf-idr-bgp-model.xml"?>
            <?rfc include="reference.RFC.5424.xml"?>
            <?rfc include="reference.RFC.7908.xml"?>
            <reference anchor="RIPE77" target="https://ripe77.ripe.net/wp-content/uploads/presentations/59-RIPE77_Snijders_Routing_Policy_Architecture.pdf">
                <front>
                    <title>Robust Routing Policy Architecture</title>
                    <author surname="Snijders" fullname="Job Snijders">
                        <organization>NTT Communications</organization>
                    </author>
                    <date month="May" year="2018"/>
                </front>
            </reference>
        </references>
    </back>
</rfc>
