<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="2"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<rfc ipr='trust200902' docName='draft-ietf-grow-bgp-gshut-09' category="info">

<front>

<title>Graceful BGP session shutdown</title>

<author surname="Francois"  initials="P." fullname="Pierre Francois">
<organization>Individual Contributor</organization> 
<address>
<email>pfrpfr@gmail.com</email>
</address>
</author>

<author surname="Decraene"  initials="B." fullname="Bruno Decraene">
<organization>Orange</organization>
<address>
<email>bruno.decraene@orange.com</email>
</address>
</author>

<author surname="Pelsser" initials="C." fullname="Cristel Pelsser">
<organization>Strasbourg University</organization>
<address>
<email>pelsser@unistra.fr</email>
</address>
</author>

<author surname="Patel"  initials="K." fullname="Keyur Patel">
<organization>Arrcus, Inc.</organization>
<address>
<email>keyur@arrcus.com</email>
</address>
</author>

<author surname="Filsfils"  initials="C." fullname="Clarence Filsfils">
<organization>Cisco Systems</organization>
<address>
<email>cfilsfil@cisco.com</email>
</address>
</author>

<date year='2017'/>


<abstract>
	
  <t>This draft describes operational procedures aimed at reducing the
  amount of traffic lost during planned maintenances of routers or links,
  involving the shutdown of BGP peering sessions. It defines a well-known BGP community, called GRACEFUL_SHUTDOWN, to signal the graceful shutdown of paths.</t>

</abstract>

</front>

<middle>
<section title="Introduction" anchor = "Introduction">

    <t> Routing changes in BGP can be caused by planned, maintenance
    operations. This document discusses operational procedures to be applied in
    order to reduce or eliminate losses of packets during the maintenance.
    These losses come from the transient lack of reachability during the BGP
    convergence following the shutdown of an EBGP peering session between two
    Autonomous System Border Routers (ASBR).</t>

	<t> This document presents procedures for the cases where the
	forwarding plane is impacted by the maintenance, hence when
	the use of Graceful Restart does not apply.</t>


    <t> The procedures described in this document can be applied to reduce or
    avoid packet loss for outbound and inbound traffic flows initially
    forwarded along the peering link to be shut down.  These procedures
    trigger, in both involved ASes, rerouting to the alternate path, while
    allowing routers to keep using old paths until alternate ones are learned, installed
    in the RIB and in the FIB.
    This ensures that routers always have a valid route available during the
    convergence process.</t>


    <t> The goal of the document is to meet the requirements described in <xref
    target="RFC6198"/> at best, without changing the BGP protocol.</t>

	<t> This document defines a well-known community <xref
    target="RFC1997"/>, called GRACEFUL_SHUTDOWN, for the purpose of
     reducing the management overhead of gracefully shutting down BGP
     sessions. The well-known community allows implementers to provide an
     automated graceful shutdown mechanism that does not require any
     router reconfiguration at maintenance time.</t>

	 <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL",
	 "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY",
	 and "OPTIONAL" in this document are to be interpreted as
	 described in RFC 2119 <xref target="RFC2119"/>.</t>



</section><!--Introduction -->

