mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 11:15:07 -05:00
rtc: check for backward RTC steps
When accumulating a new sample, check if the new RTC time is newer the last sample time. If it is not, discard all previous samples, assuming something has stepped the RTC, or it's a broken RTC/driver.
This commit is contained in:
@@ -187,6 +187,11 @@ accumulate_sample(time_t rtc, struct timespec *sys)
|
|||||||
discard_samples(NEW_FIRST_WHEN_FULL);
|
discard_samples(NEW_FIRST_WHEN_FULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Discard all samples if the RTC was stepped back (not our trim) */
|
||||||
|
if (n_samples > 0 && rtc_sec[n_samples - 1] - rtc >= rtc_trim[n_samples - 1]) {
|
||||||
|
DEBUG_LOG(LOGF_RtcLinux, "RTC samples discarded");
|
||||||
|
n_samples = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Always use most recent sample as reference */
|
/* Always use most recent sample as reference */
|
||||||
/* use sample only if n_sample is not negative*/
|
/* use sample only if n_sample is not negative*/
|
||||||
|
|||||||
Reference in New Issue
Block a user