Commit ab8b39df authored by Daniel Salzman's avatar Daniel Salzman

conf: add MIN and MAX zone refresh interval options

Based on work by Manabu Sonoda <manabu-s@iij.ad.jp>.
parent 50b98d1c
......@@ -925,6 +925,8 @@ zone:
dnssec\-policy: STR
request\-edns\-option: INT:[HEXSTR]
serial\-policy: increment | unixtime
min\-refresh\-interval: TIME
max\-refresh\-interval: TIME
module: STR/STR ...
.ft P
.fi
......@@ -1173,6 +1175,16 @@ done by hand (see RFC 1982).
.UNINDENT
.sp
\fIDefault:\fP increment
.SS min\-refresh\-interval
.sp
Forced minimum zone refresh interval to avoid flooding master.
.sp
\fIDefault:\fP 2
.SS max\-refresh\-interval
.sp
Forced maximum zone refresh interval.
.sp
\fIDefault:\fP not set
.SS module
.sp
An ordered list of references to query modules in the form of \fImodule_name\fP or
......
......@@ -1064,6 +1064,8 @@ Definition of zones served by the server.
dnssec-policy: STR
request-edns-option: INT:[HEXSTR]
serial-policy: increment | unixtime
min-refresh-interval: TIME
max-refresh-interval: TIME
module: STR/STR ...
.. _zone_domain:
......@@ -1332,6 +1334,24 @@ Possible values:
*Default:* increment
.. _zone_min-refresh-interval:
min-refresh-interval
--------------------
Forced minimum zone refresh interval to avoid flooding master.
*Default:* 2
.. _zone_max-refresh-interval:
max-refresh-interval
--------------------
Forced maximum zone refresh interval.
*Default:* not set
.. _zone_module:
module
......
......@@ -266,6 +266,8 @@ static const yp_item_t desc_policy[] = {
{ C_DNSSEC_POLICY, YP_TREF, YP_VREF = { C_POLICY }, FLAGS, { check_ref_dflt } }, \
{ C_SERIAL_POLICY, YP_TOPT, YP_VOPT = { serial_policies, SERIAL_POLICY_INCREMENT } }, \
{ C_REQUEST_EDNS_OPTION, YP_TDATA, YP_VDATA = { 0, NULL, edns_opt_to_bin, edns_opt_to_txt } }, \
{ C_MAX_REFRESH_INTERVAL,YP_TINT, YP_VINT = { 2, UINT32_MAX, UINT32_MAX, YP_STIME } }, \
{ C_MIN_REFRESH_INTERVAL,YP_TINT, YP_VINT = { 2, UINT32_MAX, 2, YP_STIME } }, \
{ C_MODULE, YP_TDATA, YP_VDATA = { 0, NULL, mod_id_to_bin, mod_id_to_txt }, \
YP_FMULTI | FLAGS, { check_modref } }, \
{ C_COMMENT, YP_TSTR, YP_VNONE }, \
......
......@@ -73,12 +73,14 @@
#define C_MAX_JOURNAL_USAGE "\x11""max-journal-usage"
#define C_MAX_JOURNAL_DEPTH "\x11""max-journal-depth"
#define C_MAX_KASP_DB_SIZE "\x10""max-kasp-db-size"
#define C_MAX_REFRESH_INTERVAL "\x14""max-refresh-interval"
#define C_MAX_TCP_CLIENTS "\x0F""max-tcp-clients"
#define C_MAX_TIMER_DB_SIZE "\x11""max-timer-db-size"
#define C_MAX_UDP_PAYLOAD "\x0F""max-udp-payload"
#define C_MAX_ZONE_SIZE "\x0D""max-zone-size"
#define C_MAX_IPV4_UDP_PAYLOAD "\x14""max-ipv4-udp-payload"
#define C_MAX_IPV6_UDP_PAYLOAD "\x14""max-ipv6-udp-payload"
#define C_MIN_REFRESH_INTERVAL "\x14""min-refresh-interval"
#define C_MODULE "\x06""module"
#define C_NOTIFY "\x06""notify"
#define C_NSEC3 "\x05""nsec3"
......
......@@ -78,7 +78,6 @@
#define BOOTSTRAP_MAXTIME (24*60*60)
#define BOOTSTRAP_JITTER (30)
#define NEXT_REFRESH_MIN (2)
enum state {
REFRESH_STATE_INVALID = 0,
......@@ -1021,6 +1020,18 @@ static int try_refresh(conf_t *conf, zone_t *zone, const conf_remote_t *master,
return ret;
}
static int64_t min_refresh_interval(conf_t *conf, const knot_dname_t *zone)
{
conf_val_t val = conf_zone_get(conf, C_MIN_REFRESH_INTERVAL, zone);
return conf_int(&val);
}
static int64_t max_refresh_interval(conf_t *conf, const knot_dname_t *zone)
{
conf_val_t val = conf_zone_get(conf, C_MAX_REFRESH_INTERVAL, zone);
return conf_int(&val);
}
int event_refresh(conf_t *conf, zone_t *zone)
{
assert(zone);
......@@ -1054,9 +1065,14 @@ int event_refresh(conf_t *conf, zone_t *zone)
zone->timers.next_refresh = now + next;
}
/* Security: avoid flooding master. */
if (zone->timers.next_refresh < now + NEXT_REFRESH_MIN) {
zone->timers.next_refresh = now + NEXT_REFRESH_MIN;
/* Check for allowed refresh interval limits. */
int64_t min_refresh = min_refresh_interval(conf, zone->name);
if(zone->timers.next_refresh < now + min_refresh) {
zone->timers.next_refresh = now + min_refresh;
}
int64_t max_refresh = max_refresh_interval(conf, zone->name);
if(zone->timers.next_refresh > now + max_refresh) {
zone->timers.next_refresh = now + max_refresh;
}
/* Rechedule events. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment