<?xml version='1.0' encoding='utf-8'?>

<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>

<rfc
   xmlns:xi="http://www.w3.org/2001/XInclude"
   category="info"
   consensus="true"
   submissionType="IETF"
   ipr="trust200902"
   docName="draft-chen-idr-tcp-user-timeout-00"
   updates=""
   obsoletes=""
   sortRefs="true"
   version="3">

  <front>
    <title abbrev="TCP-UT">Applying TCP User Timeout Parameter to BGP Sessions</title>

<author fullname='Enke Chen' initials='E' surname='Chen'>
    <organization>Palo Alto Networks</organization>
    <address>
        <postal>
            <street></street>
            <city></city>
            <region></region>
            <code></code>
            <country></country>
        </postal>
        <email>enchen@paloaltonetworks.com</email>
    </address>
</author>

<author fullname='Robert Raszuk' initials='R' surname='Raszuk'>
    <organization>NTT NI</organization>
    <address>
        <postal>
            <street></street>
            <city></city>
            <region></region>
            <code></code>
            <country></country>
        </postal>
        <email>robert@raszuk.net</email>
    </address>
</author>

<date year="2022" />
<area>Routing</area>
<workgroup>IDR Working Group</workgroup>
<keyword>I-D</keyword>
<keyword>Internet-Draft</keyword>
<keyword>BGP</keyword>
<keyword>TCP</keyword>

    <abstract>
      <t> In this document we discuss the TCP "User Timeout" parameter
          and recommend using it to handle stuck BGP sessions.</t>
    </abstract>

    <note title="Requirements Language">
      <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 <xref
      target="RFC2119">RFC 2119</xref>.</t>
    </note>

  </front>

  <middle>

    <section title="Introduction">
    
      <t> A BGP session <xref target="RFC4271" /> is said, informally, to be 
          "stuck" when BGP messages are not transmitted over the session for 
          an extended period of time. Certainly the stuck BGP session should 
          have been terminated by the BGP holdtimer. Such a case could occur, 
          though, due to software defects or under certain unusual circumstances.
          Currently it's difficult to know for sure due to lacking of automated,
          real-time detection mechanisms in BGP implementations.</t>

      <t> It has been speculated that some BGP sessions may have stuck from 
          time to time, and that may have contributed to stale routes (e.g., 
          missing route withdraws) in the routing system.</t>

      <t> Here is a specific scenario of a stuck BGP session between two BGP 
          speakers A and B:</t>

          <ul>
            <li> Due to certain software defect, B stops reading data from 
                 TCP <xref target="RFC0793" /> for an extended period of time, resulting in B advertises a zero value for its TCP window 
                 size after its TCP buffer fills up.</li>

            <li> B fails to generate BGP HOLDTIME expiration, although it has
                 not read from TCP and thus has not received any BGP KEEPALIVE
                 from A during that time.</li>

            <li> B, however, continues to send BGP KEEPALIVE to A on time.</li>
          </ul>

      <t> In this scenario A would not be able to send routing updates to B
          during that period of time. The routing system may become stale,
          not only on B, but on its BGP neighbors and beyond.</t>

      <t> It's desirable for a BGP speaker (e.g., A in the example) to be
          able to detect and then terminate such a stuck session so that the 
          stale routes are purged from the routing system.</t>

      <t> The availability of such a mechanism may also help accelerate the 
          resolution of the software defect involved.</t>

      <t> In this document we discuss the TCP "User Timeout" parameter
         <xref target="RFC0793" /> and recommend using it to handle stuck BGP sessions.</t>

    </section>

    <section title="Discussion on TCP User Timeout">

      <t> The TCP "User Timeout" parameter is designed to terminate a connection
          in a variety of cases where a TCP session does not progress
          within certain time period. It is specified in <xref target="RFC0793" />
          as follows:</t>
<artwork>
  USER TIMEOUT

     For any state if the user timeout expires, flush all queues,
     signal the user "error:  connection aborted due to user timeout"
     in general and for any outstanding calls, delete the TCB, enter
     the CLOSED state and return.
</artwork>

      <t> Clearly the TCP "User Timeout" applies when the application data is not 
          delivered on time, including the cases that transmitted data may remain 
          unacknowledged, or buffered data may remain untransmitted (due to zero window size).</t>

      <t> The TCP "User Timeout" parameter is well summarized in 
          <xref target="RFC5482" />, although the zero-window case is not 
          explicitly called out:</t>
<artwork>
        The Transmission Control Protocol (TCP) specification RFC0793 
        defines a local, per-connection  "user timeout" parameter that 
        specifies the maximum amount of time that transmitted data may 
        remain unacknowledged before TCP will forcefully close the 
        corresponding connection. Applications can set and change this 
        parameter with OPEN and SEND calls.
</artwork>

      <t> Regarding the implementation of the TCP "User Timeout" parameter,
      one example is the Linux's "TCP_USER_TIMEOUT" socket option
      documented in <xref target="LINUX-TCP" />.</t>

    </section>

    <section title="Recommendations">

      <t> As discussed in the introduction, a BGP session is considered "stuck"
          when BGP messages are not delivered for an extended period of time.</t>

      <t> Given that BGP messages are TCP data, and TCP is responsible for 
          delivering the data, thus it would be more natural and more complete 
          to address the issue at the TCP layer rather than in BGP itself
          (particularly in the case of persistent TCP zero-window).</t>

      <t> As the TCP "User Timeout" parameter is specifically defined to 
          terminate the TCP connection when something in TCP is "stuck",
          we thus recommend using it to detect and terminate these
          stuck BGP sessions.</t>

      <t> We recommend that the TCP "User Timeout" parameter be set for all 
          BGP sessions, and the default timeout value be five times the 
          configured BGP holdtime value but no less than ten minutes in order 
          to tolerate certain short-lived, transient conditions. The TCP "User 
          Timeout" value for a BGP session should be configurable.</t>

      <t> We also recommend that the TCP "User Timeout" parameter be
          set only after the End-of-RIB marker [RFC4724], if expected, is
          received from each of the (AFI, SAFI) being exchanged over the BGP
	  session, or otherwise thirty minutes after the BGP session is
	  established. The delay for setting the parameter should be
	  configurable.</t>

      <t> When the TCP "User Timeout" for a BGP session expires, the BGP 
          speaker SHOULD log the event locally. In addition, the administrator 
          of the remote BGP speaker should be informed (by means outside the scope of this document) so that the issue can be investigated.</t>

      <t> The procedures for BGP Graceful Restart <xref target="RFC4724" /> 
          SHOULD be followed when the TCP session is terminated due to TCP 
          "User Timeout" expiration.</t>

</section>

<section anchor="IANA" title="IANA Considerations">

  <t>This document has no request for IANA.</t>
        
</section>

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

  <t> The solution proposed in this document does not change the underlying
      security or confidentiality issues inherent in the existing BGP 
      <xref target="RFC4271" />.</t>

</section>

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

  <t> TBD</t>

</section>

</middle>

<back>

  <references title="References">

  <references title="Normative References">
    <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.0793.xml"/>
    <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
    <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4271.xml"/>
    <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.4724.xml"/>
    <!-- 
    <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>    
    -->
  </references>

  <references title="Informative References">

    <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5482.xml"/>

    <reference anchor="LINUX-TCP" target="https://man7.org/linux/man-pages/man7/tcp.7.html">
      <front>
        <title>Linux Man Pages</title>
        <author fullname="TCP(7)"><organization>Linux</organization></author>
        <date month="March" year="2021" />
      </front>
    </reference>
  </references>
</references>

</back>

</rfc>
