mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
resolve: fix misuse of accuracy parameter in sd_event_add_time()
Also, this makes mDNS regular queries sent without delay (except for one caused by the default accuracy of sd-event). Note, RFC 6762 Section 5.2 is about continuous mDNS query, which is not implemented yet.
This commit is contained in:
parent
4b2ceb8a48
commit
765647ba80
@ -1204,7 +1204,6 @@ static int on_conflict_dispatch(sd_event_source *es, usec_t usec, void *userdata
|
||||
}
|
||||
|
||||
int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr) {
|
||||
usec_t jitter;
|
||||
int r;
|
||||
|
||||
assert(scope);
|
||||
@ -1233,15 +1232,12 @@ int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr) {
|
||||
if (scope->conflict_event_source)
|
||||
return 0;
|
||||
|
||||
random_bytes(&jitter, sizeof(jitter));
|
||||
jitter %= LLMNR_JITTER_INTERVAL_USEC;
|
||||
|
||||
r = sd_event_add_time_relative(
|
||||
scope->manager->event,
|
||||
&scope->conflict_event_source,
|
||||
CLOCK_BOOTTIME,
|
||||
jitter,
|
||||
LLMNR_JITTER_INTERVAL_USEC,
|
||||
random_u64_range(LLMNR_JITTER_INTERVAL_USEC),
|
||||
0,
|
||||
on_conflict_dispatch, scope);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to add conflict dispatch event: %m");
|
||||
@ -1511,7 +1507,7 @@ int dns_scope_announce(DnsScope *scope, bool goodbye) {
|
||||
&scope->announce_event_source,
|
||||
CLOCK_BOOTTIME,
|
||||
MDNS_ANNOUNCE_DELAY,
|
||||
MDNS_JITTER_RANGE_USEC,
|
||||
0,
|
||||
on_announcement_timeout, scope);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to schedule second announcement: %m");
|
||||
|
@ -1951,10 +1951,12 @@ int dns_transaction_go(DnsTransaction *t) {
|
||||
|
||||
if (!t->initial_jitter_scheduled &&
|
||||
IN_SET(t->scope->protocol, DNS_PROTOCOL_LLMNR, DNS_PROTOCOL_MDNS)) {
|
||||
usec_t jitter, accuracy;
|
||||
usec_t jitter;
|
||||
|
||||
/* RFC 4795 Section 2.7 suggests all queries should be delayed by a random time from 0 to
|
||||
* JITTER_INTERVAL. */
|
||||
/* RFC 4795 Section 2.7 suggests all LLMNR queries should be delayed by a random time from 0 to
|
||||
* JITTER_INTERVAL.
|
||||
* RFC 6762 Section 8.1 suggests initial probe queries should be delayed by a random time from
|
||||
* 0 to 250ms. */
|
||||
|
||||
t->initial_jitter_scheduled = true;
|
||||
|
||||
@ -1962,12 +1964,13 @@ int dns_transaction_go(DnsTransaction *t) {
|
||||
|
||||
case DNS_PROTOCOL_LLMNR:
|
||||
jitter = random_u64_range(LLMNR_JITTER_INTERVAL_USEC);
|
||||
accuracy = LLMNR_JITTER_INTERVAL_USEC;
|
||||
break;
|
||||
|
||||
case DNS_PROTOCOL_MDNS:
|
||||
jitter = usec_add(random_u64_range(MDNS_JITTER_RANGE_USEC), MDNS_JITTER_MIN_USEC);
|
||||
accuracy = MDNS_JITTER_RANGE_USEC;
|
||||
if (t->probing)
|
||||
jitter = random_u64_range(MDNS_PROBING_INTERVAL_USEC);
|
||||
else
|
||||
jitter = 0;
|
||||
break;
|
||||
default:
|
||||
assert_not_reached();
|
||||
@ -1979,7 +1982,7 @@ int dns_transaction_go(DnsTransaction *t) {
|
||||
t->scope->manager->event,
|
||||
&t->timeout_event_source,
|
||||
CLOCK_BOOTTIME,
|
||||
jitter, accuracy,
|
||||
jitter, 0,
|
||||
on_transaction_timeout, t);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
@ -201,10 +201,6 @@ DnsTransactionSource dns_transaction_source_from_string(const char *s) _pure_;
|
||||
/* LLMNR Jitter interval, see RFC 4795 Section 7 */
|
||||
#define LLMNR_JITTER_INTERVAL_USEC (100 * USEC_PER_MSEC)
|
||||
|
||||
/* mDNS Jitter interval, see RFC 6762 Section 5.2 */
|
||||
#define MDNS_JITTER_MIN_USEC (20 * USEC_PER_MSEC)
|
||||
#define MDNS_JITTER_RANGE_USEC (100 * USEC_PER_MSEC)
|
||||
|
||||
/* mDNS probing interval, see RFC 6762 Section 8.1 */
|
||||
#define MDNS_PROBING_INTERVAL_USEC (250 * USEC_PER_MSEC)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user