idnits 2.17.1 draft-ietf-dnsop-session-signal-15.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 (September 12, 2018) is 2053 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 2292, but not defined == Missing Reference: 'TBA2' is mentioned on line 2298, 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-14 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: March 16, 2019 J. Dickinson 7 S. Dickinson 8 Sinodun 9 T. Lemon 10 Nibbhaya Consulting 11 T. Pusateri 12 Unaffiliated 13 September 12, 2018 15 DNS Stateful Operations 16 draft-ietf-dnsop-session-signal-15 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 http://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 March 16, 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 (http://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 . . . . . . . . . . . . 12 76 5.1.2. Session Establishment Success . . . . . . . . . . . . 13 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. Client Reconnection . . . . . . . . . . . . . . . . . 39 103 7. Base TLVs for DNS Stateful Operations . . . . . . . . . . . . 41 104 7.1. Keepalive TLV . . . . . . . . . . . . . . . . . . . . . . 41 105 7.1.1. Client handling of received Session Timeout values . 43 106 7.1.2. Relationship to edns-tcp-keepalive EDNS0 Option . . . 44 107 7.2. Retry Delay TLV . . . . . . . . . . . . . . . . . . . . . 45 108 7.2.1. Retry Delay TLV used as a Primary TLV . . . . . . . . 45 109 7.2.2. Retry Delay TLV used as a Response Additional TLV . . 47 110 7.3. Encryption Padding TLV . . . . . . . . . . . . . . . . . 48 111 8. Summary Highlights . . . . . . . . . . . . . . . . . . . . . 49 112 8.1. QR bit and MESSAGE ID . . . . . . . . . . . . . . . . . . 49 113 8.2. TLV Usage . . . . . . . . . . . . . . . . . . . . . . . . 50 114 9. Additional Considerations . . . . . . . . . . . . . . . . . . 52 115 9.1. Service Instances . . . . . . . . . . . . . . . . . . . . 52 116 9.2. Anycast Considerations . . . . . . . . . . . . . . . . . 53 117 9.3. Connection Sharing . . . . . . . . . . . . . . . . . . . 54 118 9.4. Zero Round-Trip Operation . . . . . . . . . . . . . . . . 55 119 9.5. Operational Considerations for Middlebox . . . . . . . . 56 120 9.6. TCP Delayed Acknowledgement Considerations . . . . . . . 57 121 10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 60 122 10.1. DSO OPCODE Registration . . . . . . . . . . . . . . . . 60 123 10.2. DSO RCODE Registration . . . . . . . . . . . . . . . . . 60 124 10.3. DSO Type Code Registry . . . . . . . . . . . . . . . . . 60 125 11. Security Considerations . . . . . . . . . . . . . . . . . . . 61 126 11.1. TCP Fast Open Considerations . . . . . . . . . . . . . . 62 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 DNS message: any DNS message, including DNS queries, response, 290 updates, DSO messages, etc. 292 DNS request message: any DNS message where the QR bit is 0. 294 DNS response message: any DNS message where the QR bit is 1. 296 DSO message: a DSO request message, DSO unidirectional message, or a 297 DSO response to a DSO request message. If the QR bit is 1 in a 298 DSO message, it is a DSO response message. If the QR bit is 0 in 299 a DSO message, it is a DSO request message or DSO unidirectional 300 message, as determined by the specification of its primary TLV. 302 DSO response message: a response to a DSO request message. 304 DSO request message: a DSO message that requires a response. 306 DSO unidirectional message: a DSO message that does not require and 307 cannot induce a response. 309 Primary TLV: The first TLV in a DSO message or DSO response; in the 310 DSO message this determines the nature of the operation being 311 performed. 313 Additional TLV: Any TLVs in a DSO message response that follow the 314 primary TLV. 316 Response Primary TLV: The (optional) first TLV in a DSO response. 318 Response Additional TLV: Any TLVs in a DSO response that follow the 319 (optional) Response Primary TLV. 321 inactivity timer: the time since the most recent non-keepalive DNS 322 message was sent or received. (see Section 6.4) 324 keepalive timer: the time since the most recent DNS message was sent 325 or received. (see Section 6.5) 327 session timeouts: the inactivity timer and the keepalive timer. 329 inactivity timeout: the maximum value that the inactivity timer can 330 have before the connection is gracefully closed. 332 keepalive interval: the maximum value that the keepalive timer can 333 have before the client is required to send a keepalive. (see 334 Section 7.1) 336 resetting a timer: setting the timer value to zero and restarting 337 the timer. 339 clearing a timer: setting the timer value to zero but not restarting 340 the timer. 342 4. Applicability 344 DNS Stateful Operations are applicable to several known use cases and 345 are only applicable on transports that are capable of supporting a 346 DSO Session. 348 4.1. Use Cases 350 There are several use cases for DNS Stateful operations that can be 351 described here. 353 4.1.1. Session Management 355 Firstly, establishing session parameters such as server-defined 356 timeouts is of great use in the general management of persistent 357 connections. For example, using DSO sessions for stub-to-recursive 358 DNS-over-TLS [RFC7858] is more flexible for both the client and the 359 server than attempting to manage sessions using just the edns-tcp- 360 keepalive EDNS0 Option [RFC7828]. The simple set of TLVs defined in 361 this document is sufficient to greatly enhance connection management 362 for this use case. 364 4.1.2. Long-lived Subscriptions 366 Secondly, DNS-SD [RFC6763] has evolved into a naturally session-based 367 mechanism where, for example, long-lived subscriptions lend 368 themselves to 'push' mechanisms as opposed to polling. Long-lived 369 stateful connections and server-initiated messages align with this 370 use case [I-D.ietf-dnssd-push]. 372 A general use case is that DNS traffic is often bursty but session 373 establishment can be expensive. One challenge with long-lived 374 connections is to maintain sufficient traffic to maintain NAT and 375 firewall state. To mitigate this issue this document introduces a 376 new concept for the DNS, that is DSO "Keepalive traffic". This 377 traffic carries no DNS data and is not considered 'activity' in the 378 classic DNS sense, but serves to maintain state in middleboxes, and 379 to assure client and server that they still have connectivity to each 380 other. 382 4.2. Applicable Transports 384 DNS Stateful Operations are applicable in cases where it is useful to 385 maintain an open session between a DNS client and server, where the 386 transport allows such a session to be maintained, and where the 387 transport guarantees in-order delivery of messages, on which DSO 388 depends. Examples of transports that can support DNS Stateful 389 Operations are DNS-over-TCP [RFC1035] [RFC7766] and DNS-over-TLS 390 [RFC7858]. 392 Note that in the case of DNS over TLS, there is no mechanism for 393 upgrading from DNS-over-TCP to DNS-over-TLS mid-connection (see 394 [RFC7858] section 7). A connection is either DNS-over-TCP from the 395 start, or DNS-over-TLS from the start. 397 DNS Stateful Operations are not applicable for transports that cannot 398 support clean session semantics, or that do not guarantee in-order 399 delivery. While in principle such a transport could be constructed 400 over UDP, the current DNS specification over UDP transport [RFC1035] 401 does not provide in-order delivery or session semantics, and hence 402 cannot be used. Similarly, DNS-over-HTTP 403 [I-D.ietf-doh-dns-over-https] cannot be used because HTTP has its own 404 mechanism for managing sessions, and this is incompatible with the 405 mechanism specified here. 407 No other transports are currently defined for use with DNS Stateful 408 Operations. Such transports can be added in the future, if they meet 409 the requirements set out in the first paragraph of this section. 411 5. Protocol Details 413 The overall flow of DNS Stateful Operations goes through a series of 414 phases: 416 Connection Establishment: A client establishes a connection to a 417 server. (Section 4.2) 419 Connected but sessionless: A connection exists, but a DSO session 420 has not been established. DNS messages can be sent from the 421 client to server, and DNS responses can be sent from servers to 422 clients. In this state a client that wishes to use DSO can 423 attempt to establish a DSO session (Section 5.1). Standard DNS- 424 over-TCP inactivity timeout handling is in effect [RFC7766] (see 425 Section 7.1.2). 427 DSO Session Establishment in Progress: A client has sent a DSO 428 request, but has not yet received a DSO response. In this phase, 429 the client may send more DSO requests and more DNS requests, but 430 MUST NOT send DSO unidirectional messages (Section 5.1). 432 DSO Session Establishment Failed: The attempt to establish the DSO 433 session did not succeed. At this point, the client is permitted 434 to continue operating without a DSO session (Connected but 435 Sessionless) but does not send further DSO messages (Section 5.1). 437 DSO Session Established: Both client and server may send DSO 438 messages and DNS messages; both may send replies in response to 439 messages they receive (Section 5.2). The inactivity timer 440 (Section 6.4) is active; the keepalive timer (Section 6.5) is 441 active. Standard DNS-over-TCP inactivity timeout handling is no 442 longer in effect [RFC7766] (see Section 7.1.2). 444 Server Shutdown: The server has decided to gracefully terminate the 445 session, and has sent the client a Retry Delay message 446 (Section 6.6.1). There may still be unprocessed messages from the 447 client; the server will ignore these. The server will not send 448 any further messages to the client (Section 6.6.1.1). 450 Client Shutdown: The client has decided to disconnect, either 451 because it no longer needs service, the connection is inactive 452 (Section 6.4.1), or because the server sent it a Retry Delay 453 message (Section 6.6.1). The client closes the connection 454 gracefully Section 5.3. 456 Reconnect: The client disconnected as a result of a server shutdown. 457 The client either waits for the server-specified Retry Delay to 458 expire (Section 6.6.2), or else contacts a different server 459 instance. If the client no longer needs service, it does not 460 reconnect. 462 Forcibly Abort: The client or server detected a protocol error, and 463 further communication would have undefined behavior. The client 464 or server forcibly aborts the connection (Section 5.3). 466 Abort Reconnect Wait: The client has forcibly aborted the 467 connection, but still needs service. Or, the server forcibly 468 aborted the connection, but the client still needs service. The 469 client either connects to a different service instance 470 (Section 9.1) or waits to reconnect (Section 6.6.2.1). 472 5.1. DSO Session Establishment 474 In order for a session to be established between a client and a 475 server, the client must first establish a connection to the server, 476 using an applicable transport (see Section 4). 478 In some environments it may be known in advance by external means 479 that both client and server support DSO, and in these cases either 480 client or server may initiate DSO messages at any time. In this 481 case, the session is established as soon as the connection is 482 established; this is referred to as implicit session establishment. 484 However, in the typical case a server will not know in advance 485 whether a client supports DSO, so in general, unless it is known in 486 advance by other means that a client does support DSO, a server MUST 487 NOT initiate DSO request messages or DSO unidirectional messages 488 until a DSO Session has been mutually established by at least one 489 successful DSO request/response exchange initiated by the client, as 490 described below. This is referred to as explicit session 491 establishment. 493 Until a DSO session has been implicitly or explicitly established, a 494 client MUST NOT initiate DSO unidirectional messages. 496 A DSO Session is established over a connection by the client sending 497 a DSO request message, such as a DSO Keepalive request message 498 (Section 7.1), and receiving a response, with matching MESSAGE ID, 499 and RCODE set to NOERROR (0), indicating that the DSO request was 500 successful. 502 5.1.1. Session Establishment Failure 504 If the response RCODE is set to NOTIMP (4), or in practise any value 505 other than NOERROR (0) or DSOTYPENI (defined below), then the client 506 MUST assume that the server does not implement DSO at all. In this 507 case the client is permitted to continue sending DNS messages on that 508 connection, but the client MUST NOT issue further DSO messages on 509 that connection. 511 If the RCODE in the response is set to DSOTYPENI ("DSO-TYPE Not 512 Implemented", [TBA2] tentatively RCODE 11) this indicates that the 513 server does support DSO, but does not implement the DSO-TYPE of the 514 primary TLV in this DSO request message. A server implementing DSO 515 MUST NOT return DSOTYPENI for a DSO Keepalive request message, 516 because the Keepalive TLV is mandatory to implement. But in the 517 future, if a client attempts to establish a DSO Session using a 518 response-requiring DSO request message using some newly-defined DSO- 519 TYPE that the server does not understand, that would result in a 520 DSOTYPENI response. If the server returns DSOTYPENI then a DSO 521 Session is not considered established, but the client is permitted to 522 continue sending DNS messages on the connection, including other DSO 523 messages such as the DSO Keepalive, which may result in a successful 524 NOERROR response, yielding the establishment of a DSO Session. 526 Two other possibilities exist: the server might drop the connection, 527 or the server might send no response to the DSO message. 529 In the first case, the client SHOULD mark that service instance as 530 not supporting DSO, and not attempt a DSO connection for some period 531 of time (at least an hour) after the failed attempt. The client MAY 532 reconnect but not use DSO, if appropriate (Section 6.6.2.2). 534 In the second case, the client SHOULD wait 30 seconds, after which 535 time the server will be assumed not to support DSO. If the server 536 doesn't respond within 30 seconds, the client MUST forcibly abort the 537 connection to the server, since the server's behavior is out of spec, 538 and hence its state is undefined. The client MAY reconnect, but not 539 use DSO, if appropriate (Section 6.6.2.1). 541 5.1.2. Session Establishment Success 543 When the server receives a DSO request message from a client, and 544 transmits a successful NOERROR response to that request, the server 545 considers the DSO Session established. 547 When the client receives the server's NOERROR response to its DSO 548 request message, the client considers the DSO Session established. 550 Once a DSO Session has been established, either end may unilaterally 551 send appropriate DSO messages at any time, and therefore either 552 client or server may be the initiator of a message. 554 5.2. Operations After Session Establishment 556 Once a DSO Session has been established, clients and servers should 557 behave as described in this specification with regard to inactivity 558 timeouts and session termination, not as previously prescribed in the 559 earlier specification for DNS over TCP [RFC7766]. 561 Because a server that supports DNS Stateful Operations MUST return an 562 RCODE of NOERROR when it receives a Keepalive TLV DSO request 563 message, the Keepalive TLV is an ideal candidate for use in 564 establishing a DSO session. Any other option that can only succeed 565 when sent to a server of the desired kind is also a good candidate 566 for use in establishing a DSO session. For clients that implement 567 only the DSO-TYPEs defined in this base specification, sending a 568 Keepalive TLV is the only DSO request message they have available to 569 initiate a DSO Session. Even for clients that do implement other 570 future DSO-TYPEs, for simplicity they MAY elect to always send an 571 initial DSO Keepalive request message as their way of initiating a 572 DSO Session. A future definition of a new response-requiring DSO- 573 TYPE gives implementers the option of using that new DSO-TYPE if they 574 wish, but does not change the fact that sending a Keepalive TLV 575 remains a valid way of initiating a DSO Session. 577 5.3. Session Termination 579 A "DSO Session" is terminated when the underlying connection is 580 closed. Sessions are "closed gracefully" as a result of the server 581 closing a session because it is overloaded, the client closing the 582 session because it is done, or the client closing the session because 583 it is inactive. Sessions are "forcibly aborted" when either the 584 client or server closes the connection because of a protocol error. 586 o Where this specification says, "close gracefully," that means 587 sending a TLS close_notify (if TLS is in use) followed by a TCP 588 FIN, or the equivalents for other protocols. Where this 589 specification requires a connection to be closed gracefully, the 590 requirement to initiate that graceful close is placed on the 591 client, to place the burden of TCP's TIME-WAIT state on the client 592 rather than the server. 594 o Where this specification says, "forcibly abort," that means 595 sending a TCP RST, or the equivalent for other protocols. In the 596 BSD Sockets API this is achieved by setting the SO_LINGER option 597 to zero before closing the socket. 599 5.3.1. Handling Protocol Errors 601 In protocol implementation there are generally two kinds of errors 602 that software writers have to deal with. The first is situations 603 that arise due to factors in the environment, such as temporary loss 604 of connectivity. While undesirable, these situations do not indicate 605 a flaw in the software, and they are situations that software should 606 generally be able to recover from. 608 The second is situations that should never happen when communicating 609 with a compliant DSO implementation. If they do happen, they 610 indicate a serious flaw in the protocol implementation, beyond what 611 it is reasonable to expect software to recover from. This document 612 describes this latter form of error condition as a "fatal error" and 613 specifies that an implementation encountering a fatal error condition 614 "MUST forcibly abort the connection immediately". 616 5.4. Message Format 618 A DSO message begins with the standard twelve-byte DNS message header 619 [RFC1035] with the OPCODE field set to the DSO OPCODE. However, 620 unlike standard DNS messages, the question section, answer section, 621 authority records section and additional records sections are not 622 present. The corresponding count fields (QDCOUNT, ANCOUNT, NSCOUNT, 623 ARCOUNT) MUST be set to zero on transmission. 625 If a DSO message is received where any of the count fields are not 626 zero, then a FORMERR MUST be returned. 628 1 1 1 1 1 1 629 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 630 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 631 | MESSAGE ID | 632 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 633 |QR | OPCODE | Z | RCODE | 634 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 635 | QDCOUNT (MUST be zero) | 636 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 637 | ANCOUNT (MUST be zero) | 638 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 639 | NSCOUNT (MUST be zero) | 640 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 641 | ARCOUNT (MUST be zero) | 642 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 643 | | 644 / DSO Data / 645 / / 646 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 648 5.4.1. DNS Header Fields in DSO Messages 650 In a DSO unidirectional message the MESSAGE ID field MUST be set to 651 zero. In a DSO request message the MESSAGE ID field MUST be set to a 652 unique nonzero value, that the initiator is not currently using for 653 any other active operation on this connection. For the purposes 654 here, a MESSAGE ID is in use in this DSO Session if the initiator has 655 used it in a DSO request message for which it is still awaiting a 656 response, or if the client has used it to set up a long-lived 657 operation that has not yet been cancelled. For example, a long-lived 658 operation could be a Push Notification subscription 659 [I-D.ietf-dnssd-push] or a Discovery Relay interface subscription 660 [I-D.ietf-dnssd-mdns-relay]. 662 Whether a message is a DSO request message or a DSO unidirectional 663 message is determined only by the specification for the Primary TLV. 664 An acknowledgment cannot be requested by including a nonzero message 665 ID in a message that is required according to its primary TLV to be 666 unidirectional. Nor can an acknowledgment be prevented by sending a 667 message ID of zero in a message that is required to be a DSO request 668 message according to its primary TLV. A responder that receives 669 either such malformed message MUST treat it as a fatal error and 670 forcibly abort the connection immediately. 672 In a DSO request message or DSO unidirectional message the DNS Header 673 QR bit MUST be zero (QR=0). If the QR bit is not zero the message is 674 not a DSO request or DSO unidirectional message. 676 In a DSO response message the DNS Header QR bit MUST be one (QR=1). 677 If the QR bit is not one, the message is not a response message. 679 In a DSO response message (QR=1) the MESSAGE ID field MUST contain a 680 copy of the value of the MESSAGE ID field in the DSO request message 681 being responded to. In a DSO response message (QR=1) the MESSAGE ID 682 field MUST NOT be zero. If a DSO response message (QR=1) is received 683 where the MESSAGE ID is zero this is a fatal error and the recipient 684 MUST forcibly abort the connection immediately. 686 The DNS Header OPCODE field holds the DSO OPCODE value. 688 The Z bits are currently unused in DSO messages, and in both DSO 689 request messages and DSO responses the Z bits MUST be set to zero (0) 690 on transmission and MUST be ignored on reception. 692 In a DSO request message (QR=0) the RCODE is set according to the 693 definition of the request. For example, in a Retry Delay message 694 (Section 6.6.1) the RCODE indicates the reason for termination. 695 However, in most cases, except where clearly specified otherwise, in 696 a DSO request message (QR=0) the RCODE is set to zero on 697 transmission, and silently ignored on reception. 699 The RCODE value in a response message (QR=1) may be one of the 700 following values: 702 +--------+-----------+----------------------------------------------+ 703 | Code | Mnemonic | Description | 704 +--------+-----------+----------------------------------------------+ 705 | 0 | NOERROR | Operation processed successfully | 706 | | | | 707 | 1 | FORMERR | Format error | 708 | | | | 709 | 2 | SERVFAIL | Server failed to process DSO request message | 710 | | | due to a problem with the server | 711 | | | | 712 | 4 | NOTIMP | DSO not supported | 713 | | | | 714 | 5 | REFUSED | Operation declined for policy reasons | 715 | | | | 716 | [TBA2] | DSOTYPENI | Primary TLV's DSO-Type is not implemented | 717 | 11 | | | 718 +--------+-----------+----------------------------------------------+ 720 Use of the above RCODEs is likely to be common in DSO but does not 721 preclude the definition and use of other codes in future documents 722 that make use of DSO. 724 If a document defining a new DSO-TYPE makes use of response codes not 725 defined here, then that document MUST specify the specific 726 interpretation of those RCODE values in the context of that new DSO 727 TLV. 729 5.4.2. DSO Data 731 The standard twelve-byte DNS message header with its zero-valued 732 count fields is followed by the DSO Data, expressed using TLV syntax, 733 as described below in Section 5.4.3. 735 A DSO request message or DSO unidirectional message MUST contain at 736 least one TLV. The first TLV in a DSO request message or DSO 737 unidirectional message is referred to as the "Primary TLV" and 738 determines the nature of the operation being performed, including 739 whether it is a DSO request or a DSO unidirectional operation. In 740 some cases it may be appropriate to include other TLVs in a DSO 741 request message or DSO unidirectional message, such as the Encryption 742 Padding TLV (Section 7.3), and these extra TLVs are referred to as 743 the "Additional TLVs" and are not limited to what is defined in this 744 document. New "Additional TLVs" may be defined in the future and 745 those definitions will describe when their use is appropriate. 747 A DSO response message may contain no TLVs, or it may be specified to 748 contain one or more TLVs appropriate to the information being 749 communicated. This includes "Primary TLVs" and "Additional TLVs" 750 defined in this document as well as in future TLV definitions. It 751 may be permissible for an additional TLV to appear in a response to a 752 primary TLV even though the specification of that primary TLV does 753 not specify it explicitly. See Section 8.2 for more information. 755 A DSO response message may contain one or more TLVs with the Primary 756 TLV DSO-TYPE the same as the Primary TLV from the corresponding DSO 757 request message or it may contain zero or more Additional TLVs only. 758 The MESSAGE ID field in the DNS message header is sufficient to 759 identify the DSO request message to which this response message 760 relates. 762 A DSO response message may contain one or more TLVs with DSO-TYPEs 763 different from the Primary TLV from the corresponding DSO request 764 message, in which case those TLV(s) are referred to as "Response 765 Additional TLVs". 767 Response Primary TLV(s), if present, MUST occur first in the response 768 message, before any Response Additional TLVs. 770 It is anticipated that most DSO operations will be specified to use 771 DSO request messages, which generate corresponding DSO responses. In 772 some specialized high-traffic use cases, it may be appropriate to 773 specify DSO unidirectional messages. DSO unidirectional messages can 774 be more efficient on the network, because they don't generate a 775 stream of corresponding reply messages. Using DSO unidirectional 776 messages can also simplify software in some cases, by removing need 777 for an initiator to maintain state while it waits to receive replies 778 it doesn't care about. When the specification for a particular TLV 779 states that, when used as a Primary TLV (i.e., first) in an outgoing 780 DSO request message (i.e., QR=0), that message is to be 781 unidirectional, the MESSAGE ID field MUST be set to zero and the 782 receiver MUST NOT generate any response message corresponding to this 783 DSO unidirectional message. 785 The previous point, that the receiver MUST NOT generate responses to 786 DSO unidirectional messages, applies even in the case of errors. 788 When a DSO message is received where both the QR bit and the MESSAGE 789 ID field are zero, the receiver MUST NOT generate any response. For 790 example, if the DSO-TYPE in the Primary TLV is unrecognized, then a 791 DSOTYPENI error MUST NOT be returned; instead the receiver MUST 792 forcibly abort the connection immediately. 794 DSO unidirectional messages MUST NOT be used "speculatively" in cases 795 where the sender doesn't know if the receiver supports the Primary 796 TLV in the message, because there is no way to receive any response 797 to indicate success or failure. DSO unidirectional messages are only 798 appropriate in cases where the sender already knows that the receiver 799 supports, and wishes to receive, these messages. 801 For example, after a client has subscribed for Push Notifications 802 [I-D.ietf-dnssd-push], the subsequent event notifications are then 803 sent as DSO unidirectional messages, and this is appropriate because 804 the client initiated the message stream by virtue of its Push 805 Notification subscription, thereby indicating its support of Push 806 Notifications, and its desire to receive those notifications. 808 Similarly, after a Discovery Relay client has subscribed to receive 809 inbound mDNS (multicast DNS, [RFC6762]) traffic from a Discovery 810 Relay, the subsequent stream of received packets is then sent using 811 DSO unidirectional messages, and this is appropriate because the 812 client initiated the message stream by virtue of its Discovery Relay 813 link subscription, thereby indicating its support of Discovery Relay, 814 and its desire to receive inbound mDNS packets over that DSO session 815 [I-D.ietf-dnssd-mdns-relay]. 817 5.4.3. TLV Syntax 819 All TLVs, whether used as "Primary", "Additional", "Response 820 Primary", or "Response Additional", use the same encoding syntax. 822 Specifications that define new TLVs must specify whether the DSO-TYPE 823 can be used as the Primary TLV, used as an Additional TLV, or used in 824 either context, both in the case of requests and of responses. The 825 specification for a TLV must also state whether, when used as the 826 Primary (i.e., first) TLV in a DSO message (i.e., QR=0), that DSO 827 message is unidirectional or is a request message which requires a 828 response. If the DSO message requires a response, the specification 829 must also state which TLVs, if any, are to be included in the 830 response. The Primary TLV may or may not be contained in the 831 response, depending on what is specified for that TLV. 833 1 1 1 1 1 1 834 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 835 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 836 | DSO-TYPE | 837 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 838 | DSO-LENGTH | 839 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 840 | | 841 / DSO-DATA / 842 / / 843 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 845 DSO-TYPE: A 16-bit unsigned integer, in network (big endian) byte 846 order, giving the DSO-TYPE of the current DSO TLV per the IANA DSO 847 Type Code Registry. 849 DSO-LENGTH: A 16-bit unsigned integer, in network (big endian) byte 850 order, giving the size in bytes of the DSO-DATA. 852 DSO-DATA: Type-code specific format. The generic DSO machinery 853 treats the DSO-DATA as an opaque "blob" without attempting to 854 interpret it. Interpretation of the meaning of the DSO-DATA for a 855 particular DSO-TYPE is the responsibility of the software that 856 implements that DSO-TYPE. 858 5.4.3.1. Request TLVs 860 The first TLV in a DSO request message or DSO unidirectional message 861 is the "Primary TLV" and indicates the operation to be performed. A 862 DSO request message or DSO unidirectional message MUST contain at at 863 least one TLV - the Primary TLV. 865 Immediately following the Primary TLV, a DSO request message or DSO 866 unidirectional message MAY contain one or more "Additional TLVs", 867 which specify additional parameters relating to the operation. 869 5.4.3.2. Response TLVs 871 Depending on the operation, a DSO response message MAY contain no 872 TLVs, because it is simply a response to a previous DSO request 873 message, and the MESSAGE ID in the header is sufficient to identify 874 the DSO request in question. Or it may contain a single response 875 TLV, with the same DSO-TYPE as the Primary TLV in the request 876 message. Alternatively it may contain one or more TLVs of other 877 types, or a combination of the above, as appropriate for the 878 information that needs to be communicated. The specification for 879 each DSO TLV determines what TLVs are required in a response to a DSO 880 request message using that TLV. 882 If a DSO response is received for an operation where the 883 specification requires that the response carry a particular TLV or 884 TLVs, and the required TLV(s) are not present, then this is a fatal 885 error and the recipient of the defective response message MUST 886 forcibly abort the connection immediately. 888 5.4.3.3. Unrecognized TLVs 890 If DSO request message is received containing an unrecognized Primary 891 TLV, with a nonzero MESSAGE ID (indicating that a response is 892 expected), then the receiver MUST send an error response with 893 matching MESSAGE ID, and RCODE DSOTYPENI. The error response MUST 894 NOT contain a copy of the unrecognized Primary TLV. 896 If DSO unidirectional message is received containing an unrecognized 897 Primary TLV, with a zero MESSAGE ID (indicating that no response is 898 expected), then this is a fatal error and the recipient MUST forcibly 899 abort the connection immediately. 901 If a DSO request message or DSO unidirectional message is received 902 where the Primary TLV is recognized, containing one or more 903 unrecognized Additional TLVs, the unrecognized Additional TLVs MUST 904 be silently ignored, and the remainder of the message is interpreted 905 and handled as if the unrecognized parts were not present. 907 Similarly, if a DSO response message is received containing one or 908 more unrecognized TLVs, the unrecognized TLVs MUST be silently 909 ignored, and the remainder of the message is interpreted and handled 910 as if the unrecognized parts were not present. 912 5.4.4. EDNS(0) and TSIG 914 Since the ARCOUNT field MUST be zero, a DSO message cannot contain a 915 valid EDNS(0) option in the additional records section. If 916 functionality provided by current or future EDNS(0) options is 917 desired for DSO messages, one or more new DSO TLVs need to be defined 918 to carry the necessary information. 920 For example, the EDNS(0) Padding Option [RFC7830] used for security 921 purposes is not permitted in a DSO message, so if message padding is 922 desired for DSO messages then the Encryption Padding TLV described in 923 Section 7.3 MUST be used. 925 A DSO message can't contain a TSIG record, because a TSIG record is 926 included in the additional section of the message, which would mean 927 that ARCOUNT would be greater than zero. DSO messages are required 928 to have an ARCOUNT of zero. Therefore, if use of signatures with DSO 929 messages becomes necessary in the future, a new DSO TLV would have to 930 be defined to perform this function. 932 Note however that, while DSO *messages* cannot include EDNS(0) or 933 TSIG records, a DSO *session* is typically used to carry a whole 934 series of DNS messages of different kinds, including DSO messages, 935 and other DNS message types like Query [RFC1034] [RFC1035] and Update 936 [RFC2136], and those messages can carry EDNS(0) and TSIG records. 938 Although messages may contain other EDNS(0) options as appropriate, 939 this specification explicitly prohibits use of the edns-tcp-keepalive 940 EDNS0 Option [RFC7828] in *any* messages sent on a DSO Session 941 (because it is obsoleted by the functionality provided by the DSO 942 Keepalive operation). If any message sent on a DSO Session contains 943 an edns-tcp-keepalive EDNS0 Option this is a fatal error and the 944 recipient of the defective message MUST forcibly abort the connection 945 immediately. 947 5.5. Message Handling 949 As described above in Section 5.4.1, whether an outgoing DSO message 950 with the QR bit in the DNS header set to zero is a DSO request or DSO 951 unidirectional message is determined by the specification for the 952 Primary TLV, which in turn determines whether the MESSAGE ID field in 953 that outgoing message will be zero or nonzero. 955 Every DSO message with the QR bit in the DNS header set to zero and a 956 nonzero MESSAGE ID field is a DSO request message, and MUST elicit a 957 corresponding response, with the QR bit in the DNS header set to one 958 and the MESSAGE ID field set to the value given in the corresponding 959 DSO request message. 961 Valid DSO request messages sent by the client with a nonzero MESSAGE 962 ID field elicit a response from the server, and valid DSO request 963 messages sent by the server with a nonzero MESSAGE ID field elicit a 964 response from the client. 966 Every DSO message with both the QR bit in the DNS header and the 967 MESSAGE ID field set to zero is a DSO unidirectional message, and 968 MUST NOT elicit a response. 970 5.5.1. Delayed Acknowledgement Management 972 Generally, most good TCP implementations employ a delayed 973 acknowledgement timer to provide more efficient use of the network 974 and better performance. 976 With a DSO request message, the TCP implementation waits for the 977 application-layer client software to generate the corresponding DSO 978 response message, which enables the TCP implementation to send a 979 single combined IP packet containing the TCP acknowledgement, the TCP 980 window update, and the application-generated DSO response message. 981 This is more efficient than sending three separate IP packets. 983 With a DSO unidirectional message or DSO response message, there is 984 no corresponding application-generated DSO response message, and 985 consequently, no hint to the transport protocol about when it should 986 send its acknowledgement and window update. Some networking APIs 987 provide a mechanism that allows the application-layer client software 988 to signal to the transport protocol that no response will be 989 forthcoming (in effect it can be thought of as a zero-length "empty" 990 write). Where available in the networking API being used, the 991 recipient of a DSO unidirectional message or DSO response message, 992 having parsed and interpreted the message, SHOULD then use this 993 mechanism provided by the networking API to signal that no response 994 for this message will be forthcoming, so that the TCP implementation 995 can go ahead and send its acknowledgement and window update without 996 further delay. See Section 9.6 for further discussion of why this is 997 important. 999 5.5.2. MESSAGE ID Namespaces 1001 The namespaces of 16-bit MESSAGE IDs are independent in each 1002 direction. This means it is *not* an error for both client and 1003 server to send DSO request messages at the same time as each other, 1004 using the same MESSAGE ID, in different directions. This 1005 simplification is necessary in order for the protocol to be 1006 implementable. It would be infeasible to require the client and 1007 server to coordinate with each other regarding allocation of new 1008 unique MESSAGE IDs. It is also not necessary to require the client 1009 and server to coordinate with each other regarding allocation of new 1010 unique MESSAGE IDs. The value of the 16-bit MESSAGE ID combined with 1011 the identity of the initiator (client or server) is sufficient to 1012 unambiguously identify the operation in question. This can be 1013 thought of as a 17-bit message identifier space, using message 1014 identifiers 0x00001-0x0FFFF for client-to-server DSO request 1015 messages, and message identifiers 0x10001-0x1FFFF for server-to- 1016 client DSO request messages. The least-significant 16 bits are 1017 stored explicitly in the MESSAGE ID field of the DSO message, and the 1018 most-significant bit is implicit from the direction of the message. 1020 As described above in Section 5.4.1, an initiator MUST NOT reuse a 1021 MESSAGE ID that it already has in use for an outstanding DSO request 1022 message (unless specified otherwise by the relevant specification for 1023 the DSO-TYPE in question). At the very least, this means that a 1024 MESSAGE ID can't be reused in a particular direction on a particular 1025 DSO Session while the initiator is waiting for a response to a 1026 previous DSO request message using that MESSAGE ID on that DSO 1027 Session (unless specified otherwise by the relevant specification for 1028 the DSO-TYPE in question), and for a long-lived operation the MESSAGE 1029 ID for the operation can't be reused while that operation remains 1030 active. 1032 If a client or server receives a response (QR=1) where the MESSAGE ID 1033 is zero, or is any other value that does not match the MESSAGE ID of 1034 any of its outstanding operations, this is a fatal error and the 1035 recipient MUST forcibly abort the connection immediately. 1037 If a responder receives a DSO request message (QR=0) where the 1038 MESSAGE ID is not zero, and the responder tracks request MESSAGE IDs, 1039 and the MESSAGE ID matches the MESSAGE ID of a DSO request message it 1040 received for which a response has not yet been sent, it MUST forcibly 1041 abort the connection immediately. This behavior is required to 1042 prevent a hypothetical attack that takes advantage of undefined 1043 behavior in this case. However, if the responder does not track 1044 MESSAGE IDs in this way, no such risk exists, so tracking MESSAGE IDs 1045 just to implement this sanity check is not required. 1047 5.5.3. Error Responses 1049 When a DSO unidirectional message type is received (MESSAGE ID field 1050 is zero), the receiver should already be expecting this DSO message 1051 type. Section 5.4.3.3 describes the handling of unknown DSO message 1052 types. Parsing errors MUST also result in the receiver forcibly 1053 aborting the connection. When a DSO unidirectional message of an 1054 unexpected type is received, the receiver SHOULD forcibly abort the 1055 connection. Whether the connection should be forcibly aborted for 1056 other internal errors processing the DSO unidirectional message is 1057 implementation dependent, according to the severity of the error. 1059 When a DSO request message is unsuccessful for some reason, the 1060 responder returns an error code to the initiator. 1062 In the case of a server returning an error code to a client in 1063 response to an unsuccessful DSO request message, the server MAY 1064 choose to end the DSO Session, or MAY choose to allow the DSO Session 1065 to remain open. For error conditions that only affect the single 1066 operation in question, the server SHOULD return an error response to 1067 the client and leave the DSO Session open for further operations. 1069 For error conditions that are likely to make all operations 1070 unsuccessful in the immediate future, the server SHOULD return an 1071 error response to the client and then end the DSO Session by sending 1072 a Retry Delay message, as described in Section 6.6.1. 1074 Upon receiving an error response from the server, a client SHOULD NOT 1075 automatically close the DSO Session. An error relating to one 1076 particular operation on a DSO Session does not necessarily imply that 1077 all other operations on that DSO Session have also failed, or that 1078 future operations will fail. The client should assume that the 1079 server will make its own decision about whether or not to end the DSO 1080 Session, based on the server's determination of whether the error 1081 condition pertains to this particular operation, or would also apply 1082 to any subsequent operations. If the server does not end the DSO 1083 Session by sending the client a Retry Delay message (Section 6.6.1) 1084 then the client SHOULD continue to use that DSO Session for 1085 subsequent operations. 1087 5.6. Responder-Initiated Operation Cancellation 1089 This document, the base specification for DNS Stateful Operations, 1090 does not itself define any long-lived operations, but it defines a 1091 framework for supporting long-lived operations, such as Push 1092 Notification subscriptions [I-D.ietf-dnssd-push] and Discovery Relay 1093 interface subscriptions [I-D.ietf-dnssd-mdns-relay]. 1095 Long-lived operations, if successful, will remain active until the 1096 initiator terminates the operation. 1098 However, it is possible that a long-lived operation may be valid at 1099 the time it was initiated, but then a later change of circumstances 1100 may render that operation invalid. For example, a long-lived client 1101 operation may pertain to a name that the server is authoritative for, 1102 but then the server configuration is changed such that it is no 1103 longer authoritative for that name. 1105 In such cases, instead of terminating the entire session it may be 1106 desirable for the responder to be able to cancel selectively only 1107 those operations that have become invalid. 1109 The responder performs this selective cancellation by sending a new 1110 response message, with the MESSAGE ID field containing the MESSAGE ID 1111 of the long-lived operation that is to be terminated (that it had 1112 previously acknowledged with a NOERROR RCODE), and the RCODE field of 1113 the new response message giving the reason for cancellation. 1115 After a response message with nonzero RCODE has been sent, that 1116 operation has been terminated from the responder's point of view, and 1117 the responder sends no more messages relating to that operation. 1119 After a response message with nonzero RCODE has been received by the 1120 initiator, that operation has been terminated from the initiator's 1121 point of view, and the cancelled operation's MESSAGE ID is now free 1122 for reuse. 1124 6. DSO Session Lifecycle and Timers 1126 6.1. DSO Session Initiation 1128 A DSO Session begins as described in Section 5.1. 1130 The client may perform as many DNS operations as it wishes using the 1131 newly created DSO Session. When the client has multiple messages to 1132 send, it SHOULD NOT wait for each response before sending the next 1133 message. 1135 The server MUST act on messages in the order they are received, but 1136 SHOULD NOT delay sending responses to those messages as they become 1137 available in order to return them in the order the requests were 1138 received. 1140 Section 6.2.1.1 of the DNS-over-TCP specification [RFC7766] specifies 1141 this in more detail. 1143 6.2. DSO Session Timeouts 1145 Two timeout values are associated with a DSO Session: the inactivity 1146 timeout, and the keepalive interval. Both values are communicated in 1147 the same TLV, the Keepalive TLV (Section 7.1). 1149 The first timeout value, the inactivity timeout, is the maximum time 1150 for which a client may speculatively keep an inactive DSO Session 1151 open in the expectation that it may have future requests to send to 1152 that server. 1154 The second timeout value, the keepalive interval, is the maximum 1155 permitted interval between messages if the client wishes to keep the 1156 DSO Session alive. 1158 The two timeout values are independent. The inactivity timeout may 1159 be lower, the same, or higher than the keepalive interval, though in 1160 most cases the inactivity timeout is expected to be shorter than the 1161 keepalive interval. 1163 A shorter inactivity timeout with a longer keepalive interval signals 1164 to the client that it should not speculatively keep an inactive DSO 1165 Session open for very long without reason, but when it does have an 1166 active reason to keep a DSO Session open, it doesn't need to be 1167 sending an aggressive level of DSO keepalive traffic to maintain that 1168 session. An example of this would be a client that has subscribed to 1169 DNS Push notifications: in this case, the client is not sending any 1170 traffic to the server, but the session is not inactive, because there 1171 is a active request to the server to receive push notifications. 1173 A longer inactivity timeout with a shorter keepalive interval signals 1174 to the client that it may speculatively keep an inactive DSO Session 1175 open for a long time, but to maintain that inactive DSO Session it 1176 should be sending a lot of DSO keepalive traffic. This configuration 1177 is expected to be less common. 1179 In the usual case where the inactivity timeout is shorter than the 1180 keepalive interval, it is only when a client has a long-lived, low- 1181 traffic, operation that the keepalive interval comes into play, to 1182 ensure that a sufficient residual amount of traffic is generated to 1183 maintain NAT and firewall state and to assure client and server that 1184 they still have connectivity to each other. 1186 On a new DSO Session, if no explicit DSO Keepalive message exchange 1187 has taken place, the default value for both timeouts is 15 seconds. 1189 For both timeouts, lower values of the timeout result in higher 1190 network traffic, and higher CPU load on the server. 1192 6.3. Inactive DSO Sessions 1194 At both servers and clients, the generation or reception of any 1195 complete DNS message (including DNS requests, responses, updates, DSO 1196 messages, etc.) resets both timers for that DSO Session, with the one 1197 exception that a DSO Keepalive message resets only the keepalive 1198 timer, not the inactivity timeout timer. 1200 In addition, for as long as the client has an outstanding operation 1201 in progress, the inactivity timer remains cleared, and an inactivity 1202 timeout cannot occur. 1204 For short-lived DNS operations like traditional queries and updates, 1205 an operation is considered in progress for the time between request 1206 and response, typically a period of a few hundred milliseconds at 1207 most. At the client, the inactivity timer is cleared upon 1208 transmission of a request and remains cleared until reception of the 1209 corresponding response. At the server, the inactivity timer is 1210 cleared upon reception of a request and remains cleared until 1211 transmission of the corresponding response. 1213 For long-lived DNS Stateful operations (such as a Push Notification 1214 subscription [I-D.ietf-dnssd-push] or a Discovery Relay interface 1215 subscription [I-D.ietf-dnssd-mdns-relay]), an operation is considered 1216 in progress for as long as the operation is active, i.e. until it is 1217 cancelled. This means that a DSO Session can exist, with active 1218 operations, with no messages flowing in either direction, for far 1219 longer than the inactivity timeout, and this is not an error. This 1220 is why there are two separate timers: the inactivity timeout, and the 1221 keepalive interval. Just because a DSO Session has no traffic for an 1222 extended period of time does not automatically make that DSO Session 1223 "inactive", if it has an active operation that is awaiting events. 1225 6.4. The Inactivity Timeout 1227 The purpose of the inactivity timeout is for the server to balance 1228 the trade off between the costs of setting up new DSO Sessions and 1229 the costs of maintaining inactive DSO Sessions. A server with 1230 abundant DSO Session capacity can offer a high inactivity timeout, to 1231 permit clients to keep a speculative DSO Session open for a long 1232 time, to save the cost of establishing a new DSO Session for future 1233 communications with that server. A server with scarce memory 1234 resources can offer a low inactivity timeout, to cause clients to 1235 promptly close DSO Sessions whenever they have no outstanding 1236 operations with that server, and then create a new DSO Session later 1237 when needed. 1239 6.4.1. Closing Inactive DSO Sessions 1241 When a connection's inactivity timeout is reached the client MUST 1242 begin closing the idle connection, but a client is not required to 1243 keep an idle connection open until the inactivity timeout is reached. 1244 A client MAY close a DSO Session at any time, at the client's 1245 discretion. If a client determines that it has no current or 1246 reasonably anticipated future need for a currently inactive DSO 1247 Session, then the client SHOULD gracefully close that connection. 1249 If, at any time during the life of the DSO Session, the inactivity 1250 timeout value (i.e., 15 seconds by default) elapses without there 1251 being any operation active on the DSO Session, the client MUST close 1252 the connection gracefully. 1254 If, at any time during the life of the DSO Session, twice the 1255 inactivity timeout value (i.e., 30 seconds by default), or five 1256 seconds, if twice the inactivity timeout value is less than five 1257 seconds, elapses without there being any operation active on the DSO 1258 Session, the server MUST consider the client delinquent, and MUST 1259 forcibly abort the DSO Session. 1261 In this context, an operation being active on a DSO Session includes 1262 a query waiting for a response, an update waiting for a response, or 1263 an active long-lived operation, but not a DSO Keepalive message 1264 exchange itself. A DSO Keepalive message exchange resets only the 1265 keepalive interval timer, not the inactivity timeout timer. 1267 If the client wishes to keep an inactive DSO Session open for longer 1268 than the default duration then it uses the DSO Keepalive message to 1269 request longer timeout values, as described in Section 7.1. 1271 6.4.2. Values for the Inactivity Timeout 1273 For the inactivity timeout value, lower values result in more 1274 frequent DSO Session teardown and re-establishment. Higher values 1275 result in lower traffic and lower CPU load on the server, but higher 1276 memory burden to maintain state for inactive DSO Sessions. 1278 A server may dictate any value it chooses for the inactivity timeout 1279 (either in a response to a client-initiated request, or in a server- 1280 initiated message) including values under one second, or even zero. 1282 An inactivity timeout of zero informs the client that it should not 1283 speculatively maintain idle connections at all, and as soon as the 1284 client has completed the operation or operations relating to this 1285 server, the client should immediately begin closing this session. 1287 A server will forcibly abort an idle client session after twice the 1288 inactivity timeout value, or five seconds, whichever is greater. In 1289 the case of a zero inactivity timeout value, this means that if a 1290 client fails to close an idle client session then the server will 1291 forcibly abort the idle session after five seconds. 1293 An inactivity timeout of 0xFFFFFFFF represents "infinity" and informs 1294 the client that it may keep an idle connection open as long as it 1295 wishes. Note that after granting an unlimited inactivity timeout in 1296 this way, at any point the server may revise that inactivity timeout 1297 by sending a new DSO Keepalive message dictating new Session Timeout 1298 values to the client. 1300 The largest *finite* inactivity timeout supported by the current 1301 Keepalive TLV is 0xFFFFFFFE (2^32-2 milliseconds, approximately 49.7 1302 days). 1304 6.5. The Keepalive Interval 1306 The purpose of the keepalive interval is to manage the generation of 1307 sufficient messages to maintain state in middleboxes (such at NAT 1308 gateways or firewalls) and for the client and server to periodically 1309 verify that they still have connectivity to each other. This allows 1310 them to clean up state when connectivity is lost, and to establish a 1311 new session if appropriate. 1313 6.5.1. Keepalive Interval Expiry 1315 If, at any time during the life of the DSO Session, the keepalive 1316 interval value (i.e., 15 seconds by default) elapses without any DNS 1317 messages being sent or received on a DSO Session, the client MUST 1318 take action to keep the DSO Session alive, by sending a DSO Keepalive 1319 message (Section 7.1). A DSO Keepalive message exchange resets only 1320 the keepalive timer, not the inactivity timer. 1322 If a client disconnects from the network abruptly, without cleanly 1323 closing its DSO Session, perhaps leaving a long-lived operation 1324 uncancelled, the server learns of this after failing to receive the 1325 required DSO keepalive traffic from that client. If, at any time 1326 during the life of the DSO Session, twice the keepalive interval 1327 value (i.e., 30 seconds by default) elapses without any DNS messages 1328 being sent or received on a DSO Session, the server SHOULD consider 1329 the client delinquent, and SHOULD forcibly abort the DSO Session. 1331 6.5.2. Values for the Keepalive Interval 1333 For the keepalive interval value, lower values result in a higher 1334 volume of DSO keepalive traffic. Higher values of the keepalive 1335 interval reduce traffic and CPU load, but have minimal effect on the 1336 memory burden at the server, because clients keep a DSO Session open 1337 for the same length of time (determined by the inactivity timeout) 1338 regardless of the level of DSO keepalive traffic required. 1340 It may be appropriate for clients and servers to select different 1341 keepalive interval values depending on the nature of the network they 1342 are on. 1344 A corporate DNS server that knows it is serving only clients on the 1345 internal network, with no intervening NAT gateways or firewalls, can 1346 impose a higher keepalive interval, because frequent DSO keepalive 1347 traffic is not required. 1349 A public DNS server that is serving primarily residential consumer 1350 clients, where it is likely there will be a NAT gateway on the path, 1351 may impose a lower keepalive interval, to generate more frequent DSO 1352 keepalive traffic. 1354 A smart client may be adaptive to its environment. A client using a 1355 private IPv4 address [RFC1918] to communicate with a DNS server at an 1356 address outside that IPv4 private address block, may conclude that 1357 there is likely to be a NAT gateway on the path, and accordingly 1358 request a lower keepalive interval. 1360 By default it is RECOMMENDED that clients request, and servers grant, 1361 a keepalive interval of 60 minutes. This keepalive interval provides 1362 for reasonably timely detection if a client abruptly disconnects 1363 without cleanly closing the session, and is sufficient to maintain 1364 state in firewalls and NAT gateways that follow the IETF recommended 1365 Best Current Practice that the "established connection idle-timeout" 1366 used by middleboxes be at least 2 hours 4 minutes [RFC5382] 1367 [RFC7857]. 1369 Note that the lower the keepalive interval value, the higher the load 1370 on client and server. For example, a (hypothetical and unrealistic) 1371 keepalive interval value of 100 ms would result in a continuous 1372 stream of ten messages per second or more, in both directions, to 1373 keep the DSO Session alive. And, in this extreme example, a single 1374 packet loss and retransmission over a long path could introduce a 1375 momentary pause in the stream of messages of over 200 ms, long enough 1376 to cause the server to overzealously abort the connection. 1378 Because of this concern, the server MUST NOT send a DSO Keepalive 1379 message (either a response to a client-initiated request, or a 1380 server-initiated message) with a keepalive interval value less than 1381 ten seconds. If a client receives a DSO Keepalive message specifying 1382 a keepalive interval value less than ten seconds this is a fatal 1383 error and the client MUST forcibly abort the connection immediately. 1385 A keepalive interval value of 0xFFFFFFFF represents "infinity" and 1386 informs the client that it should generate no DSO keepalive traffic. 1387 Note that after signaling that the client should generate no DSO 1388 keepalive traffic in this way, at any point the server may revise 1389 that DSO keepalive traffic requirement by sending a new DSO Keepalive 1390 message dictating new Session Timeout values to the client. 1392 The largest *finite* keepalive interval supported by the current 1393 Keepalive TLV is 0xFFFFFFFE (2^32-2 milliseconds, approximately 49.7 1394 days). 1396 6.6. Server-Initiated Session Termination 1398 In addition to cancelling individual long-lived operations 1399 selectively (Section 5.6) there are also occasions where a server may 1400 need to terminate one or more entire sessions. An entire session may 1401 need to be terminated if the client is defective in some way, or 1402 departs from the network without closing its session. Sessions may 1403 also need to be terminated if the server becomes overloaded, or if 1404 the server is reconfigured and lacks the ability to be selective 1405 about which operations need to be cancelled. 1407 This section discusses various reasons a session may be terminated, 1408 and the mechanisms for doing so. 1410 In normal operation, closing a DSO Session is the client's 1411 responsibility. The client makes the determination of when to close 1412 a DSO Session based on an evaluation of both its own needs, and the 1413 inactivity timeout value dictated by the server. A server only 1414 causes a DSO Session to be ended in the exceptional circumstances 1415 outlined below. Some of the exceptional situations in which a server 1416 may terminate a DSO Session include: 1418 o The server application software or underlying operating system is 1419 shutting down or restarting. 1421 o The server application software terminates unexpectedly (perhaps 1422 due to a bug that makes it crash, causing the underlying operating 1423 system to send a TCP RST). 1425 o The server is undergoing a reconfiguration or maintenance 1426 procedure, that, due to the way the server software is 1427 implemented, requires clients to be disconnected. For example, 1428 some software is implemented such that it reads a configuration 1429 file at startup, and changing the server's configuration entails 1430 modifying the configuration file and then killing and restarting 1431 the server software, which generally entails a loss of network 1432 connections. 1434 o The client fails to meets its obligation to generate the required 1435 DSO keepalive traffic, or to close an inactive session by the 1436 prescribed time (twice the time interval dictated by the server, 1437 or five seconds, whichever is greater, as described in 1438 Section 6.2). 1440 o The client sends a grossly invalid or malformed request that is 1441 indicative of a seriously defective client implementation. 1443 o The server is over capacity and needs to shed some load. 1445 6.6.1. Server-Initiated Retry Delay Message 1447 In the cases described above where a server elects to terminate a DSO 1448 Session, it could do so simply by forcibly aborting the connection. 1449 However, if it did this the likely behavior of the client might be 1450 simply to to treat this as a network failure and reconnect 1451 immediately, putting more burden on the server. 1453 Therefore, to avoid this reconnection implosion, a server SHOULD 1454 instead choose to shed client load by sending a Retry Delay message, 1455 with an appropriate RCODE value informing the client of the reason 1456 the DSO Session needs to be terminated. The format of the Retry 1457 Delay TLV, and the interpretations of the various RCODE values, are 1458 described in Section 7.2. After sending a Retry Delay message, the 1459 server MUST NOT send any further messages on that DSO Session. 1461 The server MAY randomize retry delays in situations where many retry 1462 delays are sent in quick succession, so as to avoid all the clients 1463 attempting to reconnect at once. In general, implementations should 1464 avoid using the Retry Delay message in a way that would result in 1465 many clients reconnecting at the same time, if every client attempts 1466 to reconnect at the exact time specified. 1468 Upon receipt of a Retry Delay message from the server, the client 1469 MUST make note of the reconnect delay for this server, and then 1470 immediately close the connection gracefully. 1472 After sending a Retry Delay message the server SHOULD allow the 1473 client five seconds to close the connection, and if the client has 1474 not closed the connection after five seconds then the server SHOULD 1475 forcibly abort the connection. 1477 A Retry Delay message MUST NOT be initiated by a client. If a server 1478 receives a Retry Delay message this is a fatal error and the server 1479 MUST forcibly abort the connection immediately. 1481 6.6.1.1. Outstanding Operations 1483 At the instant a server chooses to initiate a Retry Delay message 1484 there may be DNS requests already in flight from client to server on 1485 this DSO Session, which will arrive at the server after its Retry 1486 Delay message has been sent. The server MUST silently ignore such 1487 incoming requests, and MUST NOT generate any response messages for 1488 them. When the Retry Delay message from the server arrives at the 1489 client, the client will determine that any DNS requests it previously 1490 sent on this DSO Session, that have not yet received a response, now 1491 will certainly not be receiving any response. Such requests should 1492 be considered failed, and should be retried at a later time, as 1493 appropriate. 1495 In the case where some, but not all, of the existing operations on a 1496 DSO Session have become invalid (perhaps because the server has been 1497 reconfigured and is no longer authoritative for some of the names), 1498 but the server is terminating all affected DSO Sessions en masse by 1499 sending them all a Retry Delay message, the reconnect delay MAY be 1500 zero, indicating that the clients SHOULD immediately attempt to re- 1501 establish operations. 1503 It is likely that some of the attempts will be successful and some 1504 will not, depending on the nature of the reconfiguration. 1506 In the case where a server is terminating a large number of DSO 1507 Sessions at once (e.g., if the system is restarting) and the server 1508 doesn't want to be inundated with a flood of simultaneous retries, it 1509 SHOULD send different reconnect delay values to each client. These 1510 adjustments MAY be selected randomly, pseudorandomly, or 1511 deterministically (e.g., incrementing the time value by one tenth of 1512 a second for each successive client, yielding a post-restart 1513 reconnection rate of ten clients per second). 1515 6.6.2. Client Reconnection 1517 After a DSO Session is ended by the server (either by sending the 1518 client a Retry Delay message, or by forcibly aborting the underlying 1519 transport connection) the client SHOULD try to reconnect, to that 1520 service instance, or to another suitable service instance, if more 1521 than one is available. If reconnecting to the same service instance, 1522 the client MUST respect the indicated delay, if available, before 1523 attempting to reconnect. Clients should not attempt to randomize the 1524 delay; the server will randomly jitter the retry delay values it 1525 sends to each client if this behavior is desired. 1527 If the service instance will only be out of service for a short 1528 maintenance period, it should use a value a little longer that the 1529 expected maintenance window. It should not default to a very large 1530 delay value, or clients may not attempt to reconnect after it resumes 1531 service. 1533 If a particular service instance does not want a client to reconnect 1534 ever (perhaps the service instance is being de-commissioned), it 1535 SHOULD set the retry delay to the maximum value 0xFFFFFFFF (2^32-1 1536 milliseconds, approximately 49.7 days). It is not possible to 1537 instruct a client to stay away for longer than 49.7 days. If, after 1538 49.7 days, the DNS or other configuration information still indicates 1539 that this is the valid service instance for a particular service, 1540 then clients MAY attempt to reconnect. In reality, if a client is 1541 rebooted or otherwise lose state, it may well attempt to reconnect 1542 before 49.7 days elapses, for as long as the DNS or other 1543 configuration information continues to indicate that this is the 1544 service instance the client should use. 1546 6.6.2.1. Reconnecting After a Forcible Abort 1548 If a connection was forcibly aborted by the client, the client SHOULD 1549 mark that service instance as not supporting DSO. The client MAY 1550 reconnect but not attempt to use DSO, or may connect to a different 1551 service instance, if applicable. 1553 6.6.2.2. Reconnecting After an Unexplained Connection Drop 1555 It is also possible for a server to forcibly terminate the 1556 connection; in this case the client doesn't know whether the 1557 termination was the result of a protocol error or a network outage. 1558 The client could determine which of the two is occurring by noticing 1559 if a connection is repeatedly dropped by the server; if so, the 1560 client can mark the server as not supporting DSO. 1562 6.6.2.3. Probing for Working DSO Support 1564 Once a server has been marked by the client as not supporting DSO, 1565 the client SHOULD NOT attempt DSO operations on that server until 1566 some time has elapsed. A reasonable minimum would be an hour. Since 1567 forcibly aborted connections are the result of a software failure, 1568 it's not likely that the problem will be solved in the first hour 1569 after it's first encountered. However, by restricting the retry 1570 interval to an hour, the client will be able to notice when the 1571 problem has been fixed without placing an undue burden on the server. 1573 7. Base TLVs for DNS Stateful Operations 1575 This section describes the three base TLVs for DNS Stateful 1576 Operations: Keepalive, Retry Delay, and Encryption Padding. 1578 7.1. Keepalive TLV 1580 The Keepalive TLV (DSO-TYPE=1) performs two functions. Primarily it 1581 establishes the values for the Session Timeouts. Incidentally, it 1582 also resets the keepalive timer for the DSO Session, meaning that it 1583 can be used as a kind of "no-op" message for the purpose of keeping a 1584 session alive. The client will request the desired session timeout 1585 values and the server will acknowledge with the response values that 1586 it requires the client to use. 1588 The DSO-DATA for the Keepalive TLV is as follows: 1590 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 1591 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 1592 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1593 | INACTIVITY TIMEOUT (32 bits) | 1594 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1595 | KEEPALIVE INTERVAL (32 bits) | 1596 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1598 INACTIVITY TIMEOUT: The inactivity timeout for the current DSO 1599 Session, specified as a 32-bit unsigned integer, in network (big 1600 endian) byte order, in units of milliseconds. This is the timeout 1601 at which the client MUST begin closing an inactive DSO Session. 1602 The inactivity timeout can be any value of the server's choosing. 1603 If the client does not gracefully close an inactive DSO Session, 1604 then after twice this interval, or five seconds, whichever is 1605 greater, the server will forcibly abort the connection. 1607 KEEPALIVE INTERVAL: The keepalive interval for the current DSO 1608 Session, specified as a 32-bit unsigned integer, in network (big 1609 endian) byte order, in units of milliseconds. This is the 1610 interval at which a client MUST generate DSO keepalive traffic to 1611 maintain connection state. The keepalive interval MUST NOT be 1612 less than ten seconds. If the client does not generate the 1613 mandated DSO keepalive traffic, then after twice this interval the 1614 server will forcibly abort the connection. Since the minimum 1615 allowed keepalive interval is ten seconds, the minimum time at 1616 which a server will forcibly disconnect a client for failing to 1617 generate the mandated DSO keepalive traffic is twenty seconds. 1619 The transmission or reception of DSO Keepalive messages (i.e., 1620 messages where the Keepalive TLV is the first TLV) reset only the 1621 keepalive timer, not the inactivity timer. The reason for this is 1622 that periodic DSO Keepalive messages are sent for the sole purpose of 1623 keeping a DSO Session alive, when that DSO Session has current or 1624 recent non-maintenance activity that warrants keeping that DSO 1625 Session alive. Sending DSO keepalive traffic itself is not 1626 considered a client activity; it is considered a maintenance activity 1627 that is performed in service of other client activities. If DSO 1628 keepalive traffic itself were to reset the inactivity timer, then 1629 that would create a circular livelock where keepalive traffic would 1630 be sent indefinitely to keep a DSO Session alive, where the only 1631 activity on that DSO Session would be the keepalive traffic keeping 1632 the DSO Session alive so that further keepalive traffic can be sent. 1633 For a DSO Session to be considered active, it must be carrying 1634 something more than just keepalive traffic. This is why merely 1635 sending or receiving a DSO Keepalive message does not reset the 1636 inactivity timer. 1638 When sent by a client, the DSO Keepalive request message MUST be sent 1639 as an DSO request message, with a nonzero MESSAGE ID. If a server 1640 receives a DSO Keepalive message with a zero MESSAGE ID then this is 1641 a fatal error and the server MUST forcibly abort the connection 1642 immediately. The DSO Keepalive request message resets a DSO 1643 Session's keepalive timer, and at the same time communicates to the 1644 server the client's requested Session Timeout values. In a server 1645 response to a client-initiated DSO Keepalive request message, the 1646 Session Timeouts contain the server's chosen values from this point 1647 forward in the DSO Session, which the client MUST respect. This is 1648 modeled after the DHCP protocol, where the client requests a certain 1649 lease lifetime using DHCP option 51 [RFC2132], but the server is the 1650 ultimate authority for deciding what lease lifetime is actually 1651 granted. 1653 When a client is sending its second and subsequent DSO Keepalive 1654 request messages to the server, the client SHOULD continue to request 1655 its preferred values each time. This allows flexibility, so that if 1656 conditions change during the lifetime of a DSO Session, the server 1657 can adapt its responses to better fit the client's needs. 1659 Once a DSO Session is in progress (Section 5.1) a DSO Keepalive 1660 message MAY be initiated by a server. When sent by a server, the DSO 1661 Keepalive message MUST be sent as a DSO unidirectional message, with 1662 the MESSAGE ID set to zero. The client MUST NOT generate a response 1663 to a server-initiated DSO Keepalive message. If a client receives a 1664 DSO Keepalive request message with a nonzero MESSAGE ID then this is 1665 a fatal error and the client MUST forcibly abort the connection 1666 immediately. The DSO Keepalive unidirectional message from the 1667 server resets a DSO Session's keepalive timer, and at the same time 1668 unilaterally informs the client of the new Session Timeout values to 1669 use from this point forward in this DSO Session. No client DSO 1670 response to this unilateral declaration is required or allowed. 1672 In DSO Keepalive response messages, the Keepalive TLV is REQUIRED and 1673 is used only as a Response Primary TLV sent as a reply to a DSO 1674 Keepalive request message from the client. A Keepalive TLV MUST NOT 1675 be added to other responses as a Response Additional TLV. If the 1676 server wishes to update a client's Session Timeout values other than 1677 in response to a DSO Keepalive request message from the client, then 1678 it does so by sending an DSO Keepalive unidirectional message of its 1679 own, as described above. 1681 It is not required that the Keepalive TLV be used in every DSO 1682 Session. While many DNS Stateful operations will be used in 1683 conjunction with a long-lived session state, not all DNS Stateful 1684 operations require long-lived session state, and in some cases the 1685 default 15-second value for both the inactivity timeout and keepalive 1686 interval may be perfectly appropriate. However, note that for 1687 clients that implement only the DSO-TYPEs defined in this document, a 1688 DSO Keepalive request message is the only way for a client to 1689 initiate a DSO Session. 1691 7.1.1. Client handling of received Session Timeout values 1693 When a client receives a response to its client-initiated DSO 1694 Keepalive message, or receives a server-initiated DSO Keepalive 1695 message, the client has then received Session Timeout values dictated 1696 by the server. The two timeout values contained in the Keepalive TLV 1697 from the server may each be higher, lower, or the same as the 1698 respective Session Timeout values the client previously had for this 1699 DSO Session. 1701 In the case of the keepalive timer, the handling of the received 1702 value is straightforward. The act of receiving the message 1703 containing the DSO Keepalive TLV itself resets the keepalive timer, 1704 and updates the keepalive interval for the DSO Session. The new 1705 keepalive interval indicates the maximum time that may elapse before 1706 another message must be sent or received on this DSO Session, if the 1707 DSO Session is to remain alive. 1709 In the case of the inactivity timeout, the handling of the received 1710 value is a little more subtle, though the meaning of the inactivity 1711 timeout remains as specified -- it still indicates the maximum 1712 permissible time allowed without useful activity on a DSO Session. 1713 The act of receiving the message containing the Keepalive TLV does 1714 not itself reset the inactivity timer. The time elapsed since the 1715 last useful activity on this DSO Session is unaffected by exchange of 1716 DSO Keepalive messages. The new inactivity timeout value in the 1717 Keepalive TLV in the received message does update the timeout 1718 associated with the running inactivity timer; that becomes the new 1719 maximum permissible time without activity on a DSO Session. 1721 o If the current inactivity timer value is less than the new 1722 inactivity timeout, then the DSO Session may remain open for now. 1723 When the inactivity timer value reaches the new inactivity 1724 timeout, the client MUST then begin closing the DSO Session, as 1725 described above. 1727 o If the current inactivity timer value is equal to the new 1728 inactivity timeout, then this DSO Session has been inactive for 1729 exactly as long as the server will permit, and now the client MUST 1730 immediately begin closing this DSO Session. 1732 o If the current inactivity timer value is already greater than the 1733 new inactivity timeout, then this DSO Session has already been 1734 inactive for longer than the server permits, and the client MUST 1735 immediately begin closing this DSO Session. 1737 o If the current inactivity timer value is already more than twice 1738 the new inactivity timeout, then the client is immediately 1739 considered delinquent (this DSO Session is immediately eligible to 1740 be forcibly terminated by the server) and the client MUST 1741 immediately begin closing this DSO Session. However if a server 1742 abruptly reduces the inactivity timeout in this way, then, to give 1743 the client time to close the connection gracefully before the 1744 server resorts to forcibly aborting it, the server SHOULD give the 1745 client an additional grace period of one quarter of the new 1746 inactivity timeout, or five seconds, whichever is greater. 1748 7.1.2. Relationship to edns-tcp-keepalive EDNS0 Option 1750 The inactivity timeout value in the Keepalive TLV (DSO-TYPE=1) has 1751 similar intent to the edns-tcp-keepalive EDNS0 Option [RFC7828]. A 1752 client/server pair that supports DSO MUST NOT use the edns-tcp- 1753 keepalive EDNS0 Option within any message after a DSO Session has 1754 been established. A client that has sent a DSO message to establish 1755 a session MUST NOT send an edns-tcp-keepalive EDNS0 Option from this 1756 point on. Once a DSO Session has been established, if either client 1757 or server receives a DNS message over the DSO Session that contains 1758 an edns-tcp-keepalive EDNS0 Option, this is a fatal error and the 1759 receiver of the edns-tcp-keepalive EDNS0 Option MUST forcibly abort 1760 the connection immediately. 1762 7.2. Retry Delay TLV 1764 The Retry Delay TLV (DSO-TYPE=2) can be used as a Primary TLV 1765 (unidirectional) in a server-to-client message, or as a Response 1766 Additional TLV in either direction. 1768 The DSO-DATA for the Retry Delay TLV is as follows: 1770 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3 1771 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 1772 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1773 | RETRY DELAY (32 bits) | 1774 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 1776 RETRY DELAY: A time value, specified as a 32-bit unsigned integer, 1777 in network (big endian) byte order, in units of milliseconds, 1778 within which the initiator MUST NOT retry this operation, or retry 1779 connecting to this server. Recommendations for the RETRY DELAY 1780 value are given in Section 6.6.1. 1782 7.2.1. Retry Delay TLV used as a Primary TLV 1784 When sent from server to client, the Retry Delay TLV is used as the 1785 Primary TLV in a DSO unidirectional message. It is used by a server 1786 to instruct a client to close the DSO Session and underlying 1787 connection, and not to reconnect for the indicated time interval. 1789 In this case it applies to the DSO Session as a whole, and the client 1790 MUST begin closing the DSO Session, as described in Section 6.6.1. 1791 The RCODE in the message header SHOULD indicate the principal reason 1792 for the termination: 1794 o NOERROR indicates a routine shutdown or restart. 1796 o FORMERR indicates that a client request was too badly malformed 1797 for the session to continue. 1799 o SERVFAIL indicates that the server is overloaded due to resource 1800 exhaustion and needs to shed load. 1802 o REFUSED indicates that the server has been reconfigured, and at 1803 this time it is now unable to perform one or more of the long- 1804 lived client operations that were previously being performed on 1805 this DSO Session. 1807 o NOTAUTH indicates that the server has been reconfigured and at 1808 this time it is now unable to perform one or more of the long- 1809 lived client operations that were previously being performed on 1810 this DSO Session because it does not have authority over the names 1811 in question (for example, a DNS Push Notification server could be 1812 reconfigured such that is is no longer accepting DNS Push 1813 Notification requests for one or more of the currently subscribed 1814 names). 1816 This document specifies only these RCODE values for the Retry Delay 1817 message. Servers sending Retry Delay messages SHOULD use one of 1818 these values. However, future circumstances may create situations 1819 where other RCODE values are appropriate in Retry Delay messages, so 1820 clients MUST be prepared to accept Retry Delay messages with any 1821 RCODE value. 1823 In some cases, when a server sends a Retry Delay message to a client, 1824 there may be more than one reason for the server wanting to end the 1825 session. Possibly the configuration could have been changed such 1826 that some long-lived client operations can no longer be continued due 1827 to policy (REFUSED), and other long-lived client operations can no 1828 longer be performed due to the server no longer being authoritative 1829 for those names (NOTAUTH). In such cases the server MAY use any of 1830 the applicable RCODE values, or RCODE=NOERROR (routine shutdown or 1831 restart). 1833 Note that the selection of RCODE value in a Retry Delay message is 1834 not critical, since the RCODE value is generally used only for 1835 information purposes, such as writing to a log file for future human 1836 analysis regarding the nature of the disconnection. Generally 1837 clients do not modify their behavior depending on the RCODE value. 1838 The RETRY DELAY in the message tells the client how long it should 1839 wait before attempting a new connection to this service instance. 1841 For clients that do in some way modify their behavior depending on 1842 the RCODE value, they should treat unknown RCODE values the same as 1843 RCODE=NOERROR (routine shutdown or restart). 1845 A Retry Delay message from server to client is a DSO unidirectional 1846 message; the MESSAGE ID MUST be set to zero in the outgoing message 1847 and the client MUST NOT send a response. 1849 A client MUST NOT send a Retry Delay DSO message to a server. If a 1850 server receives a DSO message where the Primary TLV is the Retry 1851 Delay TLV, this is a fatal error and the server MUST forcibly abort 1852 the connection immediately. 1854 7.2.2. Retry Delay TLV used as a Response Additional TLV 1856 In the case of a DSO request message that results in a nonzero RCODE 1857 value, the responder MAY append a Retry Delay TLV to the response, 1858 indicating the time interval during which the initiator SHOULD NOT 1859 attempt this operation again. 1861 The indicated time interval during which the initiator SHOULD NOT 1862 retry applies only to the failed operation, not to the DSO Session as 1863 a whole. 1865 7.3. Encryption Padding TLV 1867 The Encryption Padding TLV (DSO-TYPE=3) can only be used as an 1868 Additional or Response Additional TLV. It is only applicable when 1869 the DSO Transport layer uses encryption such as TLS. 1871 The DSO-DATA for the Padding TLV is optional and is a variable length 1872 field containing non-specified values. A DSO-LENGTH of 0 essentially 1873 provides for 4 bytes of padding (the minimum amount). 1875 1 1 1 1 1 1 1876 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 1877 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 1878 / / 1879 / PADDING -- VARIABLE NUMBER OF BYTES / 1880 / / 1881 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 1883 As specified for the EDNS(0) Padding Option [RFC7830] the PADDING 1884 bytes SHOULD be set to 0x00. Other values MAY be used, for example, 1885 in cases where there is a concern that the padded message could be 1886 subject to compression before encryption. PADDING bytes of any value 1887 MUST be accepted in the messages received. 1889 The Encryption Padding TLV may be included in either a DSO request 1890 message, response, or both. As specified for the EDNS(0) Padding 1891 Option [RFC7830] if a DSO request message is received with an 1892 Encryption Padding TLV, then the DSO response MUST also include an 1893 Encryption Padding TLV. 1895 The length of padding is intentionally not specified in this document 1896 and is a function of current best practices with respect to the type 1897 and length of data in the preceding TLVs 1898 [I-D.ietf-dprive-padding-policy]. 1900 8. Summary Highlights 1902 This section summarizes some noteworthy highlights about various 1903 aspects of the DSO protocol. 1905 8.1. QR bit and MESSAGE ID 1907 In DSO Request Messages the QR bit is 0 and the MESSAGE ID is 1908 nonzero. 1910 In DSO Response Messages the QR bit is 1 and the MESSAGE ID is 1911 nonzero. 1913 In DSO Unidirectional Messages the QR bit is 0 and the MESSAGE ID is 1914 zero. 1916 The table below illustrates which combinations are legal and how they 1917 are interpreted: 1919 +------------------------------+------------------------+ 1920 | MESSAGE ID zero | MESSAGE ID nonzero | 1921 +--------+------------------------------+------------------------+ 1922 | QR=0 | DSO unidirectional Message | DSO Request Message | 1923 +--------+------------------------------+------------------------+ 1924 | QR=1 | Invalid - Fatal Error | DSO Response Message | 1925 +--------+------------------------------+------------------------+ 1927 8.2. TLV Usage 1929 The table below indicates, for each of the three TLVs defined in this 1930 document, whether they are valid in each of ten different contexts. 1932 The first five contexts are DSO requests or DSO unidirectional 1933 messages from client to server, and the corresponding responses from 1934 server back to client: 1936 o C-P - Primary TLV, sent in DSO Request message, from client to 1937 server, with nonzero MESSAGE ID indicating that this request MUST 1938 generate response message. 1940 o C-U - Primary TLV, sent in DSO Unidirectional message, from client 1941 to server, with zero MESSAGE ID indicating that this request MUST 1942 NOT generate response message. 1944 o C-A - Additional TLV, optionally added to a DSO request message or 1945 DSO unidirectional message from client to server. 1947 o CRP - Response Primary TLV, included in response message sent back 1948 to the client (in response to a client "C-P" request with nonzero 1949 MESSAGE ID indicating that a response is required) where the DSO- 1950 TYPE of the Response TLV matches the DSO-TYPE of the Primary TLV 1951 in the request. 1953 o CRA - Response Additional TLV, included in response message sent 1954 back to the client (in response to a client "C-P" request with 1955 nonzero MESSAGE ID indicating that a response is required) where 1956 the DSO-TYPE of the Response TLV does not match the DSO-TYPE of 1957 the Primary TLV in the request. 1959 The second five contexts are their counterparts in the opposite 1960 direction: DSO requests or DSO unidirectional messages from server to 1961 client, and the corresponding responses from client back to server. 1963 o S-P - Primary TLV, sent in DSO Request message, from server to 1964 client, with nonzero MESSAGE ID indicating that this request MUST 1965 generate response message. 1967 o S-U - Primary TLV, sent in DSO Unidirectional message, from server 1968 to client, with zero MESSAGE ID indicating that this request MUST 1969 NOT generate response message. 1971 o S-A - Additional TLV, optionally added to a DSO request message or 1972 DSO unidirectional message from server to client. 1974 o SRP - Response Primary TLV, included in response message sent back 1975 to the server (in response to a server "S-P" request with nonzero 1976 MESSAGE ID indicating that a response is required) where the DSO- 1977 TYPE of the Response TLV matches the DSO-TYPE of the Primary TLV 1978 in the request. 1980 o SRA - Response Additional TLV, included in response message sent 1981 back to the server (in response to a server "S-P" request with 1982 nonzero MESSAGE ID indicating that a response is required) where 1983 the DSO-TYPE of the Response TLV does not match the DSO-TYPE of 1984 the Primary TLV in the request. 1986 +-------------------------+-------------------------+ 1987 | C-P C-U C-A CRP CRA | S-P S-U S-A SRP SRA | 1988 +------------+-------------------------+-------------------------+ 1989 | KeepAlive | X X | X | 1990 +------------+-------------------------+-------------------------+ 1991 | RetryDelay | X | X X | 1992 +------------+-------------------------+-------------------------+ 1993 | Padding | X X | X X | 1994 +------------+-------------------------+-------------------------+ 1996 Note that some of the columns in this table are currently empty. The 1997 table provides a template for future TLV definitions to follow. It 1998 is recommended that definitions of future TLVs include a similar 1999 table summarizing the contexts where the new TLV is valid. 2001 9. Additional Considerations 2003 9.1. Service Instances 2005 We use the term service instance to refer to software running on a 2006 host which can receive connections on some set of IP address and port 2007 tuples. What makes the software an instance is that regardless of 2008 which of these tuples the client uses to connect to it, the client is 2009 connected to the same software, running on the same node (but see 2010 Section 9.2), and will receive the same answers and the same keying 2011 information. 2013 Service instances are identified from the perspective of the client. 2014 If the client is configured with IP addresses and port number tuples, 2015 it has no way to tell if the service offered at one tuple is the same 2016 server that is listening on a different tuple. So in this case, the 2017 client treats each such tuple as if it references a separate service 2018 instance. 2020 In some cases a client is configured with a hostname and a port 2021 number (either implicitly, where the port number is omitted and 2022 assumed, or explicitly, as in the case of DNS SRV records). In these 2023 cases, the (hostname, port) tuple uniquely identifies the service 2024 instance (hostname comparisons are case-insensitive [RFC1034]. 2026 It is possible that two hostnames might point to some common IP 2027 addresses; this is a configuration error which the client is not 2028 obliged to detect. The effect of this could be that after being told 2029 to disconnect, the client might reconnect to the same server because 2030 it is represented as a different service instance. 2032 Implementations SHOULD NOT resolve hostnames and then perform 2033 matching of IP address(es) in order to evaluate whether two entities 2034 should be determined to be the "same service instance". 2036 9.2. Anycast Considerations 2038 When an anycast service is configured on a particular IP address and 2039 port, it must be the case that although there is more than one 2040 physical server responding on that IP address, each such server can 2041 be treated as equivalent. What we mean by "equivalent" here is that 2042 both servers can provide the same service and, where appropriate, the 2043 same authentication information, such as PKI certificates, when 2044 establishing connections. 2046 In principle, anycast servers could maintain sufficient state that 2047 they can both handle packets in the same TCP connection. In order 2048 for this to work with DSO, they would need to also share DSO state. 2049 It is unlikely that this can be done successfully, however, so we 2050 recommend that each anycast server instance maintain its own session 2051 state. 2053 If a change in network topology causes packets in a particular TCP 2054 connection to be sent to an anycast server instance that does not 2055 know about the connection, the new server will automatically 2056 terminate the connection with a TCP reset, since it will have no 2057 record of the connection, and then the client can reconnect or stop 2058 using the connection, as appropriate. 2060 If after the connection is re-established, the client's assumption 2061 that it is connected to the same service is violated in some way, 2062 that would be considered to be incorrect behavior in this context. 2063 It is however out of the possible scope for this specification to 2064 make specific recommendations in this regard; that would be up to 2065 follow-on documents that describe specific uses of DNS stateful 2066 operations. 2068 9.3. Connection Sharing 2070 As previously specified for DNS over TCP [RFC7766]: 2072 To mitigate the risk of unintentional server overload, DNS 2073 clients MUST take care to minimize the number of concurrent 2074 TCP connections made to any individual server. It is RECOMMENDED 2075 that for any given client/server interaction there SHOULD be 2076 no more than one connection for regular queries, one for zone 2077 transfers, and one for each protocol that is being used on top 2078 of TCP (for example, if the resolver was using TLS). However, 2079 it is noted that certain primary/secondary configurations 2080 with many busy zones might need to use more than one TCP 2081 connection for zone transfers for operational reasons (for 2082 example, to support concurrent transfers of multiple zones). 2084 A single server may support multiple services, including DNS Updates 2085 [RFC2136], DNS Push Notifications [I-D.ietf-dnssd-push], and other 2086 services, for one or more DNS zones. When a client discovers that 2087 the target server for several different operations is the same 2088 service instance (see Section 9.1), the client SHOULD use a single 2089 shared DSO Session for all those operations. 2091 This requirement has two benefits. First, it reduces unnecessary 2092 connection load on the DNS server. Second, it avoids paying the TCP 2093 slow start penalty when making subsequent connections to the same 2094 server. 2096 However, server implementers and operators should be aware that 2097 connection sharing may not be possible in all cases. A single host 2098 device may be home to multiple independent client software instances 2099 that don't coordinate with each other. Similarly, multiple 2100 independent client devices behind the same NAT gateway will also 2101 typically appear to the DNS server as different source ports on the 2102 same client IP address. Because of these constraints, a DNS server 2103 MUST be prepared to accept multiple connections from different source 2104 ports on the same client IP address. 2106 9.4. Zero Round-Trip Operation 2108 DSO permits zero round-trip operation using TCP Fast Open [RFC7413] 2109 and TLS 1.3 [RFC8446] to reduce or eliminate round trips in session 2110 establishment. 2112 A client MAY send multiple response-requiring DSO messages using TCP 2113 fast open or TLS 1.3 early data, without having to wait for a DSO 2114 response to the first DSO request message to confirm successful 2115 establishment of a DSO session. 2117 However, a client MUST NOT send DSO unidirectional messages until 2118 after a DSO Session has been mutually established. 2120 Similarly, a server MUST NOT send DSO request messages until it has 2121 received a response-requiring DSO request message from a client and 2122 transmitted a successful NOERROR response for that request. 2124 Caution must be taken to ensure that DSO messages sent before the 2125 first round-trip is completed are idempotent, or are otherwise immune 2126 to any problems that could be result from the inadvertent replay that 2127 can occur with zero round-trip operation. 2129 9.5. Operational Considerations for Middlebox 2131 Where an application-layer middlebox (e.g., a DNS proxy, forwarder, 2132 or session multiplexer) is in the path, care must be taken to avoid a 2133 configuration in which DSO traffic is mis-handled. The simplest way 2134 to avoid such problems is to avoid using middleboxes. When this is 2135 not possible, middleboxes should be evaluated to make sure that they 2136 behave correctly. 2138 Correct behavior for middleboxes consists of one of: 2140 o The middlebox does not forward DSO messages, and responds to DSO 2141 messages with a response code other than NOERROR or DSOTYPENI. 2143 o The middlebox acts as a DSO server and follows this specification 2144 in establishing connections. 2146 o There is a 1:1 correspondence between incoming and outgoing 2147 connections, such that when a connection is established to the 2148 middlebox, it is guaranteed that exactly one corresponding 2149 connection will be established from the middlebox to some DNS 2150 resolver, and all incoming messages will be forwarded without 2151 modification or reordering. An example of this would be a NAT 2152 forwarder or TCP connection optimizer (e.g. for a high-latency 2153 connection such as a geosynchronous satellite link). 2155 Middleboxes that do not meet one of the above criteria are very 2156 likely to fail in unexpected and difficult-to-diagnose ways. For 2157 example, a DNS load balancer might unbundle DNS messages from the 2158 incoming TCP stream and forward each message from the stream to a 2159 different DNS server. If such a load balancer is in use, and the DNS 2160 servers it points implement DSO and are configured to enable DSO, DSO 2161 session establishment will succeed, but no coherent session will 2162 exist between the client and the server. If such a load balancer is 2163 pointed at a DNS server that does not implement DSO or is configured 2164 not to allow DSO, no such problem will exist, but such a 2165 configuration risks unexpected failure if new server software is 2166 installed which does implement DSO. 2168 It is of course possible to implement a middlebox that properly 2169 supports DSO. It is even possible to implement one that implements 2170 DSO with long-lived operations. This can be done either by 2171 maintaining a 1:1 correspondence between incoming and outgoing 2172 connections, as mentioned above, or by terminating incoming sessions 2173 at the middlebox, but maintaining state in the middlebox about any 2174 long-lived that are requested. Specifying this in detail is beyond 2175 the scope of this document. 2177 9.6. TCP Delayed Acknowledgement Considerations 2179 Most modern implementations of the Transmission Control Protocol 2180 (TCP) include a feature called "Delayed Acknowledgement" [RFC1122]. 2182 Without this feature, TCP can be very wasteful on the network. For 2183 illustration, consider a simple example like remote login, using a 2184 very simple TCP implementation that lacks delayed acks. When the 2185 user types a keystroke, a data packet is sent. When the data packet 2186 arrives at the server, the simple TCP implementation sends an 2187 immediate acknowledgement. Mere milliseconds later, the server 2188 process reads the one byte of keystroke data, and consequently the 2189 simple TCP implementation sends an immediate window update. Mere 2190 milliseconds later, the server process generates the character echo, 2191 and sends this data back in reply. The simple TCP implementation 2192 then sends this data packet immediately too. In this case, this 2193 simple TCP implementation sends a burst of three packets almost 2194 instantaneously (ack, window update, data). 2196 Clearly it would be more efficient if the TCP implementation were to 2197 combine the three separate packets into one, and this is what the 2198 delayed ack feature enables. 2200 With delayed ack, the TCP implementation waits after receiving a data 2201 packet, typically for 200 ms, and then send its ack if (a) more data 2202 packet(s) arrive (b) the receiving process generates some reply data, 2203 or (c) 200 ms elapses without either of the above occurring. 2205 With delayed ack, remote login becomes much more efficient, 2206 generating just one packet instead of three for each character echo. 2208 The logic of delayed ack is that the 200 ms delay cannot do any 2209 significant harm. If something at the other end were waiting for 2210 something, then the receiving process should generate the reply that 2211 the thing at the end is waiting for, and TCP will then immediately 2212 send that reply (and the ack and window update). And if the 2213 receiving process does not in fact generate any reply for this 2214 particular message, then by definition the thing at the other end 2215 cannot be waiting for anything, so the 200 ms delay is harmless. 2217 This assumption may be true, unless the sender is using Nagle's 2218 algorithm, a similar efficiency feature, created to protect the 2219 network from poorly written client software that performs many rapid 2220 small writes in succession. Nagle's algorithm allows these small 2221 writes to be combined into larger, less wasteful packets. 2223 Unfortunately, Nagle's algorithm and delayed ack, two valuable 2224 efficiency features, can interact badly with each other when used 2225 together [NagleDA]. 2227 DSO request messages elicit responses; DSO unidirectional messages 2228 and DSO response messages do not. 2230 For DSO request messages, which do elicit responses, Nagle's 2231 algorithm and delayed ack work as intended. 2233 For DSO messages that do not elicit responses, the delayed ack 2234 mechanism causes the ack to be delayed by 200 ms. The 200 ms delay 2235 on the ack can in turn cause Nagle's algorithm to prevent the sender 2236 from sending any more data for 200 ms until the awaited ack arrives. 2237 On an enterprise GigE backbone with sub-millisecond round-trip times, 2238 a 200 ms delay is enormous in comparison. 2240 When this issues is raised, there are two solutions that are often 2241 offered, neither of them ideal: 2243 1. Disable delayed ack. For DSO messages that elicit no response, 2244 removing delayed ack avoids the needless 200 ms delay, and sends 2245 back an immediate ack, which tells Nagle's algorithm that it 2246 should immediately grant the sender permission to send its next 2247 packet. Unfortunately, for DSO messages that *do* elicit a 2248 response, removing delayed ack removes the efficiency gains of 2249 combining acks with data, and the responder will now send two or 2250 three packets instead of one. 2252 2. Disable Nagle's algorithm. When acks are delayed by the delayed 2253 ack algorithm, removing Nagle's algorithm prevents the sender 2254 from being blocked from sending its next small packet 2255 immediately. Unfortunately, on a network with a higher round- 2256 trip time, removing Nagle's algorithm removes the efficiency 2257 gains of combining multiple small packets into fewer larger ones, 2258 with the goal of limiting the number of small packets in flight 2259 at any one time. 2261 For DSO messages that elicit a response, delayed ack and Nagle's 2262 algorithm do the right thing. 2264 The problem here is that with DSO messages that elicit no response, 2265 the TCP implementation is stuck waiting, unsure if a response is 2266 about to be generated, or whether the TCP implementation should go 2267 ahead and send an ack and window update. 2269 The solution is networking APIs that allow the receiver to inform the 2270 TCP implementation that a received message has been read, processed, 2271 and no response for this message will be generated. TCP can then 2272 stop waiting for a response that will never come, and immediately go 2273 ahead and send an ack and window update. 2275 For implementations of DSO, disabling delayed ack is NOT RECOMMENDED, 2276 because of the harm this can do to the network. 2278 For implementations of DSO, disabling Nagle's algorithm is NOT 2279 RECOMMENDED, because of the harm this can do to the network. 2281 At the time that this document is being prepared for publication, it 2282 is known that at least one TCP implementation provides the ability 2283 for the recipient of a TCP message to signal that it is not going to 2284 send a response, and hence the delayed ack mechanism can stop 2285 waiting. Implementations on operating systems where this feature is 2286 available SHOULD make use of it. 2288 10. IANA Considerations 2290 10.1. DSO OPCODE Registration 2292 The IANA is requested to record the value [TBA1] (tentatively 6) for 2293 the DSO OPCODE in the DNS OPCODE Registry. DSO stands for DNS 2294 Stateful Operations. 2296 10.2. DSO RCODE Registration 2298 The IANA is requested to record the value [TBA2] (tentatively 11) for 2299 the DSOTYPENI error code in the DNS RCODE Registry. The DSOTYPENI 2300 error code ("DSO-TYPE Not Implemented") indicates that the receiver 2301 does implement DNS Stateful Operations, but does not implement the 2302 specific DSO-TYPE of the primary TLV in the DSO request message. 2304 10.3. DSO Type Code Registry 2306 The IANA is requested to create the 16-bit DSO Type Code Registry, 2307 with initial (hexadecimal) values as shown below: 2309 +-----------+--------------------------------+----------+-----------+ 2310 | Type | Name | Status | Reference | 2311 +-----------+--------------------------------+----------+-----------+ 2312 | 0000 | Reserved | Standard | RFC-TBD | 2313 | | | | | 2314 | 0001 | KeepAlive | Standard | RFC-TBD | 2315 | | | | | 2316 | 0002 | RetryDelay | Standard | RFC-TBD | 2317 | | | | | 2318 | 0003 | EncryptionPadding | Standard | RFC-TBD | 2319 | | | | | 2320 | 0004-003F | Unassigned, reserved for | | | 2321 | | DSO session-management TLVs | | | 2322 | | | | | 2323 | 0040-F7FF | Unassigned | | | 2324 | | | | | 2325 | F800-FBFF | Experimental/local use | | | 2326 | | | | | 2327 | FC00-FFFF | Reserved for future expansion | | | 2328 +-----------+--------------------------------+----------+-----------+ 2330 DSO Type Code zero is reserved and is not currently intended for 2331 allocation. 2333 Registrations of new DSO Type Codes in the "Reserved for DSO session- 2334 management" range 0004-003F and the "Reserved for future expansion" 2335 range FC00-FFFF require publication of an IETF Standards Action 2336 document [RFC8126]. 2338 Requests to register additional new DSO Type Codes in the 2339 "Unassigned" range 0040-F7FF are to be recorded by IANA after Expert 2340 Review [RFC8126]. The expert review should validate that the 2341 requested type code is specified in a way that conforms to this 2342 specification, and that the intended use for the code would not be 2343 addressed with an experimental/local assignment. 2345 DSO Type Codes in the "experimental/local" range F800-FBFF may be 2346 used as Experimental Use or Private Use values [RFC8126] and may be 2347 used freely for development purposes, or for other purposes within a 2348 single site. No attempt is made to prevent multiple sites from using 2349 the same value in different (and incompatible) ways. There is no 2350 need for IANA to review such assignments (since IANA does not record 2351 them) and assignments are not generally useful for broad 2352 interoperability. It is the responsibility of the sites making use 2353 of "experimental/local" values to ensure that no conflicts occur 2354 within the intended scope of use. 2356 11. Security Considerations 2358 If this mechanism is to be used with DNS over TLS, then these 2359 messages are subject to the same constraints as any other DNS-over- 2360 TLS messages and MUST NOT be sent in the clear before the TLS session 2361 is established. 2363 The data field of the "Encryption Padding" TLV could be used as a 2364 covert channel. 2366 When designing new DSO TLVs, the potential for data in the TLV to be 2367 used as a tracking identifier should be taken into consideration, and 2368 should be avoided when not required. 2370 When used without TLS or similar cryptographic protection, a 2371 malicious entity maybe able to inject a malicious unidirectional DSO 2372 Retry Delay Message into the data stream, specifying an unreasonably 2373 large RETRY DELAY, causing a denial-of-service attack against the 2374 client. 2376 The establishment of DSO sessions has an impact on the number of open 2377 TCP connections on a DNS server. Additional resources may be used on 2378 the server as a result. However, because the server can limit the 2379 number of DSO sessions established and can also close existing DSO 2380 sessions as needed, denial of service or resource exhaustion should 2381 not be a concern. 2383 11.1. TCP Fast Open Considerations 2385 It would be possible to add a TLV that requires the server to do some 2386 significant work, and send that to the server as initial data in a 2387 TCP SYN packet. A flood of such packets could be used as a DoS 2388 attack on the server. None of the TLVs defined here have this 2389 property. If a new TLV is specified that does have this property, 2390 the specification should require that some kind of exchange be done 2391 with the server before work is done. That is, the TLV that requires 2392 work could not be processed without a round-trip from the server to 2393 the client to verify that the source address of the packet is 2394 reachable. 2396 One way to accomplish this would be to have the client send a TLV 2397 indicating that it wishes to have the server do work of this sort; 2398 this TLV would not actually result in work being done, but would 2399 request a nonce from the server. The client could then use that 2400 nonce to request that work be done. 2402 Alternatively, the server could simply disable TCP fast open. This 2403 same problem would exist for DNS-over-TLS with TLS early data; the 2404 same remedies would apply. 2406 12. Acknowledgements 2408 Thanks to Stephane Bortzmeyer, Tim Chown, Ralph Droms, Paul Hoffman, 2409 Jan Komissar, Edward Lewis, Allison Mankin, Rui Paulo, David 2410 Schinazi, Manju Shankar Rao, and Bernie Volz for their helpful 2411 contributions to this document. 2413 13. References 2415 13.1. Normative References 2417 [RFC1034] Mockapetris, P., "Domain names - concepts and facilities", 2418 STD 13, RFC 1034, DOI 10.17487/RFC1034, November 1987, 2419 . 2421 [RFC1035] Mockapetris, P., "Domain names - implementation and 2422 specification", STD 13, RFC 1035, DOI 10.17487/RFC1035, 2423 November 1987, . 2425 [RFC1918] Rekhter, Y., Moskowitz, B., Karrenberg, D., de Groot, G., 2426 and E. Lear, "Address Allocation for Private Internets", 2427 BCP 5, RFC 1918, DOI 10.17487/RFC1918, February 1996, 2428 . 2430 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 2431 Requirement Levels", BCP 14, RFC 2119, 2432 DOI 10.17487/RFC2119, March 1997, . 2435 [RFC2136] Vixie, P., Ed., Thomson, S., Rekhter, Y., and J. Bound, 2436 "Dynamic Updates in the Domain Name System (DNS UPDATE)", 2437 RFC 2136, DOI 10.17487/RFC2136, April 1997, 2438 . 2440 [RFC6891] Damas, J., Graff, M., and P. Vixie, "Extension Mechanisms 2441 for DNS (EDNS(0))", STD 75, RFC 6891, 2442 DOI 10.17487/RFC6891, April 2013, . 2445 [RFC7766] Dickinson, J., Dickinson, S., Bellis, R., Mankin, A., and 2446 D. Wessels, "DNS Transport over TCP - Implementation 2447 Requirements", RFC 7766, DOI 10.17487/RFC7766, March 2016, 2448 . 2450 [RFC7830] Mayrhofer, A., "The EDNS(0) Padding Option", RFC 7830, 2451 DOI 10.17487/RFC7830, May 2016, . 2454 [RFC8126] Cotton, M., Leiba, B., and T. Narten, "Guidelines for 2455 Writing an IANA Considerations Section in RFCs", BCP 26, 2456 RFC 8126, DOI 10.17487/RFC8126, June 2017, 2457 . 2459 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2460 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2461 May 2017, . 2463 13.2. Informative References 2465 [I-D.ietf-dnsop-no-response-issue] 2466 Andrews, M. and R. Bellis, "A Common Operational Problem 2467 in DNS Servers - Failure To Respond.", draft-ietf-dnsop- 2468 no-response-issue-11 (work in progress), July 2018. 2470 [I-D.ietf-dnssd-mdns-relay] 2471 Lemon, T. and S. Cheshire, "Multicast DNS Discovery 2472 Relay", draft-ietf-dnssd-mdns-relay-01 (work in progress), 2473 July 2018. 2475 [I-D.ietf-dnssd-push] 2476 Pusateri, T. and S. Cheshire, "DNS Push Notifications", 2477 draft-ietf-dnssd-push-14 (work in progress), March 2018. 2479 [I-D.ietf-doh-dns-over-https] 2480 Hoffman, P. and P. McManus, "DNS Queries over HTTPS 2481 (DoH)", draft-ietf-doh-dns-over-https-14 (work in 2482 progress), August 2018. 2484 [I-D.ietf-dprive-padding-policy] 2485 Mayrhofer, A., "Padding Policy for EDNS(0)", draft-ietf- 2486 dprive-padding-policy-06 (work in progress), July 2018. 2488 [NagleDA] Cheshire, S., "TCP Performance problems caused by 2489 interaction between Nagle's Algorithm and Delayed ACK", 2490 May 2005, 2491 . 2493 [RFC1122] Braden, R., Ed., "Requirements for Internet Hosts - 2494 Communication Layers", STD 3, RFC 1122, 2495 DOI 10.17487/RFC1122, October 1989, . 2498 [RFC2132] Alexander, S. and R. Droms, "DHCP Options and BOOTP Vendor 2499 Extensions", RFC 2132, DOI 10.17487/RFC2132, March 1997, 2500 . 2502 [RFC5382] Guha, S., Ed., Biswas, K., Ford, B., Sivakumar, S., and P. 2503 Srisuresh, "NAT Behavioral Requirements for TCP", BCP 142, 2504 RFC 5382, DOI 10.17487/RFC5382, October 2008, 2505 . 2507 [RFC6762] Cheshire, S. and M. Krochmal, "Multicast DNS", RFC 6762, 2508 DOI 10.17487/RFC6762, February 2013, . 2511 [RFC6763] Cheshire, S. and M. Krochmal, "DNS-Based Service 2512 Discovery", RFC 6763, DOI 10.17487/RFC6763, February 2013, 2513 . 2515 [RFC7413] Cheng, Y., Chu, J., Radhakrishnan, S., and A. Jain, "TCP 2516 Fast Open", RFC 7413, DOI 10.17487/RFC7413, December 2014, 2517 . 2519 [RFC7828] Wouters, P., Abley, J., Dickinson, S., and R. Bellis, "The 2520 edns-tcp-keepalive EDNS0 Option", RFC 7828, 2521 DOI 10.17487/RFC7828, April 2016, . 2524 [RFC7857] Penno, R., Perreault, S., Boucadair, M., Ed., Sivakumar, 2525 S., and K. Naito, "Updates to Network Address Translation 2526 (NAT) Behavioral Requirements", BCP 127, RFC 7857, 2527 DOI 10.17487/RFC7857, April 2016, . 2530 [RFC7858] Hu, Z., Zhu, L., Heidemann, J., Mankin, A., Wessels, D., 2531 and P. Hoffman, "Specification for DNS over Transport 2532 Layer Security (TLS)", RFC 7858, DOI 10.17487/RFC7858, May 2533 2016, . 2535 [RFC8446] Rescorla, E., "The Transport Layer Security (TLS) Protocol 2536 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 2537 . 2539 Authors' Addresses 2541 Ray Bellis 2542 Internet Systems Consortium, Inc. 2543 950 Charter Street 2544 Redwood City CA 94063 2545 USA 2547 Phone: +1 (650) 423-1200 2548 Email: ray@isc.org 2550 Stuart Cheshire 2551 Apple Inc. 2552 One Apple Park Way 2553 Cupertino CA 95014 2554 USA 2556 Phone: +1 (408) 996-1010 2557 Email: cheshire@apple.com 2559 John Dickinson 2560 Sinodun Internet Technologies 2561 Magadalen Centre 2562 Oxford Science Park 2563 Oxford OX4 4GA 2564 United Kingdom 2566 Email: jad@sinodun.com 2567 Sara Dickinson 2568 Sinodun Internet Technologies 2569 Magadalen Centre 2570 Oxford Science Park 2571 Oxford OX4 4GA 2572 United Kingdom 2574 Email: sara@sinodun.com 2576 Ted Lemon 2577 Nibbhaya Consulting 2578 P.O. Box 958 2579 Brattleboro VT 05302-0958 2580 USA 2582 Email: mellon@fugue.com 2584 Tom Pusateri 2585 Unaffiliated 2586 Raleigh NC 27608 2587 USA 2589 Phone: +1 (919) 867-1330 2590 Email: pusateri@bangj.com