#define REQ_ONOFFLINE 63
#define REQ_ADD_SOURCE 64
#define REQ_NTP_SOURCE_NAME 65
-#define N_REQUEST_TYPES 66
+#define REQ_RESET 66
+#define N_REQUEST_TYPES 67
/* Structure used to exchange timespecs independent of time_t size */
typedef struct {
"cyclelogs\0Close and re-open log files\0"
"dump\0Dump all measurements to save files\0"
"rekey\0Re-read keys from key file\0"
+ "reset\0Drop all measurements\0"
"shutdown\0Stop daemon\0"
"\0\0"
"Client commands:\0\0"
"deny", "dns", "dump", "exit", "help", "keygen", "local", "makestep",
"manual", "maxdelay", "maxdelaydevratio", "maxdelayratio", "maxpoll",
"maxupdateskew", "minpoll", "minstratum", "ntpdata", "offline", "online", "onoffline",
- "polltarget", "quit", "refresh", "rekey", "reselect", "reselectdist",
+ "polltarget", "quit", "refresh", "rekey", "reselect", "reselectdist", "reset",
"retries", "rtcdata", "serverstats", "settime", "shutdown", "smoothing",
"smoothtime", "sourcename", "sources", "sourcestats",
"timeout", "tracking", "trimrtc", "waitsync", "writertc",
/* ================================================== */
+static void
+process_cmd_reset(CMD_Request *msg, char *line)
+{
+ msg->command = htons(REQ_RESET);
+}
+
+/* ================================================== */
+
static int
process_cmd_waitsync(char *line)
{
process_cmd_reselect(&tx_message, line);
} else if (!strcmp(command, "reselectdist")) {
do_normal_submit = process_cmd_reselectdist(&tx_message, line);
+ } else if (!strcmp(command, "reset")) {
+ process_cmd_reset(&tx_message, line);
} else if (!strcmp(command, "retries")) {
ret = process_cmd_retries(line);
do_normal_submit = 0;
PERMIT_AUTH, /* ONOFFLINE */
PERMIT_AUTH, /* ADD_SOURCE */
PERMIT_OPEN, /* NTP_SOURCE_NAME */
+ PERMIT_AUTH, /* RESET */
};
/* ================================================== */
sizeof (tx_message->data.ntp_source_name.name));
}
+/* ================================================== */
+
+static void
+handle_reset(CMD_Request *rx_message, CMD_Reply *tx_message)
+{
+ struct timespec cooked_now, now;
+
+ SRC_ResetSources();
+ SCH_GetLastEventTime(&cooked_now, NULL, &now);
+ LCL_NotifyExternalTimeStep(&now, &cooked_now, 0.0, 0.0);
+}
+
/* ================================================== */
/* Read a packet and process it */
handle_ntp_source_name(&rx_message, &tx_message);
break;
+ case REQ_RESET:
+ handle_reset(&rx_message, &tx_message);
+ break;
+
default:
DEBUG_LOG("Unhandled command %d", rx_command);
tx_message.status = htons(STT_FAILED);
The *rekey* command causes *chronyd* to re-read the key file specified in the
configuration file by the <<chrony.conf.adoc#keyfile,*keyfile*>> directive.
+[[reset]]*reset*::
+The *reset* command causes *chronyd* to drop all measurements and switch to the
+unsynchronised state. This command can help *chronyd* with recovery when the
+measurements are known to be no longer valid or accurate, e.g. due to moving
+the computer to a different network, or resuming the computer from a low-power
+state (which resets the system clock).
+
[[shutdown]]*shutdown*::
The *shutdown* command causes *chronyd* to exit. This is equivalent to sending
the process the SIGTERM signal.
REQ_LENGTH_ENTRY(ntp_source, null), /* ADD_SOURCE */
REQ_LENGTH_ENTRY(ntp_source_name,
ntp_source_name), /* NTP_SOURCE_NAME */
+ REQ_LENGTH_ENTRY(null, null), /* RESET */
};
static const uint16_t reply_lengths[] = {
/* ================================================== */
+void
+SRC_ResetSources(void)
+{
+ int i;
+
+ for (i = 0; i < n_sources; i++)
+ SRC_ResetInstance(sources[i]);
+}
+
+/* ================================================== */
+
int
SRC_IsSyncPeer(SRC_Instance inst)
{
extern void SRC_ReloadSources(void);
extern void SRC_RemoveDumpFiles(void);
+extern void SRC_ResetSources(void);
+
extern int SRC_IsSyncPeer(SRC_Instance inst);
extern int SRC_IsReachable(SRC_Instance inst);
extern int SRC_ReadNumberOfSources(void);
"rekey" \
"reselect" \
"reselectdist 1e-3" \
+ "reset" \
"settime 16:30" \
"settime 16:30:05" \
"settime Nov 21, 2015 16:30:05" \