Debian Codegraph @

src/resolve/resolved-timeouts.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "resolved-def.h"
5 #include "time-util.h"
6
7 /* LLMNR Jitter interval, see RFC 4795 Section 7 */
8 #define LLMNR_JITTER_INTERVAL_USEC (100 * USEC_PER_MSEC)
9
10 /* mDNS probing interval, see RFC 6762 Section 8.1 */
11 #define MDNS_PROBING_INTERVAL_USEC (250 * USEC_PER_MSEC)
12
13 /* Maximum attempts to send DNS requests, across all DNS servers */
14 #define DNS_TRANSACTION_ATTEMPTS_MAX 24
15
16 /* Maximum attempts to send LLMNR requests, see RFC 4795 Section 2.7 */
17 #define LLMNR_TRANSACTION_ATTEMPTS_MAX 3
18
19 /* Maximum attempts to send MDNS requests, see RFC 6762 Section 8.1 */
20 #define MDNS_TRANSACTION_ATTEMPTS_MAX 3
21
22 /* Maximum attempts to send an mDNS continuous query.
23 *
24 * RFC 6762 Section 5.2 does not specify a maximum number of attempts directly.
25 * However, it outlines two important guidelines:
26 *
27 * 1. The interval between the first two queries MUST be at least one second.
28 * 2. The intervals between successive queries MUST increase by at least a factor of two.
29 *
30 * To adhere to these timing requirements for continuous queries,
31 * the maximum number of attempts should be set to 1.
32 */
33 #define MDNS_TRANSACTION_CONTINUOUS_QUERY_MAX 1U
34
35 static inline unsigned dns_transaction_attempts_max(DnsProtocol p, uint64_t query_flags) {
36 switch (p) {
37
38 case DNS_PROTOCOL_LLMNR:
39 return LLMNR_TRANSACTION_ATTEMPTS_MAX;
40
41 case DNS_PROTOCOL_MDNS:
42 if (FLAGS_SET(query_flags, SD_RESOLVED_QUERY_CONTINUOUS))
43 return MDNS_TRANSACTION_CONTINUOUS_QUERY_MAX;
44 else
45 return MDNS_TRANSACTION_ATTEMPTS_MAX;
46
47 default:
48 return DNS_TRANSACTION_ATTEMPTS_MAX;
49 }
50 }
51
52 /* After how much time to repeat classic DNS requests */
53 #define TRANSACTION_UDP_TIMEOUT_USEC (SD_RESOLVED_QUERY_TIMEOUT_USEC / DNS_TRANSACTION_ATTEMPTS_MAX)
54
55 /* When we do TCP, grant a much longer timeout, as in this case there's no need for us to quickly
56 * resend, as the kernel does that anyway for us, and we really don't want to interrupt it in that
57 * needlessly. */
58 #define TRANSACTION_TCP_TIMEOUT_USEC (10 * USEC_PER_SEC)
59
60 /* Should be longer than transaction timeout for a single UDP transaction, so we get at least
61 * one transaction retry before timeouting the whole candidate */
62 #define CANDIDATE_EXPEDITED_TIMEOUT_USEC (TRANSACTION_UDP_TIMEOUT_USEC + 1 * USEC_PER_SEC)