OpenBSD CVS

CVS log for src/usr.sbin/ntpd/ntp.c


[BACK] Up to [local] / src / usr.sbin / ntpd

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.174 / (download) - annotate - [select for diffs], Wed Feb 21 03:31:28 2024 UTC (3 months, 1 week ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, HEAD
Changes since 1.173: +2 -2 lines
Diff to previous 1.173 (colored)

DNS resolution is best effort; if at this time IP addresses for tickers
cannot be resolved, don't spam syslog like crazy.  Change the
"DNS lookup tmpfail" message into a log_debug()
ok millert

Revision 1.173 / (download) - annotate - [select for diffs], Thu Feb 8 00:15:53 2024 UTC (3 months, 3 weeks ago) by jsg
Branch: MAIN
Changes since 1.172: +2 -2 lines
Diff to previous 1.172 (colored)

correct size in ipv6 address comparison

found by "'&a->sin6_addr' too small (16 vs 28)" smatch error
ok jca@

Revision 1.172 / (download) - annotate - [select for diffs], Wed Dec 20 15:36:36 2023 UTC (5 months, 1 week ago) by otto
Branch: MAIN
Changes since 1.171: +8 -14 lines
Diff to previous 1.171 (colored)

introduce log_ntp_addr() and use it where applicable, avoids a null
pointer deref in constraint.c reported by bluhm@; ok millert@

Revision 1.171 / (download) - annotate - [select for diffs], Wed Dec 6 15:51:53 2023 UTC (5 months, 3 weeks ago) by otto
Branch: MAIN
Changes since 1.170: +14 -4 lines
Diff to previous 1.170 (colored)

Periodically reset constraint DNS info for constraints that failed
to reply; ok florian@

Revision 1.170 / (download) - annotate - [select for diffs], Sun Nov 27 13:19:00 2022 UTC (18 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.169: +2 -2 lines
Diff to previous 1.169 (colored)

Once we are synced, we can validate the certificate in the standard way.
ok tb@

Revision 1.169 / (download) - annotate - [select for diffs], Thu Mar 24 07:37:19 2022 UTC (2 years, 2 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.168: +3 -3 lines
Diff to previous 1.168 (colored)

Plus a small leak found by jmatthew; ok millert@

Revision 1.168 / (download) - annotate - [select for diffs], Sun Oct 24 21:24:19 2021 UTC (2 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.167: +2 -2 lines
Diff to previous 1.167 (colored)

For open/openat, if the flags parameter does not contain O_CREAT, the
3rd (variadic) mode_t parameter is irrelevant.  Many developers in the past
have passed mode_t (0, 044, 0644, or such), which might lead future people
to copy this broken idiom, and perhaps even believe this parameter has some
meaning or implication or application. Delete them all.
This comes out of a conversation where tb@ noticed that a strange (but
intentional) pledge behaviour is to always knock-out high-bits from
mode_t on a number of system calls as a safety factor, and his bewilderment
that this appeared to be happening against valid modes (at least visually),
but no sorry, they are all irrelevant junk.  They could all be 0xdeafbeef.
ok millert

Revision 1.167 / (download) - annotate - [select for diffs], Fri Sep 11 07:09:41 2020 UTC (3 years, 8 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9, OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.166: +24 -7 lines
Diff to previous 1.166 (colored)

If we get messages but they are not ntp replies (e.g. caused by
incoming icmp) do not register them as replies.  Also, fix a bug
introduced in the previous commit: first recompute scale, then
recompute interval, so that when the offset increases and thus the
scale is lowered both the poll interval and the check interval use
the same scale.
First issue spotted by naddy@ second one by and ok semarie@

Revision 1.166 / (download) - annotate - [select for diffs], Sun Aug 30 16:21:29 2020 UTC (3 years, 9 months ago) by otto
Branch: MAIN
Changes since 1.165: +21 -3 lines
Diff to previous 1.165 (colored)

If no replies are received for a while due to connectivity issues
go into unsynced mode. The existing code to check if we're unsycned
is only done on receiving an ntp packet which does not happen if
there are connectivity issues. Prodded by naddy@ ok @florian

Revision 1.165 / (download) - annotate - [select for diffs], Mon Jun 22 06:11:34 2020 UTC (3 years, 11 months ago) by otto
Branch: MAIN
Changes since 1.164: +3 -3 lines
Diff to previous 1.164 (colored)

When the main process exits, it closes the pipe so a read 0 occurs.
Move log level to debug for that case and while there correct the
string, we're reding, not writing.

Revision 1.164 / (download) - annotate - [select for diffs], Sat Apr 11 07:49:48 2020 UTC (4 years, 1 month ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.163: +2 -2 lines
Diff to previous 1.163 (colored)

Zap double definition of conf and make ibuf_dns static to avoid double
definition; from Michael Forney

Revision 1.163 / (download) - annotate - [select for diffs], Wed Feb 12 19:14:56 2020 UTC (4 years, 3 months ago) by otto
Branch: MAIN
Changes since 1.162: +2 -2 lines
Diff to previous 1.162 (colored)

If constraints are configured but do not work for whatever reason ntpd
does not work. Make that more clear in the log and ntpdctl -s status.
report by and ok benno@

Revision 1.162 / (download) - annotate - [select for diffs], Mon Nov 11 06:32:52 2019 UTC (4 years, 6 months ago) by otto
Branch: MAIN
Changes since 1.161: +3 -2 lines
Diff to previous 1.161 (colored)

Also implement "trusted" for sensors; do not do constraint validation
for these. ok deraadt@

Revision 1.161 / (download) - annotate - [select for diffs], Sun Nov 10 19:24:47 2019 UTC (4 years, 6 months ago) by otto
Branch: MAIN
Changes since 1.160: +3 -2 lines
Diff to previous 1.160 (colored)

Introduce a "trusted" modifier, for peers that should be on a local net
used in situations where https constraints cannot be used and we still want
auto settime. Result of discussion with and ok deraadt@

Revision 1.160 / (download) - annotate - [select for diffs], Sun Nov 10 07:32:58 2019 UTC (4 years, 6 months ago) by otto
Branch: MAIN
Changes since 1.159: +4 -3 lines
Diff to previous 1.159 (colored)

- validate sensor values against constraints
- do not restart settime timeout interval if something happens in the main
  event loop
- apply a tight loop protection; it can be painfull on a single
  core machine since the process runs at maximum priority. Should only
  happen when a bug is introduced while developing, but prevents having to
  machine taken over by ntpd.

Revision 1.159 / (download) - annotate - [select for diffs], Tue Jul 16 14:15:40 2019 UTC (4 years, 10 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.158: +7 -10 lines
Diff to previous 1.158 (colored)

1) Re-resolve and re-get constraints once the clock is synced. Constraints
are relative to monotime; so they shift when time is being adjusted.
2) Fix a race between SIGCHLD delivery and reading the result imsg.
3) Some cleanup: use a number to distinguish pools internally

Revision 1.158 / (download) - annotate - [select for diffs], Sun Jul 7 07:14:57 2019 UTC (4 years, 10 months ago) by otto
Branch: MAIN
Changes since 1.157: +61 -11 lines
Diff to previous 1.157 (colored)

Sometimes ntp peers are unreliable (looking at you pool.ntp.org!)
and net config can change as well. So if a peer does not respond,
throw it out of the pool if it's a pool member and re-resolve to
find a replacement. Hold on to good peers so we end up with a good
set of peers. ok benno@

Revision 1.157 / (download) - annotate - [select for diffs], Thu Jun 27 15:18:42 2019 UTC (4 years, 11 months ago) by otto
Branch: MAIN
Changes since 1.156: +3 -3 lines
Diff to previous 1.156 (colored)

Allow logging to both stderr and syslog; don't reset the log level if
the log destination changes. ok claudio@ benno@

Revision 1.156 / (download) - annotate - [select for diffs], Thu Jun 20 07:28:18 2019 UTC (4 years, 11 months ago) by otto
Branch: MAIN
Changes since 1.155: +15 -5 lines
Diff to previous 1.155 (colored)

Do a quick DNS probe to decide to stay in the forground and attempt
an (auto) settime or give up. 15s timeout is still in effect. ok florian@

Revision 1.155 / (download) - annotate - [select for diffs], Sun Jun 16 07:36:25 2019 UTC (4 years, 11 months ago) by otto
Branch: MAIN
Changes since 1.154: +3 -1 lines
Diff to previous 1.154 (colored)

Be more aggressive retrying dns while in settime mode. The constraint
engine does not know if we're in startup mode, so use a small interval
the first few times there.

Revision 1.154 / (download) - annotate - [select for diffs], Wed Jun 12 05:04:45 2019 UTC (4 years, 11 months ago) by otto
Branch: MAIN
Changes since 1.153: +10 -9 lines
Diff to previous 1.153 (colored)

Fix init of syslog for childs and teach dns process about synced state.
ok benno@

Revision 1.153 / (download) - annotate - [select for diffs], Sun Jun 9 08:40:54 2019 UTC (4 years, 11 months ago) by otto
Branch: MAIN
Changes since 1.152: +2 -2 lines
Diff to previous 1.152 (colored)

Introducing autmatic settime mode: if some preconditions are met
(booting, constraint(s) defined) set the time but only if the clock
should be moved forward by more than a minute, based on ntp replies
that satisfied the constraints. Tested by many; ok deraadt@

Revision 1.152 / (download) - annotate - [select for diffs], Thu May 30 13:42:19 2019 UTC (5 years ago) by otto
Branch: MAIN
Changes since 1.151: +6 -9 lines
Diff to previous 1.151 (colored)

Use proper algorithm for median computation; use fabs() for computing
an absolute value and fix poll loop to first generate messages and
then compute poll flags the write cases. This makes the timeout
workaround for constraints unneeded.  ok reyk@ tb@

Revision 1.151 / (download) - annotate - [select for diffs], Wed May 29 18:48:33 2019 UTC (5 years ago) by otto
Branch: MAIN
Changes since 1.150: +30 -2 lines
Diff to previous 1.150 (colored)

If a DBS resolve was done with the Checking Disabled flag, re-resolve
with once the clock is synced. ok deraadt@ florian@

Revision 1.150 / (download) - annotate - [select for diffs], Tue May 28 06:49:46 2019 UTC (5 years ago) by otto
Branch: MAIN
Changes since 1.149: +6 -2 lines
Diff to previous 1.149 (colored)

A step in solving the bootstrap problem in a dnssec environement.
If the time is wrong, we cannot validate dnssec, leading to failed
DNS lookups, so we cannot adjust or set the time.  Work around this
by repeating a failed DNS lookup with a lookup with the DC (check
disabled) bit set. ok florian@

Revision 1.149 / (download) - annotate - [select for diffs], Mon Jan 7 20:33:40 2019 UTC (5 years, 4 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.148: +2 -1 lines
Diff to previous 1.148 (colored)

log dns failures, even if temporary. ok benno

Revision 1.148 / (download) - annotate - [select for diffs], Thu Jul 19 10:20:09 2018 UTC (5 years, 10 months ago) by sthen
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.147: +1 -9 lines
Diff to previous 1.147 (colored)

revert previous, something isn't quite right as clients see ntpd
as unsynced. reported by naddy, also seen by me (I noticed because
monitoring-plugins check_ntp complained). ok claudio henning

Revision 1.147 / (download) - annotate - [select for diffs], Thu Jul 12 19:31:05 2018 UTC (5 years, 10 months ago) by henning
Branch: MAIN
Changes since 1.146: +8 -0 lines
Diff to previous 1.146 (colored)

if we couldn't update the clock for ~1h due to lack of data from peers and
sensors, mark us unsynced again. ok reyk krw, pt out / discussion / help naddy

Revision 1.146 / (download) - annotate - [select for diffs], Tue May 30 23:30:48 2017 UTC (7 years ago) by benno
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.145: +3 -1 lines
Diff to previous 1.145 (colored)

add option "query from <ip>" to ntpd.conf, to specify a local IP
address for outgoing ntp queries.
From Job Snijders, thanks!
with feedback and ok henning@

Revision 1.145 / (download) - annotate - [select for diffs], Fri Jan 20 01:21:18 2017 UTC (7 years, 4 months ago) by phessler
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.144: +13 -5 lines
Diff to previous 1.144 (colored)

add logging messages to distinguish which safty check failed

Revision 1.144 / (download) - annotate - [select for diffs], Mon Sep 26 16:55:02 2016 UTC (7 years, 8 months ago) by rzalamena
Branch: MAIN
Changes since 1.143: +3 -13 lines
Diff to previous 1.143 (colored)

Teach ntpd(8) how to use socket status to shutdown the daemon. While at
it, remove some verbose shutdown messages that we had before with pipe
close.

ok reyk@

Revision 1.143 / (download) - annotate - [select for diffs], Wed Sep 14 13:20:16 2016 UTC (7 years, 8 months ago) by rzalamena
Branch: MAIN
Changes since 1.142: +16 -22 lines
Diff to previous 1.142 (colored)

Teach ntpd(8) how to fork+exec.

ok reyk@, bcook@

Revision 1.142 / (download) - annotate - [select for diffs], Sat Sep 3 11:52:06 2016 UTC (7 years, 8 months ago) by reyk
Branch: MAIN
Changes since 1.141: +4 -4 lines
Diff to previous 1.141 (colored)

Remove the oh so funny "LOSS OF MIND" from the diclaimer that was not
part of the original ISC license that we use in OpenBSD.  Done for
files were Henning is the original author.

OK henning@ deraadt@

Revision 1.141 / (download) - annotate - [select for diffs], Sat Dec 19 17:55:29 2015 UTC (8 years, 5 months ago) by reyk
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.140: +5 -2 lines
Diff to previous 1.140 (colored)

Switch and sync to the log.c variant from httpd/relayd/iked/snmpd/vmd.

OK bcook@ jung@

Revision 1.140 / (download) - annotate - [select for diffs], Sat Dec 5 13:12:16 2015 UTC (8 years, 5 months ago) by claudio
Branch: MAIN
Changes since 1.139: +2 -2 lines
Diff to previous 1.139 (colored)

EAGAIN handling for imsg_read. OK henning@ benno@

Revision 1.139 / (download) - annotate - [select for diffs], Fri Oct 30 16:41:53 2015 UTC (8 years, 7 months ago) by reyk
Branch: MAIN
Changes since 1.138: +1 -69 lines
Diff to previous 1.138 (colored)

Remove support for sending status reports to syslog on SIGINFO;
we have ntpctl now and ntpd doesn't need redundant/obsolete features.

Pointed out by naddy@, with input from zhuk@ (SIGINFO doesn't need SIG_IGN)
OK deraadt@

Revision 1.138 / (download) - annotate - [select for diffs], Fri Oct 23 14:52:20 2015 UTC (8 years, 7 months ago) by phessler
Branch: MAIN
Changes since 1.137: +5 -8 lines
Diff to previous 1.137 (colored)

Allowing upstream servers of ntp being in multiple routing tables is
non-sensical.  The dns lookups happened in the process routing table
(usually '0'), which is very likely to have different results from the
other routing domains.  If you do depend on having this behaviour,
you'll need to use pf to cross the rtable boundary.

"listen on * rtable X" is still supported.

Users of "server * rtable X" will need to switch to launching ntpd with
"route -T X exec /usr/sbin/ntpd"

OK deraadt@

Revision 1.137 / (download) - annotate - [select for diffs], Mon Oct 12 06:50:08 2015 UTC (8 years, 7 months ago) by reyk
Branch: MAIN
Changes since 1.136: +15 -41 lines
Diff to previous 1.136 (colored)

Move execution of the constraints from the ntp to the parent process.
This helps the ntp process to a) give a better pledge(2) and to b)
keep the promise of "saving the world again... on time" by removing
the delays that have been introduced by expensive constraint forks.
The new design offers better privsep but introduces a few more imsgs
and runs a little bit more code in the privileged parent.  The
privileged code is minimal, carefully checked, and does not attempt to
"parse" any contents; the forked constraints instantly drop all
privileges and pledge to "stdio inet".

OK beck@ deraadt@

Revision 1.136 / (download) - annotate - [select for diffs], Fri Oct 9 03:54:53 2015 UTC (8 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.135: +16 -1 lines
Diff to previous 1.135 (colored)

the ntp engine can run with "stdio inet proc".  For many reasons,
including fork/exec cost, it would be better if constraints were
forked from the master process, which would then tell the ntp
engine.  That would increase accuracy and security.
Lots of conversations with reyk and bcook

Revision 1.135 / (download) - annotate - [select for diffs], Fri Aug 14 02:00:18 2015 UTC (8 years, 9 months ago) by millert
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.134: +2 -2 lines
Diff to previous 1.134 (colored)

When checking whether we should scan the sensors again use <= rather
than < for the comparison.  Otherwise, if we don't do enough work
in the loop to advance the clock (for instance if the network is
down) we may end up calling poll() multiple times with no timeout,
racking up CPU time for no real reason.  OK bcook@

Revision 1.134 / (download) - annotate - [select for diffs], Sat Jul 18 00:59:00 2015 UTC (8 years, 10 months ago) by bcook
Branch: MAIN
Changes since 1.133: +2 -2 lines
Diff to previous 1.133 (colored)

replace _PATH_DEVNULL with "/dev/null", assume it will not move

ok deraadt@ phessler@ claudio@

Revision 1.133 / (download) - annotate - [select for diffs], Sat Jul 18 00:53:44 2015 UTC (8 years, 10 months ago) by bcook
Branch: MAIN
Changes since 1.132: +4 -4 lines
Diff to previous 1.132 (colored)

replace bzero with memset

ok phessler@ deraadt@

Revision 1.132 / (download) - annotate - [select for diffs], Mon May 25 14:58:34 2015 UTC (9 years ago) by deraadt
Branch: MAIN
Changes since 1.131: +18 -16 lines
Diff to previous 1.131 (colored)

only scan sensors if they are configured
ok bcook

Revision 1.131 / (download) - annotate - [select for diffs], Wed May 20 13:32:39 2015 UTC (9 years ago) by reyk
Branch: MAIN
Changes since 1.130: +5 -14 lines
Diff to previous 1.130 (colored)

Remove hotplug(4) sensor support: the code has been disabled by
henning@ 9 years ago because of an issue with the /dev/hotplug device
- it does not support multiple readers opening it.  Nobody ever cared
enough to fix it so it is time to sent the dead code to the Attic.

OK henning@ (feeling sad about it), mpi@ and others

Revision 1.130 / (download) - annotate - [select for diffs], Mon Mar 2 10:31:17 2015 UTC (9 years, 3 months ago) by bcook
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.129: +2 -4 lines
Diff to previous 1.129 (colored)

remove unused variable

ok reyk@

Revision 1.129 / (download) - annotate - [select for diffs], Thu Feb 12 01:54:57 2015 UTC (9 years, 3 months ago) by reyk
Branch: MAIN
Changes since 1.128: +9 -4 lines
Diff to previous 1.128 (colored)

Use ntpd's deferred DNS resolving for constraints as well.  This
allows to get constraint addresses even if network/DNS is not
available at startup (or system boot).

thumbs up & OK henning@

Revision 1.128 / (download) - annotate - [select for diffs], Tue Feb 10 06:40:08 2015 UTC (9 years, 3 months ago) by reyk
Branch: MAIN
Changes since 1.127: +56 -7 lines
Diff to previous 1.127 (colored)

Add support for "constraints": when configured, ntpd(8) will query the
time from HTTPS servers, by parsing the Date: header, and use the
median constraint time as a boundary to verify NTP responses.  This
adds some level of authentication and protection against MITM attacks
while preserving the accuracy of the NTP protocol; without relying on
authentication options for NTP that are basically unavailable at
present.  This is an initial implementation and the semantics will be
improved once it is in the tree.

Discussed with deraadt@ and henning@
OK henning@

Revision 1.127 / (download) - annotate - [select for diffs], Tue Feb 10 06:03:43 2015 UTC (9 years, 3 months ago) by bcook
Branch: MAIN
Changes since 1.126: +8 -5 lines
Diff to previous 1.126 (colored)

be more verbose when logging privsep errors.

ok phessler@ deraadt@

Revision 1.126 / (download) - annotate - [select for diffs], Tue Jan 13 02:23:33 2015 UTC (9 years, 4 months ago) by bcook
Branch: MAIN
Changes since 1.125: +5 -5 lines
Diff to previous 1.125 (colored)

prefer sizeof(thing) to sizeof(type)

ok tedu@ deraadt@

Revision 1.125 / (download) - annotate - [select for diffs], Fri Jan 9 07:35:37 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
Changes since 1.124: +2 -2 lines
Diff to previous 1.124 (colored)

remove excessive/wrong use of sys/param.h
peanuts -- but all work has to start somewhere.

Revision 1.124 / (download) - annotate - [select for diffs], Sun Jan 4 01:48:49 2015 UTC (9 years, 4 months ago) by bcook
Branch: MAIN
Changes since 1.123: +2 -4 lines
Diff to previous 1.123 (colored)

use MAXIMUM as the canonical local MAX macro.

suggested by deraadt@ re: more general MIN/MAX cleanups

Revision 1.123 / (download) - annotate - [select for diffs], Sun Jan 4 01:19:46 2015 UTC (9 years, 4 months ago) by bcook
Branch: MAIN
Changes since 1.122: +4 -2 lines
Diff to previous 1.122 (colored)

don't rely on sys/param.h having a MAX macro.

Switch to local definitions where MAX is needed.

discussed with deraadt@

Revision 1.122 / (download) - annotate - [select for diffs], Sun Jan 4 01:16:10 2015 UTC (9 years, 4 months ago) by bcook
Branch: MAIN
Changes since 1.121: +3 -3 lines
Diff to previous 1.121 (colored)

Remove the unused dns_pid variable.

Nothing is done with the return value from ntp_dns, and it already calls
fatal() on failure.

ok deraadt@

Revision 1.121 / (download) - annotate - [select for diffs], Wed Oct 8 04:57:29 2014 UTC (9 years, 7 months ago) by deraadt
Branch: MAIN
Changes since 1.120: +5 -5 lines
Diff to previous 1.120 (colored)

easy realloc() -> reallocarray() which gives us mult int overflow checking
for free, FREE, FREEEEE
ok doug

Revision 1.120 / (download) - annotate - [select for diffs], Wed Nov 13 20:44:39 2013 UTC (10 years, 6 months ago) by benno
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6, OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.119: +5 -3 lines
Diff to previous 1.119 (colored)

from sthen: handle msgbuf_write() returning EAGAIN

ok krw

Revision 1.119 / (download) - annotate - [select for diffs], Fri Oct 4 14:28:16 2013 UTC (10 years, 7 months ago) by phessler
Branch: MAIN
Changes since 1.118: +33 -6 lines
Diff to previous 1.118 (colored)

Add ntpctl(8), which allows us to query the locally running ntpd(8) process

diff from Mike Miller <mmiller mgm51 com> (many thanks!)

OK phessler@, henning@, todd@

Revision 1.118 / (download) - annotate - [select for diffs], Sat Sep 28 12:18:05 2013 UTC (10 years, 8 months ago) by phessler
Branch: MAIN
Changes since 1.117: +7 -13 lines
Diff to previous 1.117 (colored)

Resolve the uncertainty in the REFID assignment.

Previously, when there is an even number of offsets, we did the average
of the two middle offets but would set the REFID from one of them.
Instead, we simply select the middle offset with the lowest delay.

diff from Mike Miller <mmiller mgm51 com> (many thanks!)

OK phessler@, henning@

Revision 1.117 / (download) - annotate - [select for diffs], Wed Sep 21 15:41:30 2011 UTC (12 years, 8 months ago) by phessler
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4, OPENBSD_5_3_BASE, OPENBSD_5_3, OPENBSD_5_2_BASE, OPENBSD_5_2, OPENBSD_5_1_BASE, OPENBSD_5_1
Changes since 1.116: +8 -5 lines
Diff to previous 1.116 (colored)

Add rdomain support to NTPd.

This basically adds the "rtable %d" keyword to "listen on", "server",
"servers" keywords, to specify which routing table to use.

OK henning@ claudio@ sthen@
manpage reviewed by jmc@

Revision 1.116 / (download) - annotate - [select for diffs], Fri Jun 17 18:12:05 2011 UTC (12 years, 11 months ago) by henning
Branch: MAIN
CVS Tags: OPENBSD_5_0_BASE, OPENBSD_5_0
Changes since 1.115: +2 -2 lines
Diff to previous 1.115 (colored)

close pipe_prnt[0] earlier, foremost before forking the dns process
pointed out by Running Razor <runningrazor at web dot de>

Revision 1.115 / (download) - annotate - [select for diffs], Thu Jun 16 11:46:55 2011 UTC (12 years, 11 months ago) by henning
Branch: MAIN
Changes since 1.114: +3 -1 lines
Diff to previous 1.114 (colored)

clamp stratum to NTP_MAXSTRATUM. lingering in my tree for ages. someone likely
deserves to get credited for this, but I have no idea where that came from

Revision 1.114 / (download) - annotate - [select for diffs], Thu Jun 11 17:36:53 2009 UTC (14 years, 11 months ago) by henning
Branch: MAIN
CVS Tags: OPENBSD_4_9_BASE, OPENBSD_4_9, OPENBSD_4_8_BASE, OPENBSD_4_8, OPENBSD_4_7_BASE, OPENBSD_4_7, OPENBSD_4_6_BASE, OPENBSD_4_6
Changes since 1.113: +1 -6 lines
Diff to previous 1.113 (colored)

effectively un-do r1.111, it fucks machines with bad clocks royally.
spotted the hard way by theo on armish, pinned to this changed by me.
no cookie for ckuethe for not testing on machines with bad clocks.

Revision 1.113 / (download) - annotate - [select for diffs], Sat Jun 6 18:47:19 2009 UTC (14 years, 11 months ago) by ckuethe
Branch: MAIN
Changes since 1.112: +4 -2 lines
Diff to previous 1.112 (colored)

If ntpd decides the clock has become unsynced, reset the number of saved
time corrections. Once the clock is synced again, start computing a fresh
frequency correction.
ok henning

Revision 1.112 / (download) - annotate - [select for diffs], Sat Jun 6 18:14:25 2009 UTC (14 years, 11 months ago) by pyr
Branch: MAIN
Changes since 1.111: +6 -5 lines
Diff to previous 1.111 (colored)

make ntpd imsg-in-a-lib ready as well. extensive testing done, no
behavior change.
ok eric@

Revision 1.111 / (download) - annotate - [select for diffs], Thu Jun 4 23:39:45 2009 UTC (15 years ago) by ckuethe
Branch: MAIN
Changes since 1.110: +7 -1 lines
Diff to previous 1.110 (colored)

After calling adjfreq to correct the clock's rate, measure and fix the clock
offset. This avoids future frequency adjustments based on measurements of a
clock that was being adjusted. End result: more stable clock and better
frequency convergence.

Also, fix a mis-ordered structure member while I'm here.
ok henning

Revision 1.110 / (download) - annotate - [select for diffs], Mon Jan 26 11:51:50 2009 UTC (15 years, 4 months ago) by henning
Branch: MAIN
CVS Tags: OPENBSD_4_5_BASE, OPENBSD_4_5
Changes since 1.109: +3 -3 lines
Diff to previous 1.109 (colored)

use monotime instead of wallclock for the report thing as well
found on this laptops harddisk, probably from stockholm

Revision 1.109 / (download) - annotate - [select for diffs], Wed Dec 10 09:03:30 2008 UTC (15 years, 5 months ago) by claudio
Branch: MAIN
Changes since 1.108: +2 -2 lines
Diff to previous 1.108 (colored)

Correctly skip the internal fd when checking the server sockets. Use PFD_MAX
to start the for loop and not 1 which was correct long long time ago.
OK otto@ found by Anirban Sinha ASinha(at)zeugmasystems.com

Revision 1.108 / (download) - annotate - [select for diffs], Thu Oct 2 14:00:21 2008 UTC (15 years, 8 months ago) by henning
Branch: MAIN
Changes since 1.107: +1 -10 lines
Diff to previous 1.107 (colored)

in priv_settime(), we must not adjust the 'next' timestamps on their for
the offset since we use monotime for these for some time now, and monotime
is not affected by system time changes (like, duh, that was the reason for
the change). PR5927

Revision 1.107 / (download) - annotate - [select for diffs], Fri Sep 12 10:46:09 2008 UTC (15 years, 8 months ago) by henning
Branch: MAIN
Changes since 1.106: +69 -10 lines
Diff to previous 1.106 (colored)

move dns lookups to its own (privilege revoking, not chrooting) process.
reason: the parent process must never ever block, but the dns routines can.
last not least this fixes ntpd -s 'hanging' for a long time.
tested by a couple of people

Revision 1.106 / (download) - annotate - [select for diffs], Tue Jun 10 03:46:09 2008 UTC (15 years, 11 months ago) by naddy
Branch: MAIN
CVS Tags: OPENBSD_4_4_BASE, OPENBSD_4_4
Changes since 1.105: +1 -2 lines
Diff to previous 1.105 (colored)

According to the latest SNTPv4 spec in RFC4330, secondary servers
return the address of the synchronization source as reference
identification.  Remove the obsolete special casing specified in RFC2030.
ok henning@

Revision 1.105 / (download) - annotate - [select for diffs], Sun Jun 8 19:14:40 2008 UTC (15 years, 11 months ago) by ckuethe
Branch: MAIN
Changes since 1.104: +2 -2 lines
Diff to previous 1.104 (colored)

Don't ignore a slightly unresponsive server for an hour, 5 minutes is enough.
comments & ok henning@

Revision 1.104 / (download) - annotate - [select for diffs], Sun Apr 13 00:22:17 2008 UTC (16 years, 1 month ago) by djm
Branch: MAIN
Changes since 1.103: +3 -3 lines
Diff to previous 1.103 (colored)

Use arc4random_buf() when requesting more than a single word of output

Use arc4random_uniform() when the desired random number upper bound
is not a power of two

ok deraadt@ millert@

Revision 1.103 / (download) - annotate - [select for diffs], Mon Jan 28 11:45:59 2008 UTC (16 years, 4 months ago) by mpf
Branch: MAIN
CVS Tags: OPENBSD_4_3_BASE, OPENBSD_4_3
Changes since 1.102: +14 -6 lines
Diff to previous 1.102 (colored)

Reconnect a client socket after three consecutive send failures.
This allows recovery after an IP address change (e.g. on dialup links).
Also move the update of "nextaction" timeout below the deadline check.
OK henning@

Revision 1.102 / (download) - annotate - [select for diffs], Thu Dec 27 01:46:50 2007 UTC (16 years, 5 months ago) by stevesk
Branch: MAIN
Changes since 1.101: +2 -2 lines
Diff to previous 1.101 (colored)

some fatal() calls that should be fatalx(); ok henning@

Revision 1.101 / (download) - annotate - [select for diffs], Sat Dec 22 18:26:21 2007 UTC (16 years, 5 months ago) by stevesk
Branch: MAIN
Changes since 1.100: +2 -6 lines
Diff to previous 1.100 (colored)

just call getpwnam(NTPD_USER) once; ok henning@

Revision 1.100 / (download) - annotate - [select for diffs], Mon Oct 15 06:59:31 2007 UTC (16 years, 7 months ago) by otto
Branch: MAIN
Changes since 1.99: +73 -2 lines
Diff to previous 1.99 (colored)

Allow ntpd to report the status of peers and sensors to syslog. This
happens when a SIGINFO is received, or when the majority of peers or
sensors is bad. The latter with a maximum of once per 24 hour.
ok henning@ ckuethe@ mbalmer@

Revision 1.99 / (download) - annotate - [select for diffs], Sat Aug 4 02:58:02 2007 UTC (16 years, 10 months ago) by ckuethe
Branch: MAIN
CVS Tags: OPENBSD_4_2_BASE, OPENBSD_4_2
Changes since 1.98: +5 -2 lines
Diff to previous 1.98 (colored)

This diff makes ntpd poll for sensors more aggressively when the use of
sensors is requested, but no sensors are found.
ok henning

Revision 1.98 / (download) - annotate - [select for diffs], Mon Jan 15 08:19:11 2007 UTC (17 years, 4 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_4_1_BASE, OPENBSD_4_1
Changes since 1.97: +2 -2 lines
Diff to previous 1.97 (colored)

Although Unix compilers accept more than one definition of a global
symbol, follow the guidelines from K&R: only one definition of a
global symbol (and possibly more declarations).  Rename some vars
here and there to avoid shadowing. ok henning@

Revision 1.97 / (download) - annotate - [select for diffs], Sun Jan 14 19:20:09 2007 UTC (17 years, 4 months ago) by otto
Branch: MAIN
Changes since 1.96: +6 -1 lines
Diff to previous 1.96 (colored)

Esape from the Mouth of Madness by adjusting stored sensor offsets
when we adjust time. This prevents ntpd from going wild when using
sensor time sources; ok henning@ (on an earlier version) and a LOT
of testing by naddy@

Revision 1.96 / (download) - annotate - [select for diffs], Wed Dec 20 16:50:13 2006 UTC (17 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.95: +3 -2 lines
Diff to previous 1.95 (colored)

let ntpd use sensors immediately after system boot by special casing
last_sensor_scan == 0. monotime might be very close to 0 after boot.
source unknown, maybe from naddy, rediscovered & ok mblamer

Revision 1.95 / (download) - annotate - [select for diffs], Thu Nov 30 18:42:41 2006 UTC (17 years, 6 months ago) by ckuethe
Branch: MAIN
Changes since 1.94: +3 -1 lines
Diff to previous 1.94 (colored)

Allow sensors in a sensors-only configuration to set the time at startup.

Revision 1.94 / (download) - annotate - [select for diffs], Fri Oct 27 12:22:41 2006 UTC (17 years, 7 months ago) by henning
Branch: MAIN
Changes since 1.93: +8 -8 lines
Diff to previous 1.93 (colored)

use clock_gettime(CLOCK_MONOTONIC, ..) to get a monotonically increasing
time, and make ntpd use that to send the next uery to an ntp peer and the
like. this has the advantage that changes to the clock do not interfere
with the intervals. for example, when we start on machines without an
RTC and the initial settime (-s) kicks in, intervals were strange.
idea from amandal@entrisphere.com, this implementation by me
tested ckuethe, phessler, mbalmer, ok mbalmer

Revision 1.93 / (download) - annotate - [select for diffs], Tue Oct 24 12:23:39 2006 UTC (17 years, 7 months ago) by henning
Branch: MAIN
Changes since 1.92: +1 -2 lines
Diff to previous 1.92 (colored)

timedelta sensors are usually updated very often, but we used to query
them only every 30 seconds. now query them every 5,and take the median
value from 7 queries as sensor value. this takes outliers out of the
equation and makes the overall result much better, especially for
sensors with heavy jitter (like nmea for now)

Revision 1.92 / (download) - annotate - [select for diffs], Sat Oct 21 07:30:58 2006 UTC (17 years, 7 months ago) by henning
Branch: MAIN
Changes since 1.91: +3 -2 lines
Diff to previous 1.91 (colored)

        Found that even if client fd (i.e to NTP source) is set to
        -1 because of error, it may still participate in poll()
        causing poll() to repeatedly wake up on error fd.
so make sure w edon't add -1 fds to pollevents to avoid unnecessary wakeups
From: amandal@entrisphere.com

Revision 1.91 / (download) - annotate - [select for diffs], Sat Jul 1 18:52:46 2006 UTC (17 years, 11 months ago) by otto
Branch: MAIN
CVS Tags: OPENBSD_4_0_BASE, OPENBSD_4_0
Changes since 1.90: +1 -2 lines
Diff to previous 1.90 (colored)

remove some unneeded includes; one found by vetinari

Revision 1.90 / (download) - annotate - [select for diffs], Fri Jun 30 16:52:13 2006 UTC (17 years, 11 months ago) by deraadt
Branch: MAIN
Changes since 1.89: +2 -2 lines
Diff to previous 1.89 (colored)

spaces

Revision 1.89 / (download) - annotate - [select for diffs], Mon Jun 26 09:43:06 2006 UTC (17 years, 11 months ago) by otto
Branch: MAIN
Changes since 1.88: +5 -2 lines
Diff to previous 1.88 (colored)

increase polling intervbal, but only after we are synced and have done
a few frequency adjustments. ok henning@

Revision 1.88 / (download) - annotate - [select for diffs], Wed Jun 21 07:42:00 2006 UTC (17 years, 11 months ago) by otto
Branch: MAIN
Changes since 1.87: +2 -1 lines
Diff to previous 1.87 (colored)

avoid a race by installing SIGCHLD handler before fork() is called.
ok henning@ ckuethe@

Revision 1.87 / (download) - annotate - [select for diffs], Sat Jun 17 18:40:42 2006 UTC (17 years, 11 months ago) by otto
Branch: MAIN
Changes since 1.86: +55 -1 lines
Diff to previous 1.86 (colored)

Import frequency conrrection code from dragonfly, whith some changes:
only do frequency compensation if the clock is synced, and a slightly
diffent way of computing the linear regression.
You'll need a recent kernel and libc to use this.
Testing by naddy@ and ckuethe@ and others, thanks!
ok henning@

Revision 1.86 / (download) - annotate - [select for diffs], Fri Jun 9 07:42:08 2006 UTC (17 years, 11 months ago) by otto
Branch: MAIN
Changes since 1.85: +7 -1 lines
Diff to previous 1.85 (colored)

set session id and init logging in -s mode. tested by david@ and matthieu@;
ok henning@

Revision 1.85 / (download) - annotate - [select for diffs], Thu Jun 8 06:03:07 2006 UTC (17 years, 11 months ago) by otto
Branch: MAIN
Changes since 1.84: +12 -18 lines
Diff to previous 1.84 (colored)

simplify; ok henning@

Revision 1.84 / (download) - annotate - [select for diffs], Wed Jun 7 06:29:03 2006 UTC (17 years, 11 months ago) by otto
Branch: MAIN
Changes since 1.83: +6 -2 lines
Diff to previous 1.83 (colored)

Compensate old offsets with the amount of adjustment done, avoiding
overcompensating. From DragonFly, uses recent adjtime(2) changes,
so you'll need a recent kernel. ok henning@

Revision 1.83 / (download) - annotate - [select for diffs], Sun Jun 4 18:58:13 2006 UTC (18 years ago) by otto
Branch: MAIN
Changes since 1.82: +38 -35 lines
Diff to previous 1.82 (colored)

Only invalidate stored replies if an adjustment was really made.
ok henning@

Revision 1.82 / (download) - annotate - [select for diffs], Fri Jun 2 20:45:34 2006 UTC (18 years ago) by henning
Branch: MAIN
Changes since 1.81: +2 -2 lines
Diff to previous 1.81 (colored)

incredibly stupid typo

Revision 1.81 / (download) - annotate - [select for diffs], Thu Jun 1 06:04:15 2006 UTC (18 years ago) by otto
Branch: MAIN
Changes since 1.80: +2 -1 lines
Diff to previous 1.80 (colored)

When expanding servers, do not forget to copy weight. ok henning@

Revision 1.80 / (download) - annotate - [select for diffs], Thu Jun 1 05:44:35 2006 UTC (18 years ago) by henning
Branch: MAIN
Changes since 1.79: +1 -14 lines
Diff to previous 1.79 (colored)

urgs, other stuff snuck in

Revision 1.79 / (download) - annotate - [select for diffs], Thu Jun 1 04:42:23 2006 UTC (18 years ago) by henning
Branch: MAIN
Changes since 1.78: +19 -3 lines
Diff to previous 1.78 (colored)

put back regular sensors scanning

Revision 1.78 / (download) - annotate - [select for diffs], Wed May 31 01:27:21 2006 UTC (18 years ago) by henning
Branch: MAIN
Changes since 1.77: +3 -2 lines
Diff to previous 1.77 (colored)

only actually run sensor_query when it is due, not every time poll returns

Revision 1.77 / (download) - annotate - [select for diffs], Sun May 28 20:39:16 2006 UTC (18 years ago) by henning
Branch: MAIN
Changes since 1.76: +8 -6 lines
Diff to previous 1.76 (colored)

allow for weight to be added to sensors or servers, so that one can
weight timedelta sensors higher than ntp peers, for example
ok deraadt mbalmer

Revision 1.76 / (download) - annotate - [select for diffs], Sun May 28 18:47:25 2006 UTC (18 years ago) by henning
Branch: MAIN
Changes since 1.75: +2 -3 lines
Diff to previous 1.75 (colored)

let sensor_query handle removals itself

Revision 1.75 / (download) - annotate - [select for diffs], Sun May 28 03:23:08 2006 UTC (18 years ago) by henning
Branch: MAIN
Changes since 1.74: +3 -6 lines
Diff to previous 1.74 (colored)

DV_SENSORS is no more, plug workaround for the time to the real solution

Revision 1.74 / (download) - annotate - [select for diffs], Sat May 27 22:22:47 2006 UTC (18 years ago) by henning
Branch: MAIN
Changes since 1.73: +3 -3 lines
Diff to previous 1.73 (colored)

stop passing the config around all time, just store one copy

Revision 1.73 / (download) - annotate - [select for diffs], Sat May 27 21:27:34 2006 UTC (18 years ago) by henning
Branch: MAIN
Changes since 1.72: +13 -3 lines
Diff to previous 1.72 (colored)

make ntpd listen on the hotplug socket and decode yadda yadda, because
new sensors showing up will be announced that way when slacking ml comes
back from food

Revision 1.72 / (download) - annotate - [select for diffs], Sat May 27 18:32:00 2006 UTC (18 years ago) by henning
Branch: MAIN
Changes since 1.71: +6 -3 lines
Diff to previous 1.71 (colored)

scan for new timedelta sensors every five minutes for now, ok deraadt

Revision 1.71 / (download) - annotate - [select for diffs], Fri May 26 00:33:16 2006 UTC (18 years ago) by henning
Branch: MAIN
Changes since 1.70: +35 -2 lines
Diff to previous 1.70 (colored)

add support for timedelta sensors, which pretty much means udcf(4) right
now. untested due to lack of hardware, and it wouldn't have worked in the
plane anyways. work in progress, currently picks up and uses all sensors
it finds, config file bits to be added soon. theo fine with this going in

Revision 1.70 / (download) - annotate - [select for diffs], Thu May 25 19:30:45 2006 UTC (18 years ago) by henning
Branch: MAIN
Changes since 1.69: +25 -25 lines
Diff to previous 1.69 (colored)

more bits from transatlanic flight:
make priv_adjtime() deal with offsets, not peers.

Revision 1.69 / (download) - annotate - [select for diffs], Thu May 25 19:25:46 2006 UTC (18 years ago) by henning
Branch: MAIN
Changes since 1.68: +3 -6 lines
Diff to previous 1.68 (colored)

figure out the refid to send to NTP v3 clients early and store it
first bits from a way to long flight

Revision 1.68 / (download) - annotate - [select for diffs], Sun May 14 22:33:51 2006 UTC (18 years ago) by henning
Branch: MAIN
Changes since 1.67: +2 -2 lines
Diff to previous 1.67 (colored)

PFD_MAX betterer than harcoded 1

Revision 1.67 / (download) - annotate - [select for diffs], Wed Aug 10 13:48:36 2005 UTC (18 years, 9 months ago) by dtucker
Branch: MAIN
CVS Tags: OPENBSD_3_9_BASE, OPENBSD_3_9, OPENBSD_3_8_BASE, OPENBSD_3_8
Changes since 1.66: +7 -6 lines
Diff to previous 1.66 (colored)

Propogate server's leap indicator flags to clients; ok henning@

Revision 1.66 / (download) - annotate - [select for diffs], Mon Aug 8 14:42:32 2005 UTC (18 years, 9 months ago) by henning
Branch: MAIN
Changes since 1.65: +3 -2 lines
Diff to previous 1.65 (colored)

with -s, do not wait if we don't have any peers at all.
From: Thomas Jarosch <thomas.jarosch@intra2net.com>

Revision 1.65 / (download) - annotate - [select for diffs], Fri Jul 15 03:36:10 2005 UTC (18 years, 10 months ago) by henning
Branch: MAIN
Changes since 1.64: +1 -2 lines
Diff to previous 1.64 (colored)

remove recently added "using privsep user X" message, spams console in -s
mode, noticed by kettenis

Revision 1.64 / (download) - annotate - [select for diffs], Fri Jul 15 03:34:52 2005 UTC (18 years, 10 months ago) by henning
Branch: MAIN
Changes since 1.63: +2 -2 lines
Diff to previous 1.63 (colored)

fix a function name in an error message
why this was rotting in my tree for so long, I dunno - and I dunno where it
came from

Revision 1.63 / (download) - annotate - [select for diffs], Mon Jul 11 08:05:34 2005 UTC (18 years, 10 months ago) by dtucker
Branch: MAIN
Changes since 1.62: +2 -1 lines
Diff to previous 1.62 (colored)

Print privsep user and dir when in debug mode; ok henning@

Revision 1.62 / (download) - annotate - [select for diffs], Tue Jul 5 10:09:12 2005 UTC (18 years, 11 months ago) by dtucker
Branch: MAIN
Changes since 1.61: +5 -1 lines
Diff to previous 1.61 (colored)

Save transmit time for each peer for later use as refid for SNTPv4
replies.  ok henning@

Revision 1.61 / (download) - annotate - [select for diffs], Sun Jun 19 16:42:57 2005 UTC (18 years, 11 months ago) by henning
Branch: MAIN
Changes since 1.60: +13 -4 lines
Diff to previous 1.60 (colored)

use a little state engine to keep track of delayed dns lookups and such,
eases things
tested by Jason Ackley <jason@ackley.net> Matthias Kilian
<kili@outback.escape.de> Stephen Marley <stephen@marley.org.uk> sturm@
theo ok

Revision 1.60 / (download) - annotate - [select for diffs], Thu May 26 09:13:06 2005 UTC (19 years ago) by dtucker
Branch: MAIN
Changes since 1.59: +11 -2 lines
Diff to previous 1.59 (colored)

Ensure previous adjust has completed before clearing alarm flag; ok henning@

Revision 1.59 / (download) - annotate - [select for diffs], Mon May 23 22:46:43 2005 UTC (19 years ago) by henning
Branch: MAIN
Changes since 1.58: +1 -2 lines
Diff to previous 1.58 (colored)

no need for endpwent(0 here either

Revision 1.58 / (download) - annotate - [select for diffs], Tue May 3 05:44:35 2005 UTC (19 years, 1 month ago) by djm
Branch: MAIN
Changes since 1.57: +3 -3 lines
Diff to previous 1.57 (colored)

setres[ug]id; ok deraadt@

Revision 1.57 / (download) - annotate - [select for diffs], Mon Apr 18 14:12:50 2005 UTC (19 years, 1 month ago) by henning
Branch: MAIN
Changes since 1.56: +5 -3 lines
Diff to previous 1.56 (colored)

correctness: only account for offset after settime in next and deadline
when those timers are actually running. due to the way ntpd's logic works
this does not really make a difference, but correctness is good.
spotted by me, joerg agrees

Revision 1.56 / (download) - annotate - [select for diffs], Mon Apr 18 11:07:55 2005 UTC (19 years, 1 month ago) by henning
Branch: MAIN
Changes since 1.55: +8 -1 lines
Diff to previous 1.55 (colored)

after setting the clock hard correct the "next" and "deadline" timestamps
by the offset
From: Joerg Sonnenberger <joerg@britannica.bec.de>

Revision 1.55 / (download) - annotate - [select for diffs], Thu Mar 24 14:50:07 2005 UTC (19 years, 2 months ago) by henning
Branch: MAIN
Changes since 1.54: +2 -2 lines
Diff to previous 1.54 (colored)

one more fatal/fatalx, alexander

Revision 1.54 / (download) - annotate - [select for diffs], Tue Mar 8 16:33:43 2005 UTC (19 years, 2 months ago) by henning
Branch: MAIN
CVS Tags: OPENBSD_3_7_BASE, OPENBSD_3_7
Changes since 1.53: +7 -5 lines
Diff to previous 1.53 (colored)

when trying short-circuit the wait for the first reply for -s, only
do so when
-we tried to send at least one query (that is the change)
-we could not send ou a single one without failure (this was already in
 place but catched too much)
problem independently noticed by nick and danh, ok mickey danh, testing by
many

Revision 1.53 / (download) - annotate - [select for diffs], Tue Mar 8 16:27:14 2005 UTC (19 years, 2 months ago) by deraadt
Branch: MAIN
Changes since 1.52: +3 -2 lines
Diff to previous 1.52 (colored)

knf

Revision 1.52 / (download) - annotate - [select for diffs], Tue Mar 8 14:37:16 2005 UTC (19 years, 2 months ago) by deraadt
Branch: MAIN
Changes since 1.51: +2 -1 lines
Diff to previous 1.51 (colored)

missing break spotted by lint

Revision 1.51 / (download) - annotate - [select for diffs], Tue Feb 22 12:03:24 2005 UTC (19 years, 3 months ago) by henning
Branch: MAIN
Changes since 1.50: +8 -3 lines
Diff to previous 1.50 (colored)

when sending a query already returns a failure, we're not going to see
a reply to that query.
if we get errors for all queries and the initial settime() is still due
and thus the parent process still waits (not yet daemonized!), send an
IMSG_SETTIME with offset 0.
shortens the delay dramatically when you boot without network
idea from a discussion with theo

Revision 1.50 / (download) - annotate - [select for diffs], Wed Feb 2 19:03:52 2005 UTC (19 years, 4 months ago) by henning
Branch: MAIN
Changes since 1.49: +10 -10 lines
Diff to previous 1.49 (colored)

KNF

Revision 1.49 / (download) - annotate - [select for diffs], Fri Jan 28 12:37:20 2005 UTC (19 years, 4 months ago) by dtucker
Branch: MAIN
Changes since 1.48: +17 -9 lines
Diff to previous 1.48 (colored)

Simplify interval scaling and randomize query intervals; ok henning@

Revision 1.48 / (download) - annotate - [select for diffs], Thu Jan 27 14:44:00 2005 UTC (19 years, 4 months ago) by dtucker
Branch: MAIN
Changes since 1.47: +31 -3 lines
Diff to previous 1.47 (colored)

Scale query interval by the overall offset not per-peer offset, so we
don't query outliers more often than any other server.  ok henning@

Revision 1.47 / (download) - annotate - [select for diffs], Thu Jan 27 10:32:29 2005 UTC (19 years, 4 months ago) by dtucker
Branch: MAIN
Changes since 1.46: +7 -5 lines
Diff to previous 1.46 (colored)

Delay before retrying a query on timeout; ok henning@

Revision 1.46 / (download) - annotate - [select for diffs], Thu Dec 23 16:10:10 2004 UTC (19 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.45: +1 -2 lines
Diff to previous 1.45 (colored)

KNF

Revision 1.45 / (download) - annotate - [select for diffs], Wed Dec 22 05:34:52 2004 UTC (19 years, 5 months ago) by henning
Branch: MAIN
Changes since 1.44: +2 -2 lines
Diff to previous 1.44 (colored)

if our first getpwnam(), testing for NTPD_USER, succeeded, but the second
returns NULL, we don't need loooong explanations, but at least some indicator
what went wrong, From: Michael Knudsen <e@molioner.dk>

Revision 1.44 / (download) - annotate - [select for diffs], Mon Dec 13 12:39:15 2004 UTC (19 years, 5 months ago) by dtucker
Branch: MAIN
Changes since 1.43: +7 -1 lines
Diff to previous 1.43 (colored)

Sanity check owner and permissions of privsep directory, like sshd does;
ok henning@

Revision 1.43 / (download) - annotate - [select for diffs], Mon Dec 13 12:36:02 2004 UTC (19 years, 5 months ago) by dtucker
Branch: MAIN
Changes since 1.42: +4 -4 lines
Diff to previous 1.42 (colored)

Check for error status from poll() too; ok henning@

Revision 1.42 / (download) - annotate - [select for diffs], Fri Nov 12 17:24:52 2004 UTC (19 years, 6 months ago) by henning
Branch: MAIN
Changes since 1.41: +2 -1 lines
Diff to previous 1.41 (colored)

some missing includes, from Joerg Sonnenberger <joerg@britannica.bec.de>

Revision 1.41 / (download) - annotate - [select for diffs], Wed Nov 10 11:47:28 2004 UTC (19 years, 6 months ago) by henning
Branch: MAIN
Changes since 1.40: +4 -4 lines
Diff to previous 1.40 (colored)

ntp_adjtime() -> priv_adjtime()
ntp_settime() -> priv_settime()
ntp_host_dns() -> priv_host_dns()

Revision 1.40 / (download) - annotate - [select for diffs], Wed Oct 27 14:19:12 2004 UTC (19 years, 7 months ago) by dtucker
Branch: MAIN
Changes since 1.39: +3 -2 lines
Diff to previous 1.39 (colored)

Calculate Hz and round up; ok henning@

Revision 1.39 / (download) - annotate - [select for diffs], Wed Oct 27 10:55:27 2004 UTC (19 years, 7 months ago) by henning
Branch: MAIN
Changes since 1.38: +8 -2 lines
Diff to previous 1.38 (colored)

use clock_getres(3) and calculate precision from that, and fill the
precision field when we reply in server mode accordingly. from phessler

Revision 1.38 / (download) - annotate - [select for diffs], Fri Oct 22 21:17:37 2004 UTC (19 years, 7 months ago) by henning
Branch: MAIN
Changes since 1.37: +8 -2 lines
Diff to previous 1.37 (colored)

in server mode reply with stratum from the peer that we currently prefer
plus one

Revision 1.37 / (download) - annotate - [select for diffs], Wed Oct 13 14:02:50 2004 UTC (19 years, 7 months ago) by henning
Branch: MAIN
Changes since 1.36: +9 -3 lines
Diff to previous 1.36 (colored)

set rootdelay in replies.
inherit rootdelay from the delay from the last client update from the peer
that we picked last time to adjust the local clock.
in some cases we use the average offset between two peers' client updates,
then use the average delay between the two as well.

Revision 1.36 / (download) - annotate - [select for diffs], Wed Oct 13 12:22:39 2004 UTC (19 years, 7 months ago) by henning
Branch: MAIN
Changes since 1.35: +5 -1 lines
Diff to previous 1.35 (colored)

correctly set refid in replies with NTP protocol versions < 4.
code path for NTP4 remains unchanged, we already set refid correctly there.
NTP3 and older uses an IPv4 address as refid.
use the IP of the server we last synced to if it was a IPv4 one.
sometimes we use the average offset between two, in that case just pick
one for the IP.
this scheme naturally fails when we query IPv6 servers and have to reply
to IPv4 NTP3 (or even older NTP versions) clients - refid stays at 0 then.
this is a protocol limitation, nothing we can do about it.

Revision 1.35 / (download) - annotate - [select for diffs], Wed Oct 13 09:20:41 2004 UTC (19 years, 7 months ago) by henning
Branch: MAIN
Changes since 1.34: +5 -3 lines
Diff to previous 1.34 (colored)

when we get back a IMSG_HOST_DNS message from the parent the peer ID within
might have become invalid (because the peer showed up, dns request sent to
parent, peer vanishes, and then the reply comes back), so do not fatal() in
that case but just log_warnx(). provoked by brad

Revision 1.34 / (download) - annotate - [select for diffs], Mon Oct 4 11:12:58 2004 UTC (19 years, 8 months ago) by henning
Branch: MAIN
Changes since 1.33: +43 -8 lines
Diff to previous 1.33 (colored)

do not take the average offset from all peers when calculating the total
offset to correct the local clock, but use the median.
given a reasonable sized set of servers this makes us nearly immune against
outliers or flasetickers, without the need for a horribly complicated outliers
detection which does not yield to better results anyway.
test & ok otto

Revision 1.33 / (download) - annotate - [select for diffs], Sat Sep 18 20:01:38 2004 UTC (19 years, 8 months ago) by henning
Branch: MAIN
Changes since 1.32: +23 -4 lines
Diff to previous 1.32 (colored)

add a new -s option, that tells ntpd to set the time using settimeofday()
once at startup. ntpd delays daemonizing until it has done the intial
time setting (or ran into the timeout) in this mode to make sure stuff started
later in rc is not subject to time jumps.
this eleminates the need to run rdate -n beforehands.
with some input from & ok ryan and bob, march music from mickey

Revision 1.32 / (download) - annotate - [select for diffs], Sat Sep 18 07:33:14 2004 UTC (19 years, 8 months ago) by henning
Branch: MAIN
Changes since 1.31: +9 -13 lines
Diff to previous 1.31 (colored)

do not bother overallocating and shrinking the pfd and idx2peer arrays,
doesn't by us anything. discussed with ryan during dinner at original joe's

Revision 1.31 / (download) - annotate - [select for diffs], Wed Sep 15 19:21:25 2004 UTC (19 years, 8 months ago) by henning
Branch: MAIN
Changes since 1.30: +3 -3 lines
Diff to previous 1.30 (colored)

imsg framework cleanup:
-kill the _pid flavors of imsg_create and imsg_compose, and just add pid as
argument to those
-use imsg_create in imsg_compose instead of duplicating code
-check for datalen overflow

Revision 1.30 / (download) - annotate - [select for diffs], Wed Sep 15 19:14:11 2004 UTC (19 years, 8 months ago) by henning
Branch: MAIN
Changes since 1.29: +15 -12 lines
Diff to previous 1.29 (colored)

malloc the imsg buffers instead of having them statically, suggested by
micsky some time ago, ok otto

Revision 1.29 / (download) - annotate - [select for diffs], Wed Sep 15 00:08:06 2004 UTC (19 years, 8 months ago) by henning
Branch: MAIN
Changes since 1.28: +1 -2 lines
Diff to previous 1.28 (colored)

unused variables, theo

Revision 1.28 / (download) - annotate - [select for diffs], Wed Sep 15 00:07:20 2004 UTC (19 years, 8 months ago) by henning
Branch: MAIN
Changes since 1.27: +2 -1 lines
Diff to previous 1.27 (colored)

missing include, from theo

Revision 1.27 / (download) - annotate - [select for diffs], Thu Sep 9 21:50:33 2004 UTC (19 years, 8 months ago) by henning
Branch: MAIN
CVS Tags: OPENBSD_3_6_BASE, OPENBSD_3_6
Changes since 1.26: +24 -8 lines
Diff to previous 1.26 (colored)

correctly track peer count. fixes a memory corruption.
with & ok otto millert claudio, ok deraadt canacar

Revision 1.26 / (download) - annotate - [select for diffs], Thu Aug 12 16:33:59 2004 UTC (19 years, 9 months ago) by henning
Branch: MAIN
Changes since 1.25: +55 -1 lines
Diff to previous 1.25 (colored)

do not try to getaddrinfo() in the unprivileged process, send an imsg
asking the privileged one to do it. sends back an imsg with the
resulting addresses in a bunch of struct sockaddr_storage in the data
part.
this should fix all remaining issues with dns (non-)availability at
ntpd startup, be it due to named on localhost or something else.
tested by marco@ and Chris Paul <chris.paul@sentinare.com>

Revision 1.25 / (download) - annotate - [select for diffs], Sun Jul 18 12:59:41 2004 UTC (19 years, 10 months ago) by henning
Branch: MAIN
Changes since 1.24: +13 -21 lines
Diff to previous 1.24 (colored)

query interval scaling, episode II
1) base the interval calculation on the offset from the last reply, not
   from the last peer update.
   Allows us to send more queries again faster when the local clock
   diverges too much
2) every time we form a peer update (for which we need 8 replies)
   check wether we have a ready peer update for all peers that are
   currently trusted, and if so, calculate the total offset and call
   adjtime().
   that means that adjtime is no longer called in fixed intervals
   but whenever we have enough data to reliably calculate the local
   clock offset.
   In practice, that means we call adjtime() less often, but with
   probably better data.
3) invalidate peer updates after beeing used. no point in re-using them
   - this resulted in calling adjtime() multiple times with the same
   offset, which doesn't make sense
tested by many

Revision 1.24 / (download) - annotate - [select for diffs], Wed Jul 14 20:16:31 2004 UTC (19 years, 10 months ago) by henning
Branch: MAIN
Changes since 1.23: +2 -6 lines
Diff to previous 1.23 (colored)

do not do the stratum guessing dance.
stratum is pretty much pointless anyway these days, and we certainly
do not want to send out illegal packets (stratum=0) until synced...

Revision 1.23 / (download) - annotate - [select for diffs], Tue Jul 13 19:41:26 2004 UTC (19 years, 10 months ago) by alexander
Branch: MAIN
Changes since 1.22: +27 -12 lines
Diff to previous 1.22 (colored)

Respond to client queries with better server statistics.  We now output
a close-to-reality stratum, a real reference time, and a leap indicator
that will indicate if the local clock isn't synchronized.

This also means that until the server feels it's synchronized, it will
tell the clients it isn't.  This is normal, and correct.

ok henning@

Revision 1.22 / (download) - annotate - [select for diffs], Sat Jul 10 18:42:51 2004 UTC (19 years, 10 months ago) by henning
Branch: MAIN
Changes since 1.21: +11 -55 lines
Diff to previous 1.21 (colored)

scale query interval based on local clock offset. tested by many
not as efficient as I want it to be yet, but more is coming

Revision 1.21 / (download) - annotate - [select for diffs], Fri Jul 9 15:00:43 2004 UTC (19 years, 10 months ago) by henning
Branch: MAIN
Changes since 1.20: +5 -4 lines
Diff to previous 1.20 (colored)

don't try to update the clock when we have no data

Revision 1.20 / (download) - annotate - [select for diffs], Fri Jul 9 12:21:09 2004 UTC (19 years, 10 months ago) by henning
Branch: MAIN
Changes since 1.19: +2 -1 lines
Diff to previous 1.19 (colored)

the child process needs to ignore SIGHUP for now, otto

Revision 1.19 / (download) - annotate - [select for diffs], Fri Jul 9 10:53:33 2004 UTC (19 years, 10 months ago) by henning
Branch: MAIN
Changes since 1.18: +6 -5 lines
Diff to previous 1.18 (colored)

rework dns handling with all its cosequences...
we know have both a "server" and "servers" keyword. they differ when the
hostname resolves to more than one IP, server picks one and servers expands
to all.
that means no longer stuffing a sockaddr_storage into ntp_peer but a pointer
to a linked list of ntp_addr structs.
in the "servers" case the list of n addresses returned by host() is expanded
into n ntp_peer structs and thus n individual peers.
in the "server" case the whole list is attached to ntp_peer, and whenever we
do not receive a reply in time we traverse the list one further, so that
hosts with both AAAA and A records are first tried with the AAAA one but
we gracefully fall back to the A one.
semantics with theo; hacked up on the Montreal->Frankfurt flight.
again Air Canada surprised me, that older 767 hat pretty decent seats.

Revision 1.18 / (download) - annotate - [select for diffs], Fri Jul 9 10:22:07 2004 UTC (19 years, 10 months ago) by henning
Branch: MAIN
Changes since 1.17: +4 -2 lines
Diff to previous 1.17 (colored)

when calculating the timeout for poll() we need to take the deadlines for
the outstanding queries into account
just-before-meal from the Montreal->Frankfurt flight

Revision 1.17 / (download) - annotate - [select for diffs], Thu Jul 8 15:06:13 2004 UTC (19 years, 10 months ago) by henning
Branch: MAIN
Changes since 1.16: +3 -4 lines
Diff to previous 1.16 (colored)

remove a bogus always-true test before adjtime()

Revision 1.16 / (download) - annotate - [select for diffs], Thu Jul 8 01:21:09 2004 UTC (19 years, 10 months ago) by henning
Branch: MAIN
Changes since 1.15: +3 -1 lines
Diff to previous 1.15 (colored)

log_debug() when a peer doesn't answer in time

Revision 1.15 / (download) - annotate - [select for diffs], Wed Jul 7 07:32:05 2004 UTC (19 years, 10 months ago) by alexander
Branch: MAIN
Changes since 1.14: +2 -23 lines
Diff to previous 1.14 (colored)

* Convert to use the new double-based time handling functions.
* Respond to the query with a reasonable received time (which
  will help clients get better accuracy).
* Consolidate the server response code in preparation for a
  completely 'proper' response to the client.

tips and ok from henning@

Revision 1.14 / (download) - annotate - [select for diffs], Wed Jul 7 03:57:28 2004 UTC (19 years, 11 months ago) by henning
Branch: MAIN
Changes since 1.13: +2 -2 lines
Diff to previous 1.13 (colored)

yuck, another bad sizeof(). again in code hacked on the Frankfurt->Montreal
flight. should we draw concludions from that? I'd like to blame the
Air Canada seats...

Revision 1.13 / (download) - annotate - [select for diffs], Wed Jul 7 01:01:27 2004 UTC (19 years, 11 months ago) by henning
Branch: MAIN
Changes since 1.12: +28 -13 lines
Diff to previous 1.12 (colored)

keep a "trustlevel" per peer. loose credit for loosing a packet, loose
a lot of credit for not having supplied us with enough data within an
adjtime run interval, and get a little credit each time we get a good
reply packet. if a peer is below 20%, only send a packet occasionally to
see wether it is back. send out queries much more often between 20 and 80%
to (re-)sync quickly, and above 80% usethe regular interval.
do not use peers < 60% for calculating teh local clock offset.
designed with theo at the pho, alexander ok

Revision 1.12 / (download) - annotate - [select for diffs], Tue Jul 6 23:26:38 2004 UTC (19 years, 11 months ago) by henning
Branch: MAIN
Changes since 1.11: +43 -5 lines
Diff to previous 1.11 (colored)

Implement the clock filter as descirbed by David Mills:
form the last 8 replied received from a peer, find the one with the lowest
delay. Use that as the peer's update taken into account for calculating
the local clock's offset.
Invalidate that reply and all ones received earlier than it so that they do
not get used again.

Revision 1.11 / (download) - annotate - [select for diffs], Mon Jul 5 22:12:53 2004 UTC (19 years, 11 months ago) by henning
Branch: MAIN
Changes since 1.10: +8 -8 lines
Diff to previous 1.10 (colored)

keep last 8 offset,delay pairs - we'll need them for the clock filters later.
for now, average over those to adjust the local clock.

Revision 1.10 / (download) - annotate - [select for diffs], Mon Jul 5 07:46:16 2004 UTC (19 years, 11 months ago) by henning
Branch: MAIN
Changes since 1.9: +40 -6 lines
Diff to previous 1.9 (colored)

calculate the median offset from all servers we sync to and call
adjtime() when necessary to keep the local clock in sync
yes, that means ntpd syncs the local clock now.

Revision 1.9 / (download) - annotate - [select for diffs], Tue Jun 22 07:59:48 2004 UTC (19 years, 11 months ago) by alexander
Branch: MAIN
Changes since 1.8: +4 -4 lines
Diff to previous 1.8 (colored)

Precedence and type fix; ok henning@

Revision 1.8 / (download) - annotate - [select for diffs], Fri Jun 18 04:51:31 2004 UTC (19 years, 11 months ago) by henning
Branch: MAIN
Changes since 1.7: +43 -10 lines
Diff to previous 1.7 (colored)

size struct pollfd and idx2peer dynamically instead of imposing an arbitary
limit on OPEN_MAX, modeled after bgpd

Revision 1.7 / (download) - annotate - [select for diffs], Thu Jun 17 19:17:48 2004 UTC (19 years, 11 months ago) by henning
Branch: MAIN
Changes since 1.6: +45 -5 lines
Diff to previous 1.6 (colored)

provide most of the client functionality.
hook the descriptors into the main poll and such.
we're not doing anything with the reply we recive yet, tho.

mostly hacked on the Frankfurt->Montreal flight, as batteries and those
horrible air canada seats permitted...

Revision 1.6 / (download) - annotate - [select for diffs], Wed Jun 2 10:08:59 2004 UTC (20 years ago) by henning
Branch: MAIN
Changes since 1.5: +1 -221 lines
Diff to previous 1.5 (colored)

prepare for client functionality

Revision 1.5 / (download) - annotate - [select for diffs], Tue Jun 1 21:58:08 2004 UTC (20 years ago) by henning
Branch: MAIN
Changes since 1.4: +17 -1 lines
Diff to previous 1.4 (colored)

first cut at config file parser
for now, one can set the addresses to listen on

Revision 1.4 / (download) - annotate - [select for diffs], Tue Jun 1 16:27:09 2004 UTC (20 years ago) by henning
Branch: MAIN
Changes since 1.3: +50 -64 lines
Diff to previous 1.3 (colored)

allow ntpd to listen on nearly arbitary number of sockets (OPEN_MAX - 1 atm).
default to one IPv4 wildcard and one IPv6 wildcard one.

Revision 1.3 / (download) - annotate - [select for diffs], Mon May 31 21:43:23 2004 UTC (20 years ago) by henning
Branch: MAIN
Changes since 1.2: +41 -43 lines
Diff to previous 1.2 (colored)

naming consistency

Revision 1.2 / (download) - annotate - [select for diffs], Mon May 31 15:11:56 2004 UTC (20 years ago) by henning
Branch: MAIN
Changes since 1.1: +45 -12 lines
Diff to previous 1.1 (colored)

make my japanese friends happy by supporting IPv6 as well

Revision 1.1 / (download) - annotate - [select for diffs], Mon May 31 13:46:16 2004 UTC (20 years ago) by henning
Branch: MAIN

initial cut at ntpd.
it is just capable of answering (s)ntp4 requests with the local time
for now.
imsg/buffer and logging framework from bgpd, ntp protocol hackery
with Alexander Guy

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.