idnits 2.17.1 draft-ietf-dnsop-session-signal-18.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year (Using the creation date from RFC1035, updated by this document, for RFC5378 checks: 1987-11-01) -- The document seems to lack a disclaimer for pre-RFC5378 work, but may have content which was first submitted before 10 November 2008. If you have contacted all the original authors and they are all willing to grant the BCP78 rights to the IETF Trust, then this is fine, and you can ignore this comment. If not, you may need to add the pre-RFC5378 disclaimer. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (October 23, 2018) is 2012 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Missing Reference: 'TBA1' is mentioned on line 2300, but not defined == Missing Reference: 'TBA2' is mentioned on line 2306, but not defined == Outdated reference: A later version (-23) exists of draft-ietf-dnsop-no-response-issue-11 == Outdated reference: A later version (-04) exists of draft-ietf-dnssd-mdns-relay-01 == Outdated reference: A later version (-25) exists of draft-ietf-dnssd-push-15 Summary: 0 errors (**), 0 flaws (~~), 6 warnings (==), 2 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 DNSOP Working Group R. Bellis 3 Internet-Draft ISC 4 Updates: 1035, 7766 (if approved) S. Cheshire 5 Intended status: Standards Track Apple Inc. 6 Expires: April 26, 2019 J. Dickinson 7 S. Dickinson 8 Sinodun 9 T. Lemon 10 Nibbhaya Consulting 11 T. Pusateri 12 Unaffiliated 13 October 23, 2018 15 DNS Stateful Operations 16 draft-ietf-dnsop-session-signal-18 18 Abstract 20 This document defines a new DNS OPCODE for DNS Stateful Operations 21 (DSO). DSO messages communicate operations within persistent 22 stateful sessions, using type-length-value (TLV) syntax. Three TLVs 23 are defined that manage session timeouts, termination, and encryption 24 padding, and a framework is defined for extensions to enable new 25 stateful operations. This document updates RFC 1035 by adding a new 26 DNS header opcode which has different message semantics, and a new 27 result code. This document updates RFC 7766 by redefining a session, 28 providing new guidance on connection re-use, and providing a new 29 mechanism for handling session idle timeouts. 31 Status of This Memo 33 This Internet-Draft is submitted in full conformance with the 34 provisions of BCP 78 and BCP 79. 36 Internet-Drafts are working documents of the Internet Engineering 37 Task Force (IETF). Note that other groups may also distribute 38 working documents as Internet-Drafts. The list of current Internet- 39 Drafts is at https://datatracker.ietf.org/drafts/current/. 41 Internet-Drafts are draft documents valid for a maximum of six months 42 and may be updated, replaced, or obsoleted by other documents at any 43 time. It is inappropriate to use Internet-Drafts as reference 44 material or to cite them other than as "work in progress." 46 This Internet-Draft will expire on April 26, 2019. 48 Copyright Notice 50 Copyright (c) 2018 IETF Trust and the persons identified as the 51 document authors. All rights reserved. 53 This document is subject to BCP 78 and the IETF Trust's Legal 54 Provisions Relating to IETF Documents 55 (https://trustee.ietf.org/license-info) in effect on the date of 56 publication of this document. Please review these documents 57 carefully, as they describe your rights and restrictions with respect 58 to this document. Code Components extracted from this document must 59 include Simplified BSD License text as described in Section 4.e of 60 the Trust Legal Provisions and are provided without warranty as 61 described in the Simplified BSD License. 63 Table of Contents 65 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 66 2. Requirements Language . . . . . . . . . . . . . . . . . . . . 5 67 3. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 6 68 4. Applicability . . . . . . . . . . . . . . . . . . . . . . . . 9 69 4.1. Use Cases . . . . . . . . . . . . . . . . . . . . . . . . 9 70 4.1.1. Session Management . . . . . . . . . . . . . . . . . 9 71 4.1.2. Long-lived Subscriptions . . . . . . . . . . . . . . 9 72 4.2. Applicable Transports . . . . . . . . . . . . . . . . . . 10 73 5. Protocol Details . . . . . . . . . . . . . . . . . . . . . . 11 74 5.1. DSO Session Establishment . . . . . . . . . . . . . . . . 12 75 5.1.1. Session Establishment Failure . . . . . . . . . . . . 13 76 5.1.2. Session Establishment Success . . . . . . . . . . . . 14 77 5.2. Operations After Session Establishment . . . . . . . . . 14 78 5.3. Session Termination . . . . . . . . . . . . . . . . . . . 15 79 5.3.1. Handling Protocol Errors . . . . . . . . . . . . . . 15 80 5.4. Message Format . . . . . . . . . . . . . . . . . . . . . 16 81 5.4.1. DNS Header Fields in DSO Messages . . . . . . . . . . 17 82 5.4.2. DSO Data . . . . . . . . . . . . . . . . . . . . . . 19 83 5.4.3. TLV Syntax . . . . . . . . . . . . . . . . . . . . . 21 84 5.4.4. EDNS(0) and TSIG . . . . . . . . . . . . . . . . . . 24 85 5.5. Message Handling . . . . . . . . . . . . . . . . . . . . 25 86 5.5.1. Delayed Acknowledgement Management . . . . . . . . . 26 87 5.5.2. MESSAGE ID Namespaces . . . . . . . . . . . . . . . . 27 88 5.5.3. Error Responses . . . . . . . . . . . . . . . . . . . 28 89 5.6. Responder-Initiated Operation Cancellation . . . . . . . 29 90 6. DSO Session Lifecycle and Timers . . . . . . . . . . . . . . 30 91 6.1. DSO Session Initiation . . . . . . . . . . . . . . . . . 30 92 6.2. DSO Session Timeouts . . . . . . . . . . . . . . . . . . 31 93 6.3. Inactive DSO Sessions . . . . . . . . . . . . . . . . . . 32 94 6.4. The Inactivity Timeout . . . . . . . . . . . . . . . . . 33 95 6.4.1. Closing Inactive DSO Sessions . . . . . . . . . . . . 33 96 6.4.2. Values for the Inactivity Timeout . . . . . . . . . . 34 97 6.5. The Keepalive Interval . . . . . . . . . . . . . . . . . 35 98 6.5.1. Keepalive Interval Expiry . . . . . . . . . . . . . . 35 99 6.5.2. Values for the Keepalive Interval . . . . . . . . . . 35 100 6.6. Server-Initiated Session Termination . . . . . . . . . . 37 101 6.6.1. Server-Initiated Retry Delay Message . . . . . . . . 38 102 6.6.2. Misbehaving Clients . . . . . . . . . . . . . . . . . 39 103 6.6.3. Client Reconnection . . . . . . . . . . . . . . . . . 39 104 7. Base TLVs for DNS Stateful Operations . . . . . . . . . . . . 41 105 7.1. Keepalive TLV . . . . . . . . . . . . . . . . . . . . . . 41 106 7.1.1. Client handling of received Session Timeout values . 43 107 7.1.2. Relationship to edns-tcp-keepalive EDNS0 Option . . . 44 108 7.2. Retry Delay TLV . . . . . . . . . . . . . . . . . . . . . 45 109 7.2.1. Retry Delay TLV used as a Primary TLV . . . . . . . . 45 110 7.2.2. Retry Delay TLV used as a Response Additional TLV . . 47 111 7.3. Encryption Padding TLV . . . . . . . . . . . . . . . . . 48 112 8. Summary Highlights . . . . . . . . . . . . . . . . . . . . . 49 113 8.1. QR bit and MESSAGE ID . . . . . . . . . . . . . . . . . . 49 114 8.2. TLV Usage . . . . . . . . . . . . . . . . . . . . . . . . 50 115 9. Additional Considerations . . . . . . . . . . . . . . . . . . 52 116 9.1. Service Instances . . . . . . . . . . . . . . . . . . . . 52 117 9.2. Anycast Considerations . . . . . . . . . . . . . . . . . 53 118 9.3. Connection Sharing . . . . . . . . . . . . . . . . . . . 54 119 9.4. Operational Considerations for Middlebox . . . . . . . . 55 120 9.5. TCP Delayed Acknowledgement Considerations . . . . . . . 56 121 10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 59 122 10.1. DSO OPCODE Registration . . . . . . . . . . . . . . . . 59 123 10.2. DSO RCODE Registration . . . . . . . . . . . . . . . . . 59 124 10.3. DSO Type Code Registry . . . . . . . . . . . . . . . . . 59 125 11. Security Considerations . . . . . . . . . . . . . . . . . . . 60 126 11.1. TLS 0-RTT Considerations . . . . . . . . . . . . . . . . 61 127 12. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 62 128 13. References . . . . . . . . . . . . . . . . . . . . . . . . . 62 129 13.1. Normative References . . . . . . . . . . . . . . . . . . 62 130 13.2. Informative References . . . . . . . . . . . . . . . . . 63 131 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 65 133 1. Introduction 135 This document specifies a mechanism for managing stateful DNS 136 connections. DNS most commonly operates over a UDP transport, but 137 can also operate over streaming transports; the original DNS RFC 138 specifies DNS over TCP [RFC1035] and a profile for DNS over TLS 139 [RFC7858] has been specified. These transports can offer persistent, 140 long-lived sessions and therefore when using them for transporting 141 DNS messages it is of benefit to have a mechanism that can establish 142 parameters associated with those sessions, such as timeouts. In such 143 situations it is also advantageous to support server-initiated 144 messages (such as DNS Push Notifications [I-D.ietf-dnssd-push]). 146 The existing EDNS(0) Extension Mechanism for DNS [RFC6891] is 147 explicitly defined to only have "per-message" semantics. While 148 EDNS(0) has been used to signal at least one session-related 149 parameter (edns-tcp-keepalive EDNS0 Option [RFC7828]) the result is 150 less than optimal due to the restrictions imposed by the EDNS(0) 151 semantics and the lack of server-initiated signalling. For example, 152 a server cannot arbitrarily instruct a client to close a connection 153 because the server can only send EDNS(0) options in responses to 154 queries that contained EDNS(0) options. 156 This document defines a new DNS OPCODE, DSO ([TBA1], tentatively 6), 157 for DNS Stateful Operations. DSO messages are used to communicate 158 operations within persistent stateful sessions, expressed using type- 159 length-value (TLV) syntax. This document defines an initial set of 160 three TLVs, used to manage session timeouts, termination, and 161 encryption padding. 163 All three TLVs defined here are mandatory for all implementations of 164 DSO. Further TLVs may be defined in additional specifications. 166 DSO messages may or may not be acknowledged; this is signalled by 167 providing a non-zero message ID for messages that must be 168 acknowledged (DSO request messages) and a zero message ID for 169 messages that are not to be acknowledged (DSO unidirectional 170 messages), and is also specified in the definition of a particular 171 DSO message type. Messages are pipelined; answers may appear out of 172 order when more than one answer is pending. 174 The format for DSO messages (Section 5.4) differs somewhat from the 175 traditional DNS message format used for standard queries and 176 responses. The standard twelve-byte header is used, but the four 177 count fields (QDCOUNT, ANCOUNT, NSCOUNT, ARCOUNT) are set to zero and 178 accordingly their corresponding sections are not present. 180 The actual data pertaining to DNS Stateful Operations (expressed in 181 TLV syntax) is appended to the end of the DNS message header. Just 182 as in traditional DNS over TCP [RFC1035] [RFC7766] the stream 183 protocol carrying DSO messages (which are just another kind of DNS 184 message) frames them by putting a 16-bit message length at the start, 185 so the length of the DSO message is determined from that length, 186 rather than from any of the DNS header counts. 188 When displayed using packet analyzer tools that have not been updated 189 to recognize the DSO format, this will result in the DSO data being 190 displayed as unknown additional data after the end of the DNS 191 message. 193 This new format has distinct advantages over an RR-based format 194 because it is more explicit and more compact. Each TLV definition is 195 specific to its use case, and as a result contains no redundant or 196 overloaded fields. Importantly, it completely avoids conflating DNS 197 Stateful Operations in any way with normal DNS operations or with 198 existing EDNS(0)-based functionality. A goal of this approach is to 199 avoid the operational issues that have befallen EDNS(0), particularly 200 relating to middlebox behaviour (see for example 201 [I-D.ietf-dnsop-no-response-issue] sections 3.2 and 4). 203 With EDNS(0), multiple options may be packed into a single OPT 204 pseudo-RR, and there is no generalized mechanism for a client to be 205 able to tell whether a server has processed or otherwise acted upon 206 each individual option within the combined OPT pseudo-RR. The 207 specifications for each individual option need to define how each 208 different option is to be acknowledged, if necessary. 210 In contrast to EDNS(0), with DSO there is no compelling motivation to 211 pack multiple operations into a single message for efficiency 212 reasons, because DSO always operates using a connection-oriented 213 transport protocol. Each DSO operation is communicated in its own 214 separate DNS message, and the transport protocol can take care of 215 packing several DNS messages into a single IP packet if appropriate. 216 For example, TCP can pack multiple small DNS messages into a single 217 TCP segment. This simplification allows for clearer semantics. Each 218 DSO request message communicates just one primary operation, and the 219 RCODE in the corresponding response message indicates the success or 220 failure of that operation. 222 2. Requirements Language 224 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 225 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 226 "OPTIONAL" in this document are to be interpreted as described in BCP 227 14 [RFC2119] [RFC8174] when, and only when, they appear in all 228 capitals, as shown here. 230 3. Terminology 232 DSO: DNS Stateful Operations. 234 connection: a bidirectional byte (or message) stream, where the 235 bytes (or messages) are delivered reliably and in-order, such as 236 provided by using DNS over TCP [RFC1035] [RFC7766] or DNS over TLS 237 [RFC7858]. 239 session: The unqualified term "session" in the context of this 240 document refers to a persistent network connection between two 241 endpoints which allows for the exchange of DNS messages over a 242 connection where either end of the connection can send messages to 243 the other end. (The term has no relationship to the "session 244 layer" of the OSI "seven-layer model".) 246 DSO Session: a session established between two endpoints that 247 acknowledge persistent DNS state via the exchange of DSO messages 248 over the connection. This is distinct from a DNS-over-TCP session 249 as described in the previous specification for DNS over TCP 250 [RFC7766]. 252 close gracefully: a normal session shutdown, where the client closes 253 the TCP connection to the server using a graceful close, such that 254 no data is lost (e.g., using TCP FIN, see Section 5.3). 256 forcibly abort: a session shutdown as a result of a fatal error, 257 where the TCP connection is unilaterally aborted without regard 258 for data loss (e.g., using TCP RST, see Section 5.3). 260 server: the software with a listening socket, awaiting incoming 261 connection requests, in the usual DNS sense. 263 client: the software which initiates a connection to the server's 264 listening socket, in the usual DNS sense. 266 initiator: the software which sends a DSO request message or a DSO 267 unidirectional message during a DSO session. Either a client or 268 server can be an initiator 270 responder: the software which receives a DSO request message or a 271 DSO unidirectional message during a DSO 273 session. Either a client or server can be a responder. 275 sender: the software which is sending a DNS message, a DSO message, 276 a DNS response, or a DSO response. 278 receiver: the software which is receiving a DNS message, a DSO 279 message, a DNS response, or a DSO response. 281 service instance: a specific instance of server software running on 282 a specific host (Section 9.1). 284 long-lived operation: a long-lived operation is an outstanding 285 operation on a DSO session where either the client or server, 286 acting as initiator, has requested that the responder send new 287 information regarding the request, as it becomes available. 289 Early Data: A TCP SYN packet (TCP Fast Open) containing a TLS 1.3 290 initial handshake containing early data that begins a DSO session 291 ([RFC8446] section 2.3). TCP Fast Open is only permitted when 292 using TLS encapsulation: a TCP SYN message that does not use TLS 293 encapsulation but contains data is not permitted. 295 DNS message: any DNS message, including DNS queries, response, 296 updates, DSO messages, etc. 298 DNS request message: any DNS message where the QR bit is 0. 300 DNS response message: any DNS message where the QR bit is 1. 302 DSO message: a DSO request message, DSO unidirectional message, or a 303 DSO response to a DSO request message. If the QR bit is 1 in a 304 DSO message, it is a DSO response message. If the QR bit is 0 in 305 a DSO message, it is a DSO request message or DSO unidirectional 306 message, as determined by the specification of its primary TLV. 308 DSO response message: a response to a DSO request message. 310 DSO request message: a DSO message that requires a response. 312 DSO unidirectional message: a DSO message that does not require and 313 cannot induce a response. 315 Primary TLV: The first TLV in a DSO message or DSO response; in the 316 DSO message this determines the nature of the operation being 317 performed. 319 Additional TLV: Any TLVs in a DSO message response that follow the 320 primary TLV. 322 Response Primary TLV: The (optional) first TLV in a DSO response. 324 Response Additional TLV: Any TLVs in a DSO response that follow the 325 (optional) Response Primary TLV. 327 inactivity timer: the time since the most recent non-keepalive DNS 328 message was sent or received. (see Section 6.4) 330 keepalive timer: the time since the most recent DNS message was sent 331 or received. (see Section 6.5) 333 session timeouts: the inactivity timer and the keepalive timer. 335 inactivity timeout: the maximum value that the inactivity timer can 336 have before the connection is gracefully closed. 338 keepalive interval: the maximum value that the keepalive timer can 339 have before the client is required to send a keepalive. (see 340 Section 7.1) 342 resetting a timer: setting the timer value to zero and restarting 343 the timer. 345 clearing a timer: setting the timer value to zero but not restarting 346 the timer. 348 4. Applicability 350 DNS Stateful Operations are applicable to several known use cases and 351 are only applicable on transports that are capable of supporting a 352 DSO Session. 354 4.1. Use Cases 356 There are several use cases for DNS Stateful operations that can be 357 described here. 359 4.1.1. Session Management 361 Firstly, establishing session parameters such as server-defined 362 timeouts is of great use in the general management of persistent 363 connections. For example, using DSO sessions for stub-to-recursive 364 DNS-over-TLS [RFC7858] is more flexible for both the client and the 365 server than attempting to manage sessions using just the edns-tcp- 366 keepalive EDNS0 Option [RFC7828]. The simple set of TLVs defined in 367 this document is sufficient to greatly enhance connection management 368 for this use case. 370 4.1.2. Long-lived Subscriptions 372 Secondly, DNS-SD [RFC6763] has evolved into a naturally session-based 373 mechanism where, for example, long-lived subscriptions lend 374 themselves to 'push' mechanisms as opposed to polling. Long-lived 375 stateful connections and server-initiated messages align with this 376 use case [I-D.ietf-dnssd-push]. 378 A general use case is that DNS traffic is often bursty but session 379 establishment can be expensive. One challenge with long-lived 380 connections is to maintain sufficient traffic to maintain NAT and 381 firewall state. To mitigate this issue this document introduces a 382 new concept for the DNS, that is DSO "Keepalive traffic". This 383 traffic carries no DNS data and is not considered 'activity' in the 384 classic DNS sense, but serves to maintain state in middleboxes, and 385 to assure client and server that they still have connectivity to each 386 other. 388 4.2. Applicable Transports 390 DNS Stateful Operations are applicable in cases where it is useful to 391 maintain an open session between a DNS client and server, where the 392 transport allows such a session to be maintained, and where the 393 transport guarantees in-order delivery of messages, on which DSO 394 depends. Examples of transports that can support DNS Stateful 395 Operations are DNS-over-TCP [RFC1035] [RFC7766] and DNS-over-TLS 396 [RFC7858]. 398 Note that in the case of DNS over TLS, there is no mechanism for 399 upgrading from DNS-over-TCP to DNS-over-TLS mid-connection (see 400 [RFC7858] section 7). A connection is either DNS-over-TCP from the 401 start, or DNS-over-TLS from the start. 403 DNS Stateful Operations are not applicable for transports that cannot 404 support clean session semantics, or that do not guarantee in-order 405 delivery. While in principle such a transport could be constructed 406 over UDP, the current DNS specification over UDP transport [RFC1035] 407 does not provide in-order delivery or session semantics, and hence 408 cannot be used. Similarly, DNS-over-HTTP 409 [I-D.ietf-doh-dns-over-https] cannot be used because HTTP has its own 410 mechanism for managing sessions, and this is incompatible with the 411 mechanism specified here. 413 No other transports are currently defined for use with DNS Stateful 414 Operations. Such transports can be added in the future, if they meet 415 the requirements set out in the first paragraph of this section. 417 5. Protocol Details 419 The overall flow of DNS Stateful Operations goes through a series of 420 phases: 422 Connection Establishment: A client establishes a connection to a 423 server. (Section 4.2) 425 Connected but sessionless: A connection exists, but a DSO session 426 has not been established. DNS messages can be sent from the 427 client to server, and DNS responses can be sent from servers to 428 clients. In this state a client that wishes to use DSO can 429 attempt to establish a DSO session (Section 5.1). Standard DNS- 430 over-TCP inactivity timeout handling is in effect [RFC7766] (see 431 Section 7.1.2). 433 DSO Session Establishment in Progress: A client has sent a DSO 434 request, but has not yet received a DSO response. In this phase, 435 the client may send more DSO requests and more DNS requests, but 436 MUST NOT send DSO unidirectional messages (Section 5.1). 438 DSO Session Establishment Failed: The attempt to establish the DSO 439 session did not succeed. At this point, the client is permitted 440 to continue operating without a DSO session (Connected but 441 Sessionless) but does not send further DSO messages (Section 5.1). 443 DSO Session Established: Both client and server may send DSO 444 messages and DNS messages; both may send replies in response to 445 messages they receive (Section 5.2). The inactivity timer 446 (Section 6.4) is active; the keepalive timer (Section 6.5) is 447 active. Standard DNS-over-TCP inactivity timeout handling is no 448 longer in effect [RFC7766] (see Section 7.1.2). 450 Server Shutdown: The server has decided to gracefully terminate the 451 session, and has sent the client a Retry Delay message 452 (Section 6.6.1). There may still be unprocessed messages from the 453 client; the server will ignore these. The server will not send 454 any further messages to the client (Section 6.6.1.1). 456 Client Shutdown: The client has decided to disconnect, either 457 because it no longer needs service, the connection is inactive 458 (Section 6.4.1), or because the server sent it a Retry Delay 459 message (Section 6.6.1). The client closes the connection 460 gracefully Section 5.3. 462 Reconnect: The client disconnected as a result of a server shutdown. 463 The client either waits for the server-specified Retry Delay to 464 expire (Section 6.6.3), or else contacts a different server 465 instance. If the client no longer needs service, it does not 466 reconnect. 468 Forcibly Abort: The client or server detected a protocol error, and 469 further communication would have undefined behavior. The client 470 or server forcibly aborts the connection (Section 5.3). 472 Abort Reconnect Wait: The client has forcibly aborted the 473 connection, but still needs service. Or, the server forcibly 474 aborted the connection, but the client still needs service. The 475 client either connects to a different service instance 476 (Section 9.1) or waits to reconnect (Section 6.6.3.1). 478 5.1. DSO Session Establishment 480 In order for a session to be established between a client and a 481 server, the client must first establish a connection to the server, 482 using an applicable transport (see Section 4). 484 In some environments it may be known in advance by external means 485 that both client and server support DSO, and in these cases either 486 client or server may initiate DSO messages at any time. In this 487 case, the session is established as soon as the connection is 488 established; this is referred to as implicit session establishment. 490 However, in the typical case a server will not know in advance 491 whether a client supports DSO, so in general, unless it is known in 492 advance by other means that a client does support DSO, a server MUST 493 NOT initiate DSO request messages or DSO unidirectional messages 494 until a DSO Session has been mutually established by at least one 495 successful DSO request/response exchange initiated by the client, as 496 described below. This is referred to as explicit session 497 establishment. 499 Until a DSO session has been implicitly or explicitly established, a 500 client MUST NOT initiate DSO unidirectional messages. 502 A DSO Session is established over a connection by the client sending 503 a DSO request message, such as a DSO Keepalive request message 504 (Section 7.1), and receiving a response, with matching MESSAGE ID, 505 and RCODE set to NOERROR (0), indicating that the DSO request was 506 successful. 508 Some DSO messages are permitted as early data (Section 11.1). Others 509 are not. Unidirectional messages are never permitted as early data 510 unless an implicit session exists. 512 If a server receives a DSO message in early data whose primary TLV is 513 not permitted to appear in early data, the server MUST forcible abort 514 the connection. If a client receives a DSO message in early data, 515 and there is no implicit DSO session, the client MUST forcibly abort 516 the connection. If a server or client receives a TCP Fast Open 517 message that is not a TLS 1.3 0-RTT initial handshake, it MUST 518 forcibly abort the connection. 520 5.1.1. Session Establishment Failure 522 If the response RCODE is set to NOTIMP (4), or in practise any value 523 other than NOERROR (0) or DSOTYPENI (defined below), then the client 524 MUST assume that the server does not implement DSO at all. In this 525 case the client is permitted to continue sending DNS messages on that 526 connection, but the client MUST NOT issue further DSO messages on 527 that connection. 529 If the RCODE in the response is set to DSOTYPENI ("DSO-TYPE Not 530 Implemented", [TBA2] tentatively RCODE 11) this indicates that the 531 server does support DSO, but does not implement the DSO-TYPE of the 532 primary TLV in this DSO request message. A server implementing DSO 533 MUST NOT return DSOTYPENI for a DSO Keepalive request message, 534 because the Keepalive TLV is mandatory to implement. But in the 535 future, if a client attempts to establish a DSO Session using a 536 response-requiring DSO request message using some newly-defined DSO- 537 TYPE that the server does not understand, that would result in a 538 DSOTYPENI response. If the server returns DSOTYPENI then a DSO 539 Session is not considered established, but the client is permitted to 540 continue sending DNS messages on the connection, including other DSO 541 messages such as the DSO Keepalive, which may result in a successful 542 NOERROR response, yielding the establishment of a DSO Session. 544 Two other possibilities exist: the server might drop the connection, 545 or the server might send no response to the DSO message. 547 In the first case, the client SHOULD mark that service instance as 548 not supporting DSO, and not attempt a DSO connection for some period 549 of time (at least an hour) after the failed attempt. The client MAY 550 reconnect but not use DSO, if appropriate (Section 6.6.3.2). 552 In the second case, the client SHOULD wait 30 seconds, after which 553 time the server will be assumed not to support DSO. If the server 554 doesn't respond within 30 seconds, the client MUST forcibly abort the 555 connection to the server, since the server's behavior is out of spec, 556 and hence its state is undefined. The client MAY reconnect, but not 557 use DSO, if appropriate (Section 6.6.3.1). 559 5.1.2. Session Establishment Success 561 When the server receives a DSO request message from a client, and 562 transmits a successful NOERROR response to that request, the server 563 considers the DSO Session established. 565 When the client receives the server's NOERROR response to its DSO 566 request message, the client considers the DSO Session established. 568 Once a DSO Session has been established, either end may unilaterally 569 send appropriate DSO messages at any time, and therefore either 570 client or server may be the initiator of a message. 572 5.2. Operations After Session Establishment 574 Once a DSO Session has been established, clients and servers should 575 behave as described in this specification with regard to inactivity 576 timeouts and session termination, not as previously prescribed in the 577 earlier specification for DNS over TCP [RFC7766]. 579 Because a server that supports DNS Stateful Operations MUST return an 580 RCODE of NOERROR when it receives a Keepalive TLV DSO request 581 message, the Keepalive TLV is an ideal candidate for use in 582 establishing a DSO session. Any other option that can only succeed 583 when sent to a server of the desired kind is also a good candidate 584 for use in establishing a DSO session. For clients that implement 585 only the DSO-TYPEs defined in this base specification, sending a 586 Keepalive TLV is the only DSO request message they have available to 587 initiate a DSO Session. Even for clients that do implement other 588 future DSO-TYPEs, for simplicity they MAY elect to always send an 589 initial DSO Keepalive request message as their way of initiating a 590 DSO Session. A future definition of a new response-requiring DSO- 591 TYPE gives implementers the option of using that new DSO-TYPE if they 592 wish, but does not change the fact that sending a Keepalive TLV 593 remains a valid way of initiating a DSO Session. 595 5.3. Session Termination 597 A "DSO Session" is terminated when the underlying connection is 598 closed. Sessions are "closed gracefully" as a result of the server 599 closing a session because it is overloaded, the client closing the 600 session because it is done, or the client closing the session because 601 it is inactive. Sessions are "forcibly aborted" when either the 602 client or server closes the connection because of a protocol error. 604 o Where this specification says, "close gracefully," that means 605 sending a TLS close_notify (if TLS is in use) followed by a TCP 606 FIN, or the equivalents for other protocols. Where this 607 specification requires a connection to be closed gracefully, the 608 requirement to initiate that graceful close is placed on the 609 client, to place the burden of TCP's TIME-WAIT state on the client 610 rather than the server. 612 o Where this specification says, "forcibly abort," that means 613 sending a TCP RST, or the equivalent for other protocols. In the 614 BSD Sockets API this is achieved by setting the SO_LINGER option 615 to zero before closing the socket. 617 5.3.1. Handling Protocol Errors 619 In protocol implementation there are generally two kinds of errors 620 that software writers have to deal with. The first is situations 621 that arise due to factors in the environment, such as temporary loss 622 of connectivity. While undesirable, these situations do not indicate 623 a flaw in the software, and they are situations that software should 624 generally be able to recover from. 626 The second is situations that should never happen when communicating 627 with a compliant DSO implementation. If they do happen, they 628 indicate a serious flaw in the protocol implementation, beyond what 629 it is reasonable to expect software to recover from. This document 630 describes this latter form of error condition as a "fatal error" and 631 specifies that an implementation encountering a fatal error condition 632 "MUST forcibly abort the connection immediately". 634 5.4. Message Format 636 A DSO message begins with the standard twelve-byte DNS message header 637 [RFC1035] with the OPCODE field set to the DSO OPCODE. However, 638 unlike standard DNS messages, the question section, answer section, 639 authority records section and additional records sections are not 640 present. The corresponding count fields (QDCOUNT, ANCOUNT, NSCOUNT, 641 ARCOUNT) MUST be set to zero on transmission. 643 If a DSO message is received where any of the count fields are not 644 zero, then a FORMERR MUST be returned. 646 1 1 1 1 1 1 647 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 648 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 649 | MESSAGE ID | 650 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 651 |QR | OPCODE | Z | RCODE | 652 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 653 | QDCOUNT (MUST be zero) | 654 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 655 | ANCOUNT (MUST be zero) | 656 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 657 | NSCOUNT (MUST be zero) | 658 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 659 | ARCOUNT (MUST be zero) | 660 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 661 | | 662 / DSO Data / 663 / / 664 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 666 5.4.1. DNS Header Fields in DSO Messages 668 In a DSO unidirectional message the MESSAGE ID field MUST be set to 669 zero. In a DSO request message the MESSAGE ID field MUST be set to a 670 unique nonzero value, that the initiator is not currently using for 671 any other active operation on this connection. For the purposes 672 here, a MESSAGE ID is in use in this DSO Session if the initiator has 673 used it in a DSO request message for which it is still awaiting a 674 response, or if the client has used it to set up a long-lived 675 operation that has not yet been cancelled. For example, a long-lived 676 operation could be a Push Notification subscription 677 [I-D.ietf-dnssd-push] or a Discovery Relay interface subscription 678 [I-D.ietf-dnssd-mdns-relay]. 680 Whether a message is a DSO request message or a DSO unidirectional 681 message is determined only by the specification for the Primary TLV. 682 An acknowledgment cannot be requested by including a nonzero message 683 ID in a message that is required according to its primary TLV to be 684 unidirectional. Nor can an acknowledgment be prevented by sending a 685 message ID of zero in a message that is required to be a DSO request 686 message according to its primary TLV. A responder that receives 687 either such malformed message MUST treat it as a fatal error and 688 forcibly abort the connection immediately. 690 In a DSO request message or DSO unidirectional message the DNS Header 691 QR bit MUST be zero (QR=0). If the QR bit is not zero the message is 692 not a DSO request or DSO unidirectional message. 694 In a DSO response message the DNS Header QR bit MUST be one (QR=1). 695 If the QR bit is not one, the message is not a response message. 697 In a DSO response message (QR=1) the MESSAGE ID field MUST contain a 698 copy of the value of the MESSAGE ID field in the DSO request message 699 being responded to. In a DSO response message (QR=1) the MESSAGE ID 700 field MUST NOT be zero. If a DSO response message (QR=1) is received 701 where the MESSAGE ID is zero this is a fatal error and the recipient 702 MUST forcibly abort the connection immediately. 704 The DNS Header OPCODE field holds the DSO OPCODE value. 706 The Z bits are currently unused in DSO messages, and in both DSO 707 request messages and DSO responses the Z bits MUST be set to zero (0) 708 on transmission and MUST be ignored on reception. 710 In a DSO request message (QR=0) the RCODE is set according to the 711 definition of the request. For example, in a Retry Delay message 712 (Section 6.6.1) the RCODE indicates the reason for termination. 713 However, in most cases, except where clearly specified otherwise, in 714 a DSO request message (QR=0) the RCODE is set to zero on 715 transmission, and silently ignored on reception. 717 The RCODE value in a response message (QR=1) may be one of the 718 following values: 720 +--------+-----------+----------------------------------------------+ 721 | Code | Mnemonic | Description | 722 +--------+-----------+----------------------------------------------+ 723 | 0 | NOERROR | Operation processed successfully | 724 | | | | 725 | 1 | FORMERR | Format error | 726 | | | | 727 | 2 | SERVFAIL | Server failed to process DSO request message | 728 | | | due to a problem with the server | 729 | | | | 730 | 4 | NOTIMP | DSO not supported | 731 | | | | 732 | 5 | REFUSED | Operation declined for policy reasons | 733 | | | | 734 | [TBA2] | DSOTYPENI | Primary TLV's DSO-Type is not implemented | 735 | 11 | | | 736 +--------+-----------+----------------------------------------------+ 738 Use of the above RCODEs is likely to be common in DSO but does not 739 preclude the definition and use of other codes in future documents 740 that make use of DSO. 742 If a document defining a new DSO-TYPE makes use of response codes not 743 defined here, then that document MUST specify the specific 744 interpretation of those RCODE values in the context of that new DSO 745 TLV. 747 5.4.2. DSO Data 749 The standard twelve-byte DNS message header with its zero-valued 750 count fields is followed by the DSO Data, expressed using TLV syntax, 751 as described below in Section 5.4.3. 753 A DSO request message or DSO unidirectional message MUST contain at 754 least one TLV. The first TLV in a DSO request message or DSO 755 unidirectional message is referred to as the "Primary TLV" and 756 determines the nature of the operation being performed, including 757 whether it is a DSO request or a DSO unidirectional operation. In 758 some cases it may be appropriate to include other TLVs in a DSO 759 request message or DSO unidirectional message, such as the Encryption 760 Padding TLV (Section 7.3), and these extra TLVs are referred to as 761 the "Additional TLVs" and are not limited to what is defined in this 762 document. New "Additional TLVs" may be defined in the future and 763 those definitions will describe when their use is appropriate. 765 A DSO response message may contain no TLVs, or it may be specified to 766 contain one or more TLVs appropriate to the information being 767 communicated. This includes "Primary TLVs" and "Additional TLVs" 768 defined in this document as well as in future TLV definitions. It 769 may be permissible for an additional TLV to appear in a response to a 770 primary TLV even though the specification of that primary TLV does 771 not specify it explicitly. See Section 8.2 for more information. 773 A DSO response message may contain one or more TLVs with the Primary 774 TLV DSO-TYPE the same as the Primary TLV from the corresponding DSO 775 request message or it may contain zero or more Additional TLVs only. 776 The MESSAGE ID field in the DNS message header is sufficient to 777 identify the DSO request message to which this response message 778 relates. 780 A DSO response message may contain one or more TLVs with DSO-TYPEs 781 different from the Primary TLV from the corresponding DSO request 782 message, in which case those TLV(s) are referred to as "Response 783 Additional TLVs". 785 Response Primary TLV(s), if present, MUST occur first in the response 786 message, before any Response Additional TLVs. 788 It is anticipated that most DSO operations will be specified to use 789 DSO request messages, which generate corresponding DSO responses. In 790 some specialized high-traffic use cases, it may be appropriate to 791 specify DSO unidirectional messages. DSO unidirectional messages can 792 be more efficient on the network, because they don't generate a 793 stream of corresponding reply messages. Using DSO unidirectional 794 messages can also simplify software in some cases, by removing need 795 for an initiator to maintain state while it waits to receive replies 796 it doesn't care about. When the specification for a particular TLV 797 states that, when used as a Primary TLV (i.e., first) in an outgoing 798 DSO request message (i.e., QR=0), that message is to be 799 unidirectional, the MESSAGE ID field MUST be set to zero and the 800 receiver MUST NOT generate any response message corresponding to this 801 DSO unidirectional message. 803 The previous point, that the receiver MUST NOT generate responses to 804 DSO unidirectional messages, applies even in the case of errors. 806 When a DSO message is received where both the QR bit and the MESSAGE 807 ID field are zero, the receiver MUST NOT generate any response. For 808 example, if the DSO-TYPE in the Primary TLV is unrecognized, then a 809 DSOTYPENI error MUST NOT be returned; instead the receiver MUST 810 forcibly abort the connection immediately. 812 DSO unidirectional messages MUST NOT be used "speculatively" in cases 813 where the sender doesn't know if the receiver supports the Primary 814 TLV in the message, because there is no way to receive any response 815 to indicate success or failure. DSO unidirectional messages are only 816 appropriate in cases where the sender already knows that the receiver 817 supports, and wishes to receive, these messages. 819 For example, after a client has subscribed for Push Notifications 820 [I-D.ietf-dnssd-push], the subsequent event notifications are then 821 sent as DSO unidirectional messages, and this is appropriate because 822 the client initiated the message stream by virtue of its Push 823 Notification subscription, thereby indicating its support of Push 824 Notifications, and its desire to receive those notifications. 826 Similarly, after a Discovery Relay client has subscribed to receive 827 inbound mDNS (multicast DNS, [RFC6762]) traffic from a Discovery 828 Relay, the subsequent stream of received packets is then sent using 829 DSO unidirectional messages, and this is appropriate because the 830 client initiated the message stream by virtue of its Discovery Relay 831 link subscription, thereby indicating its support of Discovery Relay, 832 and its desire to receive inbound mDNS packets over that DSO session 833 [I-D.ietf-dnssd-mdns-relay]. 835 5.4.3. TLV Syntax 837 All TLVs, whether used as "Primary", "Additional", "Response 838 Primary", or "Response Additional", use the same encoding syntax. 840 Specifications that define new TLVs must specify whether the DSO-TYPE 841 can be used as the Primary TLV, used as an Additional TLV, or used in 842 either context, both in the case of requests and of responses. The 843 specification for a TLV must also state whether, when used as the 844 Primary (i.e., first) TLV in a DSO message (i.e., QR=0), that DSO 845 message is unidirectional or is a request message which requires a 846 response. If the DSO message requires a response, the specification 847 must also state which TLVs, if any, are to be included in the 848 response. The Primary TLV may or may not be contained in the 849 response, depending on what is specified for that TLV. 851 1 1 1 1 1 1 852 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 853 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 854 | DSO-TYPE | 855 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 856 | DSO-LENGTH | 857 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 858 | | 859 / DSO-DATA / 860 / / 861 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 863 DSO-TYPE: A 16-bit unsigned integer, in network (big endian) byte 864 order, giving the DSO-TYPE of the current DSO TLV per the IANA DSO 865 Type Code Registry. 867 DSO-LENGTH: A 16-bit unsigned integer, in network (big endian) byte 868 order, giving the size in bytes of the DSO-DATA. 870 DSO-DATA: Type-code specific format. The generic DSO machinery 871 treats the DSO-DATA as an opaque "blob" without attempting to 872 interpret it. Interpretation of the meaning of the DSO-DATA for a 873 particular DSO-TYPE is the responsibility of the software that 874 implements that DSO-TYPE. 876 5.4.3.1. Request TLVs 878 The first TLV in a DSO request message or DSO unidirectional message 879 is the "Primary TLV" and indicates the operation to be performed. A 880 DSO request message or DSO unidirectional message MUST contain at at 881 least one TLV-the Primary TLV. 883 Immediately following the Primary TLV, a DSO request message or DSO 884 unidirectional message MAY contain one or more "Additional TLVs", 885 which specify additional parameters relating to the operation. 887 5.4.3.2. Response TLVs 889 Depending on the operation, a DSO response message MAY contain no 890 TLVs, because it is simply a response to a previous DSO request 891 message, and the MESSAGE ID in the header is sufficient to identify 892 the DSO request in question. Or it may contain a single response 893 TLV, with the same DSO-TYPE as the Primary TLV in the request 894 message. Alternatively it may contain one or more TLVs of other 895 types, or a combination of the above, as appropriate for the 896 information that needs to be communicated. The specification for 897 each DSO TLV determines what TLVs are required in a response to a DSO 898 request message using that TLV. 900 If a DSO response is received for an operation where the 901 specification requires that the response carry a particular TLV or 902 TLVs, and the required TLV(s) are not present, then this is a fatal 903 error and the recipient of the defective response message MUST 904 forcibly abort the connection immediately. 906 5.4.3.3. Unrecognized TLVs 908 If DSO request message is received containing an unrecognized Primary 909 TLV, with a nonzero MESSAGE ID (indicating that a response is 910 expected), then the receiver MUST send an error response with 911 matching MESSAGE ID, and RCODE DSOTYPENI. The error response MUST 912 NOT contain a copy of the unrecognized Primary TLV. 914 If DSO unidirectional message is received containing an unrecognized 915 Primary TLV, with a zero MESSAGE ID (indicating that no response is 916 expected), then this is a fatal error and the recipient MUST forcibly 917 abort the connection immediately. 919 If a DSO request message or DSO unidirectional message is received 920 where the Primary TLV is recognized, containing one or more 921 unrecognized Additional TLVs, the unrecognized Additional TLVs MUST 922 be silently ignored, and the remainder of the message is interpreted 923 and handled as if the unrecognized parts were not present. 925 Similarly, if a DSO response message is received containing one or 926 more unrecognized TLVs, the unrecognized TLVs MUST be silently 927 ignored, and the remainder of the message is interpreted and handled 928 as if the unrecognized parts were not present. 930 5.4.4. EDNS(0) and TSIG 932 Since the ARCOUNT field MUST be zero, a DSO message cannot contain a 933 valid EDNS(0) option in the additional records section. If 934 functionality provided by current or future EDNS(0) options is 935 desired for DSO messages, one or more new DSO TLVs need to be defined 936 to carry the necessary information. 938 For example, the EDNS(0) Padding Option [RFC7830] used for security 939 purposes is not permitted in a DSO message, so if message padding is 940 desired for DSO messages then the Encryption Padding TLV described in 941 Section 7.3 MUST be used. 943 A DSO message can't contain a TSIG record, because a TSIG record is 944 included in the additional section of the message, which would mean 945 that ARCOUNT would be greater than zero. DSO messages are required 946 to have an ARCOUNT of zero. Therefore, if use of signatures with DSO 947 messages becomes necessary in the future, a new DSO TLV would have to 948 be defined to perform this function. 950 Note however that, while DSO *messages* cannot include EDNS(0) or 951 TSIG records, a DSO *session* is typically used to carry a whole 952 series of DNS messages of different kinds, including DSO messages, 953 and other DNS message types like Query [RFC1034] [RFC1035] and Update 954 [RFC2136], and those messages can carry EDNS(0) and TSIG records. 956 Although messages may contain other EDNS(0) options as appropriate, 957 this specification explicitly prohibits use of the edns-tcp-keepalive 958 EDNS0 Option [RFC7828] in *any* messages sent on a DSO Session 959 (because it is obsoleted by the functionality provided by the DSO 960 Keepalive operation). If any message sent on a DSO Session contains 961 an edns-tcp-keepalive EDNS0 Option this is a fatal error and the 962 recipient of the defective message MUST forcibly abort the connection 963 immediately. 965 5.5. Message Handling 967 As described above in Section 5.4.1, whether an outgoing DSO message 968 with the QR bit in the DNS header set to zero is a DSO request or DSO 969 unidirectional message is determined by the specification for the 970 Primary TLV, which in turn determines whether the MESSAGE ID field in 971 that outgoing message will be zero or nonzero. 973 Every DSO message with the QR bit in the DNS header set to zero and a 974 nonzero MESSAGE ID field is a DSO request message, and MUST elicit a 975 corresponding response, with the QR bit in the DNS header set to one 976 and the MESSAGE ID field set to the value given in the corresponding 977 DSO request message. 979 Valid DSO request messages sent by the client with a nonzero MESSAGE 980 ID field elicit a response from the server, and valid DSO request 981 messages sent by the server with a nonzero MESSAGE ID field elicit a 982 response from the client. 984 Every DSO message with both the QR bit in the DNS header and the 985 MESSAGE ID field set to zero is a DSO unidirectional message, and 986 MUST NOT elicit a response. 988 5.5.1. Delayed Acknowledgement Management 990 Generally, most good TCP implementations employ a delayed 991 acknowledgement timer to provide more efficient use of the network 992 and better performance. 994 With a bidirectional exchange over TCP, as for example with a DSO 995 request message, the operating system TCP implementation waits for 996 the application-layer client software to generate the corresponding 997 DSO response message. It can then send a single combined packet 998 containing the TCP acknowledgement, the TCP window update, and the 999 application-generated DSO response message. This is more efficient 1000 than sending three separate packets, as would occur if the TCP packet 1001 containing the DSO request were acknowledged immediately. 1003 With a DSO unidirectional message or DSO response message, there is 1004 no corresponding application-generated DSO response message, and 1005 consequently, no hint to the transport protocol about when it should 1006 send its acknowledgement and window update. 1008 Some networking APIs provide a mechanism that allows the application- 1009 layer client software to signal to the transport protocol that no 1010 response will be forthcoming (in effect it can be thought of as a 1011 zero-length "empty" write). Where available in the networking API 1012 being used, the recipient of a DSO unidirectional message or DSO 1013 response message, having parsed and interpreted the message, SHOULD 1014 then use this mechanism provided by the networking API to signal that 1015 no response for this message will be forthcoming, so that the TCP 1016 implementation can go ahead and send its acknowledgement and window 1017 update without further delay. See Section 9.5 for further discussion 1018 of why this is important. 1020 5.5.2. MESSAGE ID Namespaces 1022 The namespaces of 16-bit MESSAGE IDs are independent in each 1023 direction. This means it is *not* an error for both client and 1024 server to send DSO request messages at the same time as each other, 1025 using the same MESSAGE ID, in different directions. This 1026 simplification is necessary in order for the protocol to be 1027 implementable. It would be infeasible to require the client and 1028 server to coordinate with each other regarding allocation of new 1029 unique MESSAGE IDs. It is also not necessary to require the client 1030 and server to coordinate with each other regarding allocation of new 1031 unique MESSAGE IDs. The value of the 16-bit MESSAGE ID combined with 1032 the identity of the initiator (client or server) is sufficient to 1033 unambiguously identify the operation in question. This can be 1034 thought of as a 17-bit message identifier space, using message 1035 identifiers 0x00001-0x0FFFF for client-to-server DSO request 1036 messages, and message identifiers 0x10001-0x1FFFF for server-to- 1037 client DSO request messages. The least-significant 16 bits are 1038 stored explicitly in the MESSAGE ID field of the DSO message, and the 1039 most-significant bit is implicit from the direction of the message. 1041 As described above in Section 5.4.1, an initiator MUST NOT reuse a 1042 MESSAGE ID that it already has in use for an outstanding DSO request 1043 message (unless specified otherwise by the relevant specification for 1044 the DSO-TYPE in question). At the very least, this means that a 1045 MESSAGE ID can't be reused in a particular direction on a particular 1046 DSO Session while the initiator is waiting for a response to a 1047 previous DSO request message using that MESSAGE ID on that DSO 1048 Session (unless specified otherwise by the relevant specification for 1049 the DSO-TYPE in question), and for a long-lived operation the MESSAGE 1050 ID for the operation can't be reused while that operation remains 1051 active. 1053 If a client or server receives a response (QR=1) where the MESSAGE ID 1054 is zero, or is any other value that does not match the MESSAGE ID of 1055 any of its outstanding operations, this is a fatal error and the 1056 recipient MUST forcibly abort the connection immediately. 1058 If a responder receives a DSO request message (QR=0) where the 1059 MESSAGE ID is not zero, and the responder tracks request MESSAGE IDs, 1060 and the MESSAGE ID matches the MESSAGE ID of a DSO request message it 1061 received for which a response has not yet been sent, it MUST forcibly 1062 abort the connection immediately. This behavior is required to 1063 prevent a hypothetical attack that takes advantage of undefined 1064 behavior in this case. However, if the responder does not track 1065 MESSAGE IDs in this way, no such risk exists, so tracking MESSAGE IDs 1066 just to implement this sanity check is not required. 1068 5.5.3. Error Responses 1070 When a DSO unidirectional message type is received (MESSAGE ID field 1071 is zero), the receiver should already be expecting this DSO message 1072 type. Section 5.4.3.3 describes the handling of unknown DSO message 1073 types. Parsing errors MUST also result in the receiver forcibly 1074 aborting the connection. When a DSO unidirectional message of an 1075 unexpected type is received, the receiver SHOULD forcibly abort the 1076 connection. Whether the connection should be forcibly aborted for 1077 other internal errors processing the DSO unidirectional message is 1078 implementation dependent, according to the severity of the error. 1080 When a DSO request message is unsuccessful for some reason, the 1081 responder returns an error code to the initiator. 1083 In the case of a server returning an error code to a client in 1084 response to an unsuccessful DSO request message, the server MAY 1085 choose to end the DSO Session, or MAY choose to allow the DSO Session 1086 to remain open. For error conditions that only affect the single 1087 operation in question, the server SHOULD return an error response to 1088 the client and leave the DSO Session open for further operations. 1090 For error conditions that are likely to make all operations 1091 unsuccessful in the immediate future, the server SHOULD return an 1092 error response to the client and then end the DSO Session by sending 1093 a Retry Delay message, as described in Section 6.6.1. 1095 Upon receiving an error response from the server, a client SHOULD NOT 1096 automatically close the DSO Session. An error relating to one 1097 particular operation on a DSO Session does not necessarily imply that 1098 all other operations on that DSO Session have also failed, or that 1099 future operations will fail. The client should assume that the 1100 server will make its own decision about whether or not to end the DSO 1101 Session, based on the server's determination of whether the error 1102 condition pertains to this particular operation, or would also apply 1103 to any subsequent operations. If the server does not end the DSO 1104 Session by sending the client a Retry Delay message (Section 6.6.1) 1105 then the client SHOULD continue to use that DSO Session for 1106 subsequent operations. 1108 5.6. Responder-Initiated Operation Cancellation 1110 This document, the base specification for DNS Stateful Operations, 1111 does not itself define any long-lived operations, but it defines a 1112 framework for supporting long-lived operations, such as Push 1113 Notification subscriptions [I-D.ietf-dnssd-push] and Discovery Relay 1114 interface subscriptions [I-D.ietf-dnssd-mdns-relay]. 1116 Long-lived operations, if successful, will remain active until the 1117 initiator terminates the operation. 1119 However, it is possible that a long-lived operation may be valid at 1120 the time it was initiated, but then a later change of circumstances 1121 may render that operation invalid. For example, a long-lived client 1122 operation may pertain to a name that the server is authoritative for, 1123 but then the server configuration is changed such that it is no 1124 longer authoritative for that name. 1126 In such cases, instead of terminating the entire session it may be 1127 desirable for the responder to be able to cancel selectively only 1128 those operations that have become invalid. 1130 The responder performs this selective cancellation by sending a new 1131 response message, with the MESSAGE ID field containing the MESSAGE ID 1132 of the long-lived operation that is to be terminated (that it had 1133 previously acknowledged with a NOERROR RCODE), and the RCODE field of 1134 the new response message giving the reason for cancellation. 1136 After a response message with nonzero RCODE has been sent, that 1137 operation has been terminated from the responder's point of view, and 1138 the responder sends no more messages relating to that operation. 1140 After a response message with nonzero RCODE has been received by the 1141 initiator, that operation has been terminated from the initiator's 1142 point of view, and the cancelled operation's MESSAGE ID is now free 1143 for reuse. 1145 6. DSO Session Lifecycle and Timers 1147 6.1. DSO Session Initiation 1149 A DSO Session begins as described in Section 5.1. 1151 The client may perform as many DNS operations as it wishes using the 1152 newly created DSO Session. When the client has multiple messages to 1153 send, it SHOULD NOT wait for each response before sending the next 1154 message. 1156 The server MUST act on messages in the order they are received, but 1157 SHOULD NOT delay sending responses to those messages as they become 1158 available in order to return them in the order the requests were 1159 received. 1161 Section 6.2.1.1 of the DNS-over-TCP specification [RFC7766] specifies 1162 this in more detail. 1164 6.2. DSO Session Timeouts 1166 Two timeout values are associated with a DSO Session: the inactivity 1167 timeout, and the keepalive interval. Both values are communicated in 1168 the same TLV, the Keepalive TLV (Section 7.1). 1170 The first timeout value, the inactivity timeout, is the maximum time 1171 for which a client may speculatively keep an inactive DSO Session 1172 open in the expectation that it may have future requests to send to 1173 that server. 1175 The second timeout value, the keepalive interval, is the maximum 1176 permitted interval between messages if the client wishes to keep the 1177 DSO Session alive. 1179 The two timeout values are independent. The inactivity timeout may 1180 be lower, the same, or higher than the keepalive interval, though in 1181 most cases the inactivity timeout is expected to be shorter than the 1182 keepalive interval. 1184 A shorter inactivity timeout with a longer keepalive interval signals 1185 to the client that it should not speculatively keep an inactive DSO 1186 Session open for very long without reason, but when it does have an 1187 active reason to keep a DSO Session open, it doesn't need to be 1188 sending an aggressive level of DSO keepalive traffic to maintain that 1189 session. An example of this would be a client that has subscribed to 1190 DNS Push notifications: in this case, the client is not sending any 1191 traffic to the server, but the session is not inactive, because there 1192 is a active request to the server to receive push notifications. 1194 A longer inactivity timeout with a shorter keepalive interval signals 1195 to the client that it may speculatively keep an inactive DSO Session 1196 open for a long time, but to maintain that inactive DSO Session it 1197 should be sending a lot of DSO keepalive traffic. This configuration 1198 is expected to be less common. 1200 In the usual case where the inactivity timeout is shorter than the 1201 keepalive interval, it is only when a client has a long-lived, low- 1202 traffic, operation that the keepalive interval comes into play, to 1203 ensure that a sufficient residual amount of traffic is generated to 1204 maintain NAT and firewall state and to assure client and server that 1205 they still have connectivity to each other. 1207 On a new DSO Session, if no explicit DSO Keepalive message exchange 1208 has taken place, the default value for both timeouts is 15 seconds. 1210 For both timeouts, lower values of the timeout result in higher 1211 network traffic, and higher CPU load on the server. 1213 6.3. Inactive DSO Sessions 1215 At both servers and clients, the generation or reception of any 1216 complete DNS message (including DNS requests, responses, updates, DSO 1217 messages, etc.) resets both timers for that DSO Session, with the one 1218 exception that a DSO Keepalive message resets only the keepalive 1219 timer, not the inactivity timeout timer. 1221 In addition, for as long as the client has an outstanding operation 1222 in progress, the inactivity timer remains cleared, and an inactivity 1223 timeout cannot occur. 1225 For short-lived DNS operations like traditional queries and updates, 1226 an operation is considered in progress for the time between request 1227 and response, typically a period of a few hundred milliseconds at 1228 most. At the client, the inactivity timer is cleared upon 1229 transmission of a request and remains cleared until reception of the 1230 corresponding response. At the server, the inactivity timer is 1231 cleared upon reception of a request and remains cleared until 1232 transmission of the corresponding response. 1234 For long-lived DNS Stateful operations (such as a Push Notification 1235 subscription [I-D.ietf-dnssd-push] or a Discovery Relay interface 1236 subscription [I-D.ietf-dnssd-mdns-relay]), an operation is considered 1237 in progress for as long as the operation is active, i.e. until it is 1238 cancelled. This means that a DSO Session can exist, with active 1239 operations, with no messages flowing in either direction, for far 1240 longer than the inactivity timeout, and this is not an error. This 1241 is why there are two separate timers: the inactivity timeout, and the 1242 keepalive interval. Just because a DSO Session has no traffic for an 1243 extended period of time does not automatically make that DSO Session 1244 "inactive", if it has an active operation that is awaiting events. 1246 6.4. The Inactivity Timeout 1248 The purpose of the inactivity timeout is for the server to balance 1249 the trade off between the costs of setting up new DSO Sessions and 1250 the costs of maintaining inactive DSO Sessions. A server with 1251 abundant DSO Session capacity can offer a high inactivity timeout, to 1252 permit clients to keep a speculative DSO Session open for a long 1253 time, to save the cost of establishing a new DSO Session for future 1254 communications with that server. A server with scarce memory 1255 resources can offer a low inactivity timeout, to cause clients to 1256 promptly close DSO Sessions whenever they have no outstanding 1257 operations with that server, and then create a new DSO Session later 1258 when needed. 1260 6.4.1. Closing Inactive DSO Sessions 1262 When a connection's inactivity timeout is reached the client MUST 1263 begin closing the idle connection, but a client is not required to 1264 keep an idle connection open until the inactivity timeout is reached. 1265 A client MAY close a DSO Session at any time, at the client's 1266 discretion. If a client determines that it has no current or 1267 reasonably anticipated future need for a currently inactive DSO 1268 Session, then the client SHOULD gracefully close that connection. 1270 If, at any time during the life of the DSO Session, the inactivity 1271 timeout value (i.e., 15 seconds by default) elapses without there 1272 being any operation active on the DSO Session, the client MUST close 1273 the connection gracefully. 1275 If, at any time during the life of the DSO Session, twice the 1276 inactivity timeout value (i.e., 30 seconds by default), or five 1277 seconds, if twice the inactivity timeout value is less than five 1278 seconds, elapses without there being any operation active on the DSO 1279 Session, the server MUST consider the client delinquent, and MUST 1280 forcibly abort the DSO Session. 1282 In this context, an operation being active on a DSO Session includes 1283 a query waiting for a response, an update waiting for a response, or 1284 an active long-lived operation, but not a DSO Keepalive message 1285 exchange itself. A DSO Keepalive message exchange resets only the 1286 keepalive interval timer, not the inactivity timeout timer. 1288 If the client wishes to keep an inactive DSO Session open for longer 1289 than the default duration then it uses the DSO Keepalive message to 1290 request longer timeout values, as described in Section 7.1. 1292 6.4.2. Values for the Inactivity Timeout 1294 For the inactivity timeout value, lower values result in more 1295 frequent DSO Session teardown and re-establishment. Higher values 1296 result in lower traffic and lower CPU load on the server, but higher 1297 memory burden to maintain state for inactive DSO Sessions. 1299 A server may dictate any value it chooses for the inactivity timeout 1300 (either in a response to a client-initiated request, or in a server- 1301 initiated message) including values under one second, or even zero. 1303 An inactivity timeout of zero informs the client that it should not 1304 speculatively maintain idle connections at all, and as soon as the 1305 client has completed the operation or operations relating to this 1306 server, the client should immediately begin closing this session. 1308 A server will forcibly abort an idle client session after twice the 1309 inactivity timeout value, or five seconds, whichever is greater. In 1310 the case of a zero inactivity timeout value, this means that if a 1311 client fails to close an idle client session then the server will 1312 forcibly abort the idle session after five seconds. 1314 An inactivity timeout of 0xFFFFFFFF represents "infinity" and informs 1315 the client that it may keep an idle connection open as long as it 1316 wishes. Note that after granting an unlimited inactivity timeout in 1317 this way, at any point the server may revise that inactivity timeout 1318 by sending a new DSO Keepalive message dictating new Session Timeout 1319 values to the client. 1321 The largest *finite* inactivity timeout supported by the current 1322 Keepalive TLV is 0xFFFFFFFE (2^32-2 milliseconds, approximately 49.7 1323 days). 1325 6.5. The Keepalive Interval 1327 The purpose of the keepalive interval is to manage the generation of 1328 sufficient messages to maintain state in middleboxes (such at NAT 1329 gateways or firewalls) and for the client and server to periodically 1330 verify that they still have connectivity to each other. This allows 1331 them to clean up state when connectivity is lost, and to establish a 1332 new session if appropriate. 1334 6.5.1. Keepalive Interval Expiry 1336 If, at any time during the life of the DSO Session, the keepalive 1337 interval value (i.e., 15 seconds by default) elapses without any DNS 1338 messages being sent or received on a DSO Session, the client MUST 1339 take action to keep the DSO Session alive, by sending a DSO Keepalive 1340 message (Section 7.1). A DSO Keepalive message exchange resets only 1341 the keepalive timer, not the inactivity timer. 1343 If a client disconnects from the network abruptly, without cleanly 1344 closing its DSO Session, perhaps leaving a long-lived operation 1345 uncancelled, the server learns of this after failing to receive the 1346 required DSO keepalive traffic from that client. If, at any time 1347 during the life of the DSO Session, twice the keepalive interval 1348 value (i.e., 30 seconds by default) elapses without any DNS messages 1349 being sent or received on a DSO Session, the server SHOULD consider 1350 the client delinquent, and SHOULD forcibly abort the DSO Session. 1352 6.5.2. Values for the Keepalive Interval 1354 For the keepalive interval value, lower values result in a higher 1355 volume of DSO keepalive traffic. Higher values of the keepalive 1356 interval reduce traffic and CPU load, but have minimal effect on the 1357 memory burden at the server, because clients keep a DSO Session open 1358 for the same length of time (determined by the inactivity timeout) 1359 regardless of the level of DSO keepalive traffic required. 1361 It may be appropriate for clients and servers to select different 1362 keepalive interval values depending on the nature of the network they 1363 are on. 1365 A corporate DNS server that knows it is serving only clients on the 1366 internal network, with no intervening NAT gateways or firewalls, can 1367 impose a higher keepalive interval, because frequent DSO keepalive 1368 traffic is not required. 1370 A public DNS server that is serving primarily residential consumer 1371 clients, where it is likely there will be a NAT gateway on the path, 1372 may impose a lower keepalive interval, to generate more frequent DSO 1373 keepalive traffic. 1375 A smart client may be adaptive to its environment. A client using a 1376 private IPv4 address [RFC1918] to communicate with a DNS server at an 1377 address outside that IPv4 private address block, may conclude that 1378 there is likely to be a NAT gateway on the path, and accordingly 1379 request a lower keepalive interval. 1381 By default it is RECOMMENDED that clients request, and servers grant, 1382 a keepalive interval of 60 minutes. This keepalive interval provides 1383 for reasonably timely detection if a client abruptly disconnects 1384 without cleanly closing the session, and is sufficient to maintain 1385 state in firewalls and NAT gateways that follow the IETF recommended 1386 Best Current Practice that the "established connection idle-timeout" 1387 used by middleboxes be at least 2 hours 4 minutes [RFC5382] 1388 [RFC7857]. 1390 Note that the lower the keepalive interval value, the higher the load 1391 on client and server. For example, a (hypothetical and unrealistic) 1392 keepalive interval value of 100 ms would result in a continuous 1393 stream of ten messages per second or more, in both directions, to 1394 keep the DSO Session alive. And, in this extreme example, a single 1395 packet loss and retransmission over a long path could introduce a 1396 momentary pause in the stream of messages of over 200 ms, long enough 1397 to cause the server to overzealously abort the connection. 1399 Because of this concern, the server MUST NOT send a DSO Keepalive 1400 message (either a response to a client-initiated request, or a 1401 server-initiated message) with a keepalive interval value less than 1402 ten seconds. If a client receives a DSO Keepalive message specifying 1403 a keepalive interval value less than ten seconds this is a fatal 1404 error and the client MUST forcibly abort the connection immediately. 1406 A keepalive interval value of 0xFFFFFFFF represents "infinity" and 1407 informs the client that it should generate no DSO keepalive traffic. 1408 Note that after signaling that the client should generate no DSO 1409 keepalive traffic in this way, at any point the server may revise 1410 that DSO keepalive traffic requirement by sending a new DSO Keepalive 1411 message dictating new Session Timeout values to the client. 1413 The largest *finite* keepalive interval supported by the current 1414 Keepalive TLV is 0xFFFFFFFE (2^32-2 milliseconds, approximately 49.7 1415 days). 1417 6.6. Server-Initiated Session Termination 1419 In addition to cancelling individual long-lived operations 1420 selectively (Section 5.6) there are also occasions where a server may 1421 need to terminate one or more entire sessions. An entire session may 1422 need to be terminated if the client is defective in some way, or 1423 departs from the network without closing its session. Sessions may 1424 also need to be terminated if the server becomes overloaded, or if 1425 the server is reconfigured and lacks the ability to be selective 1426 about which operations need to be cancelled. 1428 This section discusses various reasons a session may be terminated, 1429 and the mechanisms for doing so. 1431 In normal operation, closing a DSO Session is the client's 1432 responsibility. The client makes the determination of when to close 1433 a DSO Session based on an evaluation of both its own needs, and the 1434 inactivity timeout value dictated by the server. A server only 1435 causes a DSO Session to be ended in the exceptional circumstances 1436 outlined below. Some of the exceptional situations in which a server 1437 may terminate a DSO Session include: 1439 o The server application software or underlying operating system is 1440 shutting down or restarting. 1442 o The server application software terminates unexpectedly (perhaps 1443 due to a bug that makes it crash, causing the underlying operating 1444 system to send a TCP RST). 1446 o The server is undergoing a reconfiguration or maintenance 1447 procedure, that, due to the way the server software is 1448 implemented, requires clients to be disconnected. For example, 1449 some software is implemented such that it reads a configuration 1450 file at startup, and changing the server's configuration entails 1451 modifying the configuration file and then killing and restarting 1452 the server software, which generally entails a loss of network 1453 connections. 1455 o The client fails to meets its obligation to generate the required 1456 DSO keepalive traffic, or to close an inactive session by the 1457 prescribed time (twice the time interval dictated by the server, 1458 or five seconds, whichever is greater, as described in 1459 Section 6.2). 1461 o The client sends a grossly invalid or malformed request that is 1462 indicative of a seriously defective client implementation. 1464 o The server is over capacity and needs to shed some load. 1466 6.6.1. Server-Initiated Retry Delay Message 1468 In the cases described above where a server elects to terminate a DSO 1469 Session, it could do so simply by forcibly aborting the connection. 1470 However, if it did this the likely behavior of the client might be 1471 simply to to treat this as a network failure and reconnect 1472 immediately, putting more burden on the server. 1474 Therefore, to avoid this reconnection implosion, a server SHOULD 1475 instead choose to shed client load by sending a Retry Delay message, 1476 with an appropriate RCODE value informing the client of the reason 1477 the DSO Session needs to be terminated. The format of the Retry 1478 Delay TLV, and the interpretations of the various RCODE values, are 1479 described in Section 7.2. After sending a Retry Delay message, the 1480 server MUST NOT send any further messages on that DSO Session. 1482 The server MAY randomize retry delays in situations where many retry 1483 delays are sent in quick succession, so as to avoid all the clients 1484 attempting to reconnect at once. In general, implementations should 1485 avoid using the Retry Delay message in a way that would result in 1486 many clients reconnecting at the same time, if every client attempts 1487 to reconnect at the exact time specified. 1489 Upon receipt of a Retry Delay message from the server, the client 1490 MUST make note of the reconnect delay for this server, and then 1491 immediately close the connection gracefully. 1493 After sending a Retry Delay message the server SHOULD allow the 1494 client five seconds to close the connection, and if the client has 1495 not closed the connection after five seconds then the server SHOULD 1496 forcibly abort the connection. 1498 A Retry Delay message MUST NOT be initiated by a client. If a server 1499 receives a Retry Delay message this is a fatal error and the server 1500 MUST forcibly abort the connection immediately. 1502 6.6.1.1. Outstanding Operations 1504 At the instant a server chooses to initiate a Retry Delay message 1505 there may be DNS requests already in flight from client to server on 1506 this DSO Session, which will arrive at the server after its Retry 1507 Delay message has been sent. The server MUST silently ignore such 1508 incoming requests, and MUST NOT generate any response messages for 1509 them. When the Retry Delay message from the server arrives at the 1510 client, the client will determine that any DNS requests it previously 1511 sent on this DSO Session, that have not yet received a response, now 1512 will certainly not be receiving any response. Such requests should 1513 be considered failed, and should be retried at a later time, as 1514 appropriate. 1516 In the case where some, but not all, of the existing operations on a 1517 DSO Session have become invalid (perhaps because the server has been 1518 reconfigured and is no longer authoritative for some of the names), 1519 but the server is terminating all affected DSO Sessions en masse by 1520 sending them all a Retry Delay message, the reconnect delay MAY be 1521 zero, indicating that the clients SHOULD immediately attempt to re- 1522 establish operations. 1524 It is likely that some of the attempts will be successful and some 1525 will not, depending on the nature of the reconfiguration. 1527 In the case where a server is terminating a large number of DSO 1528 Sessions at once (e.g., if the system is restarting) and the server 1529 doesn't want to be inundated with a flood of simultaneous retries, it 1530 SHOULD send different reconnect delay values to each client. These 1531 adjustments MAY be selected randomly, pseudorandomly, or 1532 deterministically (e.g., incrementing the time value by one tenth of 1533 a second for each successive client, yielding a post-restart 1534 reconnection rate of ten clients per second). 1536 6.6.2. Misbehaving Clients 1538 A server may determine that a client is not following the protocol 1539 correctly. There may be no way for the server to recover the 1540 session, in which case the server forcibly terminates the connection. 1541 Since the client doesn't know why the connection dropped, it may 1542 reconnect immediately. If the server has determined that a client is 1543 not following the protocol correctly, it may terminate the DSO 1544 session as soon as it is established, specifying a long retry-delay 1545 to prevent the client from immediately reconnecting. 1547 6.6.3. Client Reconnection 1549 After a DSO Session is ended by the server (either by sending the 1550 client a Retry Delay message, or by forcibly aborting the underlying 1551 transport connection) the client SHOULD try to reconnect, to that 1552 service instance, or to another suitable service instance, if more 1553 than one is available. If reconnecting to the same service instance, 1554 the client MUST respect the indicated delay, if available, before 1555 attempting to reconnect. Clients should not attempt to randomize the 1556 delay; the server will randomly jitter the retry delay values it 1557 sends to each client if this behavior is desired. 1559 If the service instance will only be out of service for a short 1560 maintenance period, it should use a value a little longer that the 1561 expected maintenance window. It should not default to a very large 1562 delay value, or clients may not attempt to reconnect after it resumes 1563 service. 1565 If a particular service instance does not want a client to reconnect 1566 ever (perhaps the service instance is being de-commissioned), it 1567 SHOULD set the retry delay to the maximum value 0xFFFFFFFF (2^32-1 1568 milliseconds, approximately 49.7 days). It is not possible to 1569 instruct a client to stay away for longer than 49.7 days. If, after 1570 49.7 days, the DNS or other configuration information still indicates 1571 that this is the valid service instance for a particular service, 1572 then clients MAY attempt to reconnect. In reality, if a client is 1573 rebooted or otherwise lose state, it may well attempt to reconnect 1574 before 49.7 days elapses, for as long as the DNS or other 1575 configuration information continues to indicate that this is the 1576 service instance the client should use. 1578 6.6.3.1. Reconnecting After a Forcible Abort 1580 If a connection was forcibly aborted by the client, the client SHOULD 1581 mark that service instance as not supporting DSO. The client MAY 1582 reconnect but not attempt to use DSO, or may connect to a different 1583 service instance, if applicable. 1585 6.6.3.2. Reconnecting After an Unexplained Connection Drop 1587 It is also possible for a server to forcibly terminate the 1588 connection; in this case the client doesn't know whether the 1589 termination was the result of a protocol error or a network outage. 1590 When the client notices that the connection has been dropped, it can 1591 attempt to reconnect immediately. However, if the connection is 1592 dropped again without the client being able to successfully do 1593 whatever it is trying to do, it should mark the server as not 1594 supporting DSO. 1596 6.6.3.3. Probing for Working DSO Support 1598 Once a server has been marked by the client as not supporting DSO, 1599 the client SHOULD NOT attempt DSO operations on that server until 1600 some time has elapsed. A reasonable minimum would be an hour. Since 1601 forcibly aborted connections are the result of a software failure, 1602 it's not likely that the problem will be solved in the first hour 1603 after it's first encountered. However, by restricting the retry 1604 interval to an hour, the client will be able to notice when the 1605 problem has been fixed without placing an undue burden on the server. 1607 7. Base TLVs for DNS Stateful Operations 1609 This section describes the three base TLVs for DNS Stateful 1610 Operations: Keepalive, Retry Delay, and Encryption Padding. 1612 7.1. Keepalive TLV 1614 The Keepalive TLV (DSO-TYPE=1) performs two functions. Primarily it 1615 establishes the values for the Session Timeouts. Incidentally, it 1616 also resets the keepalive timer for the DSO Session, meaning that it 1617 can be used as a kind of "no-op" message for the purpose of keeping a 1618 session alive. The client will request the desired session timeout 1619 values and the server will acknowledge with the response values that 1620 it requires the client to use. 1622 DSO messages with the Keepalive TLV as the primary TLV may appear in 1623 early data. 1625 The DSO-DATA for the Keepalive TLV is as follows: 1627 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 1628 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1629 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1630 | INACTIVITY TIMEOUT (32 bits) | 1631 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1632 | KEEPALIVE INTERVAL (32 bits) | 1633 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1635 INACTIVITY TIMEOUT: The inactivity timeout for the current DSO 1636 Session, specified as a 32-bit unsigned integer, in network (big 1637 endian) byte order, in units of milliseconds. This is the timeout 1638 at which the client MUST begin closing an inactive DSO Session. 1639 The inactivity timeout can be any value of the server's choosing. 1640 If the client does not gracefully close an inactive DSO Session, 1641 then after twice this interval, or five seconds, whichever is 1642 greater, the server will forcibly abort the connection. 1644 KEEPALIVE INTERVAL: The keepalive interval for the current DSO 1645 Session, specified as a 32-bit unsigned integer, in network (big 1646 endian) byte order, in units of milliseconds. This is the 1647 interval at which a client MUST generate DSO keepalive traffic to 1648 maintain connection state. The keepalive interval MUST NOT be 1649 less than ten seconds. If the client does not generate the 1650 mandated DSO keepalive traffic, then after twice this interval the 1651 server will forcibly abort the connection. Since the minimum 1652 allowed keepalive interval is ten seconds, the minimum time at 1653 which a server will forcibly disconnect a client for failing to 1654 generate the mandated DSO keepalive traffic is twenty seconds. 1656 The transmission or reception of DSO Keepalive messages (i.e., 1657 messages where the Keepalive TLV is the first TLV) reset only the 1658 keepalive timer, not the inactivity timer. The reason for this is 1659 that periodic DSO Keepalive messages are sent for the sole purpose of 1660 keeping a DSO Session alive, when that DSO Session has current or 1661 recent non-maintenance activity that warrants keeping that DSO 1662 Session alive. Sending DSO keepalive traffic itself is not 1663 considered a client activity; it is considered a maintenance activity 1664 that is performed in service of other client activities. If DSO 1665 keepalive traffic itself were to reset the inactivity timer, then 1666 that would create a circular livelock where keepalive traffic would 1667 be sent indefinitely to keep a DSO Session alive, where the only 1668 activity on that DSO Session would be the keepalive traffic keeping 1669 the DSO Session alive so that further keepalive traffic can be sent. 1670 For a DSO Session to be considered active, it must be carrying 1671 something more than just keepalive traffic. This is why merely 1672 sending or receiving a DSO Keepalive message does not reset the 1673 inactivity timer. 1675 When sent by a client, the DSO Keepalive request message MUST be sent 1676 as an DSO request message, with a nonzero MESSAGE ID. If a server 1677 receives a DSO Keepalive message with a zero MESSAGE ID then this is 1678 a fatal error and the server MUST forcibly abort the connection 1679 immediately. The DSO Keepalive request message resets a DSO 1680 Session's keepalive timer, and at the same time communicates to the 1681 server the client's requested Session Timeout values. In a server 1682 response to a client-initiated DSO Keepalive request message, the 1683 Session Timeouts contain the server's chosen values from this point 1684 forward in the DSO Session, which the client MUST respect. This is 1685 modeled after the DHCP protocol, where the client requests a certain 1686 lease lifetime using DHCP option 51 [RFC2132], but the server is the 1687 ultimate authority for deciding what lease lifetime is actually 1688 granted. 1690 When a client is sending its second and subsequent DSO Keepalive 1691 request messages to the server, the client SHOULD continue to request 1692 its preferred values each time. This allows flexibility, so that if 1693 conditions change during the lifetime of a DSO Session, the server 1694 can adapt its responses to better fit the client's needs. 1696 Once a DSO Session is in progress (Section 5.1) a DSO Keepalive 1697 message MAY be initiated by a server. When sent by a server, the DSO 1698 Keepalive message MUST be sent as a DSO unidirectional message, with 1699 the MESSAGE ID set to zero. The client MUST NOT generate a response 1700 to a server-initiated DSO Keepalive message. If a client receives a 1701 DSO Keepalive request message with a nonzero MESSAGE ID then this is 1702 a fatal error and the client MUST forcibly abort the connection 1703 immediately. The DSO Keepalive unidirectional message from the 1704 server resets a DSO Session's keepalive timer, and at the same time 1705 unilaterally informs the client of the new Session Timeout values to 1706 use from this point forward in this DSO Session. No client DSO 1707 response to this unilateral declaration is required or allowed. 1709 In DSO Keepalive response messages, the Keepalive TLV is REQUIRED and 1710 is used only as a Response Primary TLV sent as a reply to a DSO 1711 Keepalive request message from the client. A Keepalive TLV MUST NOT 1712 be added to other responses as a Response Additional TLV. If the 1713 server wishes to update a client's Session Timeout values other than 1714 in response to a DSO Keepalive request message from the client, then 1715 it does so by sending an DSO Keepalive unidirectional message of its 1716 own, as described above. 1718 It is not required that the Keepalive TLV be used in every DSO 1719 Session. While many DNS Stateful operations will be used in 1720 conjunction with a long-lived session state, not all DNS Stateful 1721 operations require long-lived session state, and in some cases the 1722 default 15-second value for both the inactivity timeout and keepalive 1723 interval may be perfectly appropriate. However, note that for 1724 clients that implement only the DSO-TYPEs defined in this document, a 1725 DSO Keepalive request message is the only way for a client to 1726 initiate a DSO Session. 1728 7.1.1. Client handling of received Session Timeout values 1730 When a client receives a response to its client-initiated DSO 1731 Keepalive message, or receives a server-initiated DSO Keepalive 1732 message, the client has then received Session Timeout values dictated 1733 by the server. The two timeout values contained in the Keepalive TLV 1734 from the server may each be higher, lower, or the same as the 1735 respective Session Timeout values the client previously had for this 1736 DSO Session. 1738 In the case of the keepalive timer, the handling of the received 1739 value is straightforward. The act of receiving the message 1740 containing the DSO Keepalive TLV itself resets the keepalive timer, 1741 and updates the keepalive interval for the DSO Session. The new 1742 keepalive interval indicates the maximum time that may elapse before 1743 another message must be sent or received on this DSO Session, if the 1744 DSO Session is to remain alive. 1746 In the case of the inactivity timeout, the handling of the received 1747 value is a little more subtle, though the meaning of the inactivity 1748 timeout remains as specified -- it still indicates the maximum 1749 permissible time allowed without useful activity on a DSO Session. 1750 The act of receiving the message containing the Keepalive TLV does 1751 not itself reset the inactivity timer. The time elapsed since the 1752 last useful activity on this DSO Session is unaffected by exchange of 1753 DSO Keepalive messages. The new inactivity timeout value in the 1754 Keepalive TLV in the received message does update the timeout 1755 associated with the running inactivity timer; that becomes the new 1756 maximum permissible time without activity on a DSO Session. 1758 o If the current inactivity timer value is less than the new 1759 inactivity timeout, then the DSO Session may remain open for now. 1760 When the inactivity timer value reaches the new inactivity 1761 timeout, the client MUST then begin closing the DSO Session, as 1762 described above. 1764 o If the current inactivity timer value is equal to the new 1765 inactivity timeout, then this DSO Session has been inactive for 1766 exactly as long as the server will permit, and now the client MUST 1767 immediately begin closing this DSO Session. 1769 o If the current inactivity timer value is already greater than the 1770 new inactivity timeout, then this DSO Session has already been 1771 inactive for longer than the server permits, and the client MUST 1772 immediately begin closing this DSO Session. 1774 o If the current inactivity timer value is already more than twice 1775 the new inactivity timeout, then the client is immediately 1776 considered delinquent (this DSO Session is immediately eligible to 1777 be forcibly terminated by the server) and the client MUST 1778 immediately begin closing this DSO Session. However if a server 1779 abruptly reduces the inactivity timeout in this way, then, to give 1780 the client time to close the connection gracefully before the 1781 server resorts to forcibly aborting it, the server SHOULD give the 1782 client an additional grace period of one quarter of the new 1783 inactivity timeout, or five seconds, whichever is greater. 1785 7.1.2. Relationship to edns-tcp-keepalive EDNS0 Option 1787 The inactivity timeout value in the Keepalive TLV (DSO-TYPE=1) has 1788 similar intent to the edns-tcp-keepalive EDNS0 Option [RFC7828]. A 1789 client/server pair that supports DSO MUST NOT use the edns-tcp- 1790 keepalive EDNS0 Option within any message after a DSO Session has 1791 been established. A client that has sent a DSO message to establish 1792 a session MUST NOT send an edns-tcp-keepalive EDNS0 Option from this 1793 point on. Once a DSO Session has been established, if either client 1794 or server receives a DNS message over the DSO Session that contains 1795 an edns-tcp-keepalive EDNS0 Option, this is a fatal error and the 1796 receiver of the edns-tcp-keepalive EDNS0 Option MUST forcibly abort 1797 the connection immediately. 1799 7.2. Retry Delay TLV 1801 The Retry Delay TLV (DSO-TYPE=2) can be used as a Primary TLV 1802 (unidirectional) in a server-to-client message, or as a Response 1803 Additional TLV in either direction. DSO messages with a Relay Delay 1804 TLV as their primary TLV are not permitted in early data. 1806 The DSO-DATA for the Retry Delay TLV is as follows: 1808 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 1809 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 1810 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1811 | RETRY DELAY (32 bits) | 1812 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1814 RETRY DELAY: A time value, specified as a 32-bit unsigned integer, 1815 in network (big endian) byte order, in units of milliseconds, 1816 within which the initiator MUST NOT retry this operation, or retry 1817 connecting to this server. Recommendations for the RETRY DELAY 1818 value are given in Section 6.6.1. 1820 7.2.1. Retry Delay TLV used as a Primary TLV 1822 When sent from server to client, the Retry Delay TLV is used as the 1823 Primary TLV in a DSO unidirectional message. It is used by a server 1824 to instruct a client to close the DSO Session and underlying 1825 connection, and not to reconnect for the indicated time interval. 1827 In this case it applies to the DSO Session as a whole, and the client 1828 MUST begin closing the DSO Session, as described in Section 6.6.1. 1829 The RCODE in the message header SHOULD indicate the principal reason 1830 for the termination: 1832 o NOERROR indicates a routine shutdown or restart. 1834 o FORMERR indicates that a client request was too badly malformed 1835 for the session to continue. 1837 o SERVFAIL indicates that the server is overloaded due to resource 1838 exhaustion and needs to shed load. 1840 o REFUSED indicates that the server has been reconfigured, and at 1841 this time it is now unable to perform one or more of the long- 1842 lived client operations that were previously being performed on 1843 this DSO Session. 1845 o NOTAUTH indicates that the server has been reconfigured and at 1846 this time it is now unable to perform one or more of the long- 1847 lived client operations that were previously being performed on 1848 this DSO Session because it does not have authority over the names 1849 in question (for example, a DNS Push Notification server could be 1850 reconfigured such that is is no longer accepting DNS Push 1851 Notification requests for one or more of the currently subscribed 1852 names). 1854 This document specifies only these RCODE values for the Retry Delay 1855 message. Servers sending Retry Delay messages SHOULD use one of 1856 these values. However, future circumstances may create situations 1857 where other RCODE values are appropriate in Retry Delay messages, so 1858 clients MUST be prepared to accept Retry Delay messages with any 1859 RCODE value. 1861 In some cases, when a server sends a Retry Delay message to a client, 1862 there may be more than one reason for the server wanting to end the 1863 session. Possibly the configuration could have been changed such 1864 that some long-lived client operations can no longer be continued due 1865 to policy (REFUSED), and other long-lived client operations can no 1866 longer be performed due to the server no longer being authoritative 1867 for those names (NOTAUTH). In such cases the server MAY use any of 1868 the applicable RCODE values, or RCODE=NOERROR (routine shutdown or 1869 restart). 1871 Note that the selection of RCODE value in a Retry Delay message is 1872 not critical, since the RCODE value is generally used only for 1873 information purposes, such as writing to a log file for future human 1874 analysis regarding the nature of the disconnection. Generally 1875 clients do not modify their behavior depending on the RCODE value. 1876 The RETRY DELAY in the message tells the client how long it should 1877 wait before attempting a new connection to this service instance. 1879 For clients that do in some way modify their behavior depending on 1880 the RCODE value, they should treat unknown RCODE values the same as 1881 RCODE=NOERROR (routine shutdown or restart). 1883 A Retry Delay message from server to client is a DSO unidirectional 1884 message; the MESSAGE ID MUST be set to zero in the outgoing message 1885 and the client MUST NOT send a response. 1887 A client MUST NOT send a Retry Delay DSO message to a server. If a 1888 server receives a DSO message where the Primary TLV is the Retry 1889 Delay TLV, this is a fatal error and the server MUST forcibly abort 1890 the connection immediately. 1892 7.2.2. Retry Delay TLV used as a Response Additional TLV 1894 In the case of a DSO request message that results in a nonzero RCODE 1895 value, the responder MAY append a Retry Delay TLV to the response, 1896 indicating the time interval during which the initiator SHOULD NOT 1897 attempt this operation again. 1899 The indicated time interval during which the initiator SHOULD NOT 1900 retry applies only to the failed operation, not to the DSO Session as 1901 a whole. 1903 7.3. Encryption Padding TLV 1905 The Encryption Padding TLV (DSO-TYPE=3) can only be used as an 1906 Additional or Response Additional TLV. It is only applicable when 1907 the DSO Transport layer uses encryption such as TLS. 1909 The DSO-DATA for the Padding TLV is optional and is a variable length 1910 field containing non-specified values. A DSO-LENGTH of 0 essentially 1911 provides for 4 bytes of padding (the minimum amount). 1913 1 1 1 1 1 1 1914 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 1915 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 1916 / / 1917 / PADDING -- VARIABLE NUMBER OF BYTES / 1918 / / 1919 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 1921 As specified for the EDNS(0) Padding Option [RFC7830] the PADDING 1922 bytes SHOULD be set to 0x00. Other values MAY be used, for example, 1923 in cases where there is a concern that the padded message could be 1924 subject to compression before encryption. PADDING bytes of any value 1925 MUST be accepted in the messages received. 1927 The Encryption Padding TLV may be included in either a DSO request 1928 message, response, or both. As specified for the EDNS(0) Padding 1929 Option [RFC7830] if a DSO request message is received with an 1930 Encryption Padding TLV, then the DSO response MUST also include an 1931 Encryption Padding TLV. 1933 The length of padding is intentionally not specified in this document 1934 and is a function of current best practices with respect to the type 1935 and length of data in the preceding TLVs 1936 [I-D.ietf-dprive-padding-policy]. 1938 8. Summary Highlights 1940 This section summarizes some noteworthy highlights about various 1941 aspects of the DSO protocol. 1943 8.1. QR bit and MESSAGE ID 1945 In DSO Request Messages the QR bit is 0 and the MESSAGE ID is 1946 nonzero. 1948 In DSO Response Messages the QR bit is 1 and the MESSAGE ID is 1949 nonzero. 1951 In DSO Unidirectional Messages the QR bit is 0 and the MESSAGE ID is 1952 zero. 1954 The table below illustrates which combinations are legal and how they 1955 are interpreted: 1957 +------------------------------+------------------------+ 1958 | MESSAGE ID zero | MESSAGE ID nonzero | 1959 +--------+------------------------------+------------------------+ 1960 | QR=0 | DSO unidirectional Message | DSO Request Message | 1961 +--------+------------------------------+------------------------+ 1962 | QR=1 | Invalid - Fatal Error | DSO Response Message | 1963 +--------+------------------------------+------------------------+ 1965 8.2. TLV Usage 1967 The table below indicates, for each of the three TLVs defined in this 1968 document, whether they are valid in each of ten different contexts. 1970 The first five contexts are DSO requests or DSO unidirectional 1971 messages from client to server, and the corresponding responses from 1972 server back to client: 1974 o C-P - Primary TLV, sent in DSO Request message, from client to 1975 server, with nonzero MESSAGE ID indicating that this request MUST 1976 generate response message. 1978 o C-U - Primary TLV, sent in DSO Unidirectional message, from client 1979 to server, with zero MESSAGE ID indicating that this request MUST 1980 NOT generate response message. 1982 o C-A - Additional TLV, optionally added to a DSO request message or 1983 DSO unidirectional message from client to server. 1985 o CRP - Response Primary TLV, included in response message sent back 1986 to the client (in response to a client "C-P" request with nonzero 1987 MESSAGE ID indicating that a response is required) where the DSO- 1988 TYPE of the Response TLV matches the DSO-TYPE of the Primary TLV 1989 in the request. 1991 o CRA - Response Additional TLV, included in response message sent 1992 back to the client (in response to a client "C-P" request with 1993 nonzero MESSAGE ID indicating that a response is required) where 1994 the DSO-TYPE of the Response TLV does not match the DSO-TYPE of 1995 the Primary TLV in the request. 1997 The second five contexts are their counterparts in the opposite 1998 direction: DSO requests or DSO unidirectional messages from server to 1999 client, and the corresponding responses from client back to server. 2001 o S-P - Primary TLV, sent in DSO Request message, from server to 2002 client, with nonzero MESSAGE ID indicating that this request MUST 2003 generate response message. 2005 o S-U - Primary TLV, sent in DSO Unidirectional message, from server 2006 to client, with zero MESSAGE ID indicating that this request MUST 2007 NOT generate response message. 2009 o S-A - Additional TLV, optionally added to a DSO request message or 2010 DSO unidirectional message from server to client. 2012 o SRP - Response Primary TLV, included in response message sent back 2013 to the server (in response to a server "S-P" request with nonzero 2014 MESSAGE ID indicating that a response is required) where the DSO- 2015 TYPE of the Response TLV matches the DSO-TYPE of the Primary TLV 2016 in the request. 2018 o SRA - Response Additional TLV, included in response message sent 2019 back to the server (in response to a server "S-P" request with 2020 nonzero MESSAGE ID indicating that a response is required) where 2021 the DSO-TYPE of the Response TLV does not match the DSO-TYPE of 2022 the Primary TLV in the request. 2024 +-------------------------+-------------------------+ 2025 | C-P C-U C-A CRP CRA | S-P S-U S-A SRP SRA | 2026 +------------+-------------------------+-------------------------+ 2027 | KeepAlive | X X | X | 2028 +------------+-------------------------+-------------------------+ 2029 | RetryDelay | X | X X | 2030 +------------+-------------------------+-------------------------+ 2031 | Padding | X X | X X | 2032 +------------+-------------------------+-------------------------+ 2034 Note that some of the columns in this table are currently empty. The 2035 table provides a template for future TLV definitions to follow. It 2036 is recommended that definitions of future TLVs include a similar 2037 table summarizing the contexts where the new TLV is valid. 2039 9. Additional Considerations 2041 9.1. Service Instances 2043 We use the term service instance to refer to software running on a 2044 host which can receive connections on some set of IP address and port 2045 tuples. What makes the software an instance is that regardless of 2046 which of these tuples the client uses to connect to it, the client is 2047 connected to the same software, running on the same node (but see 2048 Section 9.2), and will receive the same answers and the same keying 2049 information. 2051 Service instances are identified from the perspective of the client. 2052 If the client is configured with IP addresses and port number tuples, 2053 it has no way to tell if the service offered at one tuple is the same 2054 server that is listening on a different tuple. So in this case, the 2055 client treats each such tuple as if it references a separate service 2056 instance. 2058 In some cases a client is configured with a hostname and a port 2059 number (either implicitly, where the port number is omitted and 2060 assumed, or explicitly, as in the case of DNS SRV records). In these 2061 cases, the (hostname, port) tuple uniquely identifies the service 2062 instance (hostname comparisons are case-insensitive [RFC1034]. 2064 It is possible that two hostnames might point to some common IP 2065 addresses; this is a configuration error which the client is not 2066 obliged to detect. The effect of this could be that after being told 2067 to disconnect, the client might reconnect to the same server because 2068 it is represented as a different service instance. 2070 Implementations SHOULD NOT resolve hostnames and then perform 2071 matching of IP address(es) in order to evaluate whether two entities 2072 should be determined to be the "same service instance". 2074 9.2. Anycast Considerations 2076 When an anycast service is configured on a particular IP address and 2077 port, it must be the case that although there is more than one 2078 physical server responding on that IP address, each such server can 2079 be treated as equivalent. What we mean by "equivalent" here is that 2080 both servers can provide the same service and, where appropriate, the 2081 same authentication information, such as PKI certificates, when 2082 establishing connections. 2084 If a change in network topology causes packets in a particular TCP 2085 connection to be sent to an anycast server instance that does not 2086 know about the connection, the new server will automatically 2087 terminate the connection with a TCP reset, since it will have no 2088 record of the connection, and then the client can reconnect or stop 2089 using the connection, as appropriate. 2091 If after the connection is re-established, the client's assumption 2092 that it is connected to the same service is violated in some way, 2093 that would be considered to be incorrect behavior in this context. 2094 It is however out of the possible scope for this specification to 2095 make specific recommendations in this regard; that would be up to 2096 follow-on documents that describe specific uses of DNS stateful 2097 operations. 2099 9.3. Connection Sharing 2101 As previously specified for DNS over TCP [RFC7766]: 2103 To mitigate the risk of unintentional server overload, DNS 2104 clients MUST take care to minimize the number of concurrent 2105 TCP connections made to any individual server. It is RECOMMENDED 2106 that for any given client/server interaction there SHOULD be 2107 no more than one connection for regular queries, one for zone 2108 transfers, and one for each protocol that is being used on top 2109 of TCP (for example, if the resolver was using TLS). However, 2110 it is noted that certain primary/secondary configurations 2111 with many busy zones might need to use more than one TCP 2112 connection for zone transfers for operational reasons (for 2113 example, to support concurrent transfers of multiple zones). 2115 A single server may support multiple services, including DNS Updates 2116 [RFC2136], DNS Push Notifications [I-D.ietf-dnssd-push], and other 2117 services, for one or more DNS zones. When a client discovers that 2118 the target server for several different operations is the same 2119 service instance (see Section 9.1), the client SHOULD use a single 2120 shared DSO Session for all those operations. 2122 This requirement has two benefits. First, it reduces unnecessary 2123 connection load on the DNS server. Second, it avoids paying the TCP 2124 slow start penalty when making subsequent connections to the same 2125 server. 2127 However, server implementers and operators should be aware that 2128 connection sharing may not be possible in all cases. A single host 2129 device may be home to multiple independent client software instances 2130 that don't coordinate with each other. Similarly, multiple 2131 independent client devices behind the same NAT gateway will also 2132 typically appear to the DNS server as different source ports on the 2133 same client IP address. Because of these constraints, a DNS server 2134 MUST be prepared to accept multiple connections from different source 2135 ports on the same client IP address. 2137 9.4. Operational Considerations for Middlebox 2139 Where an application-layer middlebox (e.g., a DNS proxy, forwarder, 2140 or session multiplexer) is in the path, care must be taken to avoid a 2141 configuration in which DSO traffic is mis-handled. The simplest way 2142 to avoid such problems is to avoid using middleboxes. When this is 2143 not possible, middleboxes should be evaluated to make sure that they 2144 behave correctly. 2146 Correct behavior for middleboxes consists of one of: 2148 o The middlebox does not forward DSO messages, and responds to DSO 2149 messages with a response code other than NOERROR or DSOTYPENI. 2151 o The middlebox acts as a DSO server and follows this specification 2152 in establishing connections. 2154 o There is a 1:1 correspondence between incoming and outgoing 2155 connections, such that when a connection is established to the 2156 middlebox, it is guaranteed that exactly one corresponding 2157 connection will be established from the middlebox to some DNS 2158 resolver, and all incoming messages will be forwarded without 2159 modification or reordering. An example of this would be a NAT 2160 forwarder or TCP connection optimizer (e.g. for a high-latency 2161 connection such as a geosynchronous satellite link). 2163 Middleboxes that do not meet one of the above criteria are very 2164 likely to fail in unexpected and difficult-to-diagnose ways. For 2165 example, a DNS load balancer might unbundle DNS messages from the 2166 incoming TCP stream and forward each message from the stream to a 2167 different DNS server. If such a load balancer is in use, and the DNS 2168 servers it points implement DSO and are configured to enable DSO, DSO 2169 session establishment will succeed, but no coherent session will 2170 exist between the client and the server. If such a load balancer is 2171 pointed at a DNS server that does not implement DSO or is configured 2172 not to allow DSO, no such problem will exist, but such a 2173 configuration risks unexpected failure if new server software is 2174 installed which does implement DSO. 2176 It is of course possible to implement a middlebox that properly 2177 supports DSO. It is even possible to implement one that implements 2178 DSO with long-lived operations. This can be done either by 2179 maintaining a 1:1 correspondence between incoming and outgoing 2180 connections, as mentioned above, or by terminating incoming sessions 2181 at the middlebox, but maintaining state in the middlebox about any 2182 long-lived that are requested. Specifying this in detail is beyond 2183 the scope of this document. 2185 9.5. TCP Delayed Acknowledgement Considerations 2187 Most modern implementations of the Transmission Control Protocol 2188 (TCP) include a feature called "Delayed Acknowledgement" [RFC1122]. 2190 Without this feature, TCP can be very wasteful on the network. For 2191 illustration, consider a simple example like remote login, using a 2192 very simple TCP implementation that lacks delayed acks. When the 2193 user types a keystroke, a data packet is sent. When the data packet 2194 arrives at the server, the simple TCP implementation sends an 2195 immediate acknowledgement. Mere milliseconds later, the server 2196 process reads the one byte of keystroke data, and consequently the 2197 simple TCP implementation sends an immediate window update. Mere 2198 milliseconds later, the server process generates the character echo, 2199 and sends this data back in reply. The simple TCP implementation 2200 then sends this data packet immediately too. In this case, this 2201 simple TCP implementation sends a burst of three packets almost 2202 instantaneously (ack, window update, data). 2204 Clearly it would be more efficient if the TCP implementation were to 2205 combine the three separate packets into one, and this is what the 2206 delayed ack feature enables. 2208 With delayed ack, the TCP implementation waits after receiving a data 2209 packet, typically for 200 ms, and then send its ack if (a) more data 2210 packet(s) arrive (b) the receiving process generates some reply data, 2211 or (c) 200 ms elapses without either of the above occurring. 2213 With delayed ack, remote login becomes much more efficient, 2214 generating just one packet instead of three for each character echo. 2216 The logic of delayed ack is that the 200 ms delay cannot do any 2217 significant harm. If something at the other end were waiting for 2218 something, then the receiving process should generate the reply that 2219 the thing at the end is waiting for, and TCP will then immediately 2220 send that reply (and the ack and window update). And if the 2221 receiving process does not in fact generate any reply for this 2222 particular message, then by definition the thing at the other end 2223 cannot be waiting for anything, so the 200 ms delay is harmless. 2225 This assumption may be true, unless the sender is using Nagle's 2226 algorithm, a similar efficiency feature, created to protect the 2227 network from poorly written client software that performs many rapid 2228 small writes in succession. Nagle's algorithm allows these small 2229 writes to be combined into larger, less wasteful packets. 2231 Unfortunately, Nagle's algorithm and delayed ack, two valuable 2232 efficiency features, can interact badly with each other when used 2233 together [NagleDA]. 2235 DSO request messages elicit responses; DSO unidirectional messages 2236 and DSO response messages do not. 2238 For DSO request messages, which do elicit responses, Nagle's 2239 algorithm and delayed ack work as intended. 2241 For DSO messages that do not elicit responses, the delayed ack 2242 mechanism causes the ack to be delayed by 200 ms. The 200 ms delay 2243 on the ack can in turn cause Nagle's algorithm to prevent the sender 2244 from sending any more data for 200 ms until the awaited ack arrives. 2245 On an enterprise GigE backbone with sub-millisecond round-trip times, 2246 a 200 ms delay is enormous in comparison. 2248 When this issues is raised, there are two solutions that are often 2249 offered, neither of them ideal: 2251 1. Disable delayed ack. For DSO messages that elicit no response, 2252 removing delayed ack avoids the needless 200 ms delay, and sends 2253 back an immediate ack, which tells Nagle's algorithm that it 2254 should immediately grant the sender permission to send its next 2255 packet. Unfortunately, for DSO messages that *do* elicit a 2256 response, removing delayed ack removes the efficiency gains of 2257 combining acks with data, and the responder will now send two or 2258 three packets instead of one. 2260 2. Disable Nagle's algorithm. When acks are delayed by the delayed 2261 ack algorithm, removing Nagle's algorithm prevents the sender 2262 from being blocked from sending its next small packet 2263 immediately. Unfortunately, on a network with a higher round- 2264 trip time, removing Nagle's algorithm removes the efficiency 2265 gains of combining multiple small packets into fewer larger ones, 2266 with the goal of limiting the number of small packets in flight 2267 at any one time. 2269 For DSO messages that elicit a response, delayed ack and Nagle's 2270 algorithm do the right thing. 2272 The problem here is that with DSO messages that elicit no response, 2273 the TCP implementation is stuck waiting, unsure if a response is 2274 about to be generated, or whether the TCP implementation should go 2275 ahead and send an ack and window update. 2277 The solution is networking APIs that allow the receiver to inform the 2278 TCP implementation that a received message has been read, processed, 2279 and no response for this message will be generated. TCP can then 2280 stop waiting for a response that will never come, and immediately go 2281 ahead and send an ack and window update. 2283 For implementations of DSO, disabling delayed ack is NOT RECOMMENDED, 2284 because of the harm this can do to the network. 2286 For implementations of DSO, disabling Nagle's algorithm is NOT 2287 RECOMMENDED, because of the harm this can do to the network. 2289 At the time that this document is being prepared for publication, it 2290 is known that at least one TCP implementation provides the ability 2291 for the recipient of a TCP message to signal that it is not going to 2292 send a response, and hence the delayed ack mechanism can stop 2293 waiting. Implementations on operating systems where this feature is 2294 available SHOULD make use of it. 2296 10. IANA Considerations 2298 10.1. DSO OPCODE Registration 2300 The IANA is requested to record the value [TBA1] (tentatively 6) for 2301 the DSO OPCODE in the DNS OPCODE Registry. DSO stands for DNS 2302 Stateful Operations. 2304 10.2. DSO RCODE Registration 2306 The IANA is requested to record the value [TBA2] (tentatively 11) for 2307 the DSOTYPENI error code in the DNS RCODE Registry. The DSOTYPENI 2308 error code ("DSO-TYPE Not Implemented") indicates that the receiver 2309 does implement DNS Stateful Operations, but does not implement the 2310 specific DSO-TYPE of the primary TLV in the DSO request message. 2312 10.3. DSO Type Code Registry 2314 The IANA is requested to create the 16-bit DSO Type Code Registry, 2315 with initial (hexadecimal) values as shown below: 2317 +-----------+------------------------+-------+----------+-----------+ 2318 | Type | Name | Early | Status | Reference | 2319 | | | Data | | | 2320 +-----------+------------------------+-------+----------+-----------+ 2321 | 0000 | Reserved | NO | Standard | RFC-TBD | 2322 | | | | | | 2323 | 0001 | KeepAlive | OK | Standard | RFC-TBD | 2324 | | | | | | 2325 | 0002 | RetryDelay | NO | Standard | RFC-TBD | 2326 | | | | | | 2327 | 0003 | EncryptionPadding | NA | Standard | RFC-TBD | 2328 | | | | | | 2329 | 0004-003F | Unassigned, reserved | NO | | | 2330 | | for DSO session- | | | | 2331 | | management TLVs | | | | 2332 | | | | | | 2333 | 0040-F7FF | Unassigned | NO | | | 2334 | | | | | | 2335 | F800-FBFF | Experimental/local use | NO | | | 2336 | | | | | | 2337 | FC00-FFFF | Reserved for future | NO | | | 2338 | | expansion | | | | 2339 +-----------+------------------------+-------+----------+-----------+ 2341 The meanings of the fields are as follows: 2343 Type: the 16-bit DSO type code 2344 Name: the human-readable name of the TLV 2346 Early Data: If OK, this TLV may be sent as early data in a TLS 0-RTT 2347 ([RFC8446] Section 2.3) initial handshake. If NA, the TLV may 2348 appear as a secondary TLV in a DSO message that is send as early 2349 data. 2351 Status: IETF Document status (or "External" if not documented in an 2352 IETF document. 2354 Reference: A stable reference to the document in which this TLV is 2355 defined. 2357 DSO Type Code zero is reserved and is not currently intended for 2358 allocation. 2360 Registrations of new DSO Type Codes in the "Reserved for DSO session- 2361 management" range 0004-003F and the "Reserved for future expansion" 2362 range FC00-FFFF require publication of an IETF Standards Action 2363 document [RFC8126]. 2365 Any document defining a new TLV which lists a value of "OK" in the 2366 0-RTT column must include a threat analysis for the use of the TLV in 2367 the case of TLS 0-RTT. See Section 11.1 for details. 2369 Requests to register additional new DSO Type Codes in the 2370 "Unassigned" range 0040-F7FF are to be recorded by IANA after Expert 2371 Review [RFC8126]. The expert review should validate that the 2372 requested type code is specified in a way that conforms to this 2373 specification, and that the intended use for the code would not be 2374 addressed with an experimental/local assignment. 2376 DSO Type Codes in the "experimental/local" range F800-FBFF may be 2377 used as Experimental Use or Private Use values [RFC8126] and may be 2378 used freely for development purposes, or for other purposes within a 2379 single site. No attempt is made to prevent multiple sites from using 2380 the same value in different (and incompatible) ways. There is no 2381 need for IANA to review such assignments (since IANA does not record 2382 them) and assignments are not generally useful for broad 2383 interoperability. It is the responsibility of the sites making use 2384 of "experimental/local" values to ensure that no conflicts occur 2385 within the intended scope of use. 2387 11. Security Considerations 2389 If this mechanism is to be used with DNS over TLS, then these 2390 messages are subject to the same constraints as any other DNS-over- 2391 TLS messages and MUST NOT be sent in the clear before the TLS session 2392 is established. 2394 The data field of the "Encryption Padding" TLV could be used as a 2395 covert channel. 2397 When designing new DSO TLVs, the potential for data in the TLV to be 2398 used as a tracking identifier should be taken into consideration, and 2399 should be avoided when not required. 2401 When used without TLS or similar cryptographic protection, a 2402 malicious entity maybe able to inject a malicious unidirectional DSO 2403 Retry Delay Message into the data stream, specifying an unreasonably 2404 large RETRY DELAY, causing a denial-of-service attack against the 2405 client. 2407 The establishment of DSO sessions has an impact on the number of open 2408 TCP connections on a DNS server. Additional resources may be used on 2409 the server as a result. However, because the server can limit the 2410 number of DSO sessions established and can also close existing DSO 2411 sessions as needed, denial of service or resource exhaustion should 2412 not be a concern. 2414 11.1. TLS 0-RTT Considerations 2416 DSO permits zero round-trip operation using TCP Fast Open [RFC7413] 2417 with TLS 1.3 [RFC8446] 0-RTT to reduce or eliminate round trips in 2418 session establishment. TCP Fast Open is only permitted in 2419 combination with TLS 0-RTT. In the rest of this section we refer to 2420 TLS 1.3 early data in a TLS 0-RTT initial handshake message that is 2421 included in a TCP Fast Open packet as "early data." 2423 A DSO message may or may not be permitted to be sent as early data. 2424 The definition for each TLV that can be used as a primary TLV is 2425 required to state whether or not that TLV is permitted as early data. 2426 Only response-requiring messages are ever permitted as early data, 2427 and only clients are permitted to send any DSO message as early data, 2428 unless there is an implicit session (see Section 5.1). 2430 For DSO messages that are permitted as early data, a client MAY 2431 include one or more such messages as early data without having to 2432 wait for a DSO response to the first DSO request message to confirm 2433 successful establishment of a DSO session. 2435 However, unless there is an implicit session, a client MUST NOT send 2436 DSO unidirectional messages until after a DSO Session has been 2437 mutually established. 2439 Similarly, unless there is an implicit session, a server MUST NOT 2440 send DSO request messages until it has received a response-requiring 2441 DSO request message from a client and transmitted a successful 2442 NOERROR response for that request. 2444 Caution must be taken to ensure that DSO messages sent as early data 2445 are idempotent, or are otherwise immune to any problems that could be 2446 result from the inadvertent replay that can occur with zero round- 2447 trip operation. 2449 It would be possible to add a TLV that requires the server to do some 2450 significant work, and send that to the server as initial data in a 2451 TCP SYN packet. A flood of such packets could be used as a DoS 2452 attack on the server. None of the TLVs defined here have this 2453 property. 2455 If a new TLV is specified that does have this property, that TLV must 2456 be specified as not permitted in 0-RTT messages. This prevents work 2457 from being done until a round-trip has occurred from the server to 2458 the client to verify that the source address of the packet is 2459 reachable. 2461 Documents that define new TLVs must state whether each new TLV may be 2462 sent as early data. Such documents must include a threat analysis in 2463 the security considerations section for each TLV defined in the 2464 document that may be sent as early data. This threat analysis should 2465 be done based on the advice given in [RFC8446] Section 2.3, 8 and 2466 Appendix E.5. 2468 12. Acknowledgements 2470 Thanks to Stephane Bortzmeyer, Tim Chown, Ralph Droms, Paul Hoffman, 2471 Jan Komissar, Edward Lewis, Allison Mankin, Rui Paulo, David 2472 Schinazi, Manju Shankar Rao, Bernie Volz and Bob Harold for their 2473 helpful contributions to this document. 2475 13. References 2477 13.1. Normative References 2479 [RFC1034] Mockapetris, P., "Domain names - concepts and facilities", 2480 STD 13, RFC 1034, DOI 10.17487/RFC1034, November 1987, 2481 . 2483 [RFC1035] Mockapetris, P., "Domain names - implementation and 2484 specification", STD 13, RFC 1035, DOI 10.17487/RFC1035, 2485 November 1987, . 2487 [RFC1918] Rekhter, Y., Moskowitz, B., Karrenberg, D., de Groot, G., 2488 and E. Lear, "Address Allocation for Private Internets", 2489 BCP 5, RFC 1918, DOI 10.17487/RFC1918, February 1996, 2490 . 2492 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2493 Requirement Levels", BCP 14, RFC 2119, 2494 DOI 10.17487/RFC2119, March 1997, 2495 . 2497 [RFC2136] Vixie, P., Ed., Thomson, S., Rekhter, Y., and J. Bound, 2498 "Dynamic Updates in the Domain Name System (DNS UPDATE)", 2499 RFC 2136, DOI 10.17487/RFC2136, April 1997, 2500 . 2502 [RFC6891] Damas, J., Graff, M., and P. Vixie, "Extension Mechanisms 2503 for DNS (EDNS(0))", STD 75, RFC 6891, 2504 DOI 10.17487/RFC6891, April 2013, 2505 . 2507 [RFC7766] Dickinson, J., Dickinson, S., Bellis, R., Mankin, A., and 2508 D. Wessels, "DNS Transport over TCP - Implementation 2509 Requirements", RFC 7766, DOI 10.17487/RFC7766, March 2016, 2510 . 2512 [RFC7830] Mayrhofer, A., "The EDNS(0) Padding Option", RFC 7830, 2513 DOI 10.17487/RFC7830, May 2016, 2514 . 2516 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 2517 Writing an IANA Considerations Section in RFCs", BCP 26, 2518 RFC 8126, DOI 10.17487/RFC8126, June 2017, 2519 . 2521 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2522 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2523 May 2017, . 2525 13.2. Informative References 2527 [I-D.ietf-dnsop-no-response-issue] 2528 Andrews, M. and R. Bellis, "A Common Operational Problem 2529 in DNS Servers - Failure To Respond.", draft-ietf-dnsop- 2530 no-response-issue-11 (work in progress), July 2018. 2532 [I-D.ietf-dnssd-mdns-relay] 2533 Lemon, T. and S. Cheshire, "Multicast DNS Discovery 2534 Relay", draft-ietf-dnssd-mdns-relay-01 (work in progress), 2535 July 2018. 2537 [I-D.ietf-dnssd-push] 2538 Pusateri, T. and S. Cheshire, "DNS Push Notifications", 2539 draft-ietf-dnssd-push-15 (work in progress), September 2540 2018. 2542 [I-D.ietf-doh-dns-over-https] 2543 Hoffman, P. and P. McManus, "DNS Queries over HTTPS 2544 (DoH)", draft-ietf-doh-dns-over-https-14 (work in 2545 progress), August 2018. 2547 [I-D.ietf-dprive-padding-policy] 2548 Mayrhofer, A., "Padding Policy for EDNS(0)", draft-ietf- 2549 dprive-padding-policy-06 (work in progress), July 2018. 2551 [NagleDA] Cheshire, S., "TCP Performance problems caused by 2552 interaction between Nagle's Algorithm and Delayed ACK", 2553 May 2005, 2554 . 2556 [RFC1122] Braden, R., Ed., "Requirements for Internet Hosts - 2557 Communication Layers", STD 3, RFC 1122, 2558 DOI 10.17487/RFC1122, October 1989, 2559 . 2561 [RFC2132] Alexander, S. and R. Droms, "DHCP Options and BOOTP Vendor 2562 Extensions", RFC 2132, DOI 10.17487/RFC2132, March 1997, 2563 . 2565 [RFC5382] Guha, S., Ed., Biswas, K., Ford, B., Sivakumar, S., and P. 2566 Srisuresh, "NAT Behavioral Requirements for TCP", BCP 142, 2567 RFC 5382, DOI 10.17487/RFC5382, October 2008, 2568 . 2570 [RFC6762] Cheshire, S. and M. Krochmal, "Multicast DNS", RFC 6762, 2571 DOI 10.17487/RFC6762, February 2013, 2572 . 2574 [RFC6763] Cheshire, S. and M. Krochmal, "DNS-Based Service 2575 Discovery", RFC 6763, DOI 10.17487/RFC6763, February 2013, 2576 . 2578 [RFC7413] Cheng, Y., Chu, J., Radhakrishnan, S., and A. Jain, "TCP 2579 Fast Open", RFC 7413, DOI 10.17487/RFC7413, December 2014, 2580 . 2582 [RFC7828] Wouters, P., Abley, J., Dickinson, S., and R. Bellis, "The 2583 edns-tcp-keepalive EDNS0 Option", RFC 7828, 2584 DOI 10.17487/RFC7828, April 2016, 2585 . 2587 [RFC7857] Penno, R., Perreault, S., Boucadair, M., Ed., Sivakumar, 2588 S., and K. Naito, "Updates to Network Address Translation 2589 (NAT) Behavioral Requirements", BCP 127, RFC 7857, 2590 DOI 10.17487/RFC7857, April 2016, 2591 . 2593 [RFC7858] Hu, Z., Zhu, L., Heidemann, J., Mankin, A., Wessels, D., 2594 and P. Hoffman, "Specification for DNS over Transport 2595 Layer Security (TLS)", RFC 7858, DOI 10.17487/RFC7858, May 2596 2016, . 2598 [RFC8446] Rescorla, E., "The Transport Layer Security (TLS) Protocol 2599 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 2600 . 2602 Authors' Addresses 2604 Ray Bellis 2605 Internet Systems Consortium, Inc. 2606 950 Charter Street 2607 Redwood City CA 94063 2608 USA 2610 Phone: +1 (650) 423-1200 2611 Email: ray@isc.org 2613 Stuart Cheshire 2614 Apple Inc. 2615 One Apple Park Way 2616 Cupertino CA 95014 2617 USA 2619 Phone: +1 (408) 996-1010 2620 Email: cheshire@apple.com 2621 John Dickinson 2622 Sinodun Internet Technologies 2623 Magadalen Centre 2624 Oxford Science Park 2625 Oxford OX4 4GA 2626 United Kingdom 2628 Email: jad@sinodun.com 2630 Sara Dickinson 2631 Sinodun Internet Technologies 2632 Magadalen Centre 2633 Oxford Science Park 2634 Oxford OX4 4GA 2635 United Kingdom 2637 Email: sara@sinodun.com 2639 Ted Lemon 2640 Nibbhaya Consulting 2641 P.O. Box 958 2642 Brattleboro VT 05302-0958 2643 USA 2645 Email: mellon@fugue.com 2647 Tom Pusateri 2648 Unaffiliated 2649 Raleigh NC 27608 2650 USA 2652 Phone: +1 (919) 867-1330 2653 Email: pusateri@bangj.com