<section title = "Terminology" anchor="Terminology">

	<t> graceful shutdown initiator: a router on which the session shutdown
	is performed for the maintenance. </t>

	<t> graceful shutdown receiver: a router that has a BGP session, to be shutdown, with the graceful shutdown
	initiator.</t>

	<t> Initiator AS: the Autonomous System of the graceful shutdown initiator.</t>

	<t> Receiver AS: the Autonomous System of the graceful shutdown receiver.</t> 

	<t> Loss of Connectivity (LoC: the state when a router has
	no path toward an affected prefix.</t>


</section><!--Terminology -->

<section title="Packet loss upon manual EBGP session shutdown" anchor="sec.loss">

	<t>Packets can be lost during a manual shutdown of an EBGP
	session for two reasons. </t>
			
	<t>First, routers involved in the convergence process can
	transiently lack of paths toward an affected prefix, and drop
	traffic destined to this prefix. This is because alternate
	paths can be hidden by nodes of an AS. This happens when the
	paths are not selected as best by the ASBR that receive them
	on an EBGP session, or by Route Reflectors that do not
	propagate them further in the IBGP topology because they do
	not select them as best. </t>

	<t>Second, within the AS, the FIB of routers can be transiently
	inconsistent during the BGP convergence and packets toward
	affected prefixes can loop and be dropped. Note that these
	loops only happen when ASBR-to-ASBR encapsulation is not used
	within the AS.</t>

	<t>This document only addresses the first reason. </t>

</section><!--Packet loss upon manual EBGP session shutdown -->




<section title = "Practices to avoid packet losses" anchor = "sec.practices">

	<t>This section describes means for an ISP to reduce the
	transient loss of packets upon a manual shutdown of a BGP
	session. </t>

	<section title = "Improving availability of alternate paths">
	  
	  <t>All solutions that increase the availability of alternate
	  BGP paths at routers performing packet lookups in BGP tables such as
	  <xref target="I-D.ietf-idr-best-external"></xref> and <xref target="RFC7911"/> help
	  in reducing the LoC bound with manual shutdown of EBGP
	  sessions.</t>

	  <t>One of such solutions increasing diversity in such a way that, at
	  any single step of the convergence process following the
	  EBGP session shutdown, a BGP router does not receive a
	  message withdrawing the only path it currently knows for a
	  given NLRI, allows for a simplified graceful shutdown procedure.</t>

      <t>Note that the LoC for the inbound traffic of the maintained router,
      induced by a lack of alternate path propagation within the IBGP topology
      of a receiver AS is not under the control of the operator performing
      the maintenance. The part of the procedure aimed at avoiding LoC for
      incoming paths can thus be applied even if no LoC are expected for the
      outgoing paths.</t>

	</section><!--Improving availability of alternate paths-->

	<section title = "Make before break convergence: graceful shutdown" anchor = "sec.summary">
	    
      <t>The goal of this procedure is to retain the paths to be shutdown between
the peers, but with a lower LOCAL_PREF value, allowing the paths to remain
in use while alternate paths are selected and propagated, rather than
simply withdrawing the paths.</t>
	  
	    <t> <xref target="gshut" /> describes configurations and actions to be performed for
      the graceful shutdown of BGP sessions.</t>

	</section><!--Make before break convergence: graceful shutdown -->  
	
	<section title="Forwarding modes and transient forwarding loops during convergence"  anchor="sec.forwarding">

    <t>The graceful shutdown procedure or the solutions improving the availability of
    alternate paths, do not change the fact that BGP convergence and the
    subsequent FIB updates are run independently on each router of the ASes.
    If the AS applying the solution does not rely on encapsulation to forward
    packets from the Ingress Border Router to the Egress Border Router, then
    transient forwarding loops and consequent packet losses can occur during
    the convergence process.  If zero LoC is required, encapsulation is
    required between ASBRs of the AS.  </t>

	</section><!--Forwarding modes-->
</section><!--Practices to avoid packet losses --> 

<section title = "EBGP graceful shutdown procedure" anchor ="gshut">

      <t>This section describes configurations and actions to be performed for the graceful shutdown of EBGP peering links.</t>

	<section title = "Pre-configuration" anchor = "sec.summary.config">

        <t> On each ASBR supporting the graceful shutdown receiver procedure, an inbound BGP route policy is
        applied on all EBGP sessions of the ASBR, that:

	    <list style = "symbols" hangIndent="5">

          <t> matches the GRACEFUL_SHUTDOWN community</t>

	      <t> sets the LOCAL_PREF attribute of the paths tagged with the
	      GRACEFUL_SHUTDOWN community to a low value</t>

	    </list></t>

      <t>Note that in the case where an AS is aggregating multiple routes under
      a covering prefix, it is recommended to filter out the GRACEFUL_SHUTDOWN community
      from the resulting aggregate BGP route.  By doing so, the setting of the GRACEFUL_SHUTDOWN
      community on one of the aggregated routes will not let the entire
      aggregate inherit the community. Not doing so would let the entire
      aggregate undergo the graceful shutdown behavior.  </t>
	    
	  </section><!--Pre-configuration-->
	  
	<section title = "Operations at maintenance time" anchor = "sec.summary.shut">
     
     <t> On the graceful shutdown initiator, upon maintenance time, it is required to: 

     <list style = "symbols">

       <t> apply an outbound BGP route policy on the EBGP session to be shutdown. This policy
       tags the paths propagated over the session with the GRACEFUL_SHUTDOWN community.
       This will trigger the BGP implementation to re-advertise all active
       routes previously advertised, and tag them with the GRACEFUL_SHUTDOWN community.
       </t>
     
       <t> apply an inbound BGP route policy on the maintained EBGP session to tag the
       paths received over the session with the GRACEFUL_SHUTDOWN community. </t>
     
       <t> wait for convergence to happen.</t>

       <t> shutdown the EBGP session, optionally using <xref target="I-D.ietf-idr-shutdown"></xref> to communicate the reason of the shutdown.</t>

     </list></t>

        <t>In the case of a shutdown of the whole router, in addition to the graceful shutdown of all EBGP sessions, there is a need to graceful shutdown the routes originated by this router (e.g, BGP aggregates redistributed from other protocols, including static routes).  This can be performed by tagging such routes with the GRACEFUL_SHUTDOWN community.</t>

     
   </section><!--Operations at maintenance time-->




	   <section title = "BGP implementation support for g-Shut" anchor = "Implementation">

   <t>A BGP router implementation MAY provide features aimed at
   automating the application of the graceful shutdown procedures
   described above.</t>

   <t>Upon a session shutdown specified as graceful by the
   operator, a BGP implementation supporting a graceful shutdown feature SHOULD: 
   </t>

   <t>

     <list style = "numbers" hangIndent="5">
     
       <t>Update all the paths propagated over the corresponding EBGP
       session, tagging the GRACEFUL_SHUTDOWN community to them. Any subsequent
       update sent over the session being gracefully shut down would be
       tagged with the GRACEFUL_SHUTDOWN community.
       </t>

       <t>Lower the LOCAL_PREF value of the paths received over the EBGP
       session being shut down.</t>

       <t>Optionally shut down the session after a configured
       time.</t>

       <t>Prevent the GRACEFUL_SHUTDOWN community from being inherited by a path
       that would aggregate some paths tagged with the GSHUT
       community. This behavior avoids the GSHUT procedure to be
       applied to the aggregate upon the graceful shutdown of one of
       its covered prefixes.</t>

     </list>
   </t>

   <t> A BGP implementation supporting a graceful shutdown feature SHOULD also automatically
   install the BGP policies that are supposed to be configured, as described in
   <xref target = "sec.summary.config"/> for sessions over which graceful shutdown
   is to be supported.  </t>
     
 </section><!--Summary of operations-->



</section><!--Graceful shutdown procedures for EBGP sessions-->
		  
<!-- 
     <section title = "Using multiple graceful shutdown community values">
     
     <t>As for the outbound traffic, and as
					illustrated in <xref target="sec.applicability"/>, a two step approach
					may be used to avoid the LoC due to a
					maintenance. The behavior described
					here for inbound traffic is equivalent
					to the in-filter reconfiguration step
					described for the outbound traffic. If
					a two step approach is required by the
					peer for its outbound traffic (i.e.,
					for the inbound traffic of the
					maintained AS), then two community values could be used.					
				</t>

				<t>One community value, GSHUT-out, could be
					tagged to the old paths in a first
					step, by the graceful shutdown initiator.  The
					out-filter of the IBGP sessions of the
					ASBR of the graceful shutdown neighbor would be
					configured to reduce the local-pref
					value of such paths.</t>

				<t>The second community value, GSHUT-in, would
					lead to a local-pref decrease in the
					in-filter of the graceful shutdown neighbor, hence
					applying the "in-filter" behavior as
					described for outbound traffic.	</t>

				<t>Of course, ISPs are free to agree upon a
					larger set of community values to apply
					more complex maintenance policies.</t>

			</section>
                      <section title = "Simplified graceful shutdown procedure" anchor = "sec.inbound.simplified">

		      </section>
-->

<section title = "Beyond EBGP graceful shutdown" anchor = "beyond">

	<section title = "IBGP graceful shutdown" anchor="IBGP">
  
		<t>For the shutdown of an IBGP session, provided the IBGP topology is viable after the
		maintenance of the session, i.e, if all BGP speakers
		of the AS have an IBGP signaling path for all prefixes
		advertised on this graceful shutdown IBGP session, then the
		shutdown of an IBGP session does not lead to transient
		unreachability. As a consequence, no specific graceful shutdown action is required.</t>

	</section><!--IBGP graceful shutdown -->


	<section title = "Link Up cases" anchor="UP">
  
  <t>We identify two potential causes for transient packet losses upon
  an EBGP link up event. The first one is local to the graceful no-shut initiator,
  the second one is due to the BGP convergence following the injection of new
  best paths within the IBGP topology. </t>

  <section title = "Unreachability local to the ASBR">
    
    <t>An ASBR that selects as best a path received over a newly
    brought up EBGP session may transiently drop traffic. This can
    typically happen when the NEXT_HOP attribute differs from the IP
    address of the EBGP peer, and the receiving ASBR has not yet
    resolved the MAC address associated with the IP address of that
    "third party" NEXT_HOP. </t>

    <t>A BGP speaker implementation could avoid such losses by
    ensuring that "third party" NEXT_HOPs are resolved before
    installing paths using these in the RIB.</t>

    <t>If the link up event corresponds to an EBGP session that is being manually
    brought up, over an already up multi-access link, then the
    operator can ping third party NEXT_HOP that are expected to be
    used before actually bringing the session up, or ping directed
    broadcast the subnet IP address of the link. By proceeding like
    this, the MAC addresses associated with these third party NEXT_HOP
    will be resolved by the graceful no-shut initiator.
    </t>

  </section><!--Unreachability local to the ASBR-->

  <section title = "IBGP convergence">

    <t>Corner cases leading to LoC can occur during an EBGP link up event.</t>

    <t>A typical example for such transient unreachability for a given
    prefix is the following:</t>

    <t> Let's consider 3 route reflectors RR1, RR2, RR3. There is a full mesh
    of IBGP session between them. </t>
	
	<t><list style="empty" hangIndent="5" >

	  <t>1. RR1 is initially advertising the
	  current best path to the members of its IBGP RR
	  full-mesh. It propagated that path within its RR
	  full-mesh. RR2 knows only that path toward the prefix.
	  </t>
	
      <t>2. RR3 receives a new best path originated by the "graceful no-shut"
      initiator, being one of its RR clients. RR3 selects it as best, and
      propagates an UPDATE within its RR full-mesh, i.e., to RR1 and RR2.  </t>
 
	  <t>3. RR1 receives that path, reruns its decision process,
	  and picks this new path as best. As a result, RR1 withdraws
	  its previously announced best-path on the IBGP sessions of its RR full-mesh.
	  </t>
	
	  <t>4. If, for any reason, RR3 processes the withdraw
	  generated in step 3, before processing the update generated
	  in step 2, RR3 transiently suffers from unreachability for
	  the affected prefix. </t>
			
	  </list>
	</t>


	<t> The use of <xref target="I-D.ietf-idr-best-external"></xref> among the RR of
	the IBGP full-mesh can solve these corner cases by ensuring
	that within an AS, the advertisement of a new route is not
	translated into the withdraw of a former route.</t>

	<t> Indeed, "best-external" ensures that an ASBR does not
	withdraw a previously advertised (EBGP) path when it receives
	an additional, preferred path over an IBGP session. Also,
	"best-intra-cluster" ensures that a RR does not withdraw a
	previously advertised (IBGP) path to its non clients
	(e.g. other RRs in a mesh of RR) when it receives a new,
	preferred path over an IBGP session.</t>

  </section><!--IBGP convergence-->

  

</section><!--Link up cases-->

</section><!--Beyond EBGP graceful shutdown-->



<section anchor="IANA" title="IANA Considerations">
<t>The IANA has assigned the community value 0xFFFF0000 to the planned-shut
  community in the "BGP Well-known Communities" registry. IANA is
 requested to change the name planned-shut to GRACEFUL_SHUTDOWN and set this document as the reference.</t>
</section><!--IANA-->

<section title = "Security Considerations"  anchor = "security">

    <t> By providing the graceful shutdown service to a neighboring AS, an ISP provides
    means to this neighbor and possibly its downstream ASes to lower the LOCAL_PREF value assigned to the paths
    received from this neighbor. </t>

    <t> The neighbor could abuse the technique and do inbound traffic
    engineering by declaring some prefixes as undergoing a maintenance so as to
    switch traffic to another peering link.</t>

    <t>If this behavior is not tolerated by the ISP, it SHOULD monitor the use
    of the graceful shutdown community by this neighbor.</t> 

</section><!-- Security Considerations-->


<section title = "Acknowledgments"  anchor = "ack">

<t>The authors wish to thank Olivier Bonaventure, Pradosh Mohapatra and Job Snijders for their useful comments on this work.</t>

</section>

</middle>
<back>

<references title="Normative References">

<?rfc include="reference.RFC.6198"?>
<?rfc include="reference.RFC.1997"?>
<?rfc include="reference.RFC.2119"?>

</references>

<references title="Informative References">
<?rfc include="reference.RFC.7911"?>
<?rfc include="reference.I-D.ietf-idr-best-external"?>
<?rfc include="reference.I-D.ietf-idr-shutdown"?>
</references>


<section title = "Alternative techniques with limited applicability">


  <t>A few alternative techniques have been considered to provide
  graceful shutdown capabilities but have been rejected due to their limited
  applicability.  This section describe them for possible
  reference.</t>



  <section title = "Multi Exit Discriminator tweaking" anchor = "sec.med-poison"> 

    <t> The MED attribute of the paths to be avoided can be increased
    so as to force the routers in the neighboring AS to select other
    paths. </t>
    
    <t> The solution only works if the alternate paths are as good as
    the initial ones with respect to the Local-Pref value and the AS
    Path Length value.  In the other cases, increasing the MED value
    will not have an impact on the decision process of the routers in
    the neighboring AS.</t>
    
  </section><!--MED-->
  
  <section title = "IGP distance Poisoning" anchor = "sec.igp-poison">
    
    <t> The distance to the BGP NEXT_HOP corresponding to the
    maintained session can be increased in the IGP so that the old
    paths will be less preferred during the application of the IGP
    distance tie-break rule. However, this solution only works for the
    paths whose alternates are as good as the old paths with respect
    to their Local-Pref value, their AS Path length, and their MED
    value.</t>
    
    <t> Also, this poisoning cannot be applied when nexthop self is
    used as there is no nexthop specific to the maintained session to
    poison in the IGP.</t>
	
  </section><!--IGP distance poisoning-->


</section><!--Techniques with limited applicability-->

<section anchor="config_examples" title="Configuration Examples">
    <t>
        This appendix is non-normative.
    </t>
	<t>
		Example routing policy configurations to honor the GRACEFUL_SHUTDOWN well-known BGP community.
	</t>
	<section title="Cisco IOS XR">
	<figure>
<artwork><![CDATA[
community-set comm-graceful-shutdown
  65535:0
end-set
!
route-policy AS64497-ebgp-inbound
  ! normally this policy would contain much more
  if community matches-any comm-graceful-shutdown then
    set local-preference 0
  endif
end-policy
!
router bgp 64496
 neighbor 2001:db8:1:2::1
  remote-as 64497
  description a fantastic EBGP neighbor
  address-family ipv6 unicast
   send-community-ebgp
   route-policy AS64497-ebgp-inbound in
   route-policy AS65040v6-bgp-out out
  !
 !
!
]]></artwork>
	</figure>
	</section><!--Cisco IOS XR-->
	<section title="BIRD">
<figure>
<artwork><![CDATA[
function honor_graceful_shutdown() {
    if (65535, 0) ~ bgp_community then {
        bgp_local_pref = 0;
    }
}
filter AS64497_ebgp_inbound
{
	# normally this policy would contain much more
	honor_graceful_shutdown();
}
protocol bgp peer_64497_1 {
    description "a fantastic EBGP neighbor";
    neighbor 2001:db8:1:2::1 as 64497;
    local as 64496;
    import keep filtered;
    import filter AS64497_ebgp_inbound;
    export filter AS64497_ebgp_outbound;
}
]]></artwork>
	</figure>
	</section><!--BIRD-->
	<section title="OpenBGPD">
<figure>
<artwork><![CDATA[
AS 64496
router-id 192.0.2.1
neighbor 2001:db8:1:2::1 {
        descr "a fantastic EBGP neighbor"
        remote-as 64497
}
# normally this policy would contain much more
match from any community GRACEFUL_SHUTDOWN set { localpref 0 }
]]></artwork>
    </figure>
    </section><!--OpenBGP-->
</section><!--Configuration Examples-->


</back>
</rfc>
