mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
Make fast-retry more configurable and do exponential backoff.
This commit is contained in:
@@ -105,11 +105,14 @@ Dnsmasq limits the value of this option to one hour, unless recompiled.
|
||||
.B --auth-ttl=<time>
|
||||
Set the TTL value returned in answers from the authoritative server.
|
||||
.TP
|
||||
.B --fast-dns-retry=<time in ms>
|
||||
.B --fast-dns-retry=[<initial retry delay in ms>[,<time to continue retries in ms>]]
|
||||
Under normal circumstances, dnsmasq relies on DNS clients to do retries; it
|
||||
does not generate timeouts itself. Setting this option
|
||||
instructs dnsmasq to generate its own retries after the specified time, which
|
||||
must be greater than 500ms. Using this option increases memory usage and
|
||||
instructs dnsmasq to generate its own retries starting after a delay
|
||||
which defaults to 1000ms. If the second parameter is given this controls
|
||||
how long the retries will continue for
|
||||
otherwise this defaults to 10000ms. Retries are repeated with exponential
|
||||
backoff. Using this option increases memory usage and
|
||||
network bandwidth.
|
||||
.TP
|
||||
.B \-k, --keep-in-foreground
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
#define SOA_EXPIRY 1209600 /* SOA expiry default */
|
||||
#define LOOP_TEST_DOMAIN "test" /* domain for loop testing, "test" is reserved by RFC 2606 and won't therefore clash */
|
||||
#define LOOP_TEST_TYPE T_TXT
|
||||
#define DEFAULT_FAST_RETRY 1000 /* ms, default delay before fast retry */
|
||||
|
||||
/* compile-time options: uncomment below to enable or do eg.
|
||||
make COPTS=-DHAVE_BROKEN_RTC
|
||||
|
||||
@@ -758,6 +758,7 @@ struct frec {
|
||||
int forwardall, flags;
|
||||
time_t time;
|
||||
u32 forward_timestamp;
|
||||
int forward_delay;
|
||||
unsigned char *hash[HASH_SIZE];
|
||||
struct blockdata *stash; /* Saved reply, whilst we validate */
|
||||
size_t stash_len;
|
||||
@@ -1187,7 +1188,7 @@ extern struct daemon {
|
||||
int dump_mask;
|
||||
unsigned long soa_sn, soa_refresh, soa_retry, soa_expiry;
|
||||
u32 metrics[__METRIC_MAX];
|
||||
int fast_retry_time;
|
||||
int fast_retry_time, fast_retry_timeout;
|
||||
#ifdef HAVE_DNSSEC
|
||||
struct ds_config *ds;
|
||||
char *timestamp_file;
|
||||
|
||||
@@ -608,7 +608,7 @@ int fast_retry(time_t now)
|
||||
u32 millis = dnsmasq_milliseconds();
|
||||
|
||||
for (f = daemon->frec_list; f; f = f->next)
|
||||
if (f->sentto && f->stash && difftime(now, f->time) < TIMEOUT)
|
||||
if (f->sentto && f->stash && difftime(now, f->time) < daemon->fast_retry_timeout)
|
||||
{
|
||||
#ifdef HAVE_DNSSEC
|
||||
if (f->blocking_query)
|
||||
@@ -617,8 +617,8 @@ int fast_retry(time_t now)
|
||||
/* t is milliseconds since last query sent. */
|
||||
int to_run, t = (int)(millis - f->forward_timestamp);
|
||||
|
||||
if (t < daemon->fast_retry_time)
|
||||
to_run = daemon->fast_retry_time - t;
|
||||
if (t < f->forward_delay)
|
||||
to_run = f->forward_delay - t;
|
||||
else
|
||||
{
|
||||
unsigned char *udpsz;
|
||||
@@ -639,7 +639,7 @@ int fast_retry(time_t now)
|
||||
forward_query(-1, NULL, NULL, 0, header, f->stash_len, ((char *) header) + udp_size, now, f,
|
||||
f->flags & FREC_AD_QUESTION, f->flags & FREC_DO_QUESTION);
|
||||
|
||||
to_run = daemon->fast_retry_time;
|
||||
to_run = f->forward_delay = 2 * f->forward_delay;
|
||||
}
|
||||
|
||||
if (ret == -1 || ret > to_run)
|
||||
@@ -2822,7 +2822,10 @@ static struct frec *get_new_frec(time_t now, struct server *master, int force)
|
||||
}
|
||||
|
||||
if (target)
|
||||
target->time = now;
|
||||
{
|
||||
target->time = now;
|
||||
target->forward_delay = daemon->fast_retry_time;
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
30
src/option.c
30
src/option.c
@@ -370,7 +370,7 @@ static const struct myoption opts[] =
|
||||
{ "umbrella", 2, 0, LOPT_UMBRELLA },
|
||||
{ "quiet-tftp", 0, 0, LOPT_QUIET_TFTP },
|
||||
{ "port-limit", 1, 0, LOPT_RANDPORT_LIM },
|
||||
{ "fast-dns-retry", 1, 0, LOPT_FAST_RETRY },
|
||||
{ "fast-dns-retry", 2, 0, LOPT_FAST_RETRY },
|
||||
{ "use-stale-cache", 0, 0 , LOPT_STALE_CACHE },
|
||||
{ NULL, 0, 0, 0 }
|
||||
};
|
||||
@@ -3230,13 +3230,27 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
||||
}
|
||||
|
||||
case LOPT_FAST_RETRY:
|
||||
{
|
||||
int retry;
|
||||
if (!atoi_check(arg, &retry) || retry < 500)
|
||||
ret_err(gen_err);
|
||||
daemon->fast_retry_time = retry;
|
||||
break;
|
||||
}
|
||||
daemon->fast_retry_timeout = TIMEOUT;
|
||||
|
||||
if (!arg)
|
||||
daemon->fast_retry_time = DEFAULT_FAST_RETRY;
|
||||
else
|
||||
{
|
||||
int retry;
|
||||
|
||||
comma = split(arg);
|
||||
if (!atoi_check(arg, &retry) || retry < 50)
|
||||
ret_err(gen_err);
|
||||
daemon->fast_retry_time = retry;
|
||||
|
||||
if (comma)
|
||||
{
|
||||
if (!atoi_check(comma, &retry))
|
||||
ret_err(gen_err);
|
||||
daemon->fast_retry_timeout = retry/1000;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef HAVE_DHCP
|
||||
case 'X': /* --dhcp-lease-max */
|
||||
|
||||
Reference in New Issue
Block a user