| [chrony-dev] [RFC PATCH v1 09/17] conf, util: Disable offset sanity check |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
- To: chrony-dev@xxxxxxxxxxxxxxxxxxxx
- Subject: [chrony-dev] [RFC PATCH v1 09/17] conf, util: Disable offset sanity check
- From: Christopher S M Hall <christopher.s.hall@xxxxxxxxx>
- Date: Sat, 6 Dec 2025 06:10:55 +0000
- Cc: christopher.s.hall@xxxxxxxxx, david.zage@xxxxxxxxx, yoong.siang.song@xxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1765002155; x=1796538155; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=h3UfKYqoP33jxrFU9fPdhFuGoeLa8OF889raTAGgHOg=; b=EMxQJPZ1u3OZLVrLVtl740jDy+btdCO8XggTy23FrNCy3HmSwZto+VH5 1Vlpj/WYOJsajQrlnuUH0+kr30hkPoueF1KpICcnfpbPwUTgsdc8bZ6cC yxcgoth00+ZZNCadVfoH0nWpweTR4naTmysoCWsn/FIMG242JIi9rllqJ fjVSsgaodp8Gf05Mauu0fSWLL0czQc39HqZ114HWDS6HtfF5qiCtTQ1W0 4AVLzVTB44ori7ZA0jdKdftmAnaAwqY+opl3W1ph1KGysU0aO0zjyQX4P 7W/CX4qV3tGFZX6br1H/u2x8l6mgF5VYdsBZAiYbZFdGQRDozQkFGioUC g==;
Linux auxiliary clocks may be used with an arbitrary timebase. An example of this is the "working" clock
proposed by the IEEE 60802 TSN profile used for industrial automation applications. The working clock is
local to a factory work cell and does no need to be traceable to UTC/TAI.
To disable the offset sanity check, a configuration direction "nooffsetsanitycheck" with no options is added.
This flag is consumed by the UTI_IsTimeOffsetSane() function.
The reference to CNF_GetOffsetSanityCheck() creates a link issue for chronyc. A weak function is added to
satisfy the linker. It is not and should not ever be used, but generates a fatal error if called.
---
conf.c | 12 ++++++++++++
conf.h | 1 +
util.c | 14 ++++++++++++++
3 files changed, 27 insertions(+)
diff --git a/conf.c b/conf.c
index 2b428af..c3e3a4b 100644
--- a/conf.c
+++ b/conf.c
@@ -106,6 +106,7 @@ static int get_auxclockid_last(int *clockid);
static int print_config = 0;
static int restarted = 0;
+static int disable_offset_sanity_check = 0;
static char *rtc_device;
static int acquisition_port = -1;
static int ntp_port = NTP_PORT;
@@ -640,6 +641,8 @@ CNF_ParseLine(const char *filename, int number, char *line)
parse_string(p, &bind_ntp_iface);
} else if (!strcasecmp(command, "broadcast")) {
parse_broadcast(p);
+ } else if (!strcasecmp(command, "nooffsetsanitycheck")) {
+ parse_null(p, &disable_offset_sanity_check);
} else if (!strcasecmp(command, "clientloglimit")) {
parse_clientloglimit(p);
} else if (!strcasecmp(command, "clockprecision")) {
@@ -2490,6 +2493,15 @@ CNF_GetMaxChange(int *delay, int *ignore, double *offset)
*offset = max_offset;
}
+/* ================================================== */
+
+int
+CNF_GetOffsetSanityCheck(void)
+{
+ return !disable_offset_sanity_check;
+}
+
+
/* ================================================== */
double
diff --git a/conf.h b/conf.h
index 613851e..0fa0895 100644
--- a/conf.h
+++ b/conf.h
@@ -181,6 +181,7 @@ extern int CNF_GetNtsRotate(void);
extern int CNF_GetNtsTrustedCertsPaths(const char ***paths, uint32_t **ids);
extern int CNF_GetNoSystemCert(void);
extern int CNF_GetNoCertTimeCheck(void);
+extern int CNF_GetOffsetSanityCheck(void);
#ifdef FEAT_AUXCLOCK
extern const int *CNF_GetAuxClockId(void);
#endif
diff --git a/util.c b/util.c
index 5388caa..7768fb9 100644
--- a/util.c
+++ b/util.c
@@ -39,10 +39,14 @@
#include "memory.h"
#include "util.h"
#include "hash.h"
+#include "conf.h"
+
#ifdef LINUX
#include <time.h>
#endif
+#include <execinfo.h>
+
#define NSEC_PER_SEC 1000000000
/* ================================================== */
@@ -862,11 +866,21 @@ UTI_DoubleToNtp64(double src, NTP_int64 *dest)
/* Minimum allowed distance from maximum 32-bit time_t */
#define MIN_ENDOFTIME_DISTANCE (365 * 24 * 3600)
+__attribute__((weak)) int CNF_GetOffsetSanityCheck()
+{
+ LOG_FATAL("Link Error: conf.o must be linked to use the provided "
+ "%s implementation", __FUNCTION__);
+ return 1;
+}
+
int
UTI_IsTimeOffsetSane(const struct timespec *ts, double offset)
{
double t;
+ if (!CNF_GetOffsetSanityCheck())
+ return 1;
+
/* Handle nan correctly here */
if (!(offset > -MAX_OFFSET && offset < MAX_OFFSET))
return 0;
--
2.34.1
--
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble? Email listmaster@xxxxxxxxxxxxxxxxxxxx.