diff options
author | imp <imp@FreeBSD.org> | 2012-08-16 02:35:44 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2012-08-16 02:35:44 +0000 |
commit | 193f715d75e090bc3cffaf3d6e27b1641798a494 (patch) | |
tree | 9a58f9880446fb331a4af1c9073659b7418ac3a0 /sys/kern/kern_ntptime.c | |
parent | 4b09851610d7251f454bd28dd2def3d9cde98dcd (diff) | |
download | FreeBSD-src-193f715d75e090bc3cffaf3d6e27b1641798a494.zip FreeBSD-src-193f715d75e090bc3cffaf3d6e27b1641798a494.tar.gz |
Limit popcorn limit to something sane (either 2ns or 2 ticks if that's
longer).
PR: 156481
Submitted by: Ian Lepore
Diffstat (limited to 'sys/kern/kern_ntptime.c')
-rw-r--r-- | sys/kern/kern_ntptime.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/kern/kern_ntptime.c b/sys/kern/kern_ntptime.c index 7da7de2..41b33b5 100644 --- a/sys/kern/kern_ntptime.c +++ b/sys/kern/kern_ntptime.c @@ -832,8 +832,15 @@ hardpps(tsp, nsec) * discarded. otherwise, if so enabled, the time offset is * updated. We can tolerate a modest loss of data here without * much degrading time accuracy. - */ - if (u_nsec > (pps_jitter << PPS_POPCORN)) { + * + * The measurements being checked here were made with the system + * timecounter, so the popcorn threshold is not allowed to fall below + * the number of nanoseconds in two ticks of the timecounter. For a + * timecounter running faster than 1 GHz the lower bound is 2ns, just + * to avoid a nonsensical threshold of zero. + */ + if (u_nsec > lmax(pps_jitter << PPS_POPCORN, + 2 * (NANOSECOND / (long)qmin(NANOSECOND, tc_getfrequency())))) { time_status |= STA_PPSJITTER; pps_jitcnt++; } else if (time_status & STA_PPSTIME) { |