Add reselectdist command
This commit is contained in:
parent
21ba1d3761
commit
8d3d45ea1a
7 changed files with 69 additions and 2 deletions
9
candm.h
9
candm.h
|
@ -86,7 +86,8 @@
|
|||
#define REQ_MODIFY_POLLTARGET 46
|
||||
#define REQ_MODIFY_MAXDELAYDEVRATIO 47
|
||||
#define REQ_RESELECT 48
|
||||
#define N_REQUEST_TYPES 49
|
||||
#define REQ_RESELECTDISTANCE 49
|
||||
#define N_REQUEST_TYPES 50
|
||||
|
||||
/* Special utoken value used to log on with first exchange being the
|
||||
password. (This time value has long since gone by) */
|
||||
|
@ -339,6 +340,11 @@ typedef struct {
|
|||
int32_t EOR;
|
||||
} REQ_Reselect;
|
||||
|
||||
typedef struct {
|
||||
Float distance;
|
||||
int32_t EOR;
|
||||
} REQ_ReselectDistance;
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
#define PKT_TYPE_CMD_REQUEST 1
|
||||
|
@ -425,6 +431,7 @@ typedef struct {
|
|||
REQ_MakeStep make_step;
|
||||
REQ_Activity activity;
|
||||
REQ_Reselect reselect;
|
||||
REQ_ReselectDistance reselect_distance;
|
||||
} data; /* Command specific parameters */
|
||||
|
||||
} CMD_Request;
|
||||
|
|
|
@ -2934,6 +2934,7 @@ interface.
|
|||
* polltarget command:: Set poll target for a source
|
||||
* quit command:: Exit from chronyc
|
||||
* reselect command:: Reselect synchronisation source
|
||||
* reselectdist command:: Set improvement in distance needed to reselect a source
|
||||
* retries command:: Set maximum number of retries
|
||||
* rtcdata command:: Display RTC parameters
|
||||
* settime command:: Provide a manual input of the current time
|
||||
|
@ -3756,6 +3757,13 @@ available sources.
|
|||
The @code{reselect} command can be used to force @code{chronyd} to
|
||||
reselect the best synchronisation source.
|
||||
@c }}}
|
||||
@c {{{ reselectdist command
|
||||
@node reselectdist command
|
||||
@subsubsection reselectdist
|
||||
The @code{reselectdist} command sets the reselect distance. It is equivalent
|
||||
to the @code{reselectdist} directive in the configuration file
|
||||
(@pxref{reselectdist directive}).
|
||||
@c }}}
|
||||
@c {{{ retries
|
||||
@node retries command
|
||||
@subsubsection retries
|
||||
|
|
19
client.c
19
client.c
|
@ -2377,6 +2377,23 @@ process_cmd_activity(const char *line)
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
static int
|
||||
process_cmd_reselectdist(CMD_Request *msg, char *line)
|
||||
{
|
||||
double dist;
|
||||
int ok;
|
||||
msg->command = htons(REQ_RESELECTDISTANCE);
|
||||
if (sscanf(line, "%lf", &dist) == 1) {
|
||||
msg->data.reselect_distance.distance = UTI_FloatHostToNetwork(dist);
|
||||
ok = 1;
|
||||
} else {
|
||||
ok = 0;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
static void
|
||||
process_cmd_reselect(CMD_Request *msg, char *line)
|
||||
{
|
||||
|
@ -2558,6 +2575,8 @@ process_line(char *line, int *quit)
|
|||
} else if (!strncmp(p, "activity", 8)) {
|
||||
ret = process_cmd_activity(p+8);
|
||||
do_normal_submit = 0;
|
||||
} else if (!strncmp(p, "reselectdist", 12)) {
|
||||
do_normal_submit = process_cmd_reselectdist(&tx_message, p+12);
|
||||
} else if (!strncmp(p, "reselect", 8)) {
|
||||
process_cmd_reselect(&tx_message, p+8);
|
||||
} else if (!strncmp(p, "dns ", 4)) {
|
||||
|
|
19
cmdmon.c
19
cmdmon.c
|
@ -158,7 +158,8 @@ static int permissions[] = {
|
|||
PERMIT_AUTH, /* MODIFY_MINSTRATUM */
|
||||
PERMIT_AUTH, /* MODIFY_POLLTARGET */
|
||||
PERMIT_AUTH, /* MODIFY_MAXDELAYDEVRATIO */
|
||||
PERMIT_AUTH /* RESELECT */
|
||||
PERMIT_AUTH, /* RESELECT */
|
||||
PERMIT_AUTH /* RESELECTDISTANCE */
|
||||
};
|
||||
|
||||
/* ================================================== */
|
||||
|
@ -1711,6 +1712,18 @@ handle_activity(CMD_Request *rx_message, CMD_Reply *tx_message)
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
static void
|
||||
handle_reselect_distance(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||
{
|
||||
double dist;
|
||||
dist = UTI_FloatNetworkToHost(rx_message->data.reselect_distance.distance);
|
||||
SRC_SetReselectDistance(dist);
|
||||
tx_message->status = htons(STT_SUCCESS);
|
||||
return;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
static void
|
||||
handle_reselect(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||
{
|
||||
|
@ -2258,6 +2271,10 @@ read_from_cmd_socket(void *anything)
|
|||
handle_activity(&rx_message, &tx_message);
|
||||
break;
|
||||
|
||||
case REQ_RESELECTDISTANCE:
|
||||
handle_reselect_distance(&rx_message, &tx_message);
|
||||
break;
|
||||
|
||||
case REQ_RESELECT:
|
||||
handle_reselect(&rx_message, &tx_message);
|
||||
break;
|
||||
|
|
|
@ -147,6 +147,8 @@ PKL_CommandLength(CMD_Request *r)
|
|||
return offsetof(CMD_Request, data.activity.EOR);
|
||||
case REQ_RESELECT:
|
||||
return offsetof(CMD_Request, data.reselect.EOR);
|
||||
case REQ_RESELECTDISTANCE:
|
||||
return offsetof(CMD_Request, data.reselect_distance.EOR);
|
||||
case REQ_MODIFY_MINSTRATUM:
|
||||
return offsetof(CMD_Request, data.modify_minstratum.EOR);
|
||||
case REQ_MODIFY_POLLTARGET:
|
||||
|
|
11
sources.c
11
sources.c
|
@ -901,6 +901,17 @@ SRC_ReselectSource(void)
|
|||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
SRC_SetReselectDistance(double distance)
|
||||
{
|
||||
if (reselect_distance != distance) {
|
||||
reselect_distance = distance;
|
||||
LOG(LOGS_INFO, LOGF_Sources, "New reselect distance %f", distance);
|
||||
}
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
double
|
||||
SRC_PredictOffset(SRC_Instance inst, struct timeval *when)
|
||||
{
|
||||
|
|
|
@ -140,6 +140,9 @@ extern void SRC_SelectSource(unsigned long match_addr);
|
|||
/* Force reselecting the best source */
|
||||
extern void SRC_ReselectSource(void);
|
||||
|
||||
/* Set reselect distance */
|
||||
extern void SRC_SetReselectDistance(double distance);
|
||||
|
||||
/* Predict the offset of the local clock relative to a given source at
|
||||
a given local cooked time. Positive indicates local clock is FAST
|
||||
relative to reference. */
|
||||
|
|
Loading…
Reference in a new issue