mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-05 06:55:08 -05:00
Add maxchange directive
This directive sets the maximum allowed offset corrected on a clock update. The check is performed only after the specified number of updates to allow a large initial adjustment of the system clock. When an offset larger than the specified maximum occurs, it will be ignored for the specified number of times and then chronyd will give up and exit (a negative value can be used to never exit). In both cases a message is sent to syslog.
This commit is contained in:
31
conf.c
31
conf.c
@@ -98,6 +98,7 @@ static void parse_noclientlog(const char *);
|
||||
static void parse_clientloglimit(const char *);
|
||||
static void parse_fallbackdrift(const char *);
|
||||
static void parse_makestep(const char *);
|
||||
static void parse_maxchange(const char *);
|
||||
static void parse_logchange(const char *);
|
||||
static void parse_mailonchange(const char *);
|
||||
static void parse_bindaddress(const char *);
|
||||
@@ -168,6 +169,12 @@ static int rtc_sync = 0;
|
||||
static int make_step_limit = 0;
|
||||
static double make_step_threshold = 0.0;
|
||||
|
||||
/* Number of updates before offset checking, number of ignored updates
|
||||
before exiting and the maximum allowed offset */
|
||||
static int max_offset_delay = -1;
|
||||
static int max_offset_ignore;
|
||||
static double max_offset;
|
||||
|
||||
/* Flag set if we should log to syslog when a time adjustment
|
||||
exceeding the threshold is initiated */
|
||||
static int do_log_change = 0;
|
||||
@@ -257,6 +264,7 @@ static const Command commands[] = {
|
||||
{"clientloglimit", 14, parse_clientloglimit},
|
||||
{"fallbackdrift", 13, parse_fallbackdrift},
|
||||
{"makestep", 8, parse_makestep},
|
||||
{"maxchange", 9, parse_maxchange},
|
||||
{"logchange", 9, parse_logchange},
|
||||
{"mailonchange", 12, parse_mailonchange},
|
||||
{"bindaddress", 11, parse_bindaddress},
|
||||
@@ -943,6 +951,19 @@ parse_makestep(const char *line)
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
static void
|
||||
parse_maxchange(const char *line)
|
||||
{
|
||||
if (sscanf(line, "%lf %d %d", &max_offset, &max_offset_delay, &max_offset_ignore) != 3) {
|
||||
max_offset_delay = -1;
|
||||
LOG(LOGS_WARN, LOGF_Configure,
|
||||
"Could not read offset, check delay or ignore limit for maximum change at line %d\n",
|
||||
line_number);
|
||||
}
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
static void
|
||||
parse_logchange(const char *line)
|
||||
{
|
||||
@@ -1567,6 +1588,16 @@ CNF_GetMakeStep(int *limit, double *threshold)
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
CNF_GetMaxChange(int *delay, int *ignore, double *offset)
|
||||
{
|
||||
*delay = max_offset_delay;
|
||||
*ignore = max_offset_ignore;
|
||||
*offset = max_offset;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
CNF_GetLogChange(int *enabled, double *threshold)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user