| SWM-NTP(8) | System Manager's Manual | SWM-NTP(8) |
NAME
swm-ntp — NTP
client of the scrotwmos net VM
SYNOPSIS
swm-ntp |
[-dnSsv] [-P
name] -f
server[,server ...] |
DESCRIPTION
swm-ntp is the NTP daemon of
OpenBSD, ntpd, on Linux in the net VM. It keeps the
net VM's clock on time from up to four NTP servers. It tells the host how
far the net VM's clock is from the host's. It is a client only: it serves no
time and has no control socket, sensors, or constraints.
scrotwmd(8), the net VM's
first process, starts it as root with -d, on the
servers of net_ntp in
scrotwmos.conf(5), else on those
of the DHCP lease. It starts it again 5 seconds after it ends, and stops it
when the list of servers or the uplink changes.
The options are as follows:
-d- Do not become a daemon; log to the standard error. Without it, it logs to syslog(3).
-fserver[,server ...]- One to four IPv4 addresses, separated by commas. This option is required.
swm-ntprefuses a name, an IPv6 address, or a fifth server. -n- Check the servers, print “configuration OK”, and exit. Descriptor 4 must be the socket for this too.
-Pname- Internal: the parent runs the program again with
-Pto start its NTP engine, and the engine runs it with-Pto start its name process. -S,-s- Ignored, with a warning.
-v- Given twice, log debug messages too.
Setting the clock
At the first start of a boot, swm-ntp sets
the clock once. It waits up to 15 seconds for an answer. When the clock is
more than 128 ms off, it steps the clock; when it is less, it slews. After
that it only slews.
Privilege separation
swm-ntp runs as three processes. The
parent stays root with CAP_SYS_TIME alone. The NTP
engine runs as uid and gid 123, “_ntp”, chrooted to
/var/empty, and the name process as the same user.
Each runs under a system call filter; a call outside it kills the process.
It needs no /etc: the user and the NTP service, UDP
port 123, are built in.
Records to the host
The parent reads the net VM's clock minus the host's on
/dev/ptp_kvm and writes it as a record on descriptor
4, which must be a SOCK_SEQPACKET socket. While the
clock is synced, it sends an offset record, at most one every 34 seconds.
After a step, it sends one step record when the clock is then more than 128
ms off the host's. An offset record that does not fit in the socket is lost
and logged. Without /dev/ptp_kvm, it logs that and
sends no records.
ENVIRONMENT
SWM_NTP_NOSTEP- When present, do not set the clock at start. scrotwmd(8) gives it on each start after the first of a boot.
TZ- scrotwmd(8) gives
UTC0.
FILES
- /dev/ptp_kvm
- the host's clock, a link scrotwmd(8) makes to the PTP device named “KVM virtual PTP”
- /var/empty
- the NTP engine's chroot
- /var/db/ntpd.drift
- the clock's frequency; the net VM has no /var/db, so it keeps none and learns the frequency again at each start
SIGNALS
EXIT STATUS
swm-ntp exits 0 on
SIGINT or SIGTERM, and after
-n with good servers. It exits 1 on a bad option or
server list, when it is not root, or when descriptor 4 is not a
SOCK_SEQPACKET socket.
SEE ALSO
HISTORY
swm-ntp is the ntpd of
OpenBSD, also known as OpenNTPD, with its source
unchanged. The Linux system calls, the system call filter, the server list,
and the records to the host are new.
AUTHORS
ntpd was written by Henning Brauer <henning@openbsd.org> with Alexander Guy and Mike Miller. Its imsg, from the libutil of OpenBSD, is by Claudio Jeker, Henning Brauer, Pierre-Yves Ritschard, and Reyk Floeter. The net VM parts are by Marco Peereboom <marco@peereboom.us>.
| November 13, 2026 | Void Linux |