Compare commits

...
134 Commits
Author SHA1 Message Date
Ed Maste 3df06c28ba Add UPDATING entry and bump version
Approved by:	so
2021-01-28 20:01:02 -05:00
Roger Pau Monné 785afb167c xen: allow limiting the amount of duplicated pending xenstore watches
Xenstore watches received are queued in a list and processed in a
deferred thread. Such queuing was done without any checking, so a
guest could potentially trigger a resource starvation against the
FreeBSD kernel if such kernel is watching any user-controlled xenstore
path.

Allowing limiting the amount of pending events a watch can accumulate
to prevent a remote guest from triggering this resource starvation
issue.

For the PV device backends and frontends this limitation is only
applied to the other end /state node, which is limited to 1 pending
event, the rest of the watched paths can still have unlimited pending
watches because they are either local or controlled by a privileged
domain.

The xenstore user-space device gets special treatment as it's not
possible for the kernel to know whether the paths being watched by
user-space processes are controlled by a guest domain. For this reason
watches set by the xenstore user-space device are limited to 1000
pending events. Note this can be modified using the
max_pending_watch_events sysctl of the device.

This is XSA-349.

Sponsored by:	Citrix Systems R&D
MFC after:	3 days

(cherry picked from commit 4e4e43dc9e)
(cherry picked from commit 2d194dc219)

Approved by:	so
Security:	XSA-349, CVE-2020-29568
2021-01-28 20:00:20 -05:00
Roger Pau Monné ee4693d4da xen/xenstore: remove unused functions
Those helpers are not used, so remove them. No functional change.

Sponsored by:	Citrix Systems R&D
MFC after:	3 days

(cherry picked from commit 2ae75536d3)
(cherry picked from commit af4ed05c3d)

Approved by:	so
2021-01-28 20:00:13 -05:00
Mark Johnston bec758f641 msdosfs: Fix a leak of dirent padding bytes
This was missed in r340856 / commit
6d2e2df764.  Three bytes from the kernel
stack may be leaked when reading directory entries.

Reported by:	Syed Faraz Abrar <[email protected]>

(cherry picked from commit 599f904463)
(cherry picked from commit 5ece34669c)

Approved by:	so
Security:	CVE-2020-25579
2021-01-28 19:59:53 -05:00
Mark Johnston 66ace87da4 Ensure that dirent's d_off field is initialized
We have the d_off field in struct dirent for providing the seek offset
of the next directory entry.  Several filesystems were not initializing
the field, which ends up being copied out to userland.

Reported by:	Syed Faraz Abrar <[email protected]>
Reviewed by:	kib

(cherry picked from commit 90f580b954)
(cherry picked from commit acaac0eefa)

Approved by:	so
Security:	CVE-2020-25578
2021-01-28 19:59:18 -05:00
Kristof Provost e0c15f45ab MFC r368237: if: Fix panic when destroying vnet and epair simultaneously
When destroying a vnet and an epair (with one end in the vnet) we often
panicked. This was the result of the destruction of the epair, which destroys
both ends simultaneously, happening while vnet_if_return() was moving the
struct ifnet to its home vnet. This can result in a freed ifnet being re-added
to the home vnet V_ifnet list. That in turn panics the next time the ifnet is
used.

Prevent this race by ensuring that vnet_if_return() cannot run at the same time
as if_detach() or epair_clone_destroy().

PR:		238870, 234985, 244703, 250870
Sponsored by:	Modirum MDPay
Approved by:	so
2021-01-28 19:58:55 -05:00
Philip Paeps ada9757963 contrib/tzdata: import tzdata 2021a
Merge commit '4cd7e1071de16a7392b0e466287f13e9e6f2081a'

Changes: https://github.com/eggert/tz/blob/2021a/NEWS

(cherry picked from commit 8c5bef2eb2)
(cherry picked from commit 085997e8f0)

Approved by:	so
2021-01-28 19:58:45 -05:00
Philip Paeps 4986b4192e MFC: contrib/tzdata: import tzdata 2020f
Merge commit '96b88ac701b35ce68425046d4be8f51cb75b5d5b' into main

Changes: https://github.com/eggert/tz/blob/2020f/NEWS

(cherry picked from commit e35a01eec6)
(cherry picked from commit ce87312019)

Approved by:	so
2021-01-28 19:58:30 -05:00
Philip Paeps 3930702f5b MFC: contrib/tzdata: import tzdata 2020e
Changes: https://github.com/eggert/tz/blob/2020e/NEWS

(cherry picked from commit dc505d53dc)
(cherry picked from commit 1a8f8af033)

Approved by:	so
2021-01-28 19:58:20 -05:00
Gordon Tetlow e30782bbda Fix OpenSSL NULL pointer de-reference.
Approved by:	so
Security:	FreeBSD-SA-20:33.openssl
Security:	CVE-2020-1971
2020-12-08 19:10:40 +00:00
Gordon Tetlow c944cb7416 Add UPDATING entries and bump version.
Approved by:	so
2020-12-01 19:40:58 +00:00
Gordon Tetlow 0c3089f7ac Fix multiple vulnerabilities in rtsold.
Approved by:	so
Security:	FreeBSD-SA-20:32.rtsold
Security:	CVE-2020-25577
2020-12-01 19:39:44 +00:00
Gordon Tetlow 88f83fe210 Fix ICMPv6 use-after-free in error message handling.
Approved by:	so
Security:	FreeBSD-SA-20:31.icmp6
Security:	CVE-2020-7469
2020-12-01 19:38:52 +00:00
Gordon Tetlow 67eeec4810 Fix race condition in callout CPU migration.
Approved by:	so
Security:	FreeBSD-EN-20:22.callout
2020-12-01 19:37:33 +00:00
Gordon Tetlow 4431dcae87 Update timezone database information.
Approved by:	so
Security:	FreeBSD-EN-20:20.tzdata
2020-12-01 19:35:48 +00:00
Gordon Tetlow 8f817ae5aa Fix execve/fexecve system call auditing.
Approved by:	so
Security:	FreeBSD-EN-20:19.audit
2020-12-01 19:34:45 +00:00
Gordon Tetlow 554a831b7d Add UPDATING entries and bump version.
Approved by:	so
Approved by:	re (implicit for releng/12.2)
2020-09-15 21:48:24 +00:00
Gordon Tetlow 7fbd0babb9 Fix ftpd privilege escalation via ftpchroot.
Approved by:	so
Approved by:	re (implicit for releng/12.2)
Security:	FreeBSD-SA-20:30.ftpd
Security:	CVE-2020-7468
2020-09-15 21:47:44 +00:00
Gordon Tetlow ae90c99ed8 Fix bhyve SVM guest escape.
This actually has a patch to sys/amd64/vmm/amd/svm.c that was accidentally
committed as part of r365779.

Approved by:	so
Approved by:	re (implicit for releng/12.2)
Security:	FreeBSD-SA-20:29.bhyve_svm
Security:	CVE-2020-7467
2020-09-15 21:46:39 +00:00
Gordon Tetlow a473c6b774 Fix bhyve privilege escalation via VMCS access.
Approved by:	so
Approved by:	re (implicit for releng/12.2)
Security:	FreeBSD-SA-20:28.bhyve_vmcs
Security:	CVE-2020-24718
2020-09-15 21:43:41 +00:00
Gordon Tetlow 1f5f8963a7 Fix ure device driver susceptible to packet-in-packet attack.
Approved by:	so
Approved by:	re (implicit for releng/12.2)
Security:	FreeBSD-SA-20:27.ure
Security:	CVE-2020-7464
2020-09-15 21:42:05 +00:00
Gordon Tetlow 145fad722b Add UPDATING entries and bump version.
Approved by:	so
2020-09-02 16:29:40 +00:00
Gordon Tetlow b2ed812dbd Fix dhclient heap overflow.
Approved by:	so
Security:	FreeBSD-SA-20:26.dhclient
Security:	CVE-2020-7461
2020-09-02 16:25:31 +00:00
Gordon Tetlow f6ce56c68c Fix SCTP socket use-after-free.
Approved by:	so
Security:	FreeBSD-SA-20:25.sctp
Security:	CVE-2020-7463
2020-09-02 16:24:32 +00:00
Gordon Tetlow 0641373860 Fix FreeBSD Linux ABI kernel panic.
Approved by:	so
Security:	FreeBSD-EN-20:17.linuxthread
2020-09-02 16:21:27 +00:00
Gordon Tetlow 136975a91f Add UPDATING entries and bump version.
Approved by:	so
2020-08-05 17:14:37 +00:00
Gordon Tetlow be89e4c6af Fix sendmsg(2) privilege escalation.
Approved by:	so
Security:	FreeBSD-SA-20:23.sendmsg
Security:	CVE-2020-7460
2020-08-05 17:14:01 +00:00
Gordon Tetlow 1b1e7cabc3 Fix multiple vulnerabilities in sqlite3.
Approved by:	so
Security:	FreeBSD-SA-20:22.sqlite
Security:	CVE-2020-11655
Security:	CVE-2020-11656
Security:	CVE-2020-13434
Security:	CVE-2020-13435
Security:	CVE-2020-13630
Security:	CVE-2020-13631
Security:	CVE-2020-13632
2020-08-05 17:13:08 +00:00
Gordon Tetlow 8608d8575f Fix memory corruption in USB network device drivers.
Approved by:	so
Security:	FreeBSD-SA-20:21.usb_net
Security:	CVE-2020-7459
2020-08-05 17:11:18 +00:00
Gordon Tetlow 4ea4239800 Fix vmx driver packet loss and degraded performance.
Approved by:	so
Security:	FreeBSD-EN-20:16.vmx
2020-08-05 17:09:54 +00:00
Gordon Tetlow 46b2ed296e Add UPDATING entries and bump version.
Approved by:	so
2020-07-08 20:26:19 +00:00
Gordon Tetlow 7b12e48625 Fix multiple vulnerabilities in unbound.
Approved by:	so
Security:	FreeBSD-SA-20:19.unbound
Security:	CVE-2020-12662
Security:	CVE-2020-12663
2020-07-08 20:25:06 +00:00
Gordon Tetlow e737287d4e Fix IPv6 socket option race condition and use after free.
Approved by:	so
Security:	FreeBSD-SA-20:20.ipv6
Security:	CVE-2020-7457
2020-07-08 20:11:40 +00:00
Gordon Tetlow 0cae766bdc Fix kernel panic in mps(4) driver.
Approved by:	so
Security:	FreeBSD-EN-20:15.mps
2020-07-08 19:58:00 +00:00
Gordon Tetlow e268defb43 Fix kernel panic in LinuxKPI subsystem.
Approved by:	so
Security:	FreeBSD-EN-20:14.linuxpki
2020-07-08 19:57:24 +00:00
Gordon Tetlow e4036fcd5e Fix host crash in bhyve with PCI device passthrough.
Approved by:	so
Security:	FreeBSD-EN-20:13.bhyve
2020-07-08 19:56:34 +00:00
Gordon Tetlow 5c94e7106d Add UPDATING entries and bump version.
Approved by:	so
Approved by:	re (implicit)
2020-06-09 16:15:07 +00:00
Gordon Tetlow bc689c2fb4 Fix USB HID descriptor parsing error.
Approved by:	so
Approved by:	re (implicit)
Security:	FreeBSD-SA-20:17.usb
Security:	CVE-2020-7456
2020-06-09 16:13:54 +00:00
Gordon Tetlow 0d707bd5b6 Fix iflib watchdog timeout resetting idle queues.
Approved by:	so
Security:	FreeBSD-EN-20:12.iflib
2020-06-09 16:11:54 +00:00
Gordon Tetlow c8c559b872 Fix stability issues in ena(4) driver.
Approved by:	so
Security:	FreeBSD-EN-20:11.ena
2020-06-09 16:10:57 +00:00
Gordon Tetlow f132e99efa Add UPDATING entries and bump version.
Approved by:	so
Approved by:	re (implicit)
2020-05-12 17:00:23 +00:00
Gordon Tetlow 9283848694 Fix insufficient cryptodev MAC key length check.
Approved by:	so
Security:	FreeBSD-SA-20:16.cryptodev
Security:	CVE-2019-15880
2020-05-12 16:59:09 +00:00
Gordon Tetlow 63e2b50842 Fix use after free in cryptodev module.
Approved by:	so
Security:	FreeBSD-SA-20:15.cryptodev
Security:	CVE-2019-15879
2020-05-12 16:57:47 +00:00
Gordon Tetlow 86a708f147 Fix memory disclosure vulnerability in libalias.
Approved by:	so
Approved by:	re (implicit)
Security:	FreeBSD-SA-20:13.libalias
Security:	CVE-2020-7455
2020-05-12 16:54:39 +00:00
Gordon Tetlow 8f442d6baa Fix insufficient packet length validation in libalias.
Approved by:	so
Approved by:	re (implicit)
Security:	FreeBSD-SA-20:12.libalias
Security:	CVE-2020-7454
2020-05-12 16:51:11 +00:00
Gordon Tetlow 97797099e2 Fix igb interfaces failing to switch to inactive state.
Approved by:	so
Security:	FreeBSD-EN-20:09.igb
2020-05-12 16:46:14 +00:00
Gordon Tetlow 42a95f3e84 Update to tzdata 2020a.
Approved by:	so
Security:	EN-20:08.tzdata
2020-05-12 16:44:13 +00:00
Ed Maste d98e1c62c3 MF10 r352637,r358076: correct Clang and lld version checks
r352637 (mhorne): Allow for compiler versions >= 10
r358076 (dim): Correctly recognize linker versions greater than 10.0.

These routines determine the host compiler and linker version, and caused
attempts to build 12.1-RELEASE on 13-CURRENT to fail after the latter was
updated to Clang 10.  We don't guarantee such a build config to work, but
it is used by FreeBSD ports build processes.  As a result the fixes from
stable/12 will be included with the next set of advisories, and are being
committed to the branch now to unblock ports builds.

PR:		245973
Reported by:	sbruno, antoine
Approved by:	so
Errata:		EN-20:10.build
Sponsored by:	The FreeBSD Foundation
2020-04-29 18:51:34 +00:00
Gordon Tetlow 3689a02291 Add UPDATING entries and bump version.
Approved by:	so
2020-04-21 15:54:08 +00:00
Gordon Tetlow 2037abc612 Fix OpenSSL remote denial of service vulnerability.
Approved by:	so
Security:	FreeBSD-SA-20:11.openssl
Security:	CVE-2020-1967
2020-04-21 15:53:08 +00:00
Gordon Tetlow b2139df42d Fix ipfw invalid mbuf handling.
Approved by:	so
Security:	FreeBSD-SA-20:10.ipfw
Security:	CVE-2019-5614
Security:	CVE-2019-15874
2020-04-21 15:52:22 +00:00
Gordon Tetlow 5a7495693c Fix regression in rpc.rquotad with certain NFS servers.
Approved by:	so
Security:	FreeBSD-EN-20:07.quotad
2020-04-21 15:50:57 +00:00
Gordon Tetlow 514c1ff991 Add UPDATING entries and bump version.
Approved by:	so
2020-03-19 17:01:57 +00:00
Gordon Tetlow 298b63370a Fix multiple denial of service in ntpd.
Approved by:	so
Security:	FreeBSD-SA-20:09.ntp
2020-03-19 16:52:41 +00:00
Gordon Tetlow dd377685f2 Fix kernel memory disclosure with nested jails.
Approved by:	so
Security:	FreeBSD-SA-20:08.jail
Security:	CVE-2020-7453
2020-03-19 16:51:33 +00:00
Gordon Tetlow fcfa8e1efd Fix incorrect user-controlled pointer use in epair.
Approved by:	so
Security:	FreeBSD-SA-20:07.epair
Security:	CVE-2020-7452
2020-03-19 16:50:36 +00:00
Gordon Tetlow 9842ed8859 Fix insufficient ixl(4) ioctl(2) privilege checking.
Approved by:	so
Security:	FreeBSD-SA-20:06.if_ixl_ioctl
Security:	CVE-2019-15877
2020-03-19 16:49:32 +00:00
Gordon Tetlow 03a5d3e78c Fix insufficient oce(4) ioctl(2) privilege checking.
Approved by:	so
Security:	FreeBSD-SA-20:05.if_oce_ioctl
Security:	CVE-2019-15876
2020-03-19 16:48:29 +00:00
Gordon Tetlow 8274d878c0 Fix TCP IPv6 SYN cache kernel information disclosure.
Approved by:	so
Security:	FreeBSD-SA-20:04.tcp
Security:	CVE-2020-7451
2020-03-19 16:46:01 +00:00
Gordon Tetlow 2db4f63add Fix incorrect checksum calculations with IPv6 extension headers.
Approved by:	so
Security:	FreeBSD-EN-20:06.ipv6
2020-03-19 16:43:37 +00:00
Gordon Tetlow cce92367e3 Fix packet forwarding performance in mlx5en(4) driver.
Approved by:	so
Security:	FreeBSD-EN-20:05.mlx5en
2020-03-19 16:41:29 +00:00
Gordon Tetlow 695a183784 Fix misleading log messages upon successful sshd login.
Approved by:	so
Security:	FreeBSD-EN-20:03.sshd
2020-03-19 16:34:11 +00:00
Gordon Tetlow e75cfcd9db Add UPDATING entries and bump version.
Approved by:	so
2020-01-28 18:58:37 +00:00
Gordon Tetlow 1804b0bd53 Fix kernel stack data disclosure
Reported by:	Ilja Van Sprundel
Approved by:	so
Security:	FreeBSD-SA-20:03.thrmisc
Security:	CVE-2019-15875
2020-01-28 18:57:45 +00:00
Gordon Tetlow 732ac9a587 Fix libfetch buffer overflow
Reported by:	Duncan Overbruck
Approved by:	so
Security:	FreeBSD-SA-20:01.libfetch
Security:	CVE-2020-7450
2020-01-28 18:55:25 +00:00
Gordon Tetlow b6c023d0cf Fix imprecise ordering of SSP canary initialization
Submitted by:	Kyle Evans
Approved by:	so
Security:	FreeBSD-EN-20:01.ssp
2020-01-28 18:53:14 +00:00
Gordon Tetlow 8cd56fbf5a Add UPDATING entries and bump version numbers.
Approved by:	so
2019-11-12 18:13:51 +00:00
Gordon Tetlow 398970d91a Fix Machine Check Exception on Page Size Change.
Approved by:	so
Security:	FreeBSD-SA-19:25.mcepsc
Security:	CVE-2018-12207
2019-11-12 18:13:04 +00:00
Gordon Tetlow 55046f686e Fix UEFI Loader Memory Fragmentation.
Approved by:	so
Security:	FreeBSD-EN-19:19.loader
2019-11-12 18:10:26 +00:00
Glen Barber cc807f9e55 - Switch releng/12.1 from RC2 to RELEASE.
- Add the anticipated 12.1-RELEASE date to UPDATING.
- Set a static __FreeBSD_version.

Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-11-01 00:00:17 +00:00
Michael Tuexen 16981b16f3 MFS r354090:
Ensure that the flags indicating IPv4/IPv6 are not changed by failing
bind() calls. This would lead to inconsistent state resulting in a panic.
A fix for stable/11 was committed in
https://svnweb.freebsd.org/base?view=revision&revision=338986

Reported by:		[email protected]
Obtained from:		jtl@
Sponsored by:		Netflix, Inc.
Approved by:		re (gjb@)
2019-10-25 18:46:53 +00:00
Glen Barber 3f53a11e19 MFC r353776 (dim):
Follow up on r351916 by also bumping the version suffix to 12.1 in
 Makefile.libcompat.

Approved by:	re (kib)
Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-10-21 17:17:21 +00:00
Glen Barber 27cbd813d3 - Update releng/12.1 from RC1 to RC2 as part of the 12.1-RELEASE
cycle.
- Update the dvd1.iso pkg(8) configuration to use the release_1
  package set to populate the dvd.

Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-10-18 00:00:11 +00:00
Ian Lepore 81b600616a MFC r353675 from stable-12 (r353651-r353652 from head)...
r353651:
Relax the sdhci(4) check that filters out the 1.8v voltage option unless
the slot is flagged as 'embedded'.

The features related to embedded and shared slots were added in v3.0 of
the sdhci spec.  Hardware prior to v3 sometimes supported 1.8v on non-
removable devices in embedded systems, but had no way to indicate that
via the standard sdhci registers (instead they use out of band metadata
such as FDT data).

This change adds the controller specification version to the check for
whether to filter out the 1.8v selection.  On older hardware, the 1.8v
option is allowed to remain.  On 3.0 or later it still requires the
embedded-slot flag to remain.

This is part of the fix for PR 241301 (eMMC not detected on Beaglebone).
Changes to the sdhci_ti driver are also needed for a full fix.

PR:           241301

r353652:
Revert r351218 (by manu).  While the changes in r351218 appear to be (and
should be) correct, they lead to the eMMC on a Beaglebone failing to work
in some situations.

The TI sdhci hardware is kind of strange.  The first device inherently
supports 1.8v and 3.3v and the abililty to switch between them, and the
other two devices must be set to 1.8v in the sdhci power control register to
operate correctly, but doing so actually makes them run at 3.3v (unless an
external level-shifter is present in the signal path).  Even the 1.8v on the
first device may actually be 3.3v (or any other value), depending on what
voltage is fed to the VDDS1-VDDS7 power supply pins on the am335x chip.

Another strange quirk is that the convention for am335x sdhci drivers in
linux and uboot and the am335x boot ROM seems to be to set the voltage in
the sdhci capabilities register to 3.0v even though the actual voltage is
3.3v.  Why this is done is a complete mystery to me, but it seems to be
required for correct operation.

If we had complete modern support for the am335x chip we could get the
actual voltages from the FDT data and the regulator framework.  But our
am335x code currently doesn't have any regulator framework support.
Reverting to the prior code will get the popular Beaglebone boards working
again.

This is part of the fix for PR 241301, but also requires r353651 for a
complete fix.

PR:           241301
Discussed with: manu

Approved by:	re(kib)
2019-10-17 16:20:24 +00:00
Eric Joyner 6e69a11a2c MFC r353660: ixgbe: Disable EEE for backplane X550EM_X
This prevents a kernel panic when configuring EEE on X552 devices.

PR:		240320
Approved by:	re@ (gjb@)
Sponsored by:	Intel Corporation
2019-10-16 21:46:49 +00:00
Mark Johnston 598b25a307 MFS r353475, r353553:
Fix a couple of bugs around handling of PGA_WRITEABLE.

Approved by:	re (kib)
2019-10-15 16:27:04 +00:00
Michael Tuexen 2d45ee3365 MFS r353563:
Ensure that local variables are reset to their initial value when
dealing with error cases in a loop over all remote addresses.
This issue was found and reported by OSS_Fuzz in:

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18080
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18086
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18121
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18163

MFS r353567:

Fix mergeinfo for r353563.

Approved by:		re(gjb)
2019-10-15 16:05:55 +00:00
Mark Johnston caa4f20dbe MFS r353554:
Fix handling of empty SCM_RIGHTS messages.

Approved by:	re (kib)
2019-10-15 14:45:33 +00:00
Toomas Soome 7f14d97e72 loader.efi: efipart needs to use ioalign
UEFI specification 2.7A, EFI_BLOCK_IO_PROTOCOL, page 566.

The ioalign property does define the alignment of data buffer.

If the alignment is required and our buffer is not aligned, or if
the data buffer is not multiple of Blocksize, we need to use bounce buffer
to perform the block IO. This is much like with BIOS version, except
there the INT13 needs buffer to be located in low memory.

MFS: r353501
MFC: r347195,350654-350656,351274,351630,351637,352421,352439,352443-352446,352451

Approved by:	re (gjb)
2019-10-15 06:19:33 +00:00
Glen Barber 3189c34aca MFS r353450:
MFC r353348:
  Connect the libucl(3) manual page to the build.

Approved by:	re (kib)
Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-10-12 17:15:32 +00:00
Glen Barber 5e786c02c7 Update releng/12.1 to RC1 as part of the 12.1-RELEASE cycle.
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-10-11 00:02:00 +00:00
Michael Tuexen 0e4420ace7 MFS r353402:
In r343587 a simple port filter as sysctl tunable was added to siftr.
The new sysctl was not added to the siftr.4 man page at the time.
This updates the man page, and removes one left over trailing whitespace.

Submitted by:		Richard Scheffenegger
Differential Revision:	https://reviews.freebsd.org/D21619
Reviewed by:		bcr@
Approved by:		re (gjb@)
2019-10-10 18:39:11 +00:00
Glen Barber fa2cb1e49d MFS r353409:
MFC r353320:
  Rework the logic for installing the pkg(8) configuration.

  'quarterly' package sets do not exist for head, so explicitly
  install the 'latest' configuration file there.  Otherwise,
  fall back to the original conditional evaluation to determine
  if the 'latest' or 'quarterly' configuration file should be
  installed.

Approved by:	re (kib)
Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-10-10 18:27:05 +00:00
Michael Tuexen 81377c9cf3 MFS r353395:
Add missing input validation. This could result in reading from
uninitialized memory.
The issue was found by OSS-Fuzz for usrsctp  and reported in
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17780

MFS r353396:

Cleanup sctp_asconf_error_response() and ensure that the parameter
is padded as required. This fixes the followig bug reported by
OSS-Fuzz for the usersctp stack:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17790

MFS r353397:

When skipping the address parameter, take the padding into account.

MFS r353398:

Fix the adding of padding to COOKIE-ECHO chunks.

Thanks to Mark Wodrich who found this issue while fuzz testing the
usrsctp stack and reported the issue in
https://github.com/sctplab/usrsctp/issues/382

MFS r353399:

Plumb an mbuf leak found by Mark Wodrich from Google by fuzz testing the
userland stack and reporting it in:
https://github.com/sctplab/usrsctp/issues/396

MFS r353400:

Fix a use after free bug when removing remote addresses.
This bug was found by OSS-Fuzz and reported in
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18004

MFS r353401:

Plumb an mbuf leak in a code path that should not be taken. Also avoid
that this path is taken by setting the tail pointer correctly.
There is still bug related to handling unordered unfragmented messages
which were delayed in deferred handling.
This issue was found by OSS-Fuzz testing the usrsctp stack and reported
in
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17794

MFS r353403:

Validate length before use it, not vice versa.
r353060 should have contained this...
This fixes
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=18070

Approved by:		re (gjb@)
2019-10-10 18:19:22 +00:00
Hans Petter Selasky 76d90eee50 MFS r353405:
Fix regression issue after r352989:

As noted by the commit message, callouts are now persistant
and should not be in the auto-zero section of the RQ's and SQ's.
This fixes an assert when using the TX completion event
factor feature with mlx5en(4).

Found by:	gallatin@
Sponsored by:	Mellanox Technologies
Approved by:	re (gjb)
2019-10-10 16:04:43 +00:00
Konstantin Belousov 44c8d0014a MFC r353065, MFS12 353385:
tmpfs_readdir(): unlock the locked node.

Approved by:	re (gjb)
2019-10-10 15:19:49 +00:00
Hans Petter Selasky 8835f27233 MFS r353177:
Add quirk for XHCI(4) controllers to support USB control transfers
above 1Kbyte.  It might look like some XHCI(4) controllers do not
support when the USB control transfer is split using a link TRB. The
next NORMAL TRB after the link TRB is simply failing with XHCI error
code 4. The quirk ensures we allocate a 64Kbyte buffer so that the
data stage TRB is not broken with a link TRB.

Found at:	EuroBSDcon 2019
Sponsored by:	Mellanox Technologies
Approved by:	re (gjb)
2019-10-07 15:29:37 +00:00
Mark Johnston 285b572382 MFS r353276:
Disallow fcntl(F_READAHEAD) when the vnode is not a regular file.

Approved by:	re (gjb)
2019-10-07 15:26:40 +00:00
Hans Petter Selasky 7452e89912 MFS r353173:
Increase the maximum user-space buffer size from 256kBytes to 32MBytes for
libusb. This is useful for speeding up large data transfers while reducing
the interrupt rate.

Found at:	EuroBSDcon 2019
Sponsored by:	Mellanox Technologies
Approved by:	re (gjb)
2019-10-07 15:25:00 +00:00
Hans Petter Selasky 07827943a8 MFS r353169:
The maximum TD size is 31 and not 15.

Found at:	EuroBSDcon 2019
Sponsored by:	Mellanox Technologies
Approved by:	re (gjb)
2019-10-07 15:03:24 +00:00
Hans Petter Selasky a3833b88b1 MFS r353184, r353186, r353188, r353190, r353192, r353194, r353196, r353198,
r353200, r353203, r353205, r353207, r353209, r353211, r353213, r353215,
r353217, r353219, r353221, r353223, r353225, r353227, r353229, r353231,
r353233, r353235, r353237, r353239, r353241, r353243, r353245, r353247,
r353249, r353251, r353253, r353255, r353257, r353259, r353261, r353263,
r353265 and r353267:

Update mlx5core, mlx5en(4) and mlx5ib(4).

Sponsored by:	Mellanox Technologies
Approved by:	re (gjb)

MFC r352956:
Fix reported max SGE calculation in mlx5ib.

Add the 512 bytes limit of RDMA READ and the size of remote address to the max
SGE calculation.

Linux commit:	288c01b746aa

MFC r352957:
Update warning and error print formats in mlx5ib.

MFC r352958:
Make sure the number of IRQ vectors doesn't exceed 256 in mlx5core.
The "intr" field in "struct mlx5_ifc_eqc_bits" is only 8 bits wide.

MFC r352959:
Check return value of mlx5_vector2eqn() function in mlx5en.

MFC r352960:
Fix for missing cleanup code in error case in mlx5en.

MFC r352961:
Implement macro for asserting priv lock in mlx5en.

MFC r352962:
Add support for Multi-Physical Function Switch, MPFS, in mlx5en.

MPFS is a logical switch in the Mellanox device which forward packets
based on a hardware driven L2 address table, to one or more physical-
or virtual- functions. The physical- or virtual- function is required
to tell the MPFS by using the MPFS firmware commands, which unicast
MAC addresses it is requesting from the physical port's traffic.
Broadcast and multicast traffic however, is copied to all listening
physical- and virtual- functions and does not need a rule in the MPFS
switching table.

Linux commit:	eeb66cdb682678bfd1f02a4547e3649b38ffea7e

MFC r352963:
Cleanup naming of IRQ vectors in mlx5en.
Remove unused IRQ naming functions and arrays.

MFC r352964:
Export channel IRQ number as part of the "hw_ctx_debug" sysctl(8) in mlx5en(4).

MFC r352965:
Correct and update some counter names in mlx5en(4).

MFC r352966:
Add port module event software counters in mlx5core.
While at it, fixup PME based on latest PRM defines.

MFC r352967:
Make the mlx5_vsc_wait_on_flag(9) function global.

MFC r352968:
Move mlx5_ifc_vsc_space_bits and mlx5_ifc_vsc_addr_bits to mlx5_ifc.h.

MFC r352969:
Use the MLX5_VSC_DOMAIN_SEMAPHORES constant instead of hand-rolled symbol
in mlx5core.

MFC r352970:
Define MLX5_VSC_DOMAIN_SCAN_CRSPACE.

MFC r352971:
Read rege map from crdump scan space in mlx5core.

MFC r352972:
Remove no longer needed fwdump register tables from mlx5core.

MFC r352973:
Add missing blank line at the end of the print in mlx5core.

MFC r352974:
Add proper print in case of 0x0 health syndrome in mlx5core.

In case of health counter fails to increment it indicates a bad device health.
In case when the syndrome indicated by firmware is 0x0, this indicates that
firmware is unable to respond to initialization segment reads.
Add proper print in this case.

MFC r352975:
Unify prints in mlx5core.

All prints in mlx5core should use on of the macros:
mlx5_core_err/dbg/warn

MFC r352976:
Unify prints in mlx5en(4).

All prints in mlx5en(4) should use on of the macros:
mlx5_en_err/dbg/warn

MFC r352977:
Sort the ports registers definitions numerically in mlx5core.

MFC r352978:
Add definition for the Port Buffer Status Register in mlx5core.

MFC r352979:
Update definitons for PPTB and PBMC registers layouts in mlx5core.

MFC r352980:
Add mlx5e_dbg() compatibility macro.

MFC r352981:
Import Linux code to query/set buffer state in mlx5en(4).

MFC r352982:
Add support for buffer parameter manipulations in mlx5en(4).

The following sysctls are added:
dev.mce.N.conf.qos.cable_length
dev.mce.N.conf.qos.buffers_size
dev.mce.N.conf.qos.buffers_prio

MFC r352983 and r353001:
Move EEPROM information query from a sysctl in mlx5en(4) to an ioctl
in mlx5core. The EEPROM information is not only a property of the
mlx5en(4) driver.

MFC r352984:
Add the ability to query the EEPROM information in mlx5tool(8).

MFC r352985:
Add sysctl(8) to get and set forward error correction, FEC, configuration
in mlx5en(4).

MFC r352986:
Return an error from ioctl(MLX5_FW_RESET) if reset was rejected in mlx5core.

MFC r352987:
Remove mkey_be from channel structure in mlx5en(4).
Use value from priv structure instead.
This saves some space in the channel structure.

MFC r352988:
Remove unused cpu field from channel structure in mlx5en(4).

MFC r352989:
Seal transmit path with regards to using destroyed mutex in mlx5en(4).

It may happen during link down that the running state may be observed
non-zero in the transmit routine, right before the running state is
cleared. This may end up using a destroyed mutex.

Make all channel mutexes and callouts persistant.

Preserve receive and send queue statistics during link toggle.

MFC r352991 and 353000:
Wait for FW readiness before initializing command interface in mlx5core.

Before attempting to initialize the command interface we must wait till
the fw_initializing bit is clear.

If we fail to meet this condition the hardware will drop our
configuration, specifically the descriptors page address.  This scenario
can happen when the firmware is still executing an FLR flow and did not
finish yet so the driver needs to wait for that to finish.

Linux commits:
6c780a0267b8
b8a92577f4be.

MFC r352992:
Use size_t for byte_to_write variable when comparing to eeprom_info_out_len
which is also size_t in mlx5tool(8).

MFC r352993:
Randomize the delay when waiting for VSC flag in mlx5core.

The PRM suggests random 0 - 10ms to prevent multiple waiters on the same
interval in order to avoid starvation.

MFC r352994:
Improve mlx5_fwdump_prep logging in mlx5core.

MFC r352995:
Only update lossy buffers config when manual PFC configuration was done
in mlx5en(4).

MFC r352996:
Add print to show user a reason for rejecting buffer size change in mlx5en(4).

MFC r352997:
Print numeric error_type and module_status in mlx5core
in case the strings are not available.

MFC r352998:
Bump driver version for mlx5core, mlx5en(4) and mlx5ib(4).
2019-10-07 13:13:06 +00:00
Hans Petter Selasky 1f4bd4741e MFS r353182:
Make sure the transmit loop doesn't get starved in ipoib.

When the software send queue gets filled up, callbacks to
if_transmit will stop. Make sure the transmit callback
routine checks the send queue and outputs any remaining
mbufs. Else the remaining mbufs may simply sit in the
output queue blocking the transmit path.

Sponsored by:	Mellanox Technologies
Approved by:	re (gjb)
2019-10-07 12:54:28 +00:00
Hans Petter Selasky 10a53980e9 MFS r353180:
Notify all sleeping threads of device removal in krping.
Implement d_purge for krping_cdevsw.

Submitted by:	slavash@
Sponsored by:	Mellanox Technologies
Approved by:	re (gjb)
2019-10-07 12:51:36 +00:00
Kyle Evans 63dcaa9109 MFS r353157: tuntap(4): loosen up tunclose restrictions
Realistically, this cannot work. We don't allow the tun to be opened twice,
so it must be done via fd passing, fork, dup, some mechanism like these.
Applications demonstrably do not enforce strict ordering when they're
handing off tun devices, so the parent closing before the child will easily
leave the tun/tap device in a bad state where it can't be destroyed and a
confused user because they did nothing wrong.

Concede that we can't leave the tun/tap device in this kind of state because
of software not playing the TUNSIFPID game, but it is still good to find and
fix this kind of thing to keep ifconfig(8) up-to-date and help ensure good
discipline in tun handling.

Approved by:	re (gjb)
2019-10-07 02:57:00 +00:00
Mark Johnston 421253b511 MFS r353106:
Implement pmap_page_is_mapped() correctly on arm64 and riscv.

Approved by:	re (kib)
2019-10-04 16:36:09 +00:00
Andrew Turner 8d00d6c887 MFS r353032:
Check the vfs option length is valid before accessing through

When a VFS option passed to nmount is present but NULL the kernel will
place an empty option in its internal list. This will have a NULL
pointer and a length of 0. When we come to read one of these the kernel
will try to load from the last address of virtual memory. This is
normally invalid so will fault resulting in a kernel panic.

Fix this by checking if the length is valid before dereferencing.

Approved by:	re (kib)
Sponsored by:	DARPA, AFRL
2019-10-04 14:10:56 +00:00
Glen Barber 887780d44c Update releng/12.1 to BETA3 as part of the 12.1-RELEASE cycle.
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-10-04 00:04:21 +00:00
Dimitry Andric 819207bec3 Merge r353031 from stable/12:
Pull in r357528 from upstream llvm trunk (by Craig Topper):

  [X86] Check MI.isConvertibleTo3Addr() before calling
  convertToThreeAddress in X86FixupLEAs.

  X86FixupLEAs just assumes convertToThreeAddress will return nullptr
  for any instruction that isn't convertible.

  But the code in convertToThreeAddress for X86 assumes that any
  instruction coming in has at least 2 operands and that the second one
  is a register. But those properties aren't guaranteed of all
  instructions. We should check the instruction property first.

Pull in r365720 from upstream llvm trunk (by Craig Topper):

  [X86] Don't convert 8 or 16 bit ADDs to LEAs on Atom in FixupLEAPass.

  We use the functions that convert to three address to do the
  conversion, but changing an 8 or 16 bit will cause it to create a
  virtual register. This can't be done after register allocation where
  this pass runs.

  I've switched the pass completely to a white list of instructions
  that can be converted to LEA instead of a blacklist that was
  incorrect. This will avoid surprises if we enhance the three address
  conversion function to include additional instructions in the future.

  Fixes PR42565.

This should fix assertions/segfaults when compiling certain ports with
CPUTYPE=atom.

Approved by:	re (kib)
PR:		240928
2019-10-03 16:22:56 +00:00
Mark Johnston 0225849177 MFS r353051:
Add IFLIB_SINGLE_IRQ_RX_ONLY.

PR:		239118
Approved by:	re (gjb)
2019-10-03 15:23:38 +00:00
Glen Barber 809258c58e MFS12 r353047:
MFC r353004, r353012:
 r353004:
  Explicitly add opensolaris_load="YES" to loader.conf through the
  installer when installing the system on a ZFS root filesystem.

  For arm64, zfs_load="YES" does not add opensolaris.ko as a kld
  dependency, so add it explicitly to prevent boot-time failures
  out-of-box.

 r353012:
  Add a comment explaining why the opensolaris_load line in loader.conf
  is explicitly added.

PR:		240478
Approved by:	re (kib)
Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-10-03 14:41:20 +00:00
Kyle Evans 095b6c1431 MFS r353041: fdt_slicer: bump to SI_ORDER_THIRD following r347183
r347183 bumped GEOM classes to SI_ORDER_SECOND to resolve a race between
them and the initialization of devsoftc.mtx in devinit, but missed this
dependency on g_flashmap that may now lose the race against GEOM
classes/g_init.

There's a great comment that describes the situation that has also been
updated with the new ordering of GEOM classes.

Approved by:	re (kib)
2019-10-03 14:27:04 +00:00
Michael Tuexen c640d5d008 MFS r352509:
Only allow a SCTP-AUTH shared key to be updated by the application
if it is not deactivated and not used.
This avoids a use-after-free problem.

MFS r352674:

Fix the handling of invalid parameters in ASCONF chunks.
Thanks to Mark Wodrich from Google for reproting the issue in
https://github.com/sctplab/usrsctp/issues/376
for the userland stack.

MFS r352675:

Cleanup the RTO calculation and perform some consistency checks
before computing the RTO.
This should fix an overflow issue reported by Felix Weinrank in
https://github.com/sctplab/usrsctp/issues/375
for the userland stack and found by running a fuzz tester.

MFS r352676:

Don't hold the info lock when calling sctp_select_a_tag().
This avoids a double lock bug in the NAT colliding state processing
of SCTP. Thanks to Felix Weinrank for finding and reporting this issue in
https://github.com/sctplab/usrsctp/issues/374
He found this bug using fuzz testing.

MFS r353034:

Plumb a memory leak.
Thanks to Felix Weinrank for finding this issue using fuzz testing
and reporting it for the userland stack:
https://github.com/sctplab/usrsctp/issues/378

MFS r353036:

Don't use stack memory which is not initialized.
Thanks to Mark Wodrich for reporting this issue for the userland stack in
https://github.com/sctplab/usrsctp/issues/380
This issue was also found for usrsctp by OSS-fuzz in
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17778

Approved by:		re (kib@)
2019-10-03 13:30:48 +00:00
Michael Tuexen 270cc62521 MFS r352673:
When the RACK stack computes the space for user data in a TCP segment,
it wasn't taking the IP level options into account. This patch fixes this.
In addition, it also corrects a KASSERT and adds protection code to assure
that the IP header chain and the TCP head fit in the first fragment as
required by RFC 7112.

MFS: r353035:

RFC 7112 requires a host to put the complete IP header chain
including the TCP header in the first IP packet.
Enforce this in tcp_output(). In addition make sure that at least
one byte payload fits in the TCP segement to allow making progress.
Without this check, a kernel with INVARIANTS will panic.
This issue was found by running an instance of syzkaller.

Approved by:		re (kib@)
Reviewed by:		rrs@ (r352673), jtl@ (r353035)
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D21665
Differential Revision:	https://reviews.freebsd.org/D21666
2019-10-03 12:26:55 +00:00
Michael Tuexen 685fa9cac2 MFS r352672:
When processing an incoming IPv6 packet over the loopback interface which
contains Hop-by-Hop options, the mbuf chain is potentially changed in
ip6_hopopts_input(), called by ip6_input_hbh().
This can happen, because of the the use of IP6_EXTHDR_CHECK, which might
call m_pullup().
So provide the updated pointer back to the called of ip6_input_hbh() to
avoid using a freed mbuf chain inip6_input().

Approved by:		re (kib@)
Reviewed by:		markj@
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D21664
2019-10-03 11:20:56 +00:00
Mike Karels 7729f9fb02 MFC r352867: Add support for ps -H on corefiles in libkvm
Add support for kernel threads in kvm_getprocs() and the underlying
kvm_proclist() in libkvm when fetching from a kernel core file. This
has been missing/needed for several releases, when kernel threads became
normal threads.  The loop over the processes now contains a sub-loop for
threads, which iterates beyond the first thread only when threads are
requested.  Also set some fields such as tid that were previously
uninitialized.

Approved by:	re (gjb)
Sponsored by:   Forcepoint LLC
2019-10-03 02:51:48 +00:00
Andriy Gapon e14f4092da MFS12 r352896: vt: fix problems with trying to switch to a closed VT
Approved by:	re (gjb)
2019-10-02 13:36:54 +00:00
Andriy Gapon 916abb2f0b MFS12 r352721: print summary line for space estimate of zfs send from bookmark
This should have been merged as a part of r352901 but I missed it.

Approved by:	re (gjb)
2019-10-02 13:25:28 +00:00
Sean Eric Fagan f45165fb6b Fix a regression introduced in r344601, and work properly with the
-v and -n options.

PR:		240640
Reported by:	Andriy Gapon <[email protected]>
Reviewed by:	avg
Differential Revision:	https://reviews.freebsd.org/D21709
Approved by:	re
2019-10-01 18:05:51 +00:00
Eric Joyner a94d7c59cf MFC r352910 and r352911
MFC r352910: iflib: Remove redundant VLAN events deregistration
MFC r352911: ix/ixv: Read MSI-X bar from device config

These fix an issue with a kernel panic on unload with an iflib-using
driver and allow certain HP-branded Intel 10G cards to use MSI-X,
respectively.

Approved by:	re@ (gjb@)
Sponsored by:	Intel Corporation
2019-09-30 18:22:33 +00:00
Andriy Gapon cc0d343bd4 Merge from stable/12 r352723: fix dsl_scan_ds_clone_swapped logic
PR:		239566
Approved by:	re (gjb)
2019-09-30 15:08:45 +00:00
Xin LI 251c3371c2 MFS r352872: MFC r351802:
Correct overflow logic in fullpath().

Obtained from:	OpenBSD
Approved by:	re (gjb)
2019-09-30 14:32:41 +00:00
Andriy Gapon 3b6d1eb2ce Merge from stable/12 r352595: Add -vnP support to 'zfs send' for bookmarks
Approved by:	re (gjb)
2019-09-30 14:19:18 +00:00
Konstantin Belousov 12c37572e1 MFC r352620, MFS12 r352892:
Fix destruction of the robust mutexes.

Approved by:	re (gjb)
2019-09-30 14:16:44 +00:00
Justin Hibbits 59d5fc9aec MF stable/12 r352685:
libm: Include float.h to get LDBL_MANT_DIG

The long double aliases of double functions are only exposed as aliases
if LDBL_MANT_DIG is 53 (same as DBL_MANT_DIG).  Without float.h
included these files were not exposing weak aliases as expected,
leading to link failures if programs use the *l functions.  This should
fix editors/calligra on targets with 64-bit long double, which uses
erfl and erfcl.  Found on powerpc64.

Approved by:	re(delphij)
2019-09-30 14:11:49 +00:00
Michael Tuexen 2f40354d9d MFS r352508:
Don't write to memory outside of the allocated array for SACK blocks.

PR:			240837
Approved by:		re (delphij@)
Obtained from:		rrs@
Sponsored by:		Netflix, Inc.
2019-09-30 04:54:02 +00:00
Li-Wen Hsu c9d67586a4 MFC r349225:
Finsh readding Big5 in r317204, which was reverting r315568.  This commit
reverts r315569.

Reported by:	Ting-Wei Lan <lantw44 gmail com>
Discussed with:	kevlo
Sponsored by:	The FreeBSD Foundation

Approved by:	re (delphij)
2019-09-30 03:35:48 +00:00
Ian Lepore 1a531a68c8 MFC r352363:
Apply a runtime patch to the FDT data for imx6 to fix iomuxc problems.

The latest imported FDT data defines a node for an iomuxc-gpr device,
which we don't support (or need, right now) in addition to the usual
iomuxc device.  Unfortunately, the dts improperly assigns overlapping
ranges of mmio space to both devices.  The -gpr device is also a syscon
and simple_mfd device.

At runtime the simple_mfd driver attaches for the iomuxc-gpr node, then
when the real iomuxc driver comes along later, it fails to attach because
it tries to allocate its register space, and it's already partially in
use by the bogus instance of simple_mfd.

This change works around the problem by simply disabling the node for
the iomuxc-gpr device, since we don't need it for anything.

Approved by:	re@ (gjb)
2019-09-29 18:33:29 +00:00
Glen Barber 5565aa6e49 Update releng/12.1 to BETA2 as part of the 12.1-RELEASE cycle.
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-09-27 00:00:21 +00:00
Alexander Motin 2293e38859 MFS r352772: MFC r349342 (by imp):
Use the cam_ed copy of ata_params rather than malloc and freeing
memory for it. This reaches into internal bits of xpt a little, and
I'll clean that up later.

Reviewed by:	imp
Approved by:	re (gjb)
2019-09-26 23:27:24 +00:00
Ed Maste 62878556e8 Regen src.conf.5 after r352768, r352769
Approved by:	re (gjb)
2019-09-26 21:06:55 +00:00
Michael Gmelin 3f82d8e0d8 MF stable/12 r352759,r352771
Approved by:	re (gjb)

r352759:
freebsd-update.8: Style fixes, document new features.
freebsd-update:   Make usage output consistent.
freebsd-update:   Add `updatesready' and `showconfig' commands
freebsd-update:   Change exit code of `freebsd-update install' to 2
                  in case there are no pending updates and there wasn't
                  a fetch phase in the same invocation.

r352771:
Add mergeinfo missing in r352759

PR:		240757, 240177, 229346
Reviewed by:	manpages (bcr), secteam (emaste), yuripv
Differential Revision:	https://reviews.freebsd.org/D21473
2019-09-26 20:56:07 +00:00
Ed Maste 6b495bed87 MFS r352752: Add a WITH_BIND_NOW build knob
MFC r340186: Add a WITH_BIND_NOW build knob

The linker's -z now flag sets the DF_BIND_NOW flag, which signals to the
runtime loader that all relocation processing should be performed at
process startup rather than on demand.  In combination with lld's
default of enabling relro this causes the GOT to be made read-only when
the process starts, preventing straightforward GOT overwrite attacks.

MFC r341429: disable BIND_NOW in libc, libthr, and rtld

An issue remains with BIND_NOW and processes using threads.  For now,
restore libc's BIND_NOW disable, and also disable BIND_NOW in rtld and
libthr.

MFC r345625: revert r341429 "disable BIND_NOW in libc, libthr, and rtld"

r345620 by kib@ fixed the rtld issue that caused a crash at startup
during resolution of libc's ifuncs with BIND_NOW.

MFC r345638: Revert change accidentally committed along with r345625

MFC r345640: Revert other accidentally committed part of r345625

Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation
2019-09-26 18:56:41 +00:00
Ed Maste 349a1e5724 MFS r352754: Add WITH_PIE knob to build Position Independent Executables
MFC r344179: Add WITH_PIE knob to build Position Independent Executables

Building binaries as PIE allows the executable itself to be loaded at a
random address when ASLR is enabled (not just its shared libraries).

With this change PIE objects have a .pieo extension and INTERNALLIB
libraries libXXX_pie.a.

MK_PIE is disabled for some kerberos5 tools, Clang, and Subversion, as
they explicitly reference .a libraries in their Makefiles.  These can
be addressed on an individual basis later.  MK_PIE is also disabled for
rtld-elf because it is already position-independent using bespoke
Makefile rules.

Currently only dynamically linked binaries will be built as PIE.

MFC r344181: Fix Makefile conditional after r344179

MFC r344182: Use make's :tl instead of checking "no" and "NO"

MFC r344189: Fixup bsd.prog.mk after r344182

MFC r344211: wlandebug: disable PIE to fix build failure

libifconfig is built as a static-only PRIVATELIB (and there is no _pie.a
version) so disable PIE in libifconfig's consumer.

r345489: Fix GNU objdump build under WITH_PIE

Explicitly specified bare .a libraries need ${PIE_SUFFIX}.

r345490: Apply WITH_PIE changes to other binutils components

Followon to r345489, explicitly specified bare .a libraries need
${PIE_SUFFIX} (although these still built).

r345778: Fix gdb/kgdb build under WITH_PIE

Explicitly specified bare .a libraries need ${PIE_SUFFIX}.

Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation
2019-09-26 18:37:58 +00:00
Mark Johnston 642a35af15 MFS r352720:
Use separate descriptors in bhyve's stdio uart backend.

Approved by:	re (gjb)
2019-09-26 18:36:52 +00:00
Mark Johnston eb29bf8968 MFS r352749:
Revert r316820.

PR:		233952
Approved by:	re (gjb)
2019-09-26 18:36:15 +00:00
Mark Johnston 083290bf0b MFS r352750:
ping6: Use caph_rights_limit(3) for STDIN_FILENO

Approved by:	re (gjb)
2019-09-26 18:35:26 +00:00
Warner Losh 21060372c6 Merge from stable/12 r352735 and r352741
Merge all the stability fixes for the mpr and mps drivers. This fixes a
number of different panics. Unfortunately, mps now requires atomic_swap_64
to work properly, so it has been disabled on 32-bit powerpc and mips. The
impact should be negligible, however, since this device is difficult to
attach to those platforms.

Approved by:	re@ (glen)
Relnotes:	YES (for ppc32 removal)
2019-09-26 16:51:51 +00:00
Alexander Motin 8b63dd4fef MFC r352493: Fix typo, setting hidden flag instead of reparse.
Approved by:	re (gjb)
2019-09-25 18:47:05 +00:00
Kyle Evans ae75ed18ec MFS r352678: msdosfs: do not deget unlinked denodes
When a file is unlinked, the denode is not reclaimed until the last
reference is dropped, but the directory entry is immediately up for reuse.
This is a problem later when createde goes to grab a denode for the newly
created entry -- we search the hash and find a dead denode, then return that
without even bumping the reference count and the data later gets truncated
when the the last reference to the unlinked file is dropped.

This manifested itself as a broken in-place strip(1) on msdosfs.

The comment indicating that we want to skip these denodes has been updated
to reflect where this is actually done.

Approved by:	re (gjb)
2019-09-25 17:16:21 +00:00
Michael Gmelin 930406df18 MF stable/12 r352608
Approved by:	re (gjb)

r352608:
freebsd-update: Fix src component detection

In case BASEDIR was set to a directory that differed from the default
filesystem root, freebsd-update wrongly checked for the existence
of /usr/src/COPYRIGHT to determine if the src component was
installed. Existing code to address this wasn't effective due to the
order in which configuration options were evaluated.

PR:		224048, 238558, 239997
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D21579
2019-09-23 15:58:54 +00:00
Alan Somers 495a41578d MF stable/12 r352489
Approved by:	re (kib)

r351192:
periodic: fix anticongestion for scripts run after security

Revision 316342, which introduced the anticongestion feature, failed to
consider that the periodic scripts are executed by a recursive invocation of
periodic.  The recursive invocation wrongly cleaned up a temporary file that
should've been cleaned up only by the original invocation.  The result is
that if the first script that requests an anticongestion sleep runs after
the security scripts, the sleep won't happen.

Fix this bug by delaying cleanup until the end of the original invocation.

PR:             236564
Submitted by:   Yasuhiro KIMURA <[email protected]>
Reviewed by:    imp

r351203:
periodic: replace "tty" with "test -t 0"

Apparently using tty for this purpose has been deprecated since 4.4 Lite.

Reviewed by:    cy
Differential Revision:  https://reviews.freebsd.org/D21318
2019-09-22 00:12:43 +00:00
Alan Somers 8be7055352 MF stable/12 r352534:
Fix an off-by-one error from r351961

That revision addressed a Coverity CID that could lead to a buffer overflow,
but it had an off-by-one error in the buffer size check.

Approved by: re (kib)
Reported by: Coverity
Coverity CID: 1405530
MFC-With: 351961
Sponsored by: The FreeBSD Foundation
2019-09-21 13:00:38 +00:00
Kyle Evans ea37c1610e MFS r352565: SIOCSIFNAME: Do nothing if we're not actually changing
Instead of throwing EEXIST, just succeed if the name isn't actually
changing. We don't need to trigger departure or any of that because there's
no change from consumers' perspective.

PR:		240539
Approved by:	re (gjb)
2019-09-21 01:39:49 +00:00
Glen Barber d04faca30e - Copy stable/12@r352480 to releng/12.1 as part of the 12.1 release
cycle.
- Update from PRERELEASE to BETA1.
- Set the default pkg(7) repository to 'quarterly'.
- Bump __FreeBSD_version.
- Prune svn:mergeinfo from the new branch.

Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-09-20 00:05:14 +00:00
719 changed files with 49612 additions and 33141 deletions

No files matched your search

+3 -3
View File
@@ -17,7 +17,7 @@ LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
.if ${WANT_COMPILER_TYPE} == gcc || \
(defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
.else
LIB32CPUFLAGS+= -target x86_64-unknown-freebsd12.0
LIB32CPUFLAGS+= -target x86_64-unknown-freebsd12.1
.endif
LIB32CPUFLAGS+= -m32
LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
@@ -49,9 +49,9 @@ LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
.endif
.else
.if ${TARGET_ARCH:Mmips64el*} != ""
LIB32CPUFLAGS= -target mipsel-unknown-freebsd12.0
LIB32CPUFLAGS= -target mipsel-unknown-freebsd12.1
.else
LIB32CPUFLAGS= -target mips-unknown-freebsd12.0
LIB32CPUFLAGS= -target mips-unknown-freebsd12.1
.endif
.endif
LIB32CPUFLAGS+= -mabi=32
+170
View File
@@ -16,6 +16,176 @@ from older versions of FreeBSD, try WITHOUT_CLANG and WITH_GCC to bootstrap to
the tip of head, and then rebuild without this option. The bootstrap process
from older version of current across the gcc/clang cutover is a bit fragile.
20210128: p13 FreeBSD-EN-21:01.tzdata
FreeBSD-EN-21:03.vnet
FreeBSD-SA-21:01.fsdisclosure
FreeBSD-SA-21:02.xenoom
Update timezone database information [EN-21:01.tzdata]
Panic when destroying VNET and epair simultaneously [EN-21:03.vnet]
Uninitialized file system kernel stack leaks [SA-21:01.fsdisclosure]
Xen guest-triggered out of memory [SA-21:02.xenoom]
20201208: p12 FreeBSD-SA-20:33.openssl
Fix OpenSSL NULL pointer de-reference. [SA-20:33.openssl]
20201201: p11 FreeBSD-EN-20:20.tzdata
FreeBSD-SA-20:31.icmp6
FreeBSD-SA-20:32.rtsold
Update timezone database information. [EN-20:20.tzdata]
Fix ICMPv6 use-after-free in error message handling. [SA-20:31.icmp6]
Fix multiple vulnerabilities in rtsold. [SA-20:32.rtsold]
20200915 p10 FreeBSD-SA-20:27.ure
FreeBSD-SA-20:28.bhyve_vmcs
FreeBSD-SA-20:29.bhyve_svm
FreeBSD-SA-20:30.ftpd
Fix ure device driver susceptible to packet-in-packet attack.
[SA-20:27.ure]
Fix bhyve privilege escalation via VMCS access. [SA-20:28.bhyve_vmcs]
Fix bhyve SVM guest escape. [SA-20:29.bhyve_svm]
Fix ftpd privilege escalation via ftpchroot. [SA-20:30.ftpd]
20200902 p9 FreeBSD-EN-20:17.linuxthread
FreeBSD-SA-20:25.sctp
FreeBSD-SA-20:26.dhclient
Fix FreeBSD Linux ABI kernel panic. [EN-20:17.linuxthread]
Fix SCTP socket use-after-free. [SA-20:25.sctp]
Fix dhclient heap overflow. [SA-20:26.dhclient]
20200805 p8 FreeBSD-EN-20:16.vmx
FreeBSD-SA-20:21.usb_net
FreeBSD-SA-20:22.unbound
FreeBSD-SA-20:23.ipv6
Fix vmx driver packet loss and degraded performance. [EN-20:16.vmx]
Fix memory corruption in USB network device drivers. [SA-20:21.usb_net]
Fix multiple vulnerabilities in sqlite3. [SA-20:22.sqlite]
Fix sendmsg(2) privilege escalation. [SA-20:23.sendmsg]
20200708 p7 FreeBSD-EN-20:13.bhyve
FreeBSD-EN-20:14.linuxkpi
FreeBSD-EN-20:15.mps
FreeBSD-SA-20:19.unbound
FreeBSD-SA-20:20.ipv6
Fix host crash in bhyve with PCI device passthrough. [EN-20:13.bhyve]
Fix kernel panic in LinuxKPI subsystem. [EN-20:14.linuxpki]
Fix kernel panic in mps(4) driver. [EN-20:15.mps]
Fix multiple vulnerabilities in unbound. [SA-20:19.unbound]
Fix IPv6 socket option race condition and use after free. [SA-20:20.ipv6]
20200609 p6 FreeBSD-EN-20:11.ena
FreeBSD-EN-20:12.iflib
FreeBSD-SA-20:17.usb
Fix stability issues in ena(4) driver. [EN-20:11.ena]
Fix iflib watchdog timeout resetting idle queues. [EN-20:12.iflib]
Fix USB HID descriptor parsing error. [SA-20:17.usb]
20200512 p5 FreeBSD-EN-20:08.tzdata
FreeBSD-EN-20:09.igb
FreeBSD-EN-20:10.build
FreeBSD-SA-20:12.libalias
FreeBSD-SA-20:13.libalias
FreeBSD-SA-20:15.cryptodev
FreeBSD-SA-20:16.cryptodev
Import tzdata 2020a. [EN-20:08.tzdata]
Fix igb interfaces failing to switch to inactive state [EN-20:09.igb]
Fix incorrect build host Clang version detection [EN-20:10.build]
Fix insufficient packet length validation in libalias [SA-20:12.libalias]
Fix memory disclosure vulnerability in libalias [SA-20:13.libalias]
Fix use after free in cryptodev module [SA-20:15.cryptodev]
Fix insufficient cryptodev MAC key length check [SA-20:16.cryptodev]
20200421 p4 FreeBSD-EN-20:07.quotad
FreeBSD-SA-20:10.ipfw
FreeBSD-SA-20:11.openssl
Fix regression in rpc.rquotad with certain NFS servers [EN-20:07.quotad]
Fix ipfw invalid mbuf handling [SA-20:10.ipfw]
Fix OpenSSL remote denial of service vulnerability [SA-20:11.openssl]
20200319 p3 FreeBSD-EN-20:03.sshd
FreeBSD-EN-20:05.mlx5en
FreeBSD-EN-20:06.ipv6
FreeBSD-SA-20:04.tcp
FreeBSD-SA-20:05.if_oce_ioctl
FreeBSD-SA-20:06.if_ixl_ioctl
FreeBSD-SA-20:07.epair
FreeBSD-SA-20:08.jail
FreeBSD-SA-20:09.ntp
Fix misleading log messages upon successful sshd login [EN-20:03.sshd]
Fix packet forwarding performance in mlx5en(4) driver [EN-20:05.mlx5en]
Fix incorrect checksum calculations with IPv6 extension headers [EN-20:06.ipv6]
Fix TCP IPv6 SYN cache kernel information disclosure [SA-20:04.tcp]
Fix insufficient oce(4) ioctl(2) privilege checking [SA-20:05.if_oce_ioctl]
Fix insufficient ixl(4) ioctl(2) privilege checking [SA-20:06.if_ixl_ioctl]
Fix incorrect user-controlled pointer use in epair [SA-20:07.epair]
Fix kernel memory disclosure with nested jails [SA-20:08.jail]
Fix multiple denial of service in ntpd [SA-20:09.ntp]
20200128 p2 FreeBSD-EN-20:01.ssp
FreeBSD-SA-20:01.libfetch
FreeBSD-SA-20:03.thrmisc
Fix imprecise ordering of SSP canary initialization [EN-20:01.ssp]
Fix libfetch buffer overflow [SA-20:01.libfetch]
Fix kernel stack data disclosure [SA-20:03.thrmisc]
20191112 p1 FreeBSD-EN-19:19.loader
FreeBSD-SA-19:25.mcepsc
Fix UEFI Loader Memory Fragmentation [EN-19:19.loader]
Fix Machine Check Exception on Page Size Change [SA-19:25.mcepsc]
20191104:
12.1-RELEASE.
20190914:
The vfs.fusefs.sync_unmount and vfs.fusefs.init_backgrounded sysctls
and the "-o sync_unmount" and "-o init_backgrounded" mount options have
+23 -4
View File
@@ -190,8 +190,8 @@
.Ar snapshot
.Nm
.Cm send
.Op Fl Lce
.Op Fl i Ar snapshot Ns | Ns bookmark
.Op Fl LPcenv
.Op Fl i Ar snapshot Ns | Ns Ar bookmark
.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
.Nm
.Cm send
@@ -2764,7 +2764,7 @@ on future versions of
.It Xo
.Nm
.Cm send
.Op Fl Lce
.Op Fl LPcenv
.Op Fl i Ar snapshot Ns | Ns Ar bookmark
.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
.Xc
@@ -2778,7 +2778,7 @@ stream generated from a filesystem or volume is received, the default snapshot
name will be
.Pq --head-- .
.Bl -tag -width indent
.It Fl i Ar snapshot Ns | Ns bookmark
.It Fl i Ar snapshot Ns | Ns Ar bookmark
Generate an incremental send stream.
The incremental source must be an earlier
snapshot in the destination's history.
@@ -2790,6 +2790,23 @@ specified as the last component of the name
If the incremental target is a clone, the incremental source can
be the origin snapshot, or an earlier snapshot in the origin's filesystem,
or the origin's origin, etc.
.It Fl n, -dryrun
Do a dry-run
.Pq Qq No-op
send.
Do not generate any actual send data.
This is useful in conjunction with the
.Fl v
or
.Fl P
flags to determine what data will be sent.
In this case, the verbose output will be written to standard output
.Po contrast with a non-dry-run, where the stream is written to standard output
and the verbose output goes to standard error
.Pc .
.It Fl v, -verbose
Print verbose information about the stream package generated.
This information includes a per-second report of how much data has been sent.
.It Fl L, -large-block
Generate a stream which may contain blocks larger than 128KB.
This flag
@@ -2806,6 +2823,8 @@ See
for details on ZFS feature flags and the
.Sy large_blocks
feature.
.It Fl P, -parsable
Print machine-parsable verbose information about the stream package generated.
.It Fl c, -compressed
Generate a more compact stream by using compressed WRITE records for blocks
which are compressed on disk and in memory (see the
+5 -14
View File
@@ -290,7 +290,7 @@ get_usage(zfs_help_t idx)
case HELP_SEND:
return (gettext("\tsend [-DnPpRvLec] [-[iI] snapshot] "
"<snapshot>\n"
"\tsend [-Le] [-i snapshot|bookmark] "
"\tsend [-LPcenv] [-i snapshot|bookmark] "
"<filesystem|volume|snapshot>\n"
"\tsend [-nvPe] -t <receive_resume_token>\n"));
case HELP_SET:
@@ -3928,13 +3928,11 @@ zfs_do_send(int argc, char **argv)
if (strchr(argv[0], '@') == NULL ||
(fromname && strchr(fromname, '#') != NULL)) {
char frombuf[ZFS_MAX_DATASET_NAME_LEN];
enum lzc_send_flags lzc_flags = 0;
if (flags.replicate || flags.doall || flags.props ||
flags.dedup || flags.dryrun || flags.verbose ||
flags.progress) {
(void) fprintf(stderr,
gettext("Error: "
flags.dedup || (strchr(argv[0], '@') == NULL &&
(flags.dryrun || flags.verbose || flags.progress))) {
(void) fprintf(stderr, gettext("Error: "
"Unsupported flag with filesystem or bookmark.\n"));
return (1);
}
@@ -3943,13 +3941,6 @@ zfs_do_send(int argc, char **argv)
if (zhp == NULL)
return (1);
if (flags.largeblock)
lzc_flags |= LZC_SEND_FLAG_LARGE_BLOCK;
if (flags.embed_data)
lzc_flags |= LZC_SEND_FLAG_EMBED_DATA;
if (flags.compress)
lzc_flags |= LZC_SEND_FLAG_COMPRESS;
if (fromname != NULL &&
(fromname[0] == '#' || fromname[0] == '@')) {
/*
@@ -3963,7 +3954,7 @@ zfs_do_send(int argc, char **argv)
(void) strlcat(frombuf, fromname, sizeof (frombuf));
fromname = frombuf;
}
err = zfs_send_one(zhp, fromname, STDOUT_FILENO, lzc_flags);
err = zfs_send_one(zhp, fromname, STDOUT_FILENO, flags);
zfs_close(zhp);
return (err != 0);
}
@@ -660,7 +660,7 @@ typedef boolean_t (snapfilter_cb_t)(zfs_handle_t *, void *);
extern int zfs_send(zfs_handle_t *, const char *, const char *,
sendflags_t *, int, snapfilter_cb_t, void *, nvlist_t **);
extern int zfs_send_one(zfs_handle_t *, const char *, int, enum lzc_send_flags);
extern int zfs_send_one(zfs_handle_t *, const char *, int, sendflags_t flags);
extern int zfs_send_resume(libzfs_handle_t *, sendflags_t *, int outfd,
const char *);
extern nvlist_t *zfs_send_resume_token_to_nvlist(libzfs_handle_t *hdl,
@@ -1190,16 +1190,14 @@ send_print_verbose(FILE *fout, const char *tosnap, const char *fromsnap,
}
}
if (size != 0) {
if (parsable) {
(void) fprintf(fout, "\t%llu",
(longlong_t)size);
} else {
char buf[16];
zfs_nicenum(size, buf, sizeof (buf));
(void) fprintf(fout, dgettext(TEXT_DOMAIN,
" estimated size is %s"), buf);
}
if (parsable) {
(void) fprintf(fout, "\t%llu",
(longlong_t)size);
} else if (size != 0) {
char buf[16];
zfs_nicenum(size, buf, sizeof (buf));
(void) fprintf(fout, dgettext(TEXT_DOMAIN,
" estimated size is %s"), buf);
}
(void) fprintf(fout, "\n");
}
@@ -1291,13 +1289,11 @@ dump_snapshot(zfs_handle_t *zhp, void *arg)
fromorigin = sdd->prevsnap[0] == '\0' &&
(sdd->fromorigin || sdd->replicate);
if (sdd->progress && sdd->dryrun) {
if (sdd->verbose || sdd->progress) {
(void) estimate_ioctl(zhp, sdd->prevsnap_obj,
fromorigin, flags, &size);
sdd->size += size;
}
if (sdd->verbose) {
send_print_verbose(fout, zhp->zfs_name,
sdd->prevsnap[0] ? sdd->prevsnap : NULL,
size, sdd->parsable);
@@ -1665,7 +1661,7 @@ zfs_send_resume(libzfs_handle_t *hdl, sendflags_t *flags, int outfd,
fromname = name;
}
if (flags->progress) {
if (flags->progress || flags->verbose) {
error = lzc_send_space(zhp->zfs_name, fromname,
lzc_flags, &size);
if (error == 0)
@@ -1935,7 +1931,7 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
sdd.cleanup_fd = -1;
sdd.snapholds = NULL;
}
if (flags->progress || sdd.snapholds != NULL) {
if (flags->progress || flags->verbose || sdd.snapholds != NULL) {
/*
* Do a verbose no-op dry run to get all the verbose output
* or to gather snapshot hold's before generating any data,
@@ -2037,17 +2033,49 @@ err_out:
}
int
zfs_send_one(zfs_handle_t *zhp, const char *from, int fd,
enum lzc_send_flags flags)
zfs_send_one(zfs_handle_t *zhp, const char *from, int fd, sendflags_t flags)
{
int err;
int err = 0;
libzfs_handle_t *hdl = zhp->zfs_hdl;
enum lzc_send_flags lzc_flags = 0;
FILE *fout = (flags.verbose && flags.dryrun) ? stdout : stderr;
char errbuf[1024];
if (flags.largeblock)
lzc_flags |= LZC_SEND_FLAG_LARGE_BLOCK;
if (flags.embed_data)
lzc_flags |= LZC_SEND_FLAG_EMBED_DATA;
if (flags.compress)
lzc_flags |= LZC_SEND_FLAG_COMPRESS;
if (flags.verbose) {
uint64_t size = 0;
err = lzc_send_space(zhp->zfs_name, from, lzc_flags, &size);
if (err == 0) {
send_print_verbose(fout, zhp->zfs_name, from, size,
flags.parsable);
if (flags.parsable) {
(void) fprintf(fout, "size\t%llu\n",
(longlong_t)size);
} else {
char buf[16];
zfs_nicenum(size, buf, sizeof (buf));
(void) fprintf(fout, dgettext(TEXT_DOMAIN,
"total estimated size is %s\n"), buf);
}
} else {
(void) fprintf(stderr, "Cannot estimate send size: "
"%s\n", strerror(errno));
}
}
if (flags.dryrun)
return (err);
(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
"warning: cannot send '%s'"), zhp->zfs_name);
err = lzc_send(zhp->zfs_name, from, fd, flags);
err = lzc_send(zhp->zfs_name, from, fd, lzc_flags);
if (err != 0) {
switch (errno) {
case EXDEV:
+21 -12
View File
@@ -154,6 +154,15 @@ FixupLEAPass::postRAConvertToLEA(MachineFunction::iterator &MFI,
MFI->insert(MBBI, NewMI); // Insert the new inst
return NewMI;
}
}
if (!MI.isConvertibleTo3Addr())
return nullptr;
switch (MI.getOpcode()) {
default:
// Only convert instructions that we've verified are safe.
return nullptr;
case X86::ADD64ri32:
case X86::ADD64ri8:
case X86::ADD64ri32_DB:
@@ -162,24 +171,24 @@ FixupLEAPass::postRAConvertToLEA(MachineFunction::iterator &MFI,
case X86::ADD32ri8:
case X86::ADD32ri_DB:
case X86::ADD32ri8_DB:
case X86::ADD16ri:
case X86::ADD16ri8:
case X86::ADD16ri_DB:
case X86::ADD16ri8_DB:
if (!MI.getOperand(2).isImm()) {
// convertToThreeAddress will call getImm()
// which requires isImm() to be true
return nullptr;
}
break;
case X86::ADD16rr:
case X86::ADD16rr_DB:
if (MI.getOperand(1).getReg() != MI.getOperand(2).getReg()) {
// if src1 != src2, then convertToThreeAddress will
// need to create a Virtual register, which we cannot do
// after register allocation.
return nullptr;
}
case X86::SHL64ri:
case X86::SHL32ri:
case X86::INC64r:
case X86::INC32r:
case X86::DEC64r:
case X86::DEC32r:
case X86::ADD64rr:
case X86::ADD64rr_DB:
case X86::ADD32rr:
case X86::ADD32rr_DB:
// These instructions are all fine to convert.
break;
}
return TII->convertToThreeAddress(MFI, MI, nullptr);
}
+2 -2
View File
@@ -3,7 +3,7 @@ This file is automatically generated from html/copyright.html
jpg "Clone me," says Dolly sheepishly.
Last update: 2-Jan-2017 11:58 UTC
Last update: 4-Feb-2020 23:47 UTC
__________________________________________________________________
The following copyright notice applies to all files collectively called
@@ -32,7 +32,7 @@ This file is automatically generated from html/copyright.html
Burnicki is:
***********************************************************************
* *
* Copyright (c) Network Time Foundation 2011-2017 *
* Copyright (c) Network Time Foundation 2011-2020 *
* *
* All Rights Reserved *
* *
+96
View File
@@ -1,3 +1,99 @@
---
(4.2.8p14) 2020/03/03 Released by Harlan Stenn <[email protected]>
* [Sec 3610] process_control() should bail earlier on short packets. stenn@
- Reported by Philippe Antoine
* [Sec 3596] Highly predictable timestamp attack. <[email protected]>
- Reported by Miroslav Lichvar
* [Sec 3592] DoS attack on client ntpd <[email protected]>
- Reported by Miroslav Lichvar
* [Bug 3637] Emit the version of ntpd in saveconfig. stenn@
* [Bug 3636] NMEA: combine time/date from multiple sentences <[email protected]>
* [Bug 3635] Make leapsecond file hash check optional <[email protected]>
* [Bug 3634] Typo in discipline.html, reported by Jason Harrison. stenn@
* [Bug 3628] raw DCF decoding - improve robustness with Zeller's congruence
- implement Zeller's congruence in libparse and libntp <[email protected]>
* [Bug 3627] SIGSEGV on FreeBSD-12 with stack limit and stack gap <[email protected]>
- integrated patch by Cy Schubert
* [Bug 3620] memory leak in ntpq sysinfo <[email protected]>
- applied patch by Gerry Garvey
* [Bug 3619] Honour drefid setting in cooked mode and sysinfo <[email protected]>
- applied patch by Gerry Garvey
* [Bug 3617] Add support for ACE III and Copernicus II receivers <[email protected]>
- integrated patch by Richard Steedman
* [Bug 3615] accelerate refclock startup <[email protected]>
* [Bug 3613] Propagate noselect to mobilized pool servers <[email protected]>
- Reported by Martin Burnicki
* [Bug 3612] Use-of-uninitialized-value in receive function <[email protected]>
- Reported by Philippe Antoine
* [Bug 3611] NMEA time interpreted incorrectly <[email protected]>
- officially document new "trust date" mode bit for NMEA driver
- restore the (previously undocumented) "trust date" feature lost with [bug 3577]
* [Bug 3609] Fixing wrong falseticker in case of non-statistic jitter <[email protected]>
- mostly based on a patch by Michael Haardt, implementing 'fudge minjitter'
* [Bug 3608] libparse fails to compile on S11.4SRU13 and later <[email protected]>
- removed ffs() and fls() prototypes as per Brian Utterback
* [Bug 3604] Wrong param byte order passing into record_raw_stats() in
ntp_io.c <[email protected]>
- fixed byte and paramter order as suggested by [email protected]
* [Bug 3601] Tests fail to link on platforms with ntp_cv_gc_sections_runs=no <[email protected]>
* [Bug 3599] Build fails on linux-m68k due to alignment issues <[email protected]>
- added padding as suggested by John Paul Adrian Glaubitz
* [Bug 3594] ntpd discards messages coming through nmead <[email protected]>
* [Bug 3593] ntpd discards silently nmea messages after the 5th string <[email protected]>
* [Bug 3590] Update refclock_oncore.c to the new GPS date API <[email protected]>
* [Bug 3585] Unity tests mix buffered and unbuffered output <[email protected]>
- stdout+stderr are set to line buffered during test setup now
* [Bug 3583] synchronization error <[email protected]>
- set clock to base date if system time is before that limit
* [Bug 3582] gpsdjson refclock fudgetime1 adjustment is doubled <[email protected]>
* [Bug 3580] Possible bug ntpq-subs (NULL dereference in dogetassoc) <[email protected]>
- Reported by Paulo Neves
* [Bug 3577] Update refclock_zyfer.c to the new GPS date API <[email protected]>
- also updates for refclock_nmea.c and refclock_jupiter.c
* [Bug 3576] New GPS date function API <[email protected]>
* [Bug 3573] nptdate: missleading error message <[email protected]>
* [Bug 3570] NMEA driver docs: talker ID not mentioned, typo <[email protected]>
* [Bug 3569] cleanup MOD_NANO/STA_NANO handling for 'ntpadjtimex()' <[email protected]>
- sidekick: service port resolution in 'ntpdate'
* [Bug 3550] Reproducible build: Respect SOURCE_DATE_EPOCH <[email protected]>
- applied patch by Douglas Royds
* [Bug 3542] ntpdc monlist parameters cannot be set <[email protected]>
* [Bug 3533] ntpdc peer_info ipv6 issues <[email protected]>
- applied patch by Gerry Garvey
* [Bug 3531] make check: test-decodenetnum fails <[email protected]>
- try to harden 'decodenetnum()' against 'getaddrinfo()' errors
- fix wrong cond-compile tests in unit tests
* [Bug 3517] Reducing build noise <[email protected]>
* [Bug 3516] Require tooling from this decade <[email protected]>
- patch by Philipp Prindeville
* [Bug 3515] Refactor ntpdmain() dispatcher loop and group common code <[email protected]>
- patch by Philipp Prindeville
* [Bug 3511] Get rid of AC_LANG_SOURCE() warnings <[email protected]>
- patch by Philipp Prindeville
* [Bug 3510] Flatten out the #ifdef nesting in ntpdmain() <[email protected]>
- partial application of patch by Philipp Prindeville
* [Bug 3491] Signed values of LFP datatypes should always display a sign
- applied patch by Gerry Garvey & fixed unit tests <[email protected]>
* [Bug 3490] Patch to support Trimble Resolution Receivers <[email protected]>
- applied (modified) patch by Richard Steedman
* [Bug 3473] RefID of refclocks should always be text format <[email protected]>
- applied patch by Gerry Garvey (with minor formatting changes)
* [Bug 3132] Building 4.2.8p8 with disabled local libopts fails <[email protected]>
- applied patch by Miroslav Lichvar
* [Bug 3094] ntpd trying to listen for broadcasts on a completely ipv6 network
<[email protected]>
* [Bug 2420] ntpd doesn't run and exits with retval 0 when invalid user
is specified with -u <[email protected]>
- monitor daemon child startup & propagate exit codes
* [Bug 1433] runtime check whether the kernel really supports capabilities
- (modified) patch by Kurt Roeckx <[email protected]>
* Clean up sntp/networking.c:sendpkt() error message. <[email protected]>
* Provide more detail on unrecognized config file parser tokens. <[email protected]>
* Startup log improvements. <[email protected]>
* Update the copyright year.
* html/confopt.html: cleanup. <[email protected]>
---
(4.2.8p13) 2019/03/07 Released by Harlan Stenn <[email protected]>
+3435 -12
View File
File diff suppressed because it is too large. Load diff
+108
View File
@@ -1,3 +1,111 @@
---
NTP 4.2.8p14 (Harlan Stenn <[email protected]>, 2020 Mar 03)
Focus: Security, Bug fixes, enhancements.
Severity: MEDIUM
This release fixes three vulnerabilities: a bug that causes causes an ntpd
instance that is explicitly configured to override the default and allow
ntpdc (mode 7) connections to be made to a server to read some uninitialized
memory; fixes the case where an unmonitored ntpd using an unauthenticated
association to its servers may be susceptible to a forged packet DoS attack;
and fixes an attack against a client instance that uses a single
unauthenticated time source. It also fixes 46 other bugs and addresses
4 other issues.
* [Sec 3610] process_control() should bail earlier on short packets. stenn@
- Reported by Philippe Antoine
* [Sec 3596] Highly predictable timestamp attack. <[email protected]>
- Reported by Miroslav Lichvar
* [Sec 3592] DoS attack on client ntpd <[email protected]>
- Reported by Miroslav Lichvar
* [Bug 3637] Emit the version of ntpd in saveconfig. stenn@
* [Bug 3636] NMEA: combine time/date from multiple sentences <[email protected]>
* [Bug 3635] Make leapsecond file hash check optional <[email protected]>
* [Bug 3634] Typo in discipline.html, reported by Jason Harrison. stenn@
* [Bug 3628] raw DCF decoding - improve robustness with Zeller's congruence
- implement Zeller's congruence in libparse and libntp <[email protected]>
* [Bug 3627] SIGSEGV on FreeBSD-12 with stack limit and stack gap <[email protected]>
- integrated patch by Cy Schubert
* [Bug 3620] memory leak in ntpq sysinfo <[email protected]>
- applied patch by Gerry Garvey
* [Bug 3619] Honour drefid setting in cooked mode and sysinfo <[email protected]>
- applied patch by Gerry Garvey
* [Bug 3617] Add support for ACE III and Copernicus II receivers <[email protected]>
- integrated patch by Richard Steedman
* [Bug 3615] accelerate refclock startup <[email protected]>
* [Bug 3613] Propagate noselect to mobilized pool servers <[email protected]>
- Reported by Martin Burnicki
* [Bug 3612] Use-of-uninitialized-value in receive function <[email protected]>
- Reported by Philippe Antoine
* [Bug 3611] NMEA time interpreted incorrectly <[email protected]>
- officially document new "trust date" mode bit for NMEA driver
- restore the (previously undocumented) "trust date" feature lost with [bug 3577]
* [Bug 3609] Fixing wrong falseticker in case of non-statistic jitter <[email protected]>
- mostly based on a patch by Michael Haardt, implementing 'fudge minjitter'
* [Bug 3608] libparse fails to compile on S11.4SRU13 and later <[email protected]>
- removed ffs() and fls() prototypes as per Brian Utterback
* [Bug 3604] Wrong param byte order passing into record_raw_stats() in
ntp_io.c <[email protected]>
- fixed byte and paramter order as suggested by [email protected]
* [Bug 3601] Tests fail to link on platforms with ntp_cv_gc_sections_runs=no <[email protected]>
* [Bug 3599] Build fails on linux-m68k due to alignment issues <[email protected]>
- added padding as suggested by John Paul Adrian Glaubitz
* [Bug 3594] ntpd discards messages coming through nmead <[email protected]>
* [Bug 3593] ntpd discards silently nmea messages after the 5th string <[email protected]>
* [Bug 3590] Update refclock_oncore.c to the new GPS date API <[email protected]>
* [Bug 3585] Unity tests mix buffered and unbuffered output <[email protected]>
- stdout+stderr are set to line buffered during test setup now
* [Bug 3583] synchronization error <[email protected]>
- set clock to base date if system time is before that limit
* [Bug 3582] gpsdjson refclock fudgetime1 adjustment is doubled <[email protected]>
* [Bug 3580] Possible bug ntpq-subs (NULL dereference in dogetassoc) <[email protected]>
- Reported by Paulo Neves
* [Bug 3577] Update refclock_zyfer.c to the new GPS date API <[email protected]>
- also updates for refclock_nmea.c and refclock_jupiter.c
* [Bug 3576] New GPS date function API <[email protected]>
* [Bug 3573] nptdate: missleading error message <[email protected]>
* [Bug 3570] NMEA driver docs: talker ID not mentioned, typo <[email protected]>
* [Bug 3569] cleanup MOD_NANO/STA_NANO handling for 'ntpadjtimex()' <[email protected]>
- sidekick: service port resolution in 'ntpdate'
* [Bug 3550] Reproducible build: Respect SOURCE_DATE_EPOCH <[email protected]>
- applied patch by Douglas Royds
* [Bug 3542] ntpdc monlist parameters cannot be set <[email protected]>
* [Bug 3533] ntpdc peer_info ipv6 issues <[email protected]>
- applied patch by Gerry Garvey
* [Bug 3531] make check: test-decodenetnum fails <[email protected]>
- try to harden 'decodenetnum()' against 'getaddrinfo()' errors
- fix wrong cond-compile tests in unit tests
* [Bug 3517] Reducing build noise <[email protected]>
* [Bug 3516] Require tooling from this decade <[email protected]>
- patch by Philipp Prindeville
* [Bug 3515] Refactor ntpdmain() dispatcher loop and group common code <[email protected]>
- patch by Philipp Prindeville
* [Bug 3511] Get rid of AC_LANG_SOURCE() warnings <[email protected]>
- patch by Philipp Prindeville
* [Bug 3510] Flatten out the #ifdef nesting in ntpdmain() <[email protected]>
- partial application of patch by Philipp Prindeville
* [Bug 3491] Signed values of LFP datatypes should always display a sign
- applied patch by Gerry Garvey & fixed unit tests <[email protected]>
* [Bug 3490] Patch to support Trimble Resolution Receivers <[email protected]>
- applied (modified) patch by Richard Steedman
* [Bug 3473] RefID of refclocks should always be text format <[email protected]>
- applied patch by Gerry Garvey (with minor formatting changes)
* [Bug 3132] Building 4.2.8p8 with disabled local libopts fails <[email protected]>
- applied patch by Miroslav Lichvar
* [Bug 3094] ntpd trying to listen for broadcasts on a completely ipv6 network
<[email protected]>
* [Bug 2420] ntpd doesn't run and exits with retval 0 when invalid user
is specified with -u <[email protected]>
- monitor daemon child startup & propagate exit codes
* [Bug 1433] runtime check whether the kernel really supports capabilities
- (modified) patch by Kurt Roeckx <[email protected]>
* Clean up sntp/networking.c:sendpkt() error message. <[email protected]>
* Provide more detail on unrecognized config file parser tokens. <[email protected]>
* Startup log improvements. <[email protected]>
* Update the copyright year.
---
NTP 4.2.8p13 (Harlan Stenn <[email protected]>, 2019 Mar 07)
+3
View File
@@ -1215,6 +1215,9 @@
/* Define if C99-compliant `vsnprintf' is available. */
#undef HAVE_VSNPRINTF
/* Define to 1 if you have the `waitpid' function. */
#undef HAVE_WAITPID
/* Define to 1 if you have the <wchar.h> header file. */
#undef HAVE_WCHAR_H
+33 -10
View File
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for ntp 4.2.8p13.
# Generated by GNU Autoconf 2.69 for ntp 4.2.8p14.
#
# Report bugs to <http://bugs.ntp.org./>.
#
@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='ntp'
PACKAGE_TARNAME='ntp'
PACKAGE_VERSION='4.2.8p13'
PACKAGE_STRING='ntp 4.2.8p13'
PACKAGE_VERSION='4.2.8p14'
PACKAGE_STRING='ntp 4.2.8p14'
PACKAGE_BUGREPORT='http://bugs.ntp.org./'
PACKAGE_URL='http://www.ntp.org./'
@@ -1617,7 +1617,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures ntp 4.2.8p13 to adapt to many kinds of systems.
\`configure' configures ntp 4.2.8p14 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1687,7 +1687,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of ntp 4.2.8p13:";;
short | recursive ) echo "Configuration of ntp 4.2.8p14:";;
esac
cat <<\_ACEOF
@@ -1930,7 +1930,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
ntp configure 4.2.8p13
ntp configure 4.2.8p14
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2639,7 +2639,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by ntp $as_me 4.2.8p13, which was
It was created by ntp $as_me 4.2.8p14, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -3640,7 +3640,7 @@ fi
# Define the identity of the package.
PACKAGE='ntp'
VERSION='4.2.8p13'
VERSION='4.2.8p14'
cat >>confdefs.h <<_ACEOF
@@ -26091,6 +26091,17 @@ fi
done
for ac_func in waitpid
do :
ac_fn_c_check_func "$LINENO" "waitpid" "ac_cv_func_waitpid"
if test "x$ac_cv_func_waitpid" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_WAITPID 1
_ACEOF
fi
done
case "$host" in
*-convex-*)
for ac_header in /sys/sync/queue.h /sys/sync/sema.h
@@ -33331,6 +33342,10 @@ case "$ntp_ept:$cross:$host" in
no:0:*-*-solaris*) ;;
*) ntp_test_ntp_restrict="yes" ;;
esac
case "$ntp_cv_gc_sections_runs" in
no) ntp_test_ntp_restrict="no" ;;
* ) ;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_test_ntp_restrict" >&5
$as_echo "$ntp_test_ntp_restrict" >&6; }
if test x$ntp_test_ntp_restrict = xyes; then
@@ -33350,6 +33365,10 @@ case "$ntp_ept:$cross:$host" in
no:0:*-*-solaris*) ;;
*) ntp_test_ntp_scanner="yes" ;;
esac
case "$ntp_cv_gc_sections_runs" in
no) ntp_test_ntp_scanner="no" ;;
* ) ;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_test_ntp_scanner" >&5
$as_echo "$ntp_test_ntp_scanner" >&6; }
if test x$ntp_test_ntp_scanner = xyes; then
@@ -33369,6 +33388,10 @@ case "$ntp_ept:$cross:$host" in
no:0:*-*-solaris*) ;;
*) ntp_test_ntp_signd="yes" ;;
esac
case "$ntp_cv_gc_sections_runs" in
no) ntp_test_ntp_signd="no" ;;
* ) ;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_test_ntp_signd" >&5
$as_echo "$ntp_test_ntp_signd" >&6; }
if test x$ntp_test_ntp_signd = xyes; then
@@ -34151,7 +34174,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by ntp $as_me 4.2.8p13, which was
This file was extended by ntp $as_me 4.2.8p14, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -34218,7 +34241,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
ntp config.status 4.2.8p13
ntp config.status 4.2.8p14
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
+5 -7
View File
@@ -1,7 +1,7 @@
dnl NTP top-level configure.ac -*- Autoconf -*-
dnl
m4_include([sntp/m4/version.m4])
AC_PREREQ([2.61])
AC_PREREQ([2.68])
AC_INIT(
[ntp],
[VERSION_NUMBER],
@@ -42,13 +42,10 @@ ntp_configure_cache_version=20120806
NTP_CACHEVERSION([main], [$ntp_configure_cache_version])
AM_INIT_AUTOMAKE([1.10 foreign -Wall -Wno-gnu])
AM_INIT_AUTOMAKE([1.15 foreign -Wall -Wno-gnu])
AM_SILENT_RULES([yes])
dnl AM_SILENT_RULES req. automake 1.11. [yes] defaults V=0
m4_ifdef(
[AM_SILENT_RULES],
[AM_SILENT_RULES([yes])]
)
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
dnl the 'build' machine is where we run configure and compile
@@ -382,6 +379,7 @@ case "$host" in
esac
AC_CHECK_HEADERS([sys/stat.h sys/stream.h stropts.h sys/stropts.h sys/syssgi.h])
AC_CHECK_HEADERS([sys/systune.h sys/termios.h sys/tpro.h sys/wait.h])
AC_CHECK_FUNCS([waitpid])
case "$host" in
*-convex-*)
AC_CHECK_HEADERS([/sys/sync/queue.h /sys/sync/sema.h])
+7 -2
View File
@@ -55,8 +55,10 @@ the <a href="accopt.html">Access Control Support</a> page.</p>
</dl>
</dd>
<dt id="restrict"><tt>restrict [-4 | -6] default [ippeerlimit <i>num</i>]
[<i>flag</i>][...]<br> restrict source [ippeerlimit <i>num</i>]
[<i>flag</i>][...]<br> restrict <i>address</i> [mask <i>mask</i>]
[<i>flag</i>][...]</tt></dt>
<dt><tt>restrict source [ippeerlimit <i>num</i>]
[<i>flag</i>][...]</tt></dt>
<dt><tt>restrict <i>address</i> [mask <i>mask</i>]
[ippeerlimit <i>num</i>] [<i>flag</i>][...]</tt></dt>
<dd>The <tt><i>address</i></tt> argument expressed in IPv4 or IPv6 numeric
address form is the address of a host or network. Alternatively,
@@ -168,6 +170,9 @@ the <a href="accopt.html">Access Control Support</a> page.</p>
UDP port (123). A restrict line containing <tt>ntpport</tt> is
considered more specific than one with the same address and mask,
but lacking <tt>ntpport</tt>.</dd>
<dt><tt>serverresponse fuzz</tt></dt>
<dd>When reponding to server requests, fuzz the low order bits of
the <tt>reftime</tt>.</dd>
<dt><tt>version</tt></dt>
<dd>Deny packets that do not match the current NTP version.</dd>
</dl>
+17 -1
View File
@@ -10,7 +10,7 @@
<h3>Reference Clock Commands and Options</h3>
<img src="pic/stack1a.jpg" alt="gif" align="left">Master Time Facility at the <a href="http://www.eecis.udel.edu/%7emills/lab.html">UDel Internet Research Laboratory</a>
<p>Last update:
<!-- #BeginDate format:En2m -->11-Sep-2010 05:55<!-- #EndDate -->
<!-- #BeginDate format:En2m -->26-Sep-2019 06:34<!-- #EndDate -->
UTC</p>
<br clear="left">
<h4>Related Links</h4>
@@ -50,6 +50,22 @@
<dd>Specifies an ASCII string of from one to four characters which defines the reference identifier used by the driver. This string overrides the default identifier ordinarily assigned by the driver itself.</dd>
<dt><tt>flag1 flag2 flag3 flag4</tt></dt>
<dd>These four flags are used for customizing the clock driver. The interpretation of these values, and whether they are used at all, is a function of the particular driver. However, by convention <tt>flag4</tt> is used to enable recording monitoring data to the <tt>clockstats</tt> file configured with the <tt>filegen</tt> command. Additional information on the <tt>filegen</tt> command is on the <a href="monopt.html">Monitoring Options</a> page.</dd>
<dt><tt>minjitter <i>secs</i></tt></dt>
<dd>If the source has a jitter that cannot be sensibly estimated, because
it is not statistic jitter, the source will be detected as falseticker
sooner or later. This has been observed e.g. with the serial data of
certain GPS receivers. Enforcing a minimal jitter value avoids a too
low estimation, keeping the clock in the zoo while still detecting
higher jitter.
</dd><dd> Note: this changes the refclock samples and ends up in the
clock dispersion, not the clock jitter, despite being called jitter. To
see the modified values, check the NTP clock variable "filtdisp", not
"jitter".
</dd><dd>The falseticker problem can also be avoided by increasing <tt>tos
mindist</tt>, which extends the intersection interval, but that affects
the root dispersion and is intended for the case of multiple reference
clocks with reliable jitter that do not intersect otherwise.
</dd>
</dl>
</dd>
</dl>
+22 -9
View File
@@ -13,7 +13,7 @@
Walt Kelly</a>
<p>The chicken is getting configuration advice.</p>
<p>Last update:
<!-- #BeginDate format:En2m -->24-Jul-2018 07:27<!-- #EndDate -->
<!-- #BeginDate format:En2m -->13-Feb-2020 10:08<!-- #EndDate -->
UTC</p>
<br clear="left">
<h4>Related Links</h4>
@@ -33,12 +33,12 @@ Walt Kelly</a>
support for the IPv6 address family is generated in addition to the default IPv4 address family. IPv6 addresses can be identified by the presence of colons &quot;:&quot; in the address field. IPv6 addresses can be used almost everywhere where IPv4 addresses can be used, with the exception of reference clock addresses, which are always IPv4. Note that in contexts where a host name is expected, a <tt>-4</tt> qualifier preceding the host name forces DNS resolution to the IPv4 namespace, while a <tt>-6</tt> qualifier forces DNS resolution to the IPv6 namespace.</p>
<h4 id="command">Server Commands</h4>
<p>Unless noted otherwise, further information about these commands is on the <a href="assoc.html">Association Management</a> page.</p><dl>
<dt id="server"><tt>server <i>address</i> [options ...]</tt><br>
<tt>peer <i>address</i> [options ...]</tt><br>
<tt>broadcast <i>address</i> [options ...]</tt><br>
<tt>manycastclient <i>address</i> [options ...]</tt><br>
<tt>pool <i>address</i> [options ...]</tt><br>
<tt>unpeer [<i>address</i> | <i>associd</i>]</tt></dt>
<dt id="server"><tt>server <i>address</i> [options ...]</tt></dt>
<dt><tt>peer <i>address</i> [options ...]</tt></dt>
<dt><tt>broadcast <i>address</i> [options ...]</tt></dt>
<dt><tt>manycastclient <i>address</i> [options ...]</tt></dt>
<dt><tt>pool <i>address</i> [options ...]</tt></dt>
<dt><tt>unpeer [<i>address</i> | <i>associd</i>]</tt></dt>
<dd>These commands specify the remote server name or address to be used and the mode in which to operate. The <i>address</i> can be either a DNS name or a IPv4 or IPv6 address in standard notation. In general, multiple commands of each type can be used for different server and peer addresses or multicast groups.
<dl>
<dt><tt>server</tt></dt>
@@ -67,8 +67,14 @@ Walt Kelly</a>
<dt><tt>ident</tt> <em><tt>group</tt></em></dt>
<dd>Specify the group name for the association. See the <a href="autokey.html">Autokey Public-Key Authentication</a> page for further information.</dd>
<dt><tt>key</tt> <i><tt>key</tt></i></dt>
<dd>Send and receive packets authenticated by the symmetric key scheme described in the <a href="authentic.html">Authentication Support</a> page. The <i><tt>key</tt></i> specifies the key identifier with values from 1 to 65535, inclusive. This option is mutually exclusive with the <tt>autokey</tt> option.</dd> <dt><tt>minpoll <i>minpoll<br>
</i></tt><tt>maxpoll <i>maxpoll</i></tt></dt>
<dd>Send and receive packets authenticated by the symmetric key scheme
described in the <a href="authentic.html">Authentication Support</a>
page. The <i><tt>key</tt></i> specifies the key identifier with values
from 1 to 65535, inclusive. This option is mutually exclusive with
the <tt>autokey</tt>
option.</dd>
<dt><tt>minpoll <i>minpoll</i></tt></dt>
<dt><tt>maxpoll <i>maxpoll</i></tt></dt>
<dd>These options specify the minimum and maximum poll intervals for NTP messages, in seconds as a power of two. The maximum poll interval defaults to 10 (1024 s), but can be increased by the <tt>maxpoll</tt> option to an upper limit of 17 (36 hr). The minimum poll interval defaults to 6 (64 s), but can be decreased by the <tt>minpoll</tt> option to a lower limit of 3 (8 s). Additional information about this option is on the <a href="poll.html">Poll Program</a> page.</dd>
<dt><tt>mode <i>option</i></tt></dt>
<dd>Pass the <tt><i>option</i></tt> to a reference clock driver, where <tt><i>option</i></tt> is an integer in the range from 0 to 255, inclusive. This option is valid only with type r addresses.</dd>
@@ -87,6 +93,13 @@ Walt Kelly</a>
outgoing NTP packets. Versions 1-4 are the choices, with version 4 the default.</dd>
<dt><tt>xleave</tt></dt>
<dd>Operate in interleaved mode (symmetric and broadcast modes only). Further information is on the <a href="xleave.html">NTP Interleaved Modes</a> page.</dd>
<dt><tt>xmtnonce</tt></dt>
<dd>Allowed in the server and pool modes, this flag causes the
client to put a random number nonce in the transmit timestamp of
its outgoing packet. Since the server will reply copying the
incoming transmit timestamp to the outgoing origin timestamp, this
flag provides extra security for the loopback test, at the expense
of the server having no idea what time the client thinks it is.</dd>
</dl>
<h4 id="aux">Auxiliary Commands</h4>
<dl>
+2 -3
View File
@@ -3,14 +3,13 @@
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>Copyright Notice</title>
<!-- Changed by: Harlan Stenn, 10-Mar-2014 -->
<link href="scripts/style.css" type="text/css" rel="stylesheet">
</head>
<body>
<h3>Copyright Notice</h3>
<img src="pic/sheepb.jpg" alt="jpg" align="left"> "Clone me," says Dolly sheepishly.
<p>Last update:
<!-- #BeginDate format:En2m -->2-Jan-2017 11:58<!-- #EndDate -->
<!-- #BeginDate format:En2m -->4-Feb-2020 23:47<!-- #EndDate -->
UTC</p>
<br clear="left">
</p>
@@ -39,7 +38,7 @@
<pre>
***********************************************************************
* *
* Copyright (c) Network Time Foundation 2011-2017 *
* Copyright (c) Network Time Foundation 2011-2020 *
* *
* All Rights Reserved *
* *
+19 -18
View File
@@ -4,12 +4,13 @@
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta name="generator" content="HTML Tidy, see www.w3.org">
<title>Clock Discipline Algorithm</title>
<!-- Changed by: stenn, 03-Jan-2020 -->
<link href="scripts/style.css" type="text/css" rel="stylesheet">
</head>
<body>
<h3>Clock Discipline Algorithm</h3>
<p>Last update:
<!-- #BeginDate format:En2m -->10-Mar-2014 05:03<!-- #EndDate -->
<!-- #BeginDate format:En2m -->3-Jan-2020 02:12<!-- #EndDate -->
UTC</p>
<h4>Table of Contents</h4>
<ul>
@@ -20,29 +21,29 @@
</ul>
<hr>
<h4 id="intro">General Overview</h4>
<p>At the heart of the NTP specification and reference implementation is the clock discipline algorithm, which is best described as an adaptive parameter, hybrid phase/frequency-lock feedback loop. It is an intricately crafted algorithm that automatically adapts for optimum performance while minimizing network overhead. Operation is in two modes, phase-lock loop (PLL), which is used at poll intervals below the Allan intercept, by default 2048 s, and frequency-lock loop (FLL), which is used above that.</p>
<p>At the heart of the NTP specification and reference implementation is the clock discipline algorithm, which is best described as an adaptive parameter, hybrid phase/frequency-lock feedback loop. It is an intricately crafted algorithm that automatically adapts for optimum performance while minimizing network overhead. Operation is in two modes, phase-lock loop (PLL), which is used at poll intervals below the Allan intercept, by default 2048 s, and frequency-lock loop (FLL), which is used above that.</p>
<div align="center"> <img src="pic/discipline.gif" alt="gif">
<p>Figure 1. Clock Discipline Algorithm</p>
</div>
<h4 id="pll">Clock Discipline Operations</h4>
<p>A block diagram of the clock discipline is shown in Figure 1. The timestamp of a reference clock or remote server is compared with the timestamp of the system clock, represented as a variable frequency oscillator (VFO), to produce a raw offset sample <em>V<sub>d</sub></em>. Offset samples are processed by the clock filter to produce a filtered update <em>V<sub>s</sub></em>. The loop filter implements a type-2 proportional-integrator controller (PIC). The PIC can minimize errors in both time and frequency using predictors <em>x</em> and <em>y</em>, respectively. The clock adjust process samples these predictors once each second for the daemon discipline or once each tick interrupt for the kernel discipline to produce the system clock update <em>V<sub>c</sub></em>.</p>
<p>In PLL mode the frequency predictor is an integral of the offset over past updates, while the phase predictor is the offset amortized over time in order to avoid setting the clock backward. In FLL mode the phase predictor is not used, while the frequency predictor is similar to the NIST <em>lockclock</em> algorithm. In this algorithm, the frequency predictor is computed as a fraction of the current offset divided by the time since the last update in order to minimize the offset at the next update.</p>
<p>The discipline response in PLL mode is determined by the <em>time constant</em>, which results in a &quot;stiffness&quot; depending on the jitter of the available sources and the wander of the system clock oscillator. The scaled time constant is also used as the poll interval described on the <a href="poll.html">Poll Program</a> page. However, in NTP symmetric mode, each peer manages its own poll interval and the two might not be the same. In such cases either peer uses the minimum of its own poll interval and that of the other peer, which is included in the NTP packet header.</p>
<p>A block diagram of the clock discipline is shown in Figure 1. The timestamp of a reference clock or remote server is compared with the timestamp of the system clock, represented as a variable frequency oscillator (VFO), to produce a raw offset sample <em>V<sub>d</sub></em>. Offset samples are processed by the clock filter to produce a filtered update <em>V<sub>s</sub></em>. The loop filter implements a type-2 proportional-integrator controller (PIC). The PIC can minimize errors in both time and frequency using predictors <em>x</em> and <em>y</em>, respectively. The clock adjust process samples these predictors once each second for the daemon discipline or once each tick interrupt for the kernel discipline to produce the system clock update <em>V<sub>c</sub></em>.</p>
<p>In PLL mode the frequency predictor is an integral of the offset over past updates, while the phase predictor is the offset amortized over time in order to avoid setting the clock backward. In FLL mode the phase predictor is not used, while the frequency predictor is similar to the NIST <em>lockclock</em> algorithm. In this algorithm, the frequency predictor is computed as a fraction of the current offset divided by the time since the last update in order to minimize the offset at the next update.</p>
<p>The discipline response in PLL mode is determined by the <em>time constant</em>, which results in a &quot;stiffness&quot; depending on the jitter of the available sources and the wander of the system clock oscillator. The scaled time constant is also used as the poll interval described on the <a href="poll.html">Poll Program</a> page. However, in NTP symmetric mode, each peer manages its own poll interval and the two might not be the same. In such cases either peer uses the minimum of its own poll interval and that of the other peer, which is included in the NTP packet header.</p>
<h4 id="loop">Loop Dynamics</h4>
<p> It is necessary to verify that the clock discipline algorithm is stable and satisfies the Nyquist criterion, which requires that the sampling rate be at least twice the bandwidth. In this case the bandwidth can be approximated by the reciprocal of the time constant. In the NTP specification and reference implementation, time constants and poll intervals are expressed as exponents of 2. By construction, the time constant exponent is five times the poll interval exponent. Thus, the default poll exponent of 6 corresponds to a poll interval of 64 s and a time constant of 2048 s. A change in the poll interval changes the time constant by a corresponding amount.. The Nyquist criterion requires the sample interval to be not more than half the time constant or 1024 s. The clock filter guarantees at least one sample in eight poll intervals, so the sample interval is not more than 512 s. This would be described as oversampling by a factor of two. Finally, the PLL parameters have been chosen for a damping factor of 2, which results in a much faster risetime than with critical damping, but results in modest overshoot of 6 percent.</p>
<p> It is important to understand how the dynamics of the PLL are affected by the time constant and poll interval. At the default poll interval of 64 s and a step offset change of 100 ms, the time response crosses zero in about 50 min and overshoots about 6 ms, as per design. Ordinarily, a step correction would causes a temporary frequency surge of about 5 PPM, which along with the overshoot slowly dissipates over a few hours.</p>
<p>However, the clock state machine used with the discipline algorithm avoids this transient at startup. It does this using a previously saved frequency file, if present, or by measuring the oscillator frequency, if not. It then quickly amortizes the residual offset at startup without affecting the oscillator frequency. In this way the offset error is less than 0.5 ms within 5 min, if the file is present, and within 10 min if not. See the <a href="clock.html">Clock State Machine</a> page for further details.</p>
<p>Since the PLL is linear, the response with different offset step amplitudes and poll intervals has the same characteristic shape, but scaled differently in amplitude and time. The response scales exactly with step amplitude, so that the response to a 10-ms step has the same shape as at 64 s, but with amplitude compressed by one-tenth. The response scales exactly with poll interval, so that response at a poll interval of 8 s has the same shape as at 64 s, but with time compressed by one-eighth.</p>
<p>The optimum time constant, and thus the poll interval, depends on the network time jitter and the oscillator frequency wander. Errors due to jitter decrease as the time constant increases, while errors due to wander decrease as the time constant decreases. For typical Internet paths, the two error characteristics intersect at a point called the <em>Allan intercept</em>, which represents the optimum time constant. With a compromise Allan intercept of 2048 s, the optimum poll interval is about 64 s, which corresponds to a compromise poll exponent of 6. For fast LANs with modern computers, the Allan intercept is somewhat lower at around 512 s, so a compromise poll exponent of 4 (16 s) is appropriate. An intricate, heuristic algorithm is used to manage the actual poll interval within a specified range. Details are on the <a href="poll.html">Poll Program</a> page.</p>
<p>In the NTPv4 specification and reference implementation a state machine is used to manage the system clock under exceptional conditions, as when the daemon is first started or when encountering severe network congestion. In extreme cases not likely to be encountered in normal operation, the system time can be stepped forward or backward more than 128 ms. Further details are on the <a href="clock.html">Clock State Machine</a> page.</p>
<p> It is necessary to verify that the clock discipline algorithm is stable and satisfies the Nyquist criterion, which requires that the sampling rate be at least twice the bandwidth. In this case the bandwidth can be approximated by the reciprocal of the time constant. In the NTP specification and reference implementation, time constants and poll intervals are expressed as exponents of 2. By construction, the time constant exponent is five times the poll interval exponent. Thus, the default poll exponent of 6 corresponds to a poll interval of 64 s and a time constant of 2048 s. A change in the poll interval changes the time constant by a corresponding amount.. The Nyquist criterion requires the sample interval to be not more than half the time constant or 1024 s. The clock filter guarantees at least one sample in eight poll intervals, so the sample interval is not more than 512 s. This would be described as oversampling by a factor of two. Finally, the PLL parameters have been chosen for a damping factor of 2, which results in a much faster risetime than with critical damping, but results in modest overshoot of 6 percent.</p>
<p> It is important to understand how the dynamics of the PLL are affected by the time constant and poll interval. At the default poll interval of 64 s and a step offset change of 100 ms, the time response crosses zero in about 50 min and overshoots about 6 ms, as per design. Ordinarily, a step correction would causes a temporary frequency surge of about 5 PPM, which along with the overshoot slowly dissipates over a few hours.</p>
<p>However, the clock state machine used with the discipline algorithm avoids this transient at startup. It does this using a previously saved frequency file, if present, or by measuring the oscillator frequency, if not. It then quickly amortizes the residual offset at startup without affecting the oscillator frequency. In this way the offset error is less than 0.5 ms within 5 min, if the file is present, and within 10 min if not. See the <a href="clock.html">Clock State Machine</a> page for further details.</p>
<p>Since the PLL is linear, the response with different offset step amplitudes and poll intervals has the same characteristic shape, but scaled differently in amplitude and time. The response scales exactly with step amplitude, so that the response to a 10-ms step has the same shape as at 64 s, but with amplitude compressed by one-tenth. The response scales exactly with poll interval, so that response at a poll interval of 8 s has the same shape as at 64 s, but with time compressed by one-eighth.</p>
<p>The optimum time constant, and thus the poll interval, depends on the network time jitter and the oscillator frequency wander. Errors due to jitter decrease as the time constant increases, while errors due to wander decrease as the time constant decreases. For typical Internet paths, the two error characteristics intersect at a point called the <em>Allan intercept</em>, which represents the optimum time constant. With a compromise Allan intercept of 2048 s, the optimum poll interval is about 64 s, which corresponds to a compromise poll exponent of 6. For fast LANs with modern computers, the Allan intercept is somewhat lower at around 512 s, so a compromise poll exponent of 4 (16 s) is appropriate. An intricate, heuristic algorithm is used to manage the actual poll interval within a specified range. Details are on the <a href="poll.html">Poll Program</a> page.</p>
<p>In the NTPv4 specification and reference implementation a state machine is used to manage the system clock under exceptional conditions, as when the daemon is first started or when encountering severe network congestion. In extreme cases not likely to be encountered in normal operation, the system time can be stepped forward or backward more than 128 ms. Further details are on the <a href="clock.html">Clock State Machine</a> page.</p>
<h4 id="house">Clock Initialization and Management</h4>
<p>If left running continuously, an NTP client on a fast LAN in a home or office environment can maintain synchronization nominally within one millisecond. When the ambient temperature variations are less than a degree Celsius, the clock oscillator frequency is disciplined to within one part per million (PPM), even when the clock oscillator native frequency offset is 100 PPM or more.</p>
<p> For laptops and portable devices when the power is turned off, the battery backup clock offset error can increase as much as one second per day. When power is restored after several hours or days, the clock offset and oscillator frequency errors must be resolved by the clock discipline algorithm, but this can take several hours without specific provisions.</p>
<p> The provisions described in this section insure that, in all but pathological situations, the startup transient is suppressed to within nominal levels in no more than five minutes after a warm start or ten minutes after a cold start. Following is a summary of these provisions. A detailed discussion of these provisions is on the <a href="clock.html">Clock State Machine</a> page.</p>
<p> The reference implementation measures the clock oscillator frequency and updates a frequency file at intervals of one hour or more, depending on the measured frequency wander. This design is intended to minimize write cycles in NVRAM that might be used in a laptop or portable device. In a warm start, the frequency is initialized from this file, which avoids a possibly lengthy convergence time. In a cold start when no frequency file is available, the reference implementation first measures the oscillator frequency over a five-min interval. This generally results in a residual frequency error less than 1 PPM. The measurement interval can be changed using the <tt>stepout</tt> option of the <a href="miscopt.html#tinker"><tt>tinker</tt></a> command.</p>
<p>In order to reduce the clock offset error at restart, the reference implementation mext disables oscillator frequency discipline and enables clock offset discipline with a small time constant. This is designed to quickly reduce the clock offset error without causing a frequency surge. This configuration is continued for an interval of five-min, after which the clock offset error is usually no more than a millisecond. The measurement interval can be changed using the <tt>stepout</tt> option of the <a href="miscopt.html#tinker"><tt>tinker</tt></a> command.</p>
<p>Another concern at restart is the time necessary for the select and cluster algorithms to refine and validate the initial clock offset estimate. Normally, this takes several updates before setting the system clock. As the default minimum poll interval in most configurations is about one minute, it can take several minutes before setting the system clock. The <tt>iburst</tt> option of the <a href="confopt.html#burst"><tt>server</tt></a> command changes the behavior at restart and is recommended for client/server configurations. When this option is enabled, the client sends a volley of six requests at intervals of two seconds. This usually insures a reliable estimate is available in about ten seconds before setting the clock. Once this initial volley is complete, the procedures described above are executed.</p>
<p>As a result of the above considerations, when a backup source, such as the local clock driver, ACTS modem driver or orphan mode is included in the system configuration, it may happen that one or more of them are selectable before one or more of the regular sources are selectable. When backup sources are included in the configuration, the reference implementation waits an interval of several minutes without regular sources before switching to backup sources. This is generally enough to avoid startup transients due to premature switching to backup sources. The interval can be changed using the <tt>orphanwait</tt> option of the <a href="miscopt.html#tos"><tt>tos</tt></a> command.</p>
<p>If left running continuously, an NTP client on a fast LAN in a home or office environment can maintain synchronization nominally within one millisecond. When the ambient temperature variations are less than a degree Celsius, the clock oscillator frequency is disciplined to within one part per million (PPM), even when the clock oscillator native frequency offset is 100 PPM or more.</p>
<p> For laptops and portable devices when the power is turned off, the battery backup clock offset error can increase as much as one second per day. When power is restored after several hours or days, the clock offset and oscillator frequency errors must be resolved by the clock discipline algorithm, but this can take several hours without specific provisions.</p>
<p> The provisions described in this section insure that, in all but pathological situations, the startup transient is suppressed to within nominal levels in no more than five minutes after a warm start or ten minutes after a cold start. Following is a summary of these provisions. A detailed discussion of these provisions is on the <a href="clock.html">Clock State Machine</a> page.</p>
<p> The reference implementation measures the clock oscillator frequency and updates a frequency file at intervals of one hour or more, depending on the measured frequency wander. This design is intended to minimize write cycles in NVRAM that might be used in a laptop or portable device. In a warm start, the frequency is initialized from this file, which avoids a possibly lengthy convergence time. In a cold start when no frequency file is available, the reference implementation first measures the oscillator frequency over a five-min interval. This generally results in a residual frequency error less than 1 PPM. The measurement interval can be changed using the <tt>stepout</tt> option of the <a href="miscopt.html#tinker"><tt>tinker</tt></a> command.</p>
<p>In order to reduce the clock offset error at restart, the reference implementation next disables oscillator frequency discipline and enables clock offset discipline with a small time constant. This is designed to quickly reduce the clock offset error without causing a frequency surge. This configuration is continued for an interval of five-min, after which the clock offset error is usually no more than a millisecond. The measurement interval can be changed using the <tt>stepout</tt> option of the <a href="miscopt.html#tinker"><tt>tinker</tt></a> command.</p>
<p>Another concern at restart is the time necessary for the select and cluster algorithms to refine and validate the initial clock offset estimate. Normally, this takes several updates before setting the system clock. As the default minimum poll interval in most configurations is about one minute, it can take several minutes before setting the system clock. The <tt>iburst</tt> option of the <a href="confopt.html#burst"><tt>server</tt></a> command changes the behavior at restart and is recommended for client/server configurations. When this option is enabled, the client sends a volley of six requests at intervals of two seconds. This usually insures a reliable estimate is available in about ten seconds before setting the clock. Once this initial volley is complete, the procedures described above are executed.</p>
<p>As a result of the above considerations, when a backup source, such as the local clock driver, ACTS modem driver or orphan mode is included in the system configuration, it may happen that one or more of them are selectable before one or more of the regular sources are selectable. When backup sources are included in the configuration, the reference implementation waits an interval of several minutes without regular sources before switching to backup sources. This is generally enough to avoid startup transients due to premature switching to backup sources. The interval can be changed using the <tt>orphanwait</tt> option of the <a href="miscopt.html#tos"><tt>tos</tt></a> command.</p>
<hr>
<script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
</body>
+161 -57
View File
@@ -1,7 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Generic NMEA GPS Receiver</title>
<!-- Changed by: Harlan &, 31-Mar-2014 -->
<!-- Changed by: Pearly &, 04-Feb-2019 -->
<link href="scripts/style.css" type="text/css" rel="stylesheet">
<style type="text/css">
table.dlstable { font-size:85%; }
@@ -13,7 +13,7 @@
<body>
<h3>Generic NMEA GPS Receiver</h3>
<p>Last update:
<!-- #BeginDate format:En2m -->31-Mar-2014 03:55<!-- #EndDate -->
<!-- #BeginDate format:En2m -->13-Jan-2020 07:12<!-- #EndDate -->
UTC</p>
<hr>
<h4>Synopsis</h4>
@@ -41,6 +41,9 @@
second insertion in UTC.&nbsp; To avoid problems mixing UTC and GPS
timescales, the driver disables processing of UTC sentences
once <tt>$GPZDG</tt> is received.
<br>
<strong>Caveat:</strong> Please see <a href="#talkerids">Talker
IDs</a> when using non-GPS or multi-system receivers.
</p>
<p>
The driver expects the receiver to be set up to transmit at least one
@@ -80,7 +83,14 @@
</tr><tr>
<td class="ttf">$GPZDG,GPSTIME,DD,MM,YYYY,AA.BB,V*CS&lt;cr&gt;&lt;lf&gt;</td>
<td>Accord</td>
</tr>
</tr><tr>
</tr><tr>
<td class="ttf">$PGRMF,gpsWk,gpsTow,DATE,UTC,LEAPS,LAT,LAT_REF,LON,LON_REF,TYPE,MODE,SPD,HDOP,TDOP*CS&lt;cr&gt;&lt;lf&gt;</td>
<td>Garmin</td>
</tr><tr>
<td class="ttf">$PUBX,04,UTC,DATE,utcTow,utcWk,LEAPS,clkBias,clkDrift,tpGran,*CS&lt;cr&gt;&lt;lf&gt;</td>
<td>UBLOX</td>
</tr>
</tbody></table></p>
<p><table class="dlstable" border="1">
@@ -91,59 +101,17 @@
</tr>
<tr>
<td class="ttf">UTC</td>
<td>Time of day on UTC timescale. Hours, minutes and seconds [fraction (opt.)]. (hhmmss[.fff])</td>
</tr><tr>
<td class="ttf">POS_STAT</td>
<td>Position status. (A = Data valid, V = Data invalid)</td>
</tr><tr>
<td class="ttf">LAT</td>
<td>Latitude (llll.ll)</td>
</tr><tr>
<td class="ttf">LAT_REF</td>
<td>Latitude direction. (N = North, S = South)</td>
</tr><tr>
<td class="ttf">LON</td>
<td>Longitude (yyyyy.yy)</td>
</tr><tr>
<td class="ttf">LON_REF</td>
<td>Longitude direction (E = East, W = West)</td>
</tr><tr>
<td class="ttf">SPD</td>
<td>Speed over ground. (knots) (x.x)</td>
</tr><tr>
<td class="ttf">HDG</td>
<td>Heading/track made good (degrees True) (x.x)</td>
</tr><tr>
<td class="ttf">DATE</td>
<td>Date (ddmmyy)</td>
</tr><tr>
<td class="ttf">MAG_VAR</td>
<td>Magnetic variation (degrees) (x.x)</td>
</tr><tr>
<td class="ttf">MAG_REF</td>
<td>Magnetic variation (E = East, W = West)</td>
</tr><tr>
<td class="ttf">FIX_MODE</td>
<td>Position Fix Mode (0 = Invalid, &gt;0 = Valid)</td>
</tr><tr>
<td class="ttf">SAT_USED</td>
<td>Number of Satellites used in solution</td>
</tr><tr>
<td class="ttf">HDOP</td>
<td>Horizontal Dilution of Precision</td>
</tr><tr>
<td class="ttf">ALT</td>
<td>Antenna Altitude</td>
</tr><tr>
<td class="ttf">ALT_UNIT</td>
<td>Altitude Units (Metres/Feet)</td>
</tr><tr>
<td class="ttf">GEO</td>
<td>Geoid/Elipsoid separation</td>
<td class="ttf">DATE</td>
<td>Date (ddmmyy)</td>
</tr><tr>
<td class="ttf">G_UNIT</td>
<td>Geoid units (M/F)</td>
<td class="ttf">DD</td>
<td>Day of the month (1-31)</td>
</tr><tr>
<td class="ttf">D_AGE</td>
<td>Age of last DGPS Fix</td>
@@ -151,17 +119,77 @@
<td class="ttf">D_REF</td>
<td>Reference ID of DGPS station</td>
</tr><tr>
<td class="ttf">GPSTIME</td>
<td>Time of day on GPS timescale. Hours, minutes and seconds [fraction (opt.)]. (hhmmss[.f])</td>
<td class="ttf">FIX_MODE</td>
<td>Position Fix Mode (0 = Invalid, &gt;0 = Valid)</td>
</tr><tr>
<td class="ttf">DD</td>
<td>Day of the month (1-31)</td>
<td class="ttf">GEO</td>
<td>Geoid/Elipsoid separation</td>
</tr><tr>
<td class="ttf">GPSTIME</td>
<td>Time of day on GPS timescale. Hours, minutes and seconds [fraction (opt.)] (hhmmss[.f])</td>
</tr><tr>
<td class="ttf">gpsTow</td>
<td>GPS week time, seconds since start of GPS week (0..604799)</td>
</tr><tr>
<td class="ttf">gpsWk</td>
<td>Week number in the GPS time scale (may exceed 1024)</td>
</tr><tr>
<td class="ttf">G_UNIT</td>
<td>Geoid units (M/F)</td>
</tr><tr>
<td class="ttf">HDG</td>
<td>Heading/track made good (degrees True) (x.x)</td>
</tr><tr>
<td class="ttf">HDOP</td>
<td>Horizontal Dilution of Precision</td>
</tr><tr>
<td class="ttf">LAT</td>
<td>Latitude (llll.ll)</td>
</tr><tr>
<td class="ttf">LAT_REF</td>
<td>Latitude direction (N = North, S = South)</td>
</tr><tr>
<td class="ttf">LEAPS</td>
<td>Leap seconds or difference between GPS time scale and UTC</td>
</tr><tr>
<td class="ttf">LON</td>
<td>Longitude (yyyyy.yy)</td>
</tr><tr>
<td class="ttf">LON_REF</td>
<td>Longitude direction (E = East, W = West)</td>
</tr><tr>
<td class="ttf">MAG_REF</td>
<td>Magnetic variation (E = East, W = West)</td>
</tr><tr>
<td class="ttf">MAG_VAR</td>
<td>Magnetic variation (degrees) (x.x)</td>
</tr><tr>
<td class="ttf">MM</td>
<td>Month of the year (1-12)</td>
</tr><tr>
<td class="ttf">POS_STAT</td>
<td>Position status. (A = Data valid, V = Data invalid)</td>
</tr><tr>
<td class="ttf">SAT_USED</td>
<td>Number of Satellites used in solution</td>
</tr><tr>
<td class="ttf">SPD</td>
<td>Speed over ground. (knots) (x.x)</td>
</tr><tr>
<td class="ttf">UTC</td>
<td>Time of day on UTC timescale. Hours, minutes and seconds [fraction (opt.)] (hhmmss[.fff])</td>
</tr><tr>
<td class="ttf">YYYY</td>
<td>Year</td>
</tr><tr>
<td class="ttf">WEEK</td>
<td>GPS week (0-1023)</td>
</tr><tr>
<td class="ttf">WSEC</td>
<td>Seconds since start of week (0-604799)</td>
</tr><tr>
<td class="ttf">LEAP</td>
<td>GPS leap seconds, that is, seconds ahead of UTC</td>
</tr><tr>
<td class="ttf">AA.BB</td>
<td>Denotes the signal strength (should be &lt; 05.00)</td>
@@ -181,6 +209,36 @@
</tbody></table></p>
<h4><a name="talkerids"/>NMEA Talker IDs</h4>
<p>
GNSS receivers use a distinct talker ID for the GNSS they
process. Receivers capable of tracking different systems at the same time
can emit <tt>$GPRMC</tt> (GPS), <tt>$GLRMC</tt> (GLONASS),
<tt>$GARMC</tt> (Galileo), <tt>$GNRMC</tt> (generic/combined) and others
all in one data stream.
</p><p>
The driver supports this to a certain degree by ignoring the
talker ID on the standard sentences RMC, GLL, GGA, ZDA and ZDG. (It
possibly should not do that on the latter, but for now, that's the way
it is.) So whenever <tt>$GPRMC</tt> is mentioned in this document,
substitute any possible talker ID your receiver might emit -- it will
still match.
</p><p>
This approach has a drawback. It is easy to use for single-system
receivers, but it cannot separate the data streams for multi-system
receiver modules. It is therefore undefined which GNSS actually
provides the data, and this can lead to strange behavior. This is
especially true if the different GNSS provide very different signal
quality to the receiver; the driver is not able to cherry-pick the best
source and might actually end up in using the worst available. It is
therefore recommended to set up such a receiver to either use just a
single GNSS (which would defeat its purpose) or to emit only the
combined data, which usually has the <tt>GN</tt> talker ID defined by
the NMEA standard.
<p>
<h4>The 'mode' byte</h4>
<p>
@@ -202,7 +260,7 @@
<td align="center">0</td>
<td align="center">1</td>
<td align="center">1</td>
<td>process <tt>$GPMRC</tt></td>
<td>process <tt>$GPRMC</tt></td>
</tr><tr>
<td align="center">1</td>
<td align="center">2</td>
@@ -259,9 +317,14 @@
<td align="center">0x100</td>
<td>process <tt>$PGRMF</tt></td>
</tr><tr>
<td align="center">9-15</td>
<td align="center">9</td>
<td align="center">512</td>
<td align="center">0x200</td>
<td>process <tt>$PUBX,04</tt></td>
</tr><tr>
<td align="center">10-15</td>
<td align="center"></td>
<td align="center">0xFE00</td>
<td align="center">0xFC00</td>
<td>reserved - leave 0</td>
</tr><tr>
<td align="center">16</td>
@@ -269,6 +332,24 @@
<td align="center">0x10000</td>
<td>Append extra statistics to the clockstats line.
Details below.</td>
</tr><tr>
<td align="center">17</td>
<td align="center">131072</td>
<td align="center">0x20000</td>
<td>"Silent PPS" mode. Use the PPS channel (if enabled with
fudge flag 1) to get precise receive time stamps.
Do <em>not</em> set the PPS flag in the clock status, so the
clock is not considered as PPS peer.
</td>
</tr><tr>
<td align="center">18</td>
<td align="center">262144</td>
<td align="center">0x40000</td>
<td>Trust the date delivered via NMEA. Do this only if
you <em>really</em> trust the receiver!
See <a href="#datetrust">below</a>. <strong>Caveat:</strong>
This (hitherto undocumented) bit has moved!
</td>
</tr>
</tbody></table>
@@ -291,7 +372,7 @@
</li></ul>
The driver uses 4800 bits per second by default, but faster bitrates can
be selected using bits 4 to 6 of the mode field.
<p></p>
</p>
<p>
<strong>Caveat:</strong> Using higher line speeds does not necessarily
@@ -306,6 +387,29 @@
linespeed of 4800 bps or 9600 bps.
</p>
<h4><a name="datetrust"/>About distrusting NMEA date stamps</h4>
<p>
Trusting the calendar dates delivered via NMEA is a risky thing, and by
default these dates are handled with a huge dose of skepticism. Many
receivers deliver a correct calendar date for a period of just 1024 weeks,
with a starting point baked somewhere into their firmware. Beyond that,
they warp back to the begin of their era and simply provide wrong date
information. To battle this widely observed effect, the date delivered is
by default reduced to GPS time again and then (re-)mapped according to the
base date, either the implicit value or the value set via "tos basedate".
If the receiver can <em>really</em> be trusted to deliver the right date
(which is not impossible, just more expensive for the manufacturer), then
mode bit 18 can be used to bypass the era mapping. Setting this bit is
not needed under most circumstances, and setting it with an unreliable
receiver can have severe effects. Handle with care.
</p><p>
<strong>Note:</strong> This functionality was available for some time as
undocumented feature, with a different bit value. It was moved in the
process of becoming officially acknowledged to avoid excessive scattering
of the mode bit mask.
</p>
<h4>Monitor Data</h4>
<p>The last GPS sentence that is accepted or rejected is written to the
+68 -10
View File
@@ -11,7 +11,7 @@
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<h1><font size="+2">Trimble Palisade and Thunderbolt Receivers</font>
<p>Last update:
<!-- #BeginDate format:En2m -->21-Oct-2010 23:44<!-- #EndDate -->
<!-- #BeginDate format:En2m -->13-Sep-2019 08:07<!-- #EndDate -->
UTC</p>
<hr>
</h1>
@@ -69,13 +69,28 @@
</td>
<td><b>9600 baud, 8-bits, 1-stop, no parity</b></td>
</tr>
<tr>
<td>
<div align="right">
<tt><font size="+1">Serial I/O (Copernicus II):</font></tt></div>
</td>
<td><b>38400 baud, 8-bits, 1-stop, no parity</b></td>
</tr>
</table>
<h2><font size="+1">Description</font></h2>
The <b>refclock_palisade</b> driver supports <a href="http://www.trimble.com/products/ntp">Trimble Navigation's Palisade Smart Antenna GPS receiver</a>.<br>
Additional software and information about the Palisade GPS is available from: <a href="http://www.trimble.com/oem/ntp">http://www.trimble.com/oem/ntp</a>.<br>
Latest NTP driver source, executables and documentation is maintained at: <a href="ftp://ftp.trimble.com/pub/ntp">ftp://ftp.trimble.com/pub/ntp</a>
<p>This documentation describes version 7.12 of the GPS Firmware and version 2.46 (July 15, 1999) and later, of the driver source.<br>&nbsp;</p>
<p>This documentation describes version 7.12 of the GPS Firmware and version 2.46 (July 15, 1999) and later, of the driver source.</p>
<p>This documentation describes version 1 of the Thunderbolt Receiver Firmware, no tests have been made on further firmwares, please read "Notes on the Thunderbolt Receiver's Firmware" at the end of this documentation for more information.</p>
<p>This driver also supports the following receivers:</p>
<blockquote>
<p>Endrun Technologies Praecis NTP server with GPS</p>
<p>Trimble Acutime Gold smart antenna</p>
<p>Trimble Resolution family</p>
<p>Trimble ACE III</p>
<p>Trimble Copernicus II</p>
</blockquote>
<h2><font size="+1">Operating System Compatibility</font></h2>
The Palisade driver has been tested on the following software and hardware platforms:<br>&nbsp;
<center>
@@ -118,7 +133,7 @@
</tr>
</table>
</center><P>
<b>Attention</b>: Thunderbolt Receiver has not being tested on the previous software and hardware plataforms.
<b>Attention</b>: Other receiver types have not being tested on the previous software and hardware plataforms.
<h2><font size="+1">GPS Receiver</font></h2>
The Palisade GPS receiver is an 8-channel smart antenna, housing the GPS receiver, antenna and interface in a single unit, and is designed for rooftop deployment in static timing applications.
<p>Palisade generates a PPS synchronized to UTC within +/- 100 ns.&nbsp; The Palisade's external event input with 40 nanosecond resolution is utilized by the Palisade NTP driver for asynchronous precision time transfer.</p>
@@ -232,7 +247,41 @@
<tt># and set flag2 to turn off event polling.</tt><br>
<tt><a href="#flag2">fudge 127.127.29.0 flag2 1</a></tt><br>
<tt>#------------------------------------------------------------------------------</tt><br>&nbsp;</p>
Currently the Thunderbolt mode doesn't support event polling, the reasons are explained on the "Notes on the Thunderbolt Receiver's Firmware" section at the end of this documentation.
<h4>Resolution NTP Configuration file</h4>
<tt>#------------------------------------------------------------------------------</tt>
<p>Configuration without event polling:<br>
<tt>#------------------------------------------------------------------------------</tt><br>
<tt># The Primary reference</tt><br>
<tt>server 127.127.29.0 mode 5 # Trimble Resolution GPS (Stratum 1).</tt><br>
<tt># Set packet delay</tt><br>
<tt><a href="#time1">fudge 127.127.29.0 time1 0.410</a></tt><br>
<tt># and set flag2 to turn off event polling.</tt><br>
<tt><a href="#flag2">fudge 127.127.29.0 flag2 1</a></tt><br>
<tt>#------------------------------------------------------------------------------</tt><br>&nbsp;</p>
<h4>ACE III NTP Configuration file</h4>
<tt>#------------------------------------------------------------------------------</tt>
<p>Configuration with event polling:<br>
<tt>#------------------------------------------------------------------------------</tt><br>
<tt># The Primary reference</tt><br>
<tt>server 127.127.29.0 mode 6 # Trimble ACE III GPS (Stratum 1).</tt><br>
<tt># Set packet delay</tt><br>
<tt><a href="#time1">fudge 127.127.29.0 time1 0.720</a></tt><br>
<tt>#------------------------------------------------------------------------------</tt><br>&nbsp;</p>
<h4>Copernicus II NTP Configuration file</h4>
<tt>#------------------------------------------------------------------------------</tt>
<p>Configuration without event polling:<br>
<tt>#------------------------------------------------------------------------------</tt><br>
<tt># The Primary reference</tt><br>
<tt>server 127.127.29.0 mode 7 # Trimble Copernicus II GPS (Stratum 1).</tt><br>
<tt># Set packet delay</tt><br>
<tt><a href="#time1">fudge 127.127.29.0 time1 0.240</a></tt><br>
<tt># and set flag2 to turn off event polling.</tt><br>
<tt><a href="#flag2">fudge 127.127.29.0 flag2 1</a></tt><br>
<tt>#------------------------------------------------------------------------------</tt><br>&nbsp;</p>
Currently the Thunderbolt mode doesn't support event polling, the reasons are explained on the "Notes on the Thunderbolt Receiver's Firmware" section at the end of this documentation. The Resolution and Copernicus II modes require event polling to be disabled whereas the ACE III requires polling to be enabled.
<h2><a name="TimeTransfer"></a><font size="+1">Time Transfer and Polling</font></h2>
Time transfer to the NTP host is performed via the Palisade's comprehensive time packet output. The time packets are output once per second, and whenever an event timestamp is requested.
<p>The driver requests an event time stamp at the end of each polling interval, by pulsing the RTS (request to send) line on the serial port. The Palisade GPS responds with a time stamped event packet.</p>
@@ -269,7 +318,16 @@
<h2><font size="+1">Mode Parameter</font></h2>
<dl>
<dt><tt><font size="+1">mode <i>number</i></font></tt>
<dd>The mode parameter to the server command specifies the specific hardware this driver is for. The default is 0 for a normal Trimble Palisade. The other options are <b>1</b> for an <b>Endrun Praecis</b> in Trimble emulation mode, and <b>2</b> for the <b>Trimble Thunderbolt</b> GPS Disciplined Clock Receiver.
<dd>
The mode parameter to the server command specifies the specific hardware this driver is for. The default is 0 for a normal Trimble Palisade. The other options are:
<blockquote>
<p><b>1</b> for an <b>Endrun Praecis</b> in Trimble emulation mode</p>
<p><b>2</b> for the <b>Trimble Thunderbolt</b> GPS Disciplined Clock Receiver</p>
<p><b>3</b> for the <b>Acutime Gold</b> smart antenna</p>
<p><b>5</b> for <b>Trimble Resolution</b> devices</p>
<p><b>6</b> for the <b>Trimble ACE III</b> board</p>
<p><b>7</b> for the <b>Trimble Copernicus II</b> device</p>
</blockquote>
</dl>
<h2><font size="+1">DEFINEs</font></h2>
The following constants are defined in the driver source code. These defines may be modified to improve performance or adapt to new operating systems.<br>&nbsp;
@@ -290,16 +348,16 @@
<td>Accuracy of time transfer</td>
<td>1 microsecond</td>
</tr>
<tr>
<td>CURRENT_UTC</td>
<td>Valid GPS - UTC offset</td>
<td>13</td>
</tr>
<tr>
<td>SPEED232</td>
<td>Host RS-232 baud rate</td>
<td>B9600</td>
</tr>
<tr>
<td>SPEED232COP</td>
<td>Host RS-232 baud rate (Copernicus II mode)</td>
<td>B38400</td>
</tr>
<tr>
<td>TRMB_MINPOLL&nbsp;</td>
<td>Minimum polling interval</td>
+28 -5
View File
@@ -10,7 +10,7 @@
<img src="pic/boom3.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Pogo</i>, Walt Kelly</a>
<p>We have three, now looking for more.</p>
<p>Last update:
<!-- #BeginDate format:En2m -->14-Oct-2017 08:34<!-- #EndDate -->
<!-- #BeginDate format:En2m -->11-Feb-2020 14:00<!-- #EndDate -->
UTC</p>
<br clear="left">
<h4>Related Links</h4>
@@ -63,8 +63,9 @@
<dd>This command allows additional configuration commands to be included from a separate file. Include files may be nested to a depth of five; upon reaching the end of any include file, command processing resumes in the previous configuration file. This option is useful for sites that run <tt>ntpd</tt> on multiple hosts, with (mostly) common options (e.g., a restriction list).</dd>
<dt id="interface"><tt>interface [listen | ignore | drop] [all | ipv4 | ipv6 | wildcard | <i>name</i> | <i>address</i>[/<i>prefixlen</i>]]</tt></dt>
<dd>This command controls which network addresses <tt>ntpd</tt> opens, and whether input is dropped without processing. The first parameter determines the action for addresses which match the second parameter. That parameter specifies a class of addresses, or a specific interface name, or an address. In the address case, <tt><i>prefixlen</i></tt> determines how many bits must match for this rule to apply. <tt>ignore</tt> prevents opening matching addresses, <tt>drop</tt> causes <tt>ntpd</tt> to open the address and drop all received packets without examination. Multiple <tt>interface</tt> commands can be used. The last rule which matches a particular address determines the action for it. <tt>interface</tt> commands are disabled if any <a href="ntpd.html#--interface"><tt>-I</tt></a>, <a href="ntpd.html#--interface"><tt>--interface</tt></a>, <a href="ntpd.html#--novirtualips"><tt>-L</tt></a>, or <a href="ntpd.html#--novirtualips"><tt>--novirtualips</tt></a> command-line options are used. If none of those options are used and no <tt>interface</tt> actions are specified in the configuration file, all available network addresses are opened. The <tt>nic</tt> command is an alias for <tt>interface</tt>.</dd>
<dt id="leapfile"><tt>leapfile <i>leapfile</i></tt></dt>
<dd>This command loads the IERS leapseconds file and initializes the leapsecond values for the next leapsecond time, expiration time and TAI offset. The file can be obtained directly from the IERS at <a href="https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list">https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list</a> or <a href="ftp://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list">ftp://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list</a>.</dd>
<dt id="leapfile"><tt>leapfile <i>leapfile</i> [checkhash|ignorehash]</tt></dt>
<dd>This command loads the IERS leapseconds file and initializes the leapsecond values for the next leapsecond time, expiration time and TAI offset. The file can be obtained directly from the IERS at <a href="https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list">https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list</a> or <a href="ftp://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list">ftp://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list</a>.
<tt>ignorehash</tt> instructs <tt>ntpd</tt> to ignore the hash signature on the file, <tt>checkhash</tt> (which is the default when omitted) needs a hash line in the file to be valid. Files without any hash signature are lodaed in both cases.</dd>
<dd>The <i>leapfile</i> is scanned when <tt>ntpd</tt> processes the <tt>leapfile</tt> directive or when <tt>ntpd</tt> detects that <i>leapfile</i> has changed. <tt>ntpd</tt> checks once a day to see if the <i>leapfile</i> has changed.</dd>
<dd>While not strictly a security function, the Autokey protocol provides means to securely retrieve the current or updated leapsecond values from a server.</dd>
<dt id="leapsmearinterval"><tt>leapsmearinterval <i>seconds</i></tt></dt>
@@ -108,6 +109,24 @@
For the ACTS modem driver (type 18), the arguments consist of a maximum of 10 telephone numbers used to dial USNO, NIST or European time services.
For the JJY driver (type 40 mode 100 - 180), the argument is one telephone number used to dial the telephone JJY service.
The Hayes command ATDT&nbsp;is normally prepended to the number, which can contain other modem control codes as well.</dd>
<dt id="pollskewlist"
><tt>pollskewlist</tt> <tt>[</tt><i>poll</i> <i>value</i><tt>
| </tt><i>value</i><tt>]</tt> <tt>...</tt> <tt>[default </tt><i>value</i><tt>
| </tt><i>value</i><tt>]</tt></dt>
<dd>Enable skewing of our poll requests to our servers.
<i>poll</i>
is a number between 3 and 17 inclusive, identifying a specific poll interval.
A poll interval is 2^n seconds in duration,
so a poll value of 3 corresponds to 8 seconds
and
a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one-half of the poll interval,
inclusive.
The first number specifies how early the poll may start,
while
the second number specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.</dd>
<dt id="reset"><tt>reset [allpeers] [auth] [ctl] [io] [mem] [sys] [timer]</tt></dt>
<dd>Reset one or more groups of counters maintained by ntpd and exposed by <tt>ntpq</tt> and <tt>ntpdc</tt>.</dd>
<dt id="rlimit"><tt>rlimit [memlock <i>Nmegabytes</i> | stacksize <i>N4kPages</i> | filenum <i>Nfiledescriptors</i>]</tt></dt>
@@ -147,12 +166,16 @@
<dd>Specifies the stepout threshold in seconds. The default without this command is 300 s. Since this option also affects the training and startup intervals, it should not be set less than the default. Further details are on the <a href="clock.html">Clock State Machine</a> page.</dd>
</dl>
</dd>
<dt id="tos"><tt>tos [basedate <i>date<i> | bcpollbstep <i>poll-gate</i> | beacon <i>beacon</i> | ceiling <i>ceiling</i> | cohort {0 | 1} | floor <i>floor</i> | maxclock <i>maxclock </i>| maxdist <i>maxdist</i> | minclock <i>minclock</i> | mindist <i>mindist </i>| minsane <i>minsane</i> | orphan <i>stratum</i> | orphanwait <em>delay</em>]</tt></dt>
<dt id="tos"><tt>tos [basedate <i>date</i> | bcpollbstep <i>poll-gate</i> | beacon <i>beacon</i> | ceiling <i>ceiling</i> | cohort {0 | 1} | floor <i>floor</i> | maxclock <i>maxclock </i>| maxdist <i>maxdist</i> | minclock <i>minclock</i> | mindist <i>mindist </i>| minsane <i>minsane</i> | orphan <i>stratum</i> | orphanwait <em>delay</em>]</tt></dt>
<dd>This command alters certain system variables used by the the clock selection and clustering algorithms. The default values of these variables have been carefully optimized for a wide range of network speeds and reliability expectations. Very rarely is it necessary to change the default values; but, some folks can't resist twisting the knobs. It can be used to select the quality and quantity of peers used to synchronize the system clock and is most useful in dynamic server discovery schemes. The options are as follows:</dd>
<dd>
<dl>
<dt><tt>basedate <i>date</i></tt></dt>
<dd>Set NTP era anchor. <tt><i>date</i></tt> is either a date in ISO8601 format (<i>YYYY-MM-DD<i>) or an integer giving the days since 1900-01-01, the start of the NTP epoch. <tt>ntpd</tt> will clamp the system time to an era starting with the begin of this this day (00:00:00Z), covering a range of 2<sup>32</sup> seconds or roughly 136 years. The default is the begin of the UNIX epoch, 1970-01-01.</dd>
<dd>Set NTP and GPS era anchor. <tt><i>date</i></tt> is either a date in ISO8601 format (<i>YYYY-MM-DD</i>) or an integer giving the days since 1900-01-01, the start of the NTP epoch. <tt>ntpd</tt> will clamp the system time to an era starting with the begin of this this day (00:00:00Z), covering a range of 2<sup>32</sup> seconds or roughly 136 years. The lowest accepted value is effectively 1970-01-02.<br>
The GPS era base is the next Sunday on or following the base date, but obviously not before 1980-01-06. GPS time stamps are mapped into the 1024 weeks following the GPS base.<br>
The default value is derived from the repository or build time stamp, minus 11 days. 1970-01-02 was chosen as lower bound so the <em>local</em> time is always after 1970-01-01,00:00. Some systems get into trouble if this is not the case.<p>
<b><u>ATTENTION:</u></b> If the system clock is before the effective (implied or specific) basedate, the system clock will be set to the base date once and immediately when <tt>ntpd</tt> starts. This helps systems that have lost time completely to recover. Though not noticeable under normal conditions, it <em>can</em> happen. Check the logs if starting <tt>ntpd</tt> causes sudden clock moves.
</dd>
<dt><tt>bcpollbstep <i>poll-gate</i></tt></dt>
<dd>This option will cause the client to delay believing backward time steps from a broadcast server for <tt>bcpollbstep</tt> poll intervals. NTP Broadcast networks are expected to be trusted, and if the server's time gets stepped backwards then it's desireable that the clients follow this change as soon as possible. However, in spite of various protections built-in to the broadcast protocol, it is possible that an attacker could perform a carefully-constructed replay attack and cause clients to erroneously step their clocks backward. If the risk of a successful broadcast replay attack is greater than the risk of the clients being out of sync in the event that there is a backward step on the broadcast time servers, this option may be used to cause the clients to delay beliveving backward time steps until <i>poll-gate</i> consecutive polls have been received. The default is 0, which means the client will accept these steps upon receipt. Any value from 0 to 4 can be specified.</dd>
<dt><tt>beacon <i>beacon</i></tt></dt>
+3
View File
@@ -25,6 +25,7 @@ noinst_HEADERS = \
ntp.h \
ntp_assert.h \
ntp_calendar.h \
ntp_calgps.h \
ntp_cmdargs.h \
ntp_config.h \
ntp_control.h \
@@ -46,6 +47,7 @@ noinst_HEADERS = \
ntp_md5.h \
ntp_net.h \
ntp_proto.h \
ntp_psl.h \
ntp_random.h \
ntp_refclock.h \
ntp_request.h \
@@ -76,6 +78,7 @@ noinst_HEADERS = \
timespecops.h \
timetoa.h \
timevalops.h \
timexsup.h \
trimble.h \
vint64ops.h \
$(NULL)
+3
View File
@@ -511,6 +511,7 @@ noinst_HEADERS = \
ntp.h \
ntp_assert.h \
ntp_calendar.h \
ntp_calgps.h \
ntp_cmdargs.h \
ntp_config.h \
ntp_control.h \
@@ -532,6 +533,7 @@ noinst_HEADERS = \
ntp_md5.h \
ntp_net.h \
ntp_proto.h \
ntp_psl.h \
ntp_random.h \
ntp_refclock.h \
ntp_request.h \
@@ -562,6 +564,7 @@ noinst_HEADERS = \
timespecops.h \
timetoa.h \
timevalops.h \
timexsup.h \
trimble.h \
vint64ops.h \
$(NULL)
+8 -2
View File
@@ -359,6 +359,7 @@ struct peer {
l_fp aorg; /* origin timestamp */
l_fp borg; /* alternate origin timestamp */
l_fp bxmt; /* most recent broadcast transmit timestamp */
l_fp nonce; /* Value of nonce we sent as the xmt stamp */
double offset; /* peer clock offset */
double delay; /* peer roundtrip delay */
double jitter; /* peer jitter (squares) */
@@ -466,6 +467,7 @@ struct peer {
# define FLAG_ASSOC 0x8000 /* autokey request */
#endif /* OPENSSL */
#define FLAG_TSTAMP_PPS 0x10000 /* PPS source provides absolute timestamp */
#define FLAG_LOOPNONCE 0x20000 /* Use a nonce for the loopback test */
/*
* Definitions for the clear() routine. We use memset() to clear
@@ -841,6 +843,7 @@ struct restrict_u_tag {
u_short rflags; /* restrict (accesslist) flags */
u_short mflags; /* match flags */
short ippeerlimit; /* IP peer limit */
int srvfuzrftpoll; /* server response: fuzz reftime */
u_long expire; /* valid until time */
union { /* variant starting here */
res_addr4 v4;
@@ -885,13 +888,16 @@ char *build_rflags(u_short rflags);
#define RES_MSSNTP 0x1000 /* enable MS-SNTP authentication */
#define RES_FLAKE 0x2000 /* flakeway - drop 10% */
#define RES_NOMRULIST 0x4000 /* mode 6 mrulist denied */
#define RES_UNUSED 0x8000 /* Unused flag bits */
#define RES_SRVRSPFUZ 0x8000 /* Server response: fuzz */
#define RES_UNUSED 0x0000 /* Unused flag bits (none left) */
#define RES_ALLFLAGS (RES_FLAGS | RES_NOQUERY | \
RES_NOMODIFY | RES_NOTRAP | \
RES_LPTRAP | RES_KOD | \
RES_MSSNTP | RES_FLAKE | \
RES_NOMRULIST)
RES_NOMRULIST | RES_SRVRSPFUZ )
/*
* Match flags (mflags)
+71 -2
View File
@@ -19,6 +19,8 @@ struct calendar {
uint8_t second; /* second of minute */
uint8_t weekday; /* 0..7, 0=Sunday */
};
typedef struct calendar TCivilDate;
typedef struct calendar const TcCivilDate;
/* ISO week calendar date */
struct isodate {
@@ -29,6 +31,8 @@ struct isodate {
uint8_t minute; /* minute of hour */
uint8_t second; /* second of minute */
};
typedef struct isodate TIsoDate;
typedef struct isodate const TcIsoDate;
/* general split representation */
typedef struct {
@@ -109,6 +113,7 @@ extern systime_func_ptr ntpcal_set_timefunc(systime_func_ptr);
extern const char * const months[12];
extern const char * const daynames[7];
extern char * ntpcal_iso8601std(char*, size_t, struct calendar const*);
extern void caljulian (uint32_t, struct calendar *);
extern uint32_t caltontp (const struct calendar *);
@@ -151,6 +156,13 @@ ntpcal_ntp_to_ntp(uint32_t /* ntp */, const time_t * /* pivot */);
extern ntpcal_split
ntpcal_daysplit(const vint64 *);
/*
* Split a time stamp in seconds into elapsed weeks and elapsed seconds
* since start of week.
*/
extern ntpcal_split
ntpcal_weeksplit(const vint64 *);
/*
* Merge a number of days and a number of seconds into seconds,
* expressed in 64 bits to avoid overflow.
@@ -158,6 +170,13 @@ ntpcal_daysplit(const vint64 *);
extern vint64
ntpcal_dayjoin(int32_t /* days */, int32_t /* seconds */);
/*
* Merge a number of weeks and a number of seconds into seconds,
* expressed in 64 bits to avoid overflow.
*/
extern vint64
ntpcal_weekjoin(int32_t /* weeks */, int32_t /* seconds */);
/* Get the number of leap years since epoch for the number of elapsed
* full years
*/
@@ -431,7 +450,7 @@ basedate_expand_gpsweek(unsigned short weekno);
/*
* Start day of the GPS epoch. This is the Rata Die of 1980-01-06
*/
#define DAY_GPS_STARTS 722819
#define DAY_GPS_STARTS 722820
/*
* Difference between UN*X and NTP epoch (25567).
@@ -467,6 +486,56 @@ basedate_expand_gpsweek(unsigned short weekno);
*/
#define GREGORIAN_CYCLE_WEEKS (GREGORIAN_CYCLE_DAYS / 7)
#define is_leapyear(y) (!((y) % 4) && !(!((y) % 100) && (y) % 400))
/*
* Is a Greogorian calendar year a leap year? The obvious solution is to
* test the expression
*
* (y % 4 == 0) && ((y % 100 != 0) || (y % 400 == 0))
*
* This needs (in theory) 2 true divisions -- most compilers check the
* (mod 4) condition by doing a bit test. Some compilers have been
* even observed to partially fuse the (mod 100) and (mod 400) test,
* but there is an alternative formula that gives the compiler even
* better chances:
*
* (y % 4 == 0) && ((y % 16 == 0) || (y % 25 != 0))
*
* The order of checks is chosen so that the shorcut evaluation can fix
* the result as soon as possible. And the compiler has to do only one
* true division here -- the (mod 4) and (mod 16) can be done with
* direct bit tests. *If* the compiler chooses to do so.
*
* The deduction is as follows: rewrite the standard formula as
* (y % 4 == 0) && ((y % 4*25 != 0) || (y % 16*25 == 0))
*
* then split the congruences:
* (y % 4 == 0) && ((y % 4 != 0 || y % 25 != 0) || (y % 16 == 0 && y % 25 == 0))
*
* eliminate the 1st inner term, as it is provably false:
* (y % 4 == 0) && (y % 25 != 0 || (y % 16 == 0 && y % 25 == 0))
*
* Use the distributive laws on the second major group:
* (y % 4 == 0) && ((y % 25 != 0 || y % 16 == 0) && (y % 25 != 0 || y % 25 == 0))
*
* Eliminate the constant term, reorder, and voila:
*/
static inline int
is_leapyear(int32_t y) {
return !(y % 4) && (!(y % 16) || (y % 25));
}
/* The (mod 4) test eliminates 3/4 (or 12/16) of all values.
* The (mod 16) test eliminates another 1/16 of all values.
* 3/16 of all values reach the final division.
* Assuming that the true division is the most costly operation, this
* sequence should give most bang for the buck.
*/
/* misc */
extern int u32mod7(uint32_t x);
extern int i32mod7(int32_t x);
extern uint32_t i32fmod(int32_t x, uint32_t d);
extern int32_t ntpcal_expand_century(uint32_t y, uint32_t m, uint32_t d, uint32_t wd);
#endif
+151
View File
@@ -0,0 +1,151 @@
/*
* ntp_calgps.h - calendar for GPS/GNSS based clocks
*
* Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project.
* The contents of 'html/copyright.html' apply.
*
* --------------------------------------------------------------------
*
* This module implements stuff often used with GPS/GNSS receivers
*/
#ifndef NTP_CALGPS_H
#define NTP_CALGPS_H
#include <time.h>
#include "ntp_types.h"
#include "ntp_fp.h"
#include "ntp_calendar.h"
/* GPS week calendar (extended weeks)
* We use weeks based on 1899-31-12, which was the last Sunday before
* the begin of the NTP epoch. (Which is equivalent to saying 1900-01-01
* was a Monday...)
*
* We simply pre-calculate the offsets and cycle shifts for the real GPS
* calendar, which starts at 1980-01-06, to simplyfy some expressions.
*
* This has a fringe benefit that should not be overlooked: Since week zero
* is around 1900, and we should never have to deal with dates before
* 1970 or 1980, a week number of zero can be easily used to indicate
* an invalid week time stamp.
*/
#define GPSNTP_WSHIFT 4175 /* weeks 1899-31-12 --> 1980-01-06 */
#define GPSNTP_WCYCLE 79 /* above, modulo 1024 */
#define GPSNTP_DSHIFT 1 /* day number of 1900-01-01 in week */
struct gpsdatum {
uint32_t weeks; /* weeks since GPS epoch */
int32_t wsecs; /* seconds since week start */
uint32_t frac; /* fractional seconds */
};
typedef struct gpsdatum TGpsDatum;
typedef struct gpsdatum const TcGpsDatum;
/* NTP date/time in split representation */
struct ntpdatum {
uint32_t days; /* since NTP epoch */
int32_t secs; /* since midnight, denorm is ok */
uint32_t frac; /* fractional seconds */
};
typedef struct ntpdatum TNtpDatum;
typedef struct ntpdatum const TcNtpDatum;
/*
* GPS week/sec calendar functions
*
* see the implementation for details, especially the
* 'gpscal_from_weektime{1,2}()'
*/
extern TGpsDatum
gpscal_fix_gps_era(TcGpsDatum *);
extern void
gpscal_add_offset(TGpsDatum *datum, l_fp offset);
extern TGpsDatum
gpscal_from_calendar_ex(TcCivilDate*, l_fp fofs, int/*BOOL*/ warp);
static inline TGpsDatum
gpscal_from_calendar(TcCivilDate *pCiv, l_fp fofs) {
return gpscal_from_calendar_ex(pCiv, fofs, TRUE);
}
extern TGpsDatum /* see source for semantic of the 'fofs' value! */
gpscal_from_gpsweek(uint16_t w, int32_t s, l_fp fofs);
extern TGpsDatum
gpscal_from_weektime1(int32_t wsecs, l_fp fofs, l_fp pivot);
extern TGpsDatum
gpscal_from_weektime2(int32_t wsecs, l_fp fofs, TcGpsDatum *pivot);
extern void
gpscal_to_calendar(TCivilDate*, TcGpsDatum*);
extern TGpsDatum
gpscal_from_gpsntp(TcNtpDatum*);
extern l_fp
ntpfp_from_gpsdatum(TcGpsDatum *);
/*
* NTP day/sec calendar functions
*
* see the implementation for details, especially the
* 'gpscal_from_daytime{1,2}()'
*/
extern TNtpDatum
gpsntp_fix_gps_era(TcNtpDatum *);
extern void
gpsntp_add_offset(TNtpDatum *datum, l_fp offset);
extern TNtpDatum
gpsntp_from_calendar_ex(TcCivilDate*, l_fp fofs, int/*BOOL*/ warp);
static inline TNtpDatum
gpsntp_from_calendar(TcCivilDate * pCiv, l_fp fofs) {
return gpsntp_from_calendar_ex(pCiv, fofs, TRUE);
}
extern TNtpDatum
gpsntp_from_daytime1_ex(TcCivilDate *dt, l_fp fofs, l_fp pivot, int/*BOOL*/ warp);
static inline TNtpDatum
gpsntp_from_daytime1(TcCivilDate *dt, l_fp fofs, l_fp pivot) {
return gpsntp_from_daytime1_ex(dt, fofs, pivot, TRUE);
}
extern TNtpDatum
gpsntp_from_daytime2_ex(TcCivilDate *dt, l_fp fofs, TcNtpDatum *pivot, int/*BOOL*/ warp);
static inline TNtpDatum
gpsntp_from_daytime2(TcCivilDate *dt, l_fp fofs, TcNtpDatum *pivot) {
return gpsntp_from_daytime2_ex(dt, fofs, pivot, TRUE);
}
extern TNtpDatum
gpsntp_from_gpscal_ex(TcGpsDatum*, int/*BOOL*/ warp);
static inline TNtpDatum
gpsntp_from_gpscal(TcGpsDatum *wd) {
return gpsntp_from_gpscal_ex(wd, FALSE);
}
extern void
gpsntp_to_calendar(TCivilDate*, TcNtpDatum*);
extern l_fp
ntpfp_from_ntpdatum(TcNtpDatum*);
/*
* Some helpers
*/
/* apply fudge to time stamp: *SUBTRACT* the given offset from an l_fp*/
extern l_fp
ntpfp_with_fudge(l_fp lfp, double ofs);
#endif /*!defined(NTP_CALGPS_H)*/
+30 -9
View File
@@ -6,6 +6,7 @@
#endif /* HAVE_SYS_RESOURCE_H */
#include "ntp_machine.h"
#include "ntp_psl.h"
#include "ntpsim.h"
@@ -68,12 +69,13 @@ struct attr_val_tag {
attr_val * link;
int attr;
int type; /* T_String, T_Integer, ... */
int flag; /* auxiliary flags */
union val {
int i;
u_int u;
int_range r;
double d;
char * s;
double d; /* T_Double */
int i; /* T_Integer */
int_range r; /* T_Intrange */
char * s; /* T_String */
u_int u; /* T_U_int */
} value;
};
@@ -110,9 +112,10 @@ struct restrict_node_tag {
restrict_node * link;
address_node * addr;
address_node * mask;
int_fifo * flag_tok_fifo;
attr_val_fifo * flag_tok_fifo;
int line_no;
short ippeerlimit;
short srvfuzrft;
};
typedef DECL_FIFO_ANCHOR(restrict_node) restrict_fifo;
@@ -246,6 +249,7 @@ struct config_tree_tag {
attr_val_fifo * vars;
nic_rule_fifo * nic_rules;
int_fifo * reset_counters;
attr_val_fifo * pollskewlist;
sim_fifo * sim_details;
int mdnstries;
@@ -272,6 +276,23 @@ typedef struct settrap_parms_tag {
} settrap_parms;
/*
* Poll Skew List
*/
psl_item psl[17-3+1]; /* values for polls 3-17 */
/* To simplify the runtime code we */
/* don't want to have to special-case */
/* dealing with a default */
/*
** Data Minimization Items
*/
/* Serverresponse fuzz reftime: stored in 'restrict' fifos */
/* get text from T_ tokens */
const char * token_name(int token);
@@ -298,9 +319,9 @@ address_node *create_address_node(char *addr, int type);
void destroy_address_node(address_node *my_node);
attr_val *create_attr_dval(int attr, double value);
attr_val *create_attr_ival(int attr, int value);
attr_val *create_attr_uval(int attr, u_int value);
attr_val *create_attr_rangeval(int attr, int first, int last);
attr_val *create_attr_rval(int attr, int first, int last);
attr_val *create_attr_sval(int attr, const char *s);
attr_val *create_attr_uval(int attr, u_int value);
void destroy_attr_val(attr_val *node);
filegen_node *create_filegen_node(int filegen_token,
attr_val_fifo *options);
@@ -308,7 +329,7 @@ string_node *create_string_node(char *str);
restrict_node *create_restrict_node(address_node *addr,
address_node *mask,
short ippeerlimit,
int_fifo *flags, int line_no);
attr_val_fifo *flags, int line_no);
int_node *create_int_node(int val);
addr_opts_node *create_addr_opts_node(address_node *addr,
attr_val_fifo *options);
+4
View File
@@ -1,3 +1,5 @@
#ifndef NTP_CONTROL_H
#define NTP_CONTROL_H
/*
* ntp_control.h - definitions related to NTP mode 6 control messages
*/
@@ -190,3 +192,5 @@ extern struct ctl_trap ctl_traps[CTL_MAXTRAPS];
#define IFSTATS_FIELDS 12
#define RESLIST_FIELDS 4
#endif /* NTP_CONTROL_H */
+2 -2
View File
@@ -344,8 +344,8 @@ typedef u_int32 u_fp;
/*
* Prototypes
*/
extern char * dofptoa (u_fp, int, short, int);
extern char * dolfptoa (u_int32, u_int32, int, short, int);
extern char * dofptoa (u_fp, char, short, int);
extern char * dolfptoa (u_int32, u_int32, char, short, int);
extern int atolfp (const char *, l_fp *);
extern int buftvtots (const char *, l_fp *);
+1 -1
View File
@@ -84,7 +84,7 @@ typedef enum {
extern int qos;
SOCKET move_fd(SOCKET fd);
isc_boolean_t get_broadcastclient_flag(void);
/*isc_boolean_t get_broadcastclient_flag(void);*/
extern void sau_from_netaddr(sockaddr_u *, const isc_netaddr_t *);
extern void add_nic_rule(nic_rule_match match_type,
const char *if_name, int prefixlen,
+17
View File
@@ -0,0 +1,17 @@
#ifndef NTP_PSL_H
#define NTP_PSL_H
/*
* Poll Skew List Item
*/
typedef struct psl_item_tag {
int sub; /* int or short? unsigned is OK, but why? */
int qty; /* int or short? unsigned is OK, but why? */
int msk; /* int or short? unsigned is OK */
} psl_item;
int get_pollskew(int, psl_item *);
#endif /* !defined(NTP_PSL_H) */
+25 -10
View File
@@ -14,11 +14,6 @@
#include "recvbuff.h"
#define SAMPLE(x) pp->coderecv = (pp->coderecv + 1) % MAXSTAGE; \
pp->filter[pp->coderecv] = (x); \
if (pp->coderecv == pp->codeproc) \
pp->codeproc = (pp->codeproc + 1) % MAXSTAGE;
/*
* Macros to determine the clock type and unit numbers from a
* 127.127.t.u address
@@ -54,6 +49,7 @@ extern struct clktype clktypes[];
#define CLK_HAVEFLAG2 0x20
#define CLK_HAVEFLAG3 0x40
#define CLK_HAVEFLAG4 0x80
#define CLK_HAVEMINJIT 0x100
/*
* Constant for disabling event reporting in
@@ -68,7 +64,7 @@ extern struct clktype clktypes[];
struct refclockstat {
u_char type; /* clock type */
u_char flags; /* clock flags */
u_char haveflags; /* bit array of valid flags */
u_short haveflags; /* bit array of valid flags */
u_short lencode; /* length of last timecode */
const char *p_lastcode; /* last timecode received */
u_int32 polls; /* transmit polls */
@@ -77,6 +73,7 @@ struct refclockstat {
u_int32 baddata; /* invalid data timecode received */
u_int32 timereset; /* driver resets */
const char *clockdesc; /* ASCII description */
double fudgeminjitter; /* configure fudge minjitter */
double fudgetime1; /* configure fudge time1 */
double fudgetime2; /* configure fudge time2 */
int32 fudgeval1; /* configure fudge value1 */
@@ -133,13 +130,12 @@ extern HANDLE WaitableIoEventHandle;
* Structure interface between the reference clock support
* ntp_refclock.c and the driver utility routines
*/
#define MAXSTAGE 60 /* max median filter stages */
#define MAXSTAGE 64 /* max median filter stages */
#define NSTAGE 5 /* default median filter stages */
#define BMAX 128 /* max timecode length */
#define GMT 0 /* I hope nobody sees this */
#define MAXDIAL 60 /* max length of modem dial strings */
struct refclockproc {
void * unitptr; /* pointer to unit structure */
struct refclock * conf; /* refclock_conf[type] */
@@ -148,6 +144,7 @@ struct refclockproc {
u_char currentstatus; /* clock status */
u_char lastevent; /* last exception event */
u_char type; /* clock type */
u_char inpoll; /* waiting for 'refclock_receive()' */
const char *clockdesc; /* clock description */
u_long nextaction; /* local activity timeout */
void (*action)(struct peer *); /* timeout callback */
@@ -162,8 +159,8 @@ struct refclockproc {
int second; /* second of minute */
long nsec; /* nanosecond of second */
u_long yearstart; /* beginning of year */
int coderecv; /* put pointer */
int codeproc; /* get pointer */
u_int coderecv; /* put pointer */
u_int codeproc; /* get pointer */
l_fp lastref; /* reference timestamp */
l_fp lastrec; /* receive timestamp */
double offset; /* mean offset */
@@ -176,6 +173,7 @@ struct refclockproc {
*/
double fudgetime1; /* fudge time1 */
double fudgetime2; /* fudge time2 */
double fudgeminjitter; /* manually set lower bound for jitter */
u_char stratum; /* server stratum */
u_int32 refid; /* reference identifier */
u_char sloppyclockflag; /* fudge flags */
@@ -229,12 +227,29 @@ extern int refclock_process(struct refclockproc *);
extern int refclock_process_f(struct refclockproc *, double);
extern void refclock_process_offset(struct refclockproc *, l_fp,
l_fp, double);
extern int refclock_samples_avail(struct refclockproc const *);
extern int refclock_samples_expire(struct refclockproc *, int);
extern void refclock_report (struct peer *, int);
extern int refclock_gtlin (struct recvbuf *, char *, int, l_fp *);
extern int refclock_gtraw (struct recvbuf *, char *, int, l_fp *);
extern int indicate_refclock_packet(struct refclockio *,
struct recvbuf *);
extern void process_refclock_packet(struct recvbuf *);
/* save string as la_code, size==(size_t)-1 ==> ASCIIZ string */
extern void refclock_save_lcode(
struct refclockproc *, char const *, size_t);
/* format data into la_code */
extern void refclock_format_lcode(
struct refclockproc *, char const *, ...);
extern void refclock_vformat_lcode(
struct refclockproc *, char const *, va_list);
struct refclock_atom;
extern int refclock_ppsaugment(
const struct refclock_atom*, l_fp *rcvtime ,
double rcvfudge, double ppsfudge);
#endif /* REFCLOCK */
#endif /* NTP_REFCLOCK_H */
+3 -1
View File
@@ -670,8 +670,10 @@ struct conf_restrict {
u_int32 addr; /* match address */
u_int32 mask; /* match mask */
short ippeerlimit; /* ip peer limit */
u_short flags; /* restrict flags */
int srvfuzrft; /* server response fuzz reftime: poll */
u_short flags; /* restrict flags XXX: OLD size and name */
u_short mflags; /* match flags */
short unused1; /* (unused) padding for v6_flag */
u_int v6_flag; /* is this v6 or not */
struct in6_addr addr6; /* match address (v6) */
struct in6_addr mask6; /* match mask (v6) */
+1 -1
View File
@@ -159,7 +159,7 @@ extern const char * modetoa (size_t);
extern const char * eventstr (int);
extern const char * ceventstr (int);
extern const char * res_match_flags(u_short);
extern const char * res_access_flags(u_short);
extern const char * res_access_flags(u_int32);
#ifdef KERNEL_PLL
extern const char * k_st_flags (u_int32);
#endif
+3
View File
@@ -83,4 +83,7 @@ do { \
msyslog msl_args; \
} while (FALSE)
extern int change_iobufs(int how);
/* how: 0->unbuffered, 1->linebuffer, 2->full */
#endif /* NTP_SYSLOG_H */
+3 -3
View File
@@ -232,7 +232,7 @@ extern double sys_mindisp;
extern double sys_maxdist;
extern char *sys_ident; /* identity scheme */
extern void poll_update (struct peer *, u_char);
extern void poll_update (struct peer *, u_char, u_char);
extern void clear (struct peer *);
extern void clock_filter (struct peer *, double, double, double);
@@ -282,7 +282,7 @@ extern u_char sys_automax; /* session key timeout */
/* ntp_util.c */
extern void init_util (void);
extern void write_stats (void);
extern void stats_config (int, const char *);
extern void stats_config (int, const char *, int optflag);
extern void record_peer_stats (sockaddr_u *, int, double, double, double, double);
extern void record_proto_stats (char *);
extern void record_loop_stats (double, double, double, double, int);
@@ -568,7 +568,7 @@ extern char *group; /* group to switch to */
extern const char *chrootdir; /* directory to chroot() to */
#endif
#ifdef HAVE_WORKING_FORK
extern int waitsync_fd_to_close; /* -w/--wait-sync */
extern int daemon_pipe[2]; /* startup monitoring */
#endif
/* ntservice.c */
+8 -179
View File
@@ -56,68 +56,11 @@
/* predicate: returns TRUE if the nanoseconds are out-of-bounds */
#define timespec_isdenormal(x) (!timespec_isnormal(x))
/* conversion between l_fp fractions and nanoseconds */
#ifdef HAVE_U_INT64
# define FTOTVN(tsf) \
((int32) \
(((u_int64)(tsf) * NANOSECONDS + 0x80000000) >> 32))
# define TVNTOF(tvu) \
((u_int32) \
((((u_int64)(tvu) << 32) + NANOSECONDS / 2) / \
NANOSECONDS))
#else
# define NSECFRAC (FRAC / NANOSECONDS)
# define FTOTVN(tsf) \
((int32)((tsf) / NSECFRAC + 0.5))
# define TVNTOF(tvu) \
((u_int32)((tvu) * NSECFRAC + 0.5))
#endif
/* make sure nanoseconds are in nominal range */
static inline struct timespec
normalize_tspec(
struct timespec x
)
{
#if SIZEOF_LONG > 4
long z;
/*
* tv_nsec is of type 'long', and on a 64-bit machine using only
* loops becomes prohibitive once the upper 32 bits get
* involved. On the other hand, division by constant should be
* fast enough; so we do a division of the nanoseconds in that
* case. The floor adjustment step follows with the standard
* normalisation loops. And labs() is intentionally not used
* here: it has implementation-defined behaviour when applied
* to LONG_MIN.
*/
if (x.tv_nsec < -3l * NANOSECONDS ||
x.tv_nsec > 3l * NANOSECONDS) {
z = x.tv_nsec / NANOSECONDS;
x.tv_nsec -= z * NANOSECONDS;
x.tv_sec += z;
}
#endif
/* since 10**9 is close to 2**32, we don't divide but do a
* normalisation in a loop; this takes 3 steps max, and should
* outperform a division even if the mul-by-inverse trick is
* employed. */
if (x.tv_nsec < 0)
do {
x.tv_nsec += NANOSECONDS;
x.tv_sec--;
} while (x.tv_nsec < 0);
else if (x.tv_nsec >= NANOSECONDS)
do {
x.tv_nsec -= NANOSECONDS;
x.tv_sec++;
} while (x.tv_nsec >= NANOSECONDS);
return x;
}
extern struct timespec normalize_tspec(struct timespec x);
/* x = a + b */
static inline struct timespec
@@ -196,45 +139,13 @@ neg_tspec(
}
/* x = abs(a) */
static inline struct timespec
abs_tspec(
struct timespec a
)
{
struct timespec c;
c = normalize_tspec(a);
if (c.tv_sec < 0) {
if (c.tv_nsec != 0) {
c.tv_sec = -c.tv_sec - 1;
c.tv_nsec = NANOSECONDS - c.tv_nsec;
} else {
c.tv_sec = -c.tv_sec;
}
}
return c;
}
struct timespec abs_tspec(struct timespec a);
/*
* compare previously-normalised a and b
* return 1 / 0 / -1 if a < / == / > b
*/
static inline int
cmp_tspec(
struct timespec a,
struct timespec b
)
{
int r;
r = (a.tv_sec > b.tv_sec) - (a.tv_sec < b.tv_sec);
if (0 == r)
r = (a.tv_nsec > b.tv_nsec) -
(a.tv_nsec < b.tv_nsec);
return r;
}
extern int cmp_tspec(struct timespec a, struct timespec b);
/*
* compare possibly-denormal a and b
@@ -253,19 +164,7 @@ cmp_tspec_denorm(
* test previously-normalised a
* return 1 / 0 / -1 if a < / == / > 0
*/
static inline int
test_tspec(
struct timespec a
)
{
int r;
r = (a.tv_sec > 0) - (a.tv_sec < 0);
if (r == 0)
r = (a.tv_nsec > 0);
return r;
}
extern int test_tspec(struct timespec a);
/*
* test possibly-denormal a
@@ -293,20 +192,7 @@ tspectoa(
*/
/* convert from timespec duration to l_fp duration */
static inline l_fp
tspec_intv_to_lfp(
struct timespec x
)
{
struct timespec v;
l_fp y;
v = normalize_tspec(x);
y.l_uf = TVNTOF(v.tv_nsec);
y.l_i = (int32)v.tv_sec;
return y;
}
extern l_fp tspec_intv_to_lfp(struct timespec x);
/* x must be UN*X epoch, output will be in NTP epoch */
static inline l_fp
@@ -323,71 +209,14 @@ tspec_stamp_to_lfp(
}
/* convert from l_fp type, relative signed/unsigned and absolute */
static inline struct timespec
lfp_intv_to_tspec(
l_fp x
)
{
struct timespec out;
l_fp absx;
int neg;
neg = L_ISNEG(&x);
absx = x;
if (neg) {
L_NEG(&absx);
}
out.tv_nsec = FTOTVN(absx.l_uf);
out.tv_sec = absx.l_i;
if (neg) {
out.tv_sec = -out.tv_sec;
out.tv_nsec = -out.tv_nsec;
out = normalize_tspec(out);
}
return out;
}
static inline struct timespec
lfp_uintv_to_tspec(
l_fp x
)
{
struct timespec out;
out.tv_nsec = FTOTVN(x.l_uf);
out.tv_sec = x.l_ui;
return out;
}
extern struct timespec lfp_intv_to_tspec(l_fp x);
extern struct timespec lfp_uintv_to_tspec(l_fp x);
/*
* absolute (timestamp) conversion. Input is time in NTP epoch, output
* is in UN*X epoch. The NTP time stamp will be expanded around the
* pivot time *p or the current time, if p is NULL.
*/
static inline struct timespec
lfp_stamp_to_tspec(
l_fp x,
const time_t * p
)
{
struct timespec out;
vint64 sec;
sec = ntpcal_ntp_to_time(x.l_ui, p);
out.tv_nsec = FTOTVN(x.l_uf);
/* copying a vint64 to a time_t needs some care... */
#if SIZEOF_TIME_T <= 4
out.tv_sec = (time_t)sec.d_s.lo;
#elif defined(HAVE_INT64)
out.tv_sec = (time_t)sec.q_s;
#else
out.tv_sec = ((time_t)sec.d_s.hi << 32) | sec.d_s.lo;
#endif
return out;
}
extern struct timespec lfp_stamp_to_tspec(l_fp x, const time_t *pivot);
#endif /* TIMESPECOPS_H */
+42
View File
@@ -0,0 +1,42 @@
/*
* timexsup.h - 'struct timex' support functions
*
* Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project.
* The contents of 'html/copyright.html' apply.
*/
#ifndef TIMEXSUP_H
#define TIMEXSUP_H
/* convert a 'long' time value (in usec or nsec) into seconds, expressed
* as a 'double'. If 'STA_NANO' is not defined, this will always convert
* from usec. ('STA_NANO' is Linux specific at the time of this
* writing.)
*
* If 'STA_NANO' is defined, it will be checked in 'status' to decide
* which time base (usec or nsec) applies for this conversion.
*/
extern double dbl_from_var_long(long lval, int status);
/* convert a 'long' time value in usec into seconds, expressed as
* 'double'. This function is there for pure symmetry right now -- it
* just casts and scales without any additional bells and whistles.
*/
extern double dbl_from_usec_long(long lval);
/* If MOD_NANO is defined, set the MOD_NANO bit in '*modes' and
* calculate the time stamp in nsec; otherwise, calculate the result in
* usec.
*
* Applies proper bounds checks and saturation on LONG_MAX/LONG_MIN to
* avoid undefined behaviour.
*/
extern long var_long_from_dbl(double dval, unsigned int *modes);
/* convert a 'double' time value (in seconds) into usec with proper
* bounds check and range clamp.
*/
extern long usec_long_from_dbl(double dval);
#endif
/* -*- that's all folks -*- */
+3
View File
@@ -81,6 +81,7 @@ libntp_a_SRCS = \
msyslog.c \
netof.c \
ntp_calendar.c \
ntp_calgps.c \
ntp_crypto_rnd.c \
ntp_intres.c \
ntp_libopts.c \
@@ -104,8 +105,10 @@ libntp_a_SRCS = \
strdup.c \
strl_obsd.c \
syssignal.c \
timespecops.c \
timetoa.c \
timevalops.c \
timexsup.c \
uglydate.c \
vint64ops.c \
work_fork.c \
+28 -19
View File
@@ -154,13 +154,14 @@ am__libntp_a_SOURCES_DIST = systime.c a_md5encrypt.c adjtime.c \
hextoint.c hextolfp.c humandate.c icom.c iosignal.c \
is_ip_address.c lib_strbuf.c libssl_compat.c machines.c \
mktime.c modetoa.c mstolfp.c msyslog.c netof.c ntp_calendar.c \
ntp_crypto_rnd.c ntp_intres.c ntp_libopts.c ntp_lineedit.c \
ntp_random.c ntp_rfc2553.c ntp_worker.c numtoa.c numtohost.c \
octtoint.c prettydate.c refidsmear.c recvbuff.c refnumtoa.c \
snprintf.c socket.c socktoa.c socktohost.c ssl_init.c \
statestr.c strdup.c strl_obsd.c syssignal.c timetoa.c \
timevalops.c uglydate.c vint64ops.c work_fork.c work_thread.c \
xsbprintf.c ymd2yd.c $(srcdir)/../lib/isc/assertions.c \
ntp_calgps.c ntp_crypto_rnd.c ntp_intres.c ntp_libopts.c \
ntp_lineedit.c ntp_random.c ntp_rfc2553.c ntp_worker.c \
numtoa.c numtohost.c octtoint.c prettydate.c refidsmear.c \
recvbuff.c refnumtoa.c snprintf.c socket.c socktoa.c \
socktohost.c ssl_init.c statestr.c strdup.c strl_obsd.c \
syssignal.c timespecops.c timetoa.c timevalops.c timexsup.c \
uglydate.c vint64ops.c work_fork.c work_thread.c xsbprintf.c \
ymd2yd.c $(srcdir)/../lib/isc/assertions.c \
$(srcdir)/../lib/isc/buffer.c \
$(srcdir)/../lib/isc/backtrace-emptytbl.c \
$(srcdir)/../lib/isc/backtrace.c \
@@ -213,7 +214,7 @@ am__objects_4 = a_md5encrypt.$(OBJEXT) adjtime.$(OBJEXT) \
is_ip_address.$(OBJEXT) lib_strbuf.$(OBJEXT) \
libssl_compat.$(OBJEXT) machines.$(OBJEXT) mktime.$(OBJEXT) \
modetoa.$(OBJEXT) mstolfp.$(OBJEXT) msyslog.$(OBJEXT) \
netof.$(OBJEXT) ntp_calendar.$(OBJEXT) \
netof.$(OBJEXT) ntp_calendar.$(OBJEXT) ntp_calgps.$(OBJEXT) \
ntp_crypto_rnd.$(OBJEXT) ntp_intres.$(OBJEXT) \
ntp_libopts.$(OBJEXT) ntp_lineedit.$(OBJEXT) \
ntp_random.$(OBJEXT) ntp_rfc2553.$(OBJEXT) \
@@ -222,10 +223,11 @@ am__objects_4 = a_md5encrypt.$(OBJEXT) adjtime.$(OBJEXT) \
recvbuff.$(OBJEXT) refnumtoa.$(OBJEXT) snprintf.$(OBJEXT) \
socket.$(OBJEXT) socktoa.$(OBJEXT) socktohost.$(OBJEXT) \
ssl_init.$(OBJEXT) statestr.$(OBJEXT) strdup.$(OBJEXT) \
strl_obsd.$(OBJEXT) syssignal.$(OBJEXT) timetoa.$(OBJEXT) \
timevalops.$(OBJEXT) uglydate.$(OBJEXT) vint64ops.$(OBJEXT) \
work_fork.$(OBJEXT) work_thread.$(OBJEXT) xsbprintf.$(OBJEXT) \
ymd2yd.$(OBJEXT) $(am__objects_3) $(am__objects_1)
strl_obsd.$(OBJEXT) syssignal.$(OBJEXT) timespecops.$(OBJEXT) \
timetoa.$(OBJEXT) timevalops.$(OBJEXT) timexsup.$(OBJEXT) \
uglydate.$(OBJEXT) vint64ops.$(OBJEXT) work_fork.$(OBJEXT) \
work_thread.$(OBJEXT) xsbprintf.$(OBJEXT) ymd2yd.$(OBJEXT) \
$(am__objects_3) $(am__objects_1)
am_libntp_a_OBJECTS = systime.$(OBJEXT) $(am__objects_4)
libntp_a_OBJECTS = $(am_libntp_a_OBJECTS)
libntpsim_a_AR = $(AR) $(ARFLAGS)
@@ -238,13 +240,14 @@ am__libntpsim_a_SOURCES_DIST = systime_s.c a_md5encrypt.c adjtime.c \
hextoint.c hextolfp.c humandate.c icom.c iosignal.c \
is_ip_address.c lib_strbuf.c libssl_compat.c machines.c \
mktime.c modetoa.c mstolfp.c msyslog.c netof.c ntp_calendar.c \
ntp_crypto_rnd.c ntp_intres.c ntp_libopts.c ntp_lineedit.c \
ntp_random.c ntp_rfc2553.c ntp_worker.c numtoa.c numtohost.c \
octtoint.c prettydate.c refidsmear.c recvbuff.c refnumtoa.c \
snprintf.c socket.c socktoa.c socktohost.c ssl_init.c \
statestr.c strdup.c strl_obsd.c syssignal.c timetoa.c \
timevalops.c uglydate.c vint64ops.c work_fork.c work_thread.c \
xsbprintf.c ymd2yd.c $(srcdir)/../lib/isc/assertions.c \
ntp_calgps.c ntp_crypto_rnd.c ntp_intres.c ntp_libopts.c \
ntp_lineedit.c ntp_random.c ntp_rfc2553.c ntp_worker.c \
numtoa.c numtohost.c octtoint.c prettydate.c refidsmear.c \
recvbuff.c refnumtoa.c snprintf.c socket.c socktoa.c \
socktohost.c ssl_init.c statestr.c strdup.c strl_obsd.c \
syssignal.c timespecops.c timetoa.c timevalops.c timexsup.c \
uglydate.c vint64ops.c work_fork.c work_thread.c xsbprintf.c \
ymd2yd.c $(srcdir)/../lib/isc/assertions.c \
$(srcdir)/../lib/isc/buffer.c \
$(srcdir)/../lib/isc/backtrace-emptytbl.c \
$(srcdir)/../lib/isc/backtrace.c \
@@ -675,6 +678,7 @@ libntp_a_SRCS = \
msyslog.c \
netof.c \
ntp_calendar.c \
ntp_calgps.c \
ntp_crypto_rnd.c \
ntp_intres.c \
ntp_libopts.c \
@@ -698,8 +702,10 @@ libntp_a_SRCS = \
strdup.c \
strl_obsd.c \
syssignal.c \
timespecops.c \
timetoa.c \
timevalops.c \
timexsup.c \
uglydate.c \
vint64ops.c \
work_fork.c \
@@ -834,6 +840,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netof.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netscope.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_calendar.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_calgps.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_crypto_rnd.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_intres.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_libopts.Po@am__quote@
@@ -870,8 +877,10 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/task.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thread.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timespecops.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timetoa.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timevalops.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timexsup.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsmemcmp.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uglydate.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vint64ops.Po@am__quote@
+57 -25
View File
@@ -15,6 +15,19 @@
#include "ntp_stdlib.h"
#include "ntp_assert.h"
#define PORTSTR(x) _PORTSTR(x)
#define _PORTSTR(x) #x
static int
isnumstr(
const char *s
)
{
while (*s >= '0' && *s <= '9')
++s;
return !*s;
}
/*
* decodenetnum convert text IP address and port to sockaddr_u
*
@@ -26,22 +39,25 @@ decodenetnum(
sockaddr_u *netnum
)
{
static const char * const servicename = "ntp";
static const char * const serviceport = PORTSTR(NTP_PORT);
struct addrinfo hints, *ai = NULL;
int err;
u_short port;
const char *cp;
const char *host_str;
const char *port_str;
char *pp;
char *np;
char name[80];
char nbuf[80];
REQUIRE(num != NULL);
if (strlen(num) >= sizeof(name)) {
return 0;
if (strlen(num) >= sizeof(nbuf)) {
printf("length error\n");
return FALSE;
}
port_str = NULL;
port_str = servicename;
if ('[' != num[0]) {
/*
* to distinguish IPv6 embedded colons from a port
@@ -50,37 +66,53 @@ decodenetnum(
*/
pp = strchr(num, ':');
if (NULL == pp)
cp = num; /* no colons */
host_str = num; /* no colons */
else if (NULL != strchr(pp + 1, ':'))
cp = num; /* two or more colons */
host_str = num; /* two or more colons */
else { /* one colon */
strlcpy(name, num, sizeof(name));
cp = name;
pp = strchr(cp, ':');
strlcpy(nbuf, num, sizeof(nbuf));
host_str = nbuf;
pp = strchr(nbuf, ':');
*pp = '\0';
port_str = pp + 1;
}
} else {
cp = num + 1;
np = name;
while (*cp && ']' != *cp)
*np++ = *cp++;
host_str = np = nbuf;
while (*++num && ']' != *num)
*np++ = *num;
*np = 0;
if (']' == cp[0] && ':' == cp[1] && '\0' != cp[2])
port_str = &cp[2];
cp = name;
if (']' == num[0] && ':' == num[1] && '\0' != num[2])
port_str = &num[2];
}
if ( ! *host_str)
return FALSE;
if ( ! *port_str)
port_str = servicename;
ZERO(hints);
hints.ai_flags = Z_AI_NUMERICHOST;
err = getaddrinfo(cp, "ntp", &hints, &ai);
hints.ai_flags |= Z_AI_NUMERICHOST;
if (isnumstr(port_str))
hints.ai_flags |= Z_AI_NUMERICSERV;
err = getaddrinfo(host_str, port_str, &hints, &ai);
/* retry with default service name if the service lookup failed */
if (err == EAI_SERVICE && strcmp(port_str, servicename)) {
hints.ai_flags &= ~Z_AI_NUMERICSERV;
port_str = servicename;
err = getaddrinfo(host_str, port_str, &hints, &ai);
}
/* retry another time with default service port if the service lookup failed */
if (err == EAI_SERVICE && strcmp(port_str, serviceport)) {
hints.ai_flags |= Z_AI_NUMERICSERV;
port_str = serviceport;
err = getaddrinfo(host_str, port_str, &hints, &ai);
}
if (err != 0)
return 0;
return FALSE;
INSIST(ai->ai_addrlen <= sizeof(*netnum));
ZERO(*netnum);
memcpy(netnum, ai->ai_addr, ai->ai_addrlen);
freeaddrinfo(ai);
if (NULL == port_str || 1 != sscanf(port_str, "%hu", &port))
port = NTP_PORT;
SET_PORT(netnum, port);
return 1;
return TRUE;
}
+5 -5
View File
@@ -12,7 +12,7 @@
char *
dofptoa(
u_fp fpv,
int neg,
char sign,
short ndec,
int msec
)
@@ -106,8 +106,8 @@ dofptoa(
* Copy it into the buffer, asciizing as we go.
*/
bp = buf;
if (neg)
*bp++ = '-';
if (sign)
*bp++ = sign;
while (cp < cpend) {
if (cp == cpdec)
@@ -135,7 +135,7 @@ fptoa(
plusfp = (u_fp)fpv;
}
return dofptoa(plusfp, neg, ndec, FALSE);
return dofptoa(plusfp, (neg?'-':0), ndec, FALSE);
}
@@ -155,5 +155,5 @@ fptoms(
plusfp = (u_fp)fpv;
}
return dofptoa(plusfp, neg, ndec, TRUE);
return dofptoa(plusfp, (neg?'-':0), ndec, TRUE);
}
+5 -5
View File
@@ -13,7 +13,7 @@ char *
dolfptoa(
u_int32 fpi,
u_int32 fpv,
int neg,
char sign,
short ndec,
int msec
)
@@ -120,8 +120,8 @@ dolfptoa(
cp = cpdec - 1;
bp = buf;
if (neg)
*bp++ = '-';
if (sign)
*bp++ = sign;
while (cp < cpend) {
if (cp == cpdec)
*bp++ = '.';
@@ -150,7 +150,7 @@ mfptoa(
M_NEG(fpi, fpf);
}
return dolfptoa(fpi, fpf, isneg, ndec, FALSE);
return dolfptoa(fpi, fpf, (isneg?'-':'+'), ndec, FALSE);
}
@@ -168,7 +168,7 @@ mfptoms(
M_NEG(fpi, fpf);
}
return dolfptoa(fpi, fpf, isneg, ndec, TRUE);
return dolfptoa(fpi, fpf, (isneg?'-':'+'), ndec, TRUE);
}
+3 -4
View File
@@ -22,7 +22,7 @@ mstolfp(
/*
* We understand numbers of the form:
*
* [spaces][-][digits][.][digits][spaces|\n|\0]
* [spaces][-|+][digits][.][digits][spaces|\n|\0]
*
* This is one enormous hack. Since I didn't feel like
* rewriting the decoding routine for milliseconds, what
@@ -35,9 +35,8 @@ mstolfp(
while (isspace((unsigned char)*cp))
cp++;
if (*cp == '-') {
*bp++ = '-';
cp++;
if (*cp == '-' || *cp == '+') {
*bp++ = *cp++;
}
if (*cp != '.' && !isdigit((unsigned char)*cp))
+38
View File
@@ -582,3 +582,41 @@ setup_logfile(
msyslog(LOG_ERR, "Cannot reopen log file %s, %m",
syslog_fname);
}
/* Helper for unit tests, where stdout + stderr are piped to the same
* stream. This works moderately reliable only if both streams are
* unbuffered or line buffered. Unfortunately stdout can be fully
* buffered on pipes or files...
*/
int
change_iobufs(
int how
)
{
int retv = 0;
# ifdef HAVE_SETVBUF
int mode;
switch (how) {
case 0 : mode = _IONBF; break; /* no buffering */
case 1 : mode = _IOLBF; break; /* line buffering */
case 2 : mode = _IOFBF; break; /* full buffering */
default: mode = _IOLBF; break; /* line buffering */
}
retv = 1;
if (setvbuf(stdout, NULL, mode, BUFSIZ) != 0)
retv = -1;
if (setvbuf(stderr, NULL, mode, BUFSIZ) != 0)
retv = -1;
# else
UNUSED_ARG(how);
# endif
return retv;
}
File diff suppressed because it is too large. Load diff
+634
View File
@@ -0,0 +1,634 @@
/*
* ntp_calgps.c - calendar for GPS/GNSS based clocks
*
* Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project.
* The contents of 'html/copyright.html' apply.
*
* --------------------------------------------------------------------
*
* This module implements stuff often used with GPS/GNSS receivers
*/
#include <config.h>
#include <sys/types.h>
#include "ntp_types.h"
#include "ntp_calendar.h"
#include "ntp_calgps.h"
#include "ntp_stdlib.h"
#include "ntp_unixtime.h"
#include "ntp_fp.h"
#include "ntpd.h"
#include "vint64ops.h"
/* ====================================================================
* misc. helpers -- might go elsewhere sometime?
* ====================================================================
*/
l_fp
ntpfp_with_fudge(
l_fp lfp,
double ofs
)
{
l_fp fpo;
/* calculate 'lfp - ofs' as '(l_fp)(-ofs) + lfp': negating a
* double is cheap, as it only flips one bit...
*/
ofs = -ofs;
DTOLFP(ofs, &fpo);
L_ADD(&fpo, &lfp);
return fpo;
}
/* ====================================================================
* GPS calendar functions
* ====================================================================
*/
/* --------------------------------------------------------------------
* normalization functions for day/time and week/time representations.
* Since we only use moderate offsets (leap second corrections and
* alike) it does not really pay off to do a floor-corrected division
* here. We use compare/decrement/increment loops instead.
* --------------------------------------------------------------------
*/
static void
_norm_ntp_datum(
TNtpDatum * datum
)
{
static const int32_t limit = SECSPERDAY;
if (datum->secs >= limit) {
do
++datum->days;
while ((datum->secs -= limit) >= limit);
} else if (datum->secs < 0) {
do
--datum->days;
while ((datum->secs += limit) < 0);
}
}
static void
_norm_gps_datum(
TGpsDatum * datum
)
{
static const int32_t limit = 7 * SECSPERDAY;
if (datum->wsecs >= limit) {
do
++datum->weeks;
while ((datum->wsecs -= limit) >= limit);
} else if (datum->wsecs < 0) {
do
--datum->weeks;
while ((datum->wsecs += limit) < 0);
}
}
/* --------------------------------------------------------------------
* Add an offset to a day/time and week/time representation.
*
* !!Attention!! the offset should be small, compared to the time period
* (either a day or a week).
* --------------------------------------------------------------------
*/
void
gpsntp_add_offset(
TNtpDatum * datum,
l_fp offset
)
{
/* fraction can be added easily */
datum->frac += offset.l_uf;
datum->secs += (datum->frac < offset.l_uf);
/* avoid integer overflow on the seconds */
if (offset.l_ui >= INT32_MAX)
datum->secs -= (int32_t)~offset.l_ui + 1;
else
datum->secs += (int32_t)offset.l_ui;
_norm_ntp_datum(datum);
}
void
gpscal_add_offset(
TGpsDatum * datum,
l_fp offset
)
{
/* fraction can be added easily */
datum->frac += offset.l_uf;
datum->wsecs += (datum->frac < offset.l_uf);
/* avoid integer overflow on the seconds */
if (offset.l_ui >= INT32_MAX)
datum->wsecs -= (int32_t)~offset.l_ui + 1;
else
datum->wsecs += (int32_t)offset.l_ui;
_norm_gps_datum(datum);
}
/* -------------------------------------------------------------------
* API functions civil calendar and NTP datum
* -------------------------------------------------------------------
*/
static TNtpDatum
_gpsntp_fix_gps_era(
TcNtpDatum * in
)
{
/* force result in basedate era
*
* When calculating this directly in days, we have to execute a
* real modulus calculation, since we're obviously not doing a
* modulus by a power of 2. Executing this as true floor mod
* needs some care and is done under explicit usage of one's
* complement and masking to get mostly branchless code.
*/
static uint32_t const clen = 7*1024;
uint32_t base, days, sign;
TNtpDatum out = *in;
/* Get base in NTP day scale. No overflows here. */
base = (basedate_get_gpsweek() + GPSNTP_WSHIFT) * 7
- GPSNTP_DSHIFT;
days = out.days;
sign = (uint32_t)-(days < base);
days = sign ^ (days - base);
days %= clen;
days = base + (sign & clen) + (sign ^ days);
out.days = days;
return out;
}
TNtpDatum
gpsntp_fix_gps_era(
TcNtpDatum * in
)
{
TNtpDatum out = *in;
_norm_ntp_datum(&out);
return _gpsntp_fix_gps_era(&out);
}
/* ----------------------------------------------------------------- */
static TNtpDatum
_gpsntp_from_daytime(
TcCivilDate * jd,
l_fp fofs,
TcNtpDatum * pivot,
int warp
)
{
static const int32_t shift = SECSPERDAY / 2;
TNtpDatum retv;
/* set result based on pivot -- ops order is important here */
ZERO(retv);
retv.secs = ntpcal_date_to_daysec(jd);
gpsntp_add_offset(&retv, fofs); /* result is normalized */
retv.days = pivot->days;
/* Manual periodic extension without division: */
if (pivot->secs < shift) {
int32_t lim = pivot->secs + shift;
retv.days -= (retv.secs > lim ||
(retv.secs == lim && retv.frac >= pivot->frac));
} else {
int32_t lim = pivot->secs - shift;
retv.days += (retv.secs < lim ||
(retv.secs == lim && retv.frac < pivot->frac));
}
return warp ? _gpsntp_fix_gps_era(&retv) : retv;
}
/* -----------------------------------------------------------------
* Given the time-of-day part of a civil datum and an additional
* (fractional) offset, calculate a full time stamp around a given pivot
* time so that the difference between the pivot and the resulting time
* stamp is less or equal to 12 hours absolute.
*/
TNtpDatum
gpsntp_from_daytime2_ex(
TcCivilDate * jd,
l_fp fofs,
TcNtpDatum * pivot,
int/*BOOL*/ warp
)
{
TNtpDatum dpiv = *pivot;
_norm_ntp_datum(&dpiv);
return _gpsntp_from_daytime(jd, fofs, &dpiv, warp);
}
/* -----------------------------------------------------------------
* This works similar to 'gpsntp_from_daytime1()' and actually even uses
* it, but the pivot is calculated from the pivot given as 'l_fp' in NTP
* time scale. This is in turn expanded around the current system time,
* and the resulting absolute pivot is then used to calculate the full
* NTP time stamp.
*/
TNtpDatum
gpsntp_from_daytime1_ex(
TcCivilDate * jd,
l_fp fofs,
l_fp pivot,
int/*BOOL*/ warp
)
{
vint64 pvi64;
TNtpDatum dpiv;
ntpcal_split split;
pvi64 = ntpcal_ntp_to_ntp(pivot.l_ui, NULL);
split = ntpcal_daysplit(&pvi64);
dpiv.days = split.hi;
dpiv.secs = split.lo;
dpiv.frac = pivot.l_uf;
return _gpsntp_from_daytime(jd, fofs, &dpiv, warp);
}
/* -----------------------------------------------------------------
* Given a calendar date, zap it into a GPS time format and then convert
* that one into the NTP time scale.
*/
TNtpDatum
gpsntp_from_calendar_ex(
TcCivilDate * jd,
l_fp fofs,
int/*BOOL*/ warp
)
{
TGpsDatum gps;
gps = gpscal_from_calendar_ex(jd, fofs, warp);
return gpsntp_from_gpscal_ex(&gps, FALSE);
}
/* -----------------------------------------------------------------
* create a civil calendar datum from a NTP date representation
*/
void
gpsntp_to_calendar(
TCivilDate * cd,
TcNtpDatum * nd
)
{
memset(cd, 0, sizeof(*cd));
ntpcal_rd_to_date(
cd,
nd->days + DAY_NTP_STARTS + ntpcal_daysec_to_date(
cd, nd->secs));
}
/* -----------------------------------------------------------------
* get day/tod representation from week/tow datum
*/
TNtpDatum
gpsntp_from_gpscal_ex(
TcGpsDatum * gd,
int/*BOOL*/ warp
)
{
TNtpDatum retv;
vint64 ts64;
ntpcal_split split;
TGpsDatum date = *gd;
if (warp) {
uint32_t base = basedate_get_gpsweek() + GPSNTP_WSHIFT;
_norm_gps_datum(&date);
date.weeks = ((date.weeks - base) & 1023u) + base;
}
ts64 = ntpcal_weekjoin(date.weeks, date.wsecs);
ts64 = subv64u32(&ts64, (GPSNTP_DSHIFT * SECSPERDAY));
split = ntpcal_daysplit(&ts64);
retv.frac = gd->frac;
retv.secs = split.lo;
retv.days = split.hi;
return retv;
}
/* -----------------------------------------------------------------
* get LFP from ntp datum
*/
l_fp
ntpfp_from_ntpdatum(
TcNtpDatum * nd
)
{
l_fp retv;
retv.l_uf = nd->frac;
retv.l_ui = nd->days * (uint32_t)SECSPERDAY
+ nd->secs;
return retv;
}
/* -------------------------------------------------------------------
* API functions GPS week calendar
*
* Here we use a calendar base of 1899-12-31, so the NTP epoch has
* { 0, 86400.0 } in this representation.
* -------------------------------------------------------------------
*/
static TGpsDatum
_gpscal_fix_gps_era(
TcGpsDatum * in
)
{
/* force result in basedate era
*
* This is based on calculating the modulus to a power of two,
* so signed integer overflow does not affect the result. Which
* in turn makes for a very compact calculation...
*/
uint32_t base, week;
TGpsDatum out = *in;
week = out.weeks;
base = basedate_get_gpsweek() + GPSNTP_WSHIFT;
week = base + ((week - base) & (GPSWEEKS - 1));
out.weeks = week;
return out;
}
TGpsDatum
gpscal_fix_gps_era(
TcGpsDatum * in
)
{
TGpsDatum out = *in;
_norm_gps_datum(&out);
return _gpscal_fix_gps_era(&out);
}
/* -----------------------------------------------------------------
* Given a calendar date, zap it into a GPS time format and the do a
* proper era mapping in the GPS time scale, based on the GPS base date,
* if so requested.
*
* This function also augments the century if just a 2-digit year
* (0..99) is provided on input.
*
* This is a fail-safe against GPS receivers with an unknown starting
* point for their internal calendar calculation and therefore
* unpredictable (but reproducible!) rollover behavior. While there
* *are* receivers that create a full date in the proper way, many
* others just don't. The overall damage is minimized by simply not
* trusting the era mapping of the receiver and doing the era assignment
* with a configurable base date *inside* ntpd.
*/
TGpsDatum
gpscal_from_calendar_ex(
TcCivilDate * jd,
l_fp fofs,
int/*BOOL*/ warp
)
{
/* (-DAY_GPS_STARTS) (mod 7*1024) -- complement of cycle shift */
static const uint32_t s_compl_shift =
(7 * 1024) - DAY_GPS_STARTS % (7 * 1024);
TGpsDatum gps;
TCivilDate cal;
int32_t days, week;
/* if needed, convert from 2-digit year to full year
* !!NOTE!! works only between 1980 and 2079!
*/
cal = *jd;
if (cal.year < 80)
cal.year += 2000;
else if (cal.year < 100)
cal.year += 1900;
/* get RDN from date, possibly adjusting the century */
again: if (cal.month && cal.monthday) { /* use Y/M/D civil date */
days = ntpcal_date_to_rd(&cal);
} else { /* using Y/DoY date */
days = ntpcal_year_to_ystart(cal.year)
+ (int32_t)cal.yearday
- 1; /* both RDN and yearday start with '1'. */
}
/* Rebase to days after the GPS epoch. 'days' is positive here,
* but it might be less than the GPS epoch start. Depending on
* the input, we have to do different things to get the desired
* result. (Since we want to remap the era anyway, we only have
* to retain congruential identities....)
*/
if (days >= DAY_GPS_STARTS) {
/* simply shift to days since GPS epoch */
days -= DAY_GPS_STARTS;
} else if (jd->year < 100) {
/* Two-digit year on input: add another century and
* retry. This can happen only if the century expansion
* yielded a date between 1980-01-01 and 1980-01-05,
* both inclusive. We have at most one retry here.
*/
cal.year += 100;
goto again;
} else {
/* A very bad date before the GPS epoch. There's not
* much we can do, except to add the complement of
* DAY_GPS_STARTS % (7 * 1024) here, that is, use a
* congruential identity: Add the complement instead of
* subtracting the value gives a value with the same
* modulus. But of course, now we MUST to go through a
* cycle fix... because the date was obviously wrong!
*/
warp = TRUE;
days += s_compl_shift;
}
/* Splitting to weeks is simple now: */
week = days / 7;
days -= week * 7;
/* re-base on start of NTP with weeks mapped to 1024 weeks
* starting with the GPS base day set in the calendar.
*/
gps.weeks = week + GPSNTP_WSHIFT;
gps.wsecs = days * SECSPERDAY + ntpcal_date_to_daysec(&cal);
gps.frac = 0;
gpscal_add_offset(&gps, fofs);
return warp ? _gpscal_fix_gps_era(&gps) : gps;
}
/* -----------------------------------------------------------------
* get civil date from week/tow representation
*/
void
gpscal_to_calendar(
TCivilDate * cd,
TcGpsDatum * wd
)
{
TNtpDatum nd;
memset(cd, 0, sizeof(*cd));
nd = gpsntp_from_gpscal_ex(wd, FALSE);
gpsntp_to_calendar(cd, &nd);
}
/* -----------------------------------------------------------------
* Given the week and seconds in week, as well as the fraction/offset
* (which should/could include the leap seconds offset), unfold the
* weeks (which are assumed to have just 10 bits) into expanded weeks
* based on the GPS base date derived from the build date (default) or
* set by the configuration.
*
* !NOTE! This function takes RAW GPS weeks, aligned to the GPS start
* (1980-01-06) on input. The output weeks will be aligned to NTPD's
* week calendar start (1899-12-31)!
*/
TGpsDatum
gpscal_from_gpsweek(
uint16_t week,
int32_t secs,
l_fp fofs
)
{
TGpsDatum retv;
retv.frac = 0;
retv.wsecs = secs;
retv.weeks = week + GPSNTP_WSHIFT;
gpscal_add_offset(&retv, fofs);
return _gpscal_fix_gps_era(&retv);
}
/* -----------------------------------------------------------------
* internal work horse for time-of-week expansion
*/
static TGpsDatum
_gpscal_from_weektime(
int32_t wsecs,
l_fp fofs,
TcGpsDatum * pivot
)
{
static const int32_t shift = SECSPERWEEK / 2;
TGpsDatum retv;
/* set result based on pivot -- ops order is important here */
ZERO(retv);
retv.wsecs = wsecs;
gpscal_add_offset(&retv, fofs); /* result is normalized */
retv.weeks = pivot->weeks;
/* Manual periodic extension without division: */
if (pivot->wsecs < shift) {
int32_t lim = pivot->wsecs + shift;
retv.weeks -= (retv.wsecs > lim ||
(retv.wsecs == lim && retv.frac >= pivot->frac));
} else {
int32_t lim = pivot->wsecs - shift;
retv.weeks += (retv.wsecs < lim ||
(retv.wsecs == lim && retv.frac < pivot->frac));
}
return _gpscal_fix_gps_era(&retv);
}
/* -----------------------------------------------------------------
* expand a time-of-week around a pivot given as week datum
*/
TGpsDatum
gpscal_from_weektime2(
int32_t wsecs,
l_fp fofs,
TcGpsDatum * pivot
)
{
TGpsDatum wpiv = * pivot;
_norm_gps_datum(&wpiv);
return _gpscal_from_weektime(wsecs, fofs, &wpiv);
}
/* -----------------------------------------------------------------
* epand a time-of-week around an pivot given as LFP, which in turn
* is expanded around the current system time and then converted
* into a week datum.
*/
TGpsDatum
gpscal_from_weektime1(
int32_t wsecs,
l_fp fofs,
l_fp pivot
)
{
vint64 pvi64;
TGpsDatum wpiv;
ntpcal_split split;
/* get 64-bit pivot in NTP epoch */
pvi64 = ntpcal_ntp_to_ntp(pivot.l_ui, NULL);
/* convert to weeks since 1899-12-31 and seconds in week */
pvi64 = addv64u32(&pvi64, (GPSNTP_DSHIFT * SECSPERDAY));
split = ntpcal_weeksplit(&pvi64);
wpiv.weeks = split.hi;
wpiv.wsecs = split.lo;
wpiv.frac = pivot.l_uf;
return _gpscal_from_weektime(wsecs, fofs, &wpiv);
}
/* -----------------------------------------------------------------
* get week/tow representation from day/tod datum
*/
TGpsDatum
gpscal_from_gpsntp(
TcNtpDatum * gd
)
{
TGpsDatum retv;
vint64 ts64;
ntpcal_split split;
ts64 = ntpcal_dayjoin(gd->days, gd->secs);
ts64 = addv64u32(&ts64, (GPSNTP_DSHIFT * SECSPERDAY));
split = ntpcal_weeksplit(&ts64);
retv.frac = gd->frac;
retv.wsecs = split.lo;
retv.weeks = split.hi;
return retv;
}
/* -----------------------------------------------------------------
* convert week/tow to LFP stamp
*/
l_fp
ntpfp_from_gpsdatum(
TcGpsDatum * gd
)
{
l_fp retv;
retv.l_uf = gd->frac;
retv.l_ui = gd->weeks * (uint32_t)SECSPERWEEK
+ (uint32_t)gd->wsecs
- (uint32_t)SECSPERDAY * GPSNTP_DSHIFT;
return retv;
}
/* -*-EOF-*- */
-2
View File
@@ -226,7 +226,6 @@ get_full_recv_buffer(void)
LOCK();
#ifdef HAVE_SIGNALED_IO
/*
* make sure there are free buffers when we
* wander off to do lengthy packet processing with
@@ -241,7 +240,6 @@ get_full_recv_buffer(void)
*/
create_buffers(RECV_INC);
}
#endif
/*
* try to grab a full buffer
+12 -5
View File
@@ -181,16 +181,23 @@ static const struct codestring res_access_bits[] = {
{ RES_IGNORE, "ignore", 0 },
{ RES_DONTSERVE, "noserve", "serve" },
{ RES_DONTTRUST, "notrust", "trust" },
{ RES_NOQUERY, "noquery", "query" },
{ RES_NOMODIFY, "nomodify", 0 },
{ RES_VERSION, "version", 0 },
{ RES_NOPEER, "nopeer", "peer" },
{ RES_NOEPEER, "noepeer", "epeer" },
{ RES_LIMITED, "limited", 0 },
{ RES_NOQUERY, "noquery", "query" },
{ RES_NOMODIFY, "nomodify", 0 },
{ RES_NOTRAP, "notrap", "trap" },
{ RES_LPTRAP, "lptrap", 0 },
{ RES_LIMITED, "limited", 0 },
{ RES_VERSION, "version", 0 },
{ RES_KOD, "kod", 0 },
{ RES_MSSNTP, "mssntp", 0 },
{ RES_FLAKE, "flake", 0 },
{ RES_NOMRULIST, "nomrulist", 0 },
{ RES_SRVRSPFUZ, "serverresponse fuzz", 0 },
/* not used with getcode(), no terminating entry needed */
};
@@ -418,7 +425,7 @@ res_match_flags(
const char *
res_access_flags(
u_short af
u_int32 af
)
{
return decode_bitflags(af, " ", res_access_bits,
+11 -15
View File
@@ -619,12 +619,11 @@ clamp_systime(void)
{
#if SIZEOF_TIME_T > 4
struct timeval timetv, tvlast;
struct timeval tvbase, tvlast;
struct timespec timets;
uint32_t tdiff;
timetv.tv_sec = basedate_get_erabase();
tvbase.tv_sec = basedate_get_erabase();
tvbase.tv_usec = 0;
/* ---> time-critical path starts ---> */
@@ -636,28 +635,24 @@ clamp_systime(void)
tvlast.tv_usec -= 1000000;
tvlast.tv_sec += 1;
}
timetv.tv_usec = tvlast.tv_usec;
tdiff = (uint32_t)(tvlast.tv_sec & UINT32_MAX) -
(uint32_t)(timetv.tv_sec & UINT32_MAX);
timetv.tv_sec += tdiff;
if (timetv.tv_sec != tvlast.tv_sec) {
if (tvbase.tv_sec > tvlast.tv_sec) {
/* now set new system time */
if (ntp_set_tod(&timetv, NULL) != 0) {
if (ntp_set_tod(&tvbase, NULL) != 0) {
msyslog(LOG_ERR, "clamp-systime: %m");
return FALSE;
}
} else {
msyslog(LOG_INFO,
"clamp-systime: clock (%s) in allowed range",
tv_fmt_libbuf(&timetv));
tv_fmt_libbuf(&tvlast));
return FALSE;
}
/* <--- time-critical path ended with 'ntp_set_tod()' <--- */
sys_residual = 0;
lamport_violated = (timetv.tv_sec < tvlast.tv_sec);
lamport_violated = (tvbase.tv_sec < tvlast.tv_sec);
if (step_callback)
(*step_callback)();
@@ -668,15 +663,16 @@ clamp_systime(void)
_clear_adjtime();
# endif
update_uwtmp(timetv, tvlast);
update_uwtmp(tvbase, tvlast);
msyslog(LOG_WARNING,
"clamp-systime: clock stepped from %s to %s!",
tv_fmt_libbuf(&tvlast), tv_fmt_libbuf(&timetv));
tv_fmt_libbuf(&tvlast), tv_fmt_libbuf(&tvbase));
return TRUE;
#else
return 0;
return FALSE;
#endif
}
+233
View File
@@ -0,0 +1,233 @@
/*
* timespecops.c -- calculations on 'struct timespec' values
*
* Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project.
* The contents of 'html/copyright.html' apply.
*
*/
#include "config.h"
#include <sys/types.h>
#include <stdio.h>
#include <math.h>
#include "ntp.h"
#include "timetoa.h"
#include "timespecops.h"
/* nanoseconds per second */
#define NANOSECONDS 1000000000
/* conversion between l_fp fractions and nanoseconds */
#ifdef HAVE_U_INT64
# define FTOTVN(tsf) \
((int32) \
(((u_int64)(tsf) * NANOSECONDS + 0x80000000) >> 32))
# define TVNTOF(tvu) \
((u_int32) \
((((u_int64)(tvu) << 32) + NANOSECONDS / 2) / \
NANOSECONDS))
#else
# define NSECFRAC (FRAC / NANOSECONDS)
# define FTOTVN(tsf) \
((int32)((tsf) / NSECFRAC + 0.5))
# define TVNTOF(tvu) \
((u_int32)((tvu) * NSECFRAC + 0.5))
#endif
/* make sure nanoseconds are in nominal range */
struct timespec
normalize_tspec(
struct timespec x
)
{
#if SIZEOF_LONG > 4
long z;
/*
* tv_nsec is of type 'long', and on a 64-bit machine using only
* loops becomes prohibitive once the upper 32 bits get
* involved. On the other hand, division by constant should be
* fast enough; so we do a division of the nanoseconds in that
* case. The floor adjustment step follows with the standard
* normalisation loops. And labs() is intentionally not used
* here: it has implementation-defined behaviour when applied
* to LONG_MIN.
*/
if (x.tv_nsec < -3l * NANOSECONDS ||
x.tv_nsec > 3l * NANOSECONDS) {
z = x.tv_nsec / NANOSECONDS;
x.tv_nsec -= z * NANOSECONDS;
x.tv_sec += z;
}
#endif
/* since 10**9 is close to 2**32, we don't divide but do a
* normalisation in a loop; this takes 3 steps max, and should
* outperform a division even if the mul-by-inverse trick is
* employed. */
if (x.tv_nsec < 0)
do {
x.tv_nsec += NANOSECONDS;
x.tv_sec--;
} while (x.tv_nsec < 0);
else if (x.tv_nsec >= NANOSECONDS)
do {
x.tv_nsec -= NANOSECONDS;
x.tv_sec++;
} while (x.tv_nsec >= NANOSECONDS);
return x;
}
/* x = abs(a) */
struct timespec
abs_tspec(
struct timespec a
)
{
struct timespec c;
c = normalize_tspec(a);
if (c.tv_sec < 0) {
if (c.tv_nsec != 0) {
c.tv_sec = -c.tv_sec - 1;
c.tv_nsec = NANOSECONDS - c.tv_nsec;
} else {
c.tv_sec = -c.tv_sec;
}
}
return c;
}
/*
* compare previously-normalised a and b
* return 1 / 0 / -1 if a < / == / > b
*/
int
cmp_tspec(
struct timespec a,
struct timespec b
)
{
int r;
r = (a.tv_sec > b.tv_sec) - (a.tv_sec < b.tv_sec);
if (0 == r)
r = (a.tv_nsec > b.tv_nsec) -
(a.tv_nsec < b.tv_nsec);
return r;
}
/*
* test previously-normalised a
* return 1 / 0 / -1 if a < / == / > 0
*/
int
test_tspec(
struct timespec a
)
{
int r;
r = (a.tv_sec > 0) - (a.tv_sec < 0);
if (r == 0)
r = (a.tv_nsec > 0);
return r;
}
/*
* convert to l_fp type, relative and absolute
*/
/* convert from timespec duration to l_fp duration */
l_fp
tspec_intv_to_lfp(
struct timespec x
)
{
struct timespec v;
l_fp y;
v = normalize_tspec(x);
y.l_uf = TVNTOF(v.tv_nsec);
y.l_i = (int32)v.tv_sec;
return y;
}
/* convert from l_fp type, relative signed/unsigned and absolute */
struct timespec
lfp_intv_to_tspec(
l_fp x
)
{
struct timespec out;
l_fp absx;
int neg;
neg = L_ISNEG(&x);
absx = x;
if (neg) {
L_NEG(&absx);
}
out.tv_nsec = FTOTVN(absx.l_uf);
out.tv_sec = absx.l_i;
if (neg) {
out.tv_sec = -out.tv_sec;
out.tv_nsec = -out.tv_nsec;
out = normalize_tspec(out);
}
return out;
}
struct timespec
lfp_uintv_to_tspec(
l_fp x
)
{
struct timespec out;
out.tv_nsec = FTOTVN(x.l_uf);
out.tv_sec = x.l_ui;
return out;
}
/*
* absolute (timestamp) conversion. Input is time in NTP epoch, output
* is in UN*X epoch. The NTP time stamp will be expanded around the
* pivot time *p or the current time, if p is NULL.
*/
struct timespec
lfp_stamp_to_tspec(
l_fp x,
const time_t * p
)
{
struct timespec out;
vint64 sec;
sec = ntpcal_ntp_to_time(x.l_ui, p);
out.tv_nsec = FTOTVN(x.l_uf);
/* copying a vint64 to a time_t needs some care... */
#if SIZEOF_TIME_T <= 4
out.tv_sec = (time_t)sec.d_s.lo;
#elif defined(HAVE_INT64)
out.tv_sec = (time_t)sec.q_s;
#else
out.tv_sec = ((time_t)sec.d_s.hi << 32) | sec.d_s.lo;
#endif
return out;
}
/* -*-EOF-*- */
+83
View File
@@ -0,0 +1,83 @@
/*
* timexsup.c - 'struct timex' support functions
*
* Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project.
* The contents of 'html/copyright.html' apply.
*/
#include "config.h"
#include "timexsup.h"
#include <limits.h>
#include <math.h>
#ifdef HAVE_SYS_TIMEX_H
# include <sys/timex.h>
#endif
#if defined(MOD_NANO) != defined(STA_NANO)
# warning inconsistent definitions of MOD_NANO vs STA_NANO
#endif
static long
clamp_rounded(
double dval
)
{
/* round */
dval = floor(dval + 0.5);
/* clamp / saturate */
if (dval >= LONG_MAX)
return LONG_MAX;
if (dval <= LONG_MIN)
return LONG_MIN;
return (long)dval;
}
double
dbl_from_var_long(
long lval,
int status
)
{
#ifdef STA_NANO
if (status & STA_NANO)
return (double)lval * 1e-9;
#else
(void)status;
#endif
return (double)lval * 1e-6;
}
double
dbl_from_usec_long(
long lval
)
{
return (double)lval * 1e-6;
}
long
var_long_from_dbl(
double dval,
unsigned int * modes
)
{
#ifdef MOD_NANO
*modes |= MOD_NANO;
dval *= 1e+9;
#else
(void)modes;
dval *= 1e+6;
#endif
return clamp_rounded(dval);
}
long
usec_long_from_dbl(
double dval
)
{
return clamp_rounded(dval * 1e+6);
}
+3 -1
View File
@@ -164,9 +164,11 @@ parse: $(parsesolaris_OBJECTS) libparse_kernel.a ../libntp/libntp.a
parsesolaris.o: sys/systm.h
# [Bug3608] Solaris has inconsistent definitions of ffs() and fls(). Drop the
# ones from 'systm.h'.
sys/systm.h:
-mkdir sys
sed -e '/ffs(.*)/d' < /usr/include/sys/systm.h > sys/systm.h
sed -e '/f[fl]s(.*)/d' < /usr/include/sys/systm.h > sys/systm.h
## check-libparse is invoked by ntpd/Makefile.am
check-libparse: $(noinst_LIBRARIES)
+3 -1
View File
@@ -1000,9 +1000,11 @@ parse: $(parsesolaris_OBJECTS) libparse_kernel.a ../libntp/libntp.a
parsesolaris.o: sys/systm.h
# [Bug3608] Solaris has inconsistent definitions of ffs() and fls(). Drop the
# ones from 'systm.h'.
sys/systm.h:
-mkdir sys
sed -e '/ffs(.*)/d' < /usr/include/sys/systm.h > sys/systm.h
sed -e '/f[fl]s(.*)/d' < /usr/include/sys/systm.h > sys/systm.h
check-libparse: $(noinst_LIBRARIES)
@: do-nothing action to avoid default SCCS get
+55
View File
@@ -220,6 +220,58 @@ pcheck(
return psum;
}
static int/*BOOL*/
zeller_expand(
clocktime_t *clock_time,
unsigned int wd
)
{
unsigned int y = (unsigned int)clock_time->year;
unsigned int m = (unsigned int)clock_time->month - 1u;
unsigned int d = (unsigned int)clock_time->day - 1u;
unsigned int c;
/* Check basic constraints first. */
if ((y >= 100u) || (m >= 12u) || (d >= 31u) || (--wd >= 7u))
return FALSE;
/* Get weekday of date in 1st century by a variation on Zeller's
* congruence. All operands are non-negative, and the month
* formula is adjusted to use a divider of 32, so we can do a
* shift instead of a 'true' division:
*/
if ((m += 10u) >= 12u) /* shift base to 0000-03-01 */
m -= 12u;
else if (--y >= 100u)
y += 100;
d += y + (y >> 2) + 2u; /* year-related share */
d += (m * 83u + 16u) >> 5; /* month-related share */
/* The next step combines the exact division by modular inverse
* with the (mod 7) step in such way that no true division and
* only one multiplication is needed. The multiplier is
* M <- ceil((3*8)/7 * 2**29)
* and combines multiplication by invmod(5, 7) -> 3 and modulus
* by 7 transformation to (mod 8) in one step.
* Note that 252 == 0 (mod 7) and that 'd' is less than 185,
* so the number to invert and reduce is strictly positive. In
* the end, 'c' is number of centuries since start of a great
* cycle and must be in [0..3] or we had bad input.
*/
c = (((252u + wd - d) * 0x6db6db6eU) >> 29) & 7u;
if (c >= 4)
return FALSE;
/* undo calendar base shift now */
if ((m > 9u) && (++y >= 100u)) {
y -= 100u;
c = (c + 1u) & 3u;
}
/* combine year with centuries & map to [1970..2369] */
y += (c * 100u);
clock_time->year = (int)y + ((y < 370u) ? 2000 : 1600);
return TRUE;
}
static u_long
convert_rawdcf(
unsigned char *buffer,
@@ -288,6 +340,9 @@ convert_rawdcf(
clock_time->year = ext_bf(buffer, DCF_Y10, dcfprm->zerobits);
clock_time->year = TIMES10(clock_time->year) + ext_bf(buffer, DCF_Y1, dcfprm->zerobits);
if (!zeller_expand(clock_time, ext_bf(buffer, DCF_DW, dcfprm->zerobits)))
return CVT_FAIL|CVT_BADFMT;
switch (ext_bf(buffer, DCF_Z, dcfprm->zerobits))
{
case DCF_Z_MET:
+49 -7
View File
@@ -25,7 +25,7 @@ if SAVECONFIG_ENABLED
if NTP_CROSSCOMPILE
CHECK_SAVECONFIG=
else
CHECK_SAVECONFIG= check-saveconfig
CHECK_SAVECONFIG= check-saveconfig check-pslsaveconfig
endif
else !SAVECONFIG_ENABLED
CHECK_SAVECONFIG=
@@ -110,9 +110,20 @@ DISTCLEANFILES = \
$(NULL)
CLEANFILES = \
check-psl0 \
check-psl1 \
check-psl2 \
check-pslsaveconfig \
check-saveconfig \
compsave.conf \
compsave.conf+ \
k-g-u-submake \
psl0save.conf \
psl0save.conf+ \
psl1save.conf \
psl1save.conf+ \
psl2save.conf \
psl2save.conf+ \
$(EXTRA_PROGRAMS) \
$(NULL)
@@ -147,6 +158,9 @@ EXTRA_DIST = \
ntpd.html \
ntpd.texi \
ntpdbase-opts.def \
psl0.conf \
psl1.conf \
psl2.conf \
refclock_msfees.c \
$(B_S_DIST) \
$(NULL)
@@ -345,13 +359,13 @@ $(srcdir)/invoke-ntp.keys.menu: $(srcdir)/invoke-ntp.keys.texi
$(srcdir)/invoke-ntp.keys.texi: $(srcdir)/ntp.keys.def $(std_def_list)
$(run_ag) -Tagtexi-file.tpl -DLEVEL=section ntp.keys.def
$(srcdir)/ntp.conf.html: $(srcdir)/ntp.conf.texi $(top_srcdir)/sntp/include/version.texi
$(srcdir)/ntp.conf.html: $(srcdir)/ntp.conf.texi $(srcdir)/invoke-ntp.conf.texi $(top_srcdir)/sntp/include/version.texi
cd $(srcdir) && ( makeinfo --force --html --no-split -o ntp.conf.html ntp.conf.texi || true )
$(srcdir)/ntp.keys.html: $(srcdir)/ntp.keys.texi $(top_srcdir)/sntp/include/version.texi
$(srcdir)/ntp.keys.html: $(srcdir)/ntp.keys.texi $(srcdir)/invoke-ntp.keys.texi $(top_srcdir)/sntp/include/version.texi
cd $(srcdir) && ( makeinfo --force --html --no-split -o ntp.keys.html ntp.keys.texi || true )
$(srcdir)/ntpd.html: $(srcdir)/ntpd.texi $(top_srcdir)/sntp/include/version.texi
$(srcdir)/ntpd.html: $(srcdir)/ntpd.texi $(srcdir)/invoke-ntpd.texi $(top_srcdir)/sntp/include/version.texi
cd $(srcdir) && ( makeinfo --force --html --no-split -o ntpd.html ntpd.texi || true )
###
@@ -413,13 +427,41 @@ $(srcdir)/invoke-ntpd.texi: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def
$(PROGRAMS): $(LDADD)
compsave.conf: ntpd complete.conf
./ntpd --configfile complete.conf --saveconfigquit $@
check-saveconfig: complete.conf compsave.conf
-diff -u complete.conf compsave.conf
cmp complete.conf compsave.conf && echo stamp > $@
compsave.conf: ntpd complete.conf
./ntpd --configfile complete.conf --saveconfigquit $@+
grep -v '^#' $@+ > $@
check-pslsaveconfig: check-psl0 check-psl1 check-psl2
echo stamp > $@
check-psl0: psl0.conf psl0save.conf
-diff -u $< psl0save.conf
cmp $< psl0save.conf && echo stamp > $@
psl0save.conf: psl0.conf ntpd
./ntpd --configfile $< --saveconfigquit $@+
grep -v '^#' $@+ > $@
check-psl1: psl1.conf psl1save.conf
-diff -u $< psl1save.conf
cmp $< psl1save.conf && echo stamp > $@
psl1save.conf: psl1.conf ntpd
./ntpd --configfile $< --saveconfigquit $@+
grep -v '^#' $@+ > $@
check-psl2: psl2.conf psl2save.conf
-diff -u $< psl2save.conf
cmp $< psl2save.conf && echo stamp > $@
psl2save.conf: psl2.conf ntpd
./ntpd --configfile $< --saveconfigquit $@+
grep -v '^#' $@+ > $@
../libntp/libntpsim.a:
cd ../libntp && $(MAKE) $(AM_MAKEFLAGS) libntpsim.a
+43 -9
View File
@@ -615,7 +615,7 @@ AM_LDFLAGS = $(LDFLAGS_NTP) $(NTP_HARD_LDFLAGS)
# LDADD might need RESLIB and ADJLIB.
LDADD = version.o libntpd.a $(LIBPARSE)
AM_YFLAGS = -d -t -r all
@NTP_CROSSCOMPILE_FALSE@@SAVECONFIG_ENABLED_TRUE@CHECK_SAVECONFIG = check-saveconfig
@NTP_CROSSCOMPILE_FALSE@@SAVECONFIG_ENABLED_TRUE@CHECK_SAVECONFIG = check-saveconfig check-pslsaveconfig
@NTP_CROSSCOMPILE_TRUE@@SAVECONFIG_ENABLED_TRUE@CHECK_SAVECONFIG =
@SAVECONFIG_ENABLED_FALSE@CHECK_SAVECONFIG =
@VPATH_HACK_FALSE@VPHACK =
@@ -667,8 +667,11 @@ DISTCLEANFILES = \
$(man_MANS) \
$(NULL)
CLEANFILES = check-saveconfig compsave.conf k-g-u-submake \
$(EXTRA_PROGRAMS) $(NULL) check-libopts check-libntp .deps-ver
CLEANFILES = check-psl0 check-psl1 check-psl2 check-pslsaveconfig \
check-saveconfig compsave.conf compsave.conf+ k-g-u-submake \
psl0save.conf psl0save.conf+ psl1save.conf psl1save.conf+ \
psl2save.conf psl2save.conf+ $(EXTRA_PROGRAMS) $(NULL) \
check-libopts check-libntp .deps-ver
EXTRA_DIST = \
complete.conf.in \
invoke-ntp.conf.menu \
@@ -700,6 +703,9 @@ EXTRA_DIST = \
ntpd.html \
ntpd.texi \
ntpdbase-opts.def \
psl0.conf \
psl1.conf \
psl2.conf \
refclock_msfees.c \
$(B_S_DIST) \
$(NULL)
@@ -1743,13 +1749,13 @@ $(srcdir)/invoke-ntp.keys.menu: $(srcdir)/invoke-ntp.keys.texi
$(srcdir)/invoke-ntp.keys.texi: $(srcdir)/ntp.keys.def $(std_def_list)
$(run_ag) -Tagtexi-file.tpl -DLEVEL=section ntp.keys.def
$(srcdir)/ntp.conf.html: $(srcdir)/ntp.conf.texi $(top_srcdir)/sntp/include/version.texi
$(srcdir)/ntp.conf.html: $(srcdir)/ntp.conf.texi $(srcdir)/invoke-ntp.conf.texi $(top_srcdir)/sntp/include/version.texi
cd $(srcdir) && ( makeinfo --force --html --no-split -o ntp.conf.html ntp.conf.texi || true )
$(srcdir)/ntp.keys.html: $(srcdir)/ntp.keys.texi $(top_srcdir)/sntp/include/version.texi
$(srcdir)/ntp.keys.html: $(srcdir)/ntp.keys.texi $(srcdir)/invoke-ntp.keys.texi $(top_srcdir)/sntp/include/version.texi
cd $(srcdir) && ( makeinfo --force --html --no-split -o ntp.keys.html ntp.keys.texi || true )
$(srcdir)/ntpd.html: $(srcdir)/ntpd.texi $(top_srcdir)/sntp/include/version.texi
$(srcdir)/ntpd.html: $(srcdir)/ntpd.texi $(srcdir)/invoke-ntpd.texi $(top_srcdir)/sntp/include/version.texi
cd $(srcdir) && ( makeinfo --force --html --no-split -o ntpd.html ntpd.texi || true )
###
@@ -1811,13 +1817,41 @@ $(srcdir)/invoke-ntpd.texi: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def
$(PROGRAMS): $(LDADD)
compsave.conf: ntpd complete.conf
./ntpd --configfile complete.conf --saveconfigquit $@
check-saveconfig: complete.conf compsave.conf
-diff -u complete.conf compsave.conf
cmp complete.conf compsave.conf && echo stamp > $@
compsave.conf: ntpd complete.conf
./ntpd --configfile complete.conf --saveconfigquit $@+
grep -v '^#' $@+ > $@
check-pslsaveconfig: check-psl0 check-psl1 check-psl2
echo stamp > $@
check-psl0: psl0.conf psl0save.conf
-diff -u $< psl0save.conf
cmp $< psl0save.conf && echo stamp > $@
psl0save.conf: psl0.conf ntpd
./ntpd --configfile $< --saveconfigquit $@+
grep -v '^#' $@+ > $@
check-psl1: psl1.conf psl1save.conf
-diff -u $< psl1save.conf
cmp $< psl1save.conf && echo stamp > $@
psl1save.conf: psl1.conf ntpd
./ntpd --configfile $< --saveconfigquit $@+
grep -v '^#' $@+ > $@
check-psl2: psl2.conf psl2save.conf
-diff -u $< psl2save.conf
cmp $< psl2save.conf && echo stamp > $@
psl2save.conf: psl2.conf ntpd
./ntpd --configfile $< --saveconfigquit $@+
grep -v '^#' $@+ > $@
../libntp/libntpsim.a:
cd ../libntp && $(MAKE) $(AM_MAKEFLAGS) libntpsim.a
+3 -3
View File
@@ -71,7 +71,7 @@ getCmdOpts(
}
if (HAVE_OPT( DRIFTFILE ))
stats_config(STATS_FREQ_FILE, OPT_ARG( DRIFTFILE ));
stats_config(STATS_FREQ_FILE, OPT_ARG( DRIFTFILE ), 0);
if (HAVE_OPT( PANICGATE ))
allow_panic = TRUE;
@@ -90,7 +90,7 @@ getCmdOpts(
getauthkeys(OPT_ARG( KEYFILE ));
if (HAVE_OPT( PIDFILE ))
stats_config(STATS_PID_FILE, OPT_ARG( PIDFILE ));
stats_config(STATS_PID_FILE, OPT_ARG( PIDFILE ), 0);
if (HAVE_OPT( QUIT ))
mode_ntpdate = TRUE;
@@ -110,7 +110,7 @@ getCmdOpts(
} while (0);
if (HAVE_OPT( STATSDIR ))
stats_config(STATS_STATSDIR, OPT_ARG( STATSDIR ));
stats_config(STATS_STATSDIR, OPT_ARG( STATSDIR ), 0);
if (HAVE_OPT( TRUSTEDKEY )) {
int ct = STACKCT_OPT( TRUSTEDKEY );
+7 -4
View File
@@ -1,7 +1,8 @@
saveconfigdir "/etc/ntp/conf"
driftfile "/etc/ntp.drift" 1e-7
driftfile "/etc/ntp.drift"
logfile "/var/log/ntp.log"
leapfile "/etc/ntp.leapseconds"
leapfile "/etc/ntp.leapseconds" ignorehash
leapfile "/etc/ntp.leapseconds" checkhash
@HAVE_LEAPSMEARINTERVAL@
nonvolatile 1e-7
ident "udent"
@@ -31,14 +32,14 @@ rlimit@HAVE_RLIMIT_MEMLOCK@@HAVE_RLIMIT_STACK@
tinker allan 1500 dispersion 15 freq 0 huffpuff 7200 panic 1000 step 0.128 stepout 900 tick 0.01
broadcastclient
server 127.127.1.0 mode 4294967295 prefer true
fudge 127.127.1.0 time1 0 time2 1.1 stratum 7 refid Abcd
fudge 127.127.1.0 time1 0 time2 1.1 stratum 7 refid Abcd minjitter 0.2
pool 0.north-america.pool.ntp.org. iburst preempt
server 1.north-america.pool.ntp.org. iburst
server -4 2.north-america.pool.ntp.org. minpoll 6 maxpoll 10 iburst
server -6 ntp.davehart.net. minpoll 6 maxpoll 10 version 5 burst iburst
peer -6 davehart.broker.freenet6.net. ident "autokey-group" xleave autokey
peer -4 192.168.192.168 key 1 noselect
server [fe80::123%1]
server [fe80::123%1] xmtnonce
broadcast 192.168.192.255
manycastclient 224.0.1.1
manycastclient ff05::101
@@ -46,6 +47,7 @@ manycastserver 224.0.1.1 ff05::101
multicastclient 224.0.1.1 ff05::101
mru maxage 64 mindepth 600 initalloc 600 initmem 16 incalloc 99 incmem 4 maxdepth 1024 maxmem 4096
discard minimum 1 average 3 monitor 3000
pollskewlist 3 1|2 4 3|4 default 6|7
restrict default ippeerlimit -1
restrict default ippeerlimit 0 nomodify limited kod noserve nomrulist
restrict source ippeerlimit 1
@@ -53,6 +55,7 @@ restrict source ippeerlimit 2 nomodify limited kod
restrict trusted.host.name.example.com. ippeerlimit -1 nomodify
restrict [fe80::1] mask [ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff] ippeerlimit -1
restrict 127.0.0.1 mask 255.255.255.255 ippeerlimit -1
restrict 127.0.0.2 ippeerlimit -1 serverresponse fuzz
restrict ::1 ippeerlimit -1
interface drop ipv6
interface ignore ipv4
+31 -7
View File
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntp.conf.texi)
#
# It has been AutoGen-ed February 20, 2019 at 09:56:39 AM by AutoGen 5.18.5
# It has been AutoGen-ed March 3, 2020 at 05:40:57 PM by AutoGen 5.18.5
# From the definitions ntp.conf.def
# and the template file agtexi-file.tpl
@end ignore
@@ -134,8 +134,8 @@ qualifier forces DNS resolution to the IPv6 namespace.
See IPv6 references for the
equivalent classes for that address family.
@table @asis
@item @code{pool} @kbd{address} @code{[@code{burst}]} @code{[@code{iburst}]} @code{[@code{version} @kbd{version}]} @code{[@code{prefer}]} @code{[@code{minpoll} @kbd{minpoll}]} @code{[@code{maxpoll} @kbd{maxpoll}]}
@item @code{server} @kbd{address} @code{[@code{key} @kbd{key} @kbd{|} @code{autokey}]} @code{[@code{burst}]} @code{[@code{iburst}]} @code{[@code{version} @kbd{version}]} @code{[@code{prefer}]} @code{[@code{minpoll} @kbd{minpoll}]} @code{[@code{maxpoll} @kbd{maxpoll}]} @code{[@code{true}]}
@item @code{pool} @kbd{address} @code{[@code{burst}]} @code{[@code{iburst}]} @code{[@code{version} @kbd{version}]} @code{[@code{prefer}]} @code{[@code{minpoll} @kbd{minpoll}]} @code{[@code{maxpoll} @kbd{maxpoll}]} @code{[@code{xmtnonce}]}
@item @code{server} @kbd{address} @code{[@code{key} @kbd{key} @kbd{|} @code{autokey}]} @code{[@code{burst}]} @code{[@code{iburst}]} @code{[@code{version} @kbd{version}]} @code{[@code{prefer}]} @code{[@code{minpoll} @kbd{minpoll}]} @code{[@code{maxpoll} @kbd{maxpoll}]} @code{[@code{true}]} @code{[@code{xmtnonce}]}
@item @code{peer} @kbd{address} @code{[@code{key} @kbd{key} @kbd{|} @code{autokey}]} @code{[@code{version} @kbd{version}]} @code{[@code{prefer}]} @code{[@code{minpoll} @kbd{minpoll}]} @code{[@code{maxpoll} @kbd{maxpoll}]} @code{[@code{true}]} @code{[@code{xleave}]}
@item @code{broadcast} @kbd{address} @code{[@code{key} @kbd{key} @kbd{|} @code{autokey}]} @code{[@code{version} @kbd{version}]} @code{[@code{prefer}]} @code{[@code{minpoll} @kbd{minpoll}]} @code{[@code{ttl} @kbd{ttl}]} @code{[@code{xleave}]}
@item @code{manycastclient} @kbd{address} @code{[@code{key} @kbd{key} @kbd{|} @code{autokey}]} @code{[@code{version} @kbd{version}]} @code{[@code{prefer}]} @code{[@code{minpoll} @kbd{minpoll}]} @code{[@code{maxpoll} @kbd{maxpoll}]} @code{[@code{ttl} @kbd{ttl}]}
@@ -305,9 +305,6 @@ Marks the server as unused, except for display purposes.
The server is discarded by the selection algroithm.
@item @code{preempt}
Says the association can be preempted.
@item @code{true}
Marks the server as a truechimer.
Use this option only for testing.
@item @code{prefer}
Marks the server as preferred.
All other things being equal,
@@ -321,7 +318,8 @@ provided in
@file{/usr/share/doc/ntp})
for further information.
@item @code{true}
Forces the association to always survive the selection and clustering algorithms.
Marks the server as a truechimer,
forcing the association to always survive the selection and clustering algorithms.
This option should almost certainly
@emph{only}
be used while testing an association.
@@ -349,6 +347,13 @@ Valid in
and
@code{broadcast}
modes only, this flag enables interleave mode.
@item @code{xmtnonce}
Valid only for
@code{server}
and
@code{pool}
modes, this flag puts a random number in the packet's transmit timestamp.
@end table
@subsubsection Auxiliary Commands
@table @asis
@@ -1622,6 +1627,10 @@ The
@code{ntpport}
is considered more specific and
is sorted later in the list.
@item @code{serverresponse fuzz}
When reponding to server requests,
fuzz the low order bits of the
@code{reftime}.
@item @code{version}
Deny packets that do not match the current NTP version.
@end table
@@ -2766,6 +2775,21 @@ For the JJY driver (type 40 mode 100 - 180), the argument is
one telephone number used to dial the telephone JJY service.
The Hayes command ATDT is normally prepended to the number.
The number can contain other modem control codes as well.
@item @code{pollskewlist} @code{[@kbd{poll} @kbd{value} | @kbd{value}]} @kbd{...} @code{[@code{default} @kbd{value} | @kbd{value}]}
Enable skewing of our poll requests to our servers.
@kbd{poll}
is a number between 3 and 17 inclusive, identifying a specific poll interval.
A poll interval is 2^n seconds in duration,
so a poll value of 3 corresponds to 8 seconds
and
a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one-half of the poll interval,
inclusive.
The first number specifies how early the poll may start,
while
the second number specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.
@item @code{reset} @code{[@code{allpeers}]} @code{[@code{auth}]} @code{[@code{ctl}]} @code{[@code{io}]} @code{[@code{mem}]} @code{[@code{sys}]} @code{[@code{timer}]}
Reset one or more groups of counters maintained by
@code{ntpd}
+1 -1
View File
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntp.keys.texi)
#
# It has been AutoGen-ed February 20, 2019 at 09:56:41 AM by AutoGen 5.18.5
# It has been AutoGen-ed March 3, 2020 at 05:40:59 PM by AutoGen 5.18.5
# From the definitions ntp.keys.def
# and the template file agtexi-file.tpl
@end ignore
+2 -2
View File
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntpd.texi)
#
# It has been AutoGen-ed February 20, 2019 at 09:56:42 AM by AutoGen 5.18.5
# It has been AutoGen-ed March 3, 2020 at 05:41:00 PM by AutoGen 5.18.5
# From the definitions ntpd-opts.def
# and the template file agtexi-cmd.tpl
@end ignore
@@ -142,7 +142,7 @@ with a status code of 0.
@exampleindent 0
@example
ntpd - NTP daemon program - Ver. 4.2.8p13
ntpd - NTP daemon program - Ver. 4.2.8p14
Usage: ntpd [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... \
[ <server1> ... <serverN> ]
Flg Arg Option-Name Description
+1 -1
View File
@@ -1 +1 @@
* Generated 2018-01-14 03:53:33 UTC diff_ignore_line
* Generated 2020-02-13 08:56:28 UTC diff_ignore_line
+8
View File
@@ -43,6 +43,7 @@ struct key_tok ntp_keywords[] = {
{ "broadcast", T_Broadcast, FOLLBY_STRING },
{ "broadcastclient", T_Broadcastclient, FOLLBY_TOKEN },
{ "broadcastdelay", T_Broadcastdelay, FOLLBY_TOKEN },
{ "checkhash", T_Checkhash, FOLLBY_TOKEN },
{ "ctl", T_Ctl, FOLLBY_TOKEN },
{ "disable", T_Disable, FOLLBY_TOKEN },
{ "driftfile", T_Driftfile, FOLLBY_STRING },
@@ -51,6 +52,7 @@ struct key_tok ntp_keywords[] = {
{ "end", T_End, FOLLBY_TOKEN },
{ "filegen", T_Filegen, FOLLBY_TOKEN },
{ "fudge", T_Fudge, FOLLBY_STRING },
{ "ignorehash", T_Ignorehash, FOLLBY_TOKEN },
{ "io", T_Io, FOLLBY_TOKEN },
{ "includefile", T_Includefile, FOLLBY_STRING },
{ "leapfile", T_Leapfile, FOLLBY_STRING },
@@ -64,12 +66,16 @@ struct key_tok ntp_keywords[] = {
{ "peer", T_Peer, FOLLBY_STRING },
{ "phone", T_Phone, FOLLBY_STRINGS_TO_EOC },
{ "pidfile", T_Pidfile, FOLLBY_STRING },
{ "pollskewlist", T_PollSkewList, FOLLBY_TOKEN },
{ "pool", T_Pool, FOLLBY_STRING },
{ "discard", T_Discard, FOLLBY_TOKEN },
{ "reset", T_Reset, FOLLBY_TOKEN },
{ "restrict", T_Restrict, FOLLBY_TOKEN },
{ "rlimit", T_Rlimit, FOLLBY_TOKEN },
{ "server", T_Server, FOLLBY_STRING },
{ "serverresponse", T_Serverresponse, FOLLBY_TOKEN },
{ "fuzz", T_Fuzz, FOLLBY_TOKEN },
{ "poll", T_Poll, FOLLBY_TOKEN },
{ "setvar", T_Setvar, FOLLBY_STRING },
{ "statistics", T_Statistics, FOLLBY_TOKEN },
{ "statsdir", T_Statsdir, FOLLBY_STRING },
@@ -81,6 +87,7 @@ struct key_tok ntp_keywords[] = {
{ "trap", T_Trap, FOLLBY_STRING },
{ "unconfig", T_Unconfig, FOLLBY_STRING },
{ "unpeer", T_Unpeer, FOLLBY_STRING },
{ "xmtnonce", T_Xmtnonce, FOLLBY_TOKEN },
/* authentication_command */
{ "controlkey", T_ControlKey, FOLLBY_TOKEN },
{ "crypto", T_Crypto, FOLLBY_TOKEN },
@@ -199,6 +206,7 @@ struct key_tok ntp_keywords[] = {
{ "stratum", T_Stratum, FOLLBY_TOKEN },
{ "time1", T_Time1, FOLLBY_TOKEN },
{ "time2", T_Time2, FOLLBY_TOKEN },
{ "minjitter", T_Minjitter, FOLLBY_TOKEN },
/* system_option */
{ "auth", T_Auth, FOLLBY_TOKEN },
{ "bclient", T_Bclient, FOLLBY_TOKEN },
+35 -10
View File
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
.TH ntp.conf 5man "20 Feb 2019" "4.2.8p13" "File Formats"
.TH ntp.conf 5man "03 Mar 2020" "4.2.8p14" "File Formats"
.\"
.\" EDIT THIS FILE WITH CAUTION (in-mem file)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:43 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:41:02 PM by AutoGen 5.18.5
.\" From the definitions ntp.conf.def
.\" and the template file agman-cmd.tpl
.SH NAME
@@ -161,9 +161,9 @@ qualifier forces DNS resolution to the IPv6 namespace.
See IPv6 references for the
equivalent classes for that address family.
.TP 7
.NOP \f\*[B-Font]pool\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]burst\f[]] [\f\*[B-Font]iburst\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]]
.NOP \f\*[B-Font]pool\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]burst\f[]] [\f\*[B-Font]iburst\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]] [\f\*[B-Font]xmtnonce\f[]]
.TP 7
.NOP \f\*[B-Font]server\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]key\f[] \f\*[I-Font]key\f[] \f\*[I-Font]\&|\f[] \f\*[B-Font]autokey\f[]] [\f\*[B-Font]burst\f[]] [\f\*[B-Font]iburst\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]] [\f\*[B-Font]true\f[]]
.NOP \f\*[B-Font]server\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]key\f[] \f\*[I-Font]key\f[] \f\*[I-Font]\&|\f[] \f\*[B-Font]autokey\f[]] [\f\*[B-Font]burst\f[]] [\f\*[B-Font]iburst\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]] [\f\*[B-Font]true\f[]] [\f\*[B-Font]xmtnonce\f[]]
.TP 7
.NOP \f\*[B-Font]peer\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]key\f[] \f\*[I-Font]key\f[] \f\*[I-Font]\&|\f[] \f\*[B-Font]autokey\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]] [\f\*[B-Font]true\f[]] [\f\*[B-Font]xleave\f[]]
.TP 7
@@ -352,10 +352,6 @@ The server is discarded by the selection algroithm.
.NOP \f\*[B-Font]preempt\f[]
Says the association can be preempted.
.TP 7
.NOP \f\*[B-Font]true\f[]
Marks the server as a truechimer.
Use this option only for testing.
.TP 7
.NOP \f\*[B-Font]prefer\f[]
Marks the server as preferred.
All other things being equal,
@@ -370,7 +366,8 @@ provided in
for further information.
.TP 7
.NOP \f\*[B-Font]true\f[]
Forces the association to always survive the selection and clustering algorithms.
Marks the server as a truechimer,
forcing the association to always survive the selection and clustering algorithms.
This option should almost certainly
\fIonly\f[]
be used while testing an association.
@@ -401,6 +398,13 @@ Valid in
and
\f\*[B-Font]broadcast\f[]
modes only, this flag enables interleave mode.
.TP 7
.NOP \f\*[B-Font]xmtnonce\f[]
Valid only for
\f\*[B-Font]server\f[]
and
\f\*[B-Font]pool\f[]
modes, this flag puts a random number in the packet's transmit timestamp.
.PP
.SS Auxiliary Commands
.TP 7
@@ -1838,6 +1842,11 @@ The
is considered more specific and
is sorted later in the list.
.TP 7
.NOP \f\*[B-Font]serverresponse fuzz\f[]
When reponding to server requests,
fuzz the low order bits of the
\f\*[B-Font]reftime\f[].
.TP 7
.NOP \f\*[B-Font]version\f[]
Deny packets that do not match the current NTP version.
.RE
@@ -3092,6 +3101,22 @@ one telephone number used to dial the telephone JJY service.
The Hayes command ATDT is normally prepended to the number.
The number can contain other modem control codes as well.
.TP 7
.NOP \f\*[B-Font]pollskewlist\f[] [\f\*[I-Font]poll\f[] \f\*[I-Font]value\f[] | \f\*[I-Font]value\f[]] \f\*[I-Font]...\f[] [\f\*[B-Font]default\f[] \f\*[I-Font]value\f[] | \f\*[I-Font]value\f[]]
Enable skewing of our poll requests to our servers.
\f\*[I-Font]poll\f[]
is a number between 3 and 17 inclusive, identifying a specific poll interval.
A poll interval is 2^n seconds in duration,
so a poll value of 3 corresponds to 8 seconds
and
a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one-half of the poll interval,
inclusive.
The first number specifies how early the poll may start,
while
the second number specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.
.TP 7
.NOP \f\*[B-Font]reset\f[] [\f\*[B-Font]allpeers\f[]] [\f\*[B-Font]auth\f[]] [\f\*[B-Font]ctl\f[]] [\f\*[B-Font]io\f[]] [\f\*[B-Font]mem\f[]] [\f\*[B-Font]sys\f[]] [\f\*[B-Font]timer\f[]]
Reset one or more groups of counters maintained by
\f\*[B-Font]ntpd\f[]
@@ -3424,7 +3449,7 @@ RFC5905
.SH "AUTHORS"
The University of Delaware and Network Time Foundation
.SH "COPYRIGHT"
Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.SH BUGS
The syntax checking is not picky; some combinations of
+42 -7
View File
@@ -1,9 +1,9 @@
.Dd February 20 2019
.Dd March 3 2020
.Dt NTP_CONF 5mdoc File Formats
.Os
.\" EDIT THIS FILE WITH CAUTION (ntp.mdoc)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:34 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:40:53 PM by AutoGen 5.18.5
.\" From the definitions ntp.conf.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
@@ -144,6 +144,7 @@ equivalent classes for that address family.
.Op Cm prefer
.Op Cm minpoll Ar minpoll
.Op Cm maxpoll Ar maxpoll
.Op Cm xmtnonce
.Xc
.It Xo Ic server Ar address
.Op Cm key Ar key \&| Cm autokey
@@ -154,6 +155,7 @@ equivalent classes for that address family.
.Op Cm minpoll Ar minpoll
.Op Cm maxpoll Ar maxpoll
.Op Cm true
.Op Cm xmtnonce
.Xc
.It Xo Ic peer Ar address
.Op Cm key Ar key \&| Cm autokey
@@ -346,9 +348,6 @@ Marks the server as unused, except for display purposes.
The server is discarded by the selection algroithm.
.It Cm preempt
Says the association can be preempted.
.It Cm true
Marks the server as a truechimer.
Use this option only for testing.
.It Cm prefer
Marks the server as preferred.
All other things being equal,
@@ -362,7 +361,8 @@ provided in
.Pa /usr/share/doc/ntp )
for further information.
.It Cm true
Forces the association to always survive the selection and clustering algorithms.
Marks the server as a truechimer,
forcing the association to always survive the selection and clustering algorithms.
This option should almost certainly
.Em only
be used while testing an association.
@@ -390,6 +390,12 @@ Valid in
and
.Cm broadcast
modes only, this flag enables interleave mode.
.It Cm xmtnonce
Valid only for
.Cm server
and
.Cm pool
modes, this flag puts a random number in the packet's transmit timestamp.
.El
.Ss Auxiliary Commands
.Bl -tag -width indent
@@ -1694,6 +1700,10 @@ The
.Cm ntpport
is considered more specific and
is sorted later in the list.
.It Ic "serverresponse fuzz"
When reponding to server requests,
fuzz the low order bits of the
.Cm reftime .
.It Cm version
Deny packets that do not match the current NTP version.
.El
@@ -2919,6 +2929,31 @@ For the JJY driver (type 40 mode 100 \- 180), the argument is
one telephone number used to dial the telephone JJY service.
The Hayes command ATDT is normally prepended to the number.
The number can contain other modem control codes as well.
.It Xo Cm pollskewlist
.Oo
.Ar poll
.Ar value | value
.Oc
.Ar ...
.Oo
.Cm default
.Ar value | value
.Oc
.Xc
Enable skewing of our poll requests to our servers.
.Ar poll
is a number between 3 and 17 inclusive, identifying a specific poll interval.
A poll interval is 2^n seconds in duration,
so a poll value of 3 corresponds to 8 seconds
and
a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one\-half of the poll interval,
inclusive.
The first number specifies how early the poll may start,
while
the second number specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.
.It Xo Ic reset
.Oo
.Ic allpeers
@@ -3255,7 +3290,7 @@ A snapshot of this documentation is available in HTML format in
.Sh "AUTHORS"
The University of Delaware and Network Time Foundation
.Sh "COPYRIGHT"
Copyright (C) 1992\-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992\-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.Sh BUGS
The syntax checking is not picky; some combinations of
+40 -4
View File
@@ -146,6 +146,7 @@ equivalent classes for that address family.
.Op Cm prefer
.Op Cm minpoll Ar minpoll
.Op Cm maxpoll Ar maxpoll
.Op Cm xmtnonce
.Xc
.It Xo Ic server Ar address
.Op Cm key Ar key \&| Cm autokey
@@ -156,6 +157,7 @@ equivalent classes for that address family.
.Op Cm minpoll Ar minpoll
.Op Cm maxpoll Ar maxpoll
.Op Cm true
.Op Cm xmtnonce
.Xc
.It Xo Ic peer Ar address
.Op Cm key Ar key \&| Cm autokey
@@ -348,9 +350,6 @@ Marks the server as unused, except for display purposes.
The server is discarded by the selection algroithm.
.It Cm preempt
Says the association can be preempted.
.It Cm true
Marks the server as a truechimer.
Use this option only for testing.
.It Cm prefer
Marks the server as preferred.
All other things being equal,
@@ -364,7 +363,8 @@ provided in
.Pa /usr/share/doc/ntp )
for further information.
.It Cm true
Forces the association to always survive the selection and clustering algorithms.
Marks the server as a truechimer,
forcing the association to always survive the selection and clustering algorithms.
This option should almost certainly
.Em only
be used while testing an association.
@@ -392,6 +392,13 @@ Valid in
and
.Cm broadcast
modes only, this flag enables interleave mode.
.It Cm xmtnonce
Valid only for
.Cm server
and
.Cm pool
modes, this flag puts a random number in the packet's transmit timestamp.
.El
.Ss Auxiliary Commands
.Bl -tag -width indent
@@ -1696,6 +1703,10 @@ The
.Cm ntpport
is considered more specific and
is sorted later in the list.
.It Ic "serverresponse fuzz"
When reponding to server requests,
fuzz the low order bits of the
.Cm reftime .
.It Cm version
Deny packets that do not match the current NTP version.
.El
@@ -2921,6 +2932,31 @@ For the JJY driver (type 40 mode 100 - 180), the argument is
one telephone number used to dial the telephone JJY service.
The Hayes command ATDT is normally prepended to the number.
The number can contain other modem control codes as well.
.It Xo Cm pollskewlist
.Oo
.Ar poll
.Ar value | value
.Oc
.Ar ...
.Oo
.Cm default
.Ar value | value
.Oc
.Xc
Enable skewing of our poll requests to our servers.
.Ar poll
is a number between 3 and 17 inclusive, identifying a specific poll interval.
A poll interval is 2^n seconds in duration,
so a poll value of 3 corresponds to 8 seconds
and
a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one-half of the poll interval,
inclusive.
The first number specifies how early the poll may start,
while
the second number specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.
.It Xo Ic reset
.Oo
.Ic allpeers
+34 -8
View File
@@ -61,7 +61,7 @@ Next: <a href="#ntp_002econf-Description" accesskey="n" rel="next">ntp.conf Desc
<p>This document describes the configuration file for the NTP Project&rsquo;s
<code>ntpd</code> program.
</p>
<p>This document applies to version 4.2.8p13 of <code>ntp.conf</code>.
<p>This document applies to version 4.2.8p14 of <code>ntp.conf</code>.
</p>
<a name="SEC_Overview"></a>
<h2 class="shortcontents-heading">Short Table of Contents</h2>
@@ -257,8 +257,8 @@ qualifier forces DNS resolution to the IPv6 namespace.
See IPv6 references for the
equivalent classes for that address family.
</p><dl compact="compact">
<dt><code>pool</code> <kbd>address</kbd> <code>[<code>burst</code>]</code> <code>[<code>iburst</code>]</code> <code>[<code>version</code> <kbd>version</kbd>]</code> <code>[<code>prefer</code>]</code> <code>[<code>minpoll</code> <kbd>minpoll</kbd>]</code> <code>[<code>maxpoll</code> <kbd>maxpoll</kbd>]</code></dt>
<dt><code>server</code> <kbd>address</kbd> <code>[<code>key</code> <kbd>key</kbd> <kbd>|</kbd> <code>autokey</code>]</code> <code>[<code>burst</code>]</code> <code>[<code>iburst</code>]</code> <code>[<code>version</code> <kbd>version</kbd>]</code> <code>[<code>prefer</code>]</code> <code>[<code>minpoll</code> <kbd>minpoll</kbd>]</code> <code>[<code>maxpoll</code> <kbd>maxpoll</kbd>]</code> <code>[<code>true</code>]</code></dt>
<dt><code>pool</code> <kbd>address</kbd> <code>[<code>burst</code>]</code> <code>[<code>iburst</code>]</code> <code>[<code>version</code> <kbd>version</kbd>]</code> <code>[<code>prefer</code>]</code> <code>[<code>minpoll</code> <kbd>minpoll</kbd>]</code> <code>[<code>maxpoll</code> <kbd>maxpoll</kbd>]</code> <code>[<code>xmtnonce</code>]</code></dt>
<dt><code>server</code> <kbd>address</kbd> <code>[<code>key</code> <kbd>key</kbd> <kbd>|</kbd> <code>autokey</code>]</code> <code>[<code>burst</code>]</code> <code>[<code>iburst</code>]</code> <code>[<code>version</code> <kbd>version</kbd>]</code> <code>[<code>prefer</code>]</code> <code>[<code>minpoll</code> <kbd>minpoll</kbd>]</code> <code>[<code>maxpoll</code> <kbd>maxpoll</kbd>]</code> <code>[<code>true</code>]</code> <code>[<code>xmtnonce</code>]</code></dt>
<dt><code>peer</code> <kbd>address</kbd> <code>[<code>key</code> <kbd>key</kbd> <kbd>|</kbd> <code>autokey</code>]</code> <code>[<code>version</code> <kbd>version</kbd>]</code> <code>[<code>prefer</code>]</code> <code>[<code>minpoll</code> <kbd>minpoll</kbd>]</code> <code>[<code>maxpoll</code> <kbd>maxpoll</kbd>]</code> <code>[<code>true</code>]</code> <code>[<code>xleave</code>]</code></dt>
<dt><code>broadcast</code> <kbd>address</kbd> <code>[<code>key</code> <kbd>key</kbd> <kbd>|</kbd> <code>autokey</code>]</code> <code>[<code>version</code> <kbd>version</kbd>]</code> <code>[<code>prefer</code>]</code> <code>[<code>minpoll</code> <kbd>minpoll</kbd>]</code> <code>[<code>ttl</code> <kbd>ttl</kbd>]</code> <code>[<code>xleave</code>]</code></dt>
<dt><code>manycastclient</code> <kbd>address</kbd> <code>[<code>key</code> <kbd>key</kbd> <kbd>|</kbd> <code>autokey</code>]</code> <code>[<code>version</code> <kbd>version</kbd>]</code> <code>[<code>prefer</code>]</code> <code>[<code>minpoll</code> <kbd>minpoll</kbd>]</code> <code>[<code>maxpoll</code> <kbd>maxpoll</kbd>]</code> <code>[<code>ttl</code> <kbd>ttl</kbd>]</code></dt>
@@ -440,10 +440,6 @@ The server is discarded by the selection algroithm.
<dt><code>preempt</code></dt>
<dd><p>Says the association can be preempted.
</p></dd>
<dt><code>true</code></dt>
<dd><p>Marks the server as a truechimer.
Use this option only for testing.
</p></dd>
<dt><code>prefer</code></dt>
<dd><p>Marks the server as preferred.
All other things being equal,
@@ -458,7 +454,8 @@ provided in
for further information.
</p></dd>
<dt><code>true</code></dt>
<dd><p>Forces the association to always survive the selection and clustering algorithms.
<dd><p>Marks the server as a truechimer,
forcing the association to always survive the selection and clustering algorithms.
This option should almost certainly
<em>only</em>
be used while testing an association.
@@ -490,6 +487,14 @@ and
<code>broadcast</code>
modes only, this flag enables interleave mode.
</p></dd>
<dt><code>xmtnonce</code></dt>
<dd><p>Valid only for
<code>server</code>
and
<code>pool</code>
modes, this flag puts a random number in the packet&rsquo;s transmit timestamp.
</p>
</dd>
</dl>
<a name="Auxiliary-Commands"></a>
<h4 class="subsubsection">1.1.1.2 Auxiliary Commands</h4>
@@ -1862,6 +1867,11 @@ The
is considered more specific and
is sorted later in the list.
</p></dd>
<dt><code>serverresponse fuzz</code></dt>
<dd><p>When reponding to server requests,
fuzz the low order bits of the
<code>reftime</code>.
</p></dd>
<dt><code>version</code></dt>
<dd><p>Deny packets that do not match the current NTP version.
</p></dd>
@@ -3077,6 +3087,22 @@ one telephone number used to dial the telephone JJY service.
The Hayes command ATDT is normally prepended to the number.
The number can contain other modem control codes as well.
</p></dd>
<dt><code>pollskewlist</code> <code>[<kbd>poll</kbd> <kbd>value</kbd> | <kbd>value</kbd>]</code> <kbd>...</kbd> <code>[<code>default</code> <kbd>value</kbd> | <kbd>value</kbd>]</code></dt>
<dd><p>Enable skewing of our poll requests to our servers.
<kbd>poll</kbd>
is a number between 3 and 17 inclusive, identifying a specific poll interval.
A poll interval is 2^n seconds in duration,
so a poll value of 3 corresponds to 8 seconds
and
a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one-half of the poll interval,
inclusive.
The first number specifies how early the poll may start,
while
the second number specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.
</p></dd>
<dt><code>reset</code> <code>[<code>allpeers</code>]</code> <code>[<code>auth</code>]</code> <code>[<code>ctl</code>]</code> <code>[<code>io</code>]</code> <code>[<code>mem</code>]</code> <code>[<code>sys</code>]</code> <code>[<code>timer</code>]</code></dt>
<dd><p>Reset one or more groups of counters maintained by
<code>ntpd</code>
+35 -10
View File
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
.TH ntp.conf 5 "20 Feb 2019" "4.2.8p13" "File Formats"
.TH ntp.conf 5 "03 Mar 2020" "4.2.8p14" "File Formats"
.\"
.\" EDIT THIS FILE WITH CAUTION (in-mem file)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:43 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:41:02 PM by AutoGen 5.18.5
.\" From the definitions ntp.conf.def
.\" and the template file agman-cmd.tpl
.SH NAME
@@ -161,9 +161,9 @@ qualifier forces DNS resolution to the IPv6 namespace.
See IPv6 references for the
equivalent classes for that address family.
.TP 7
.NOP \f\*[B-Font]pool\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]burst\f[]] [\f\*[B-Font]iburst\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]]
.NOP \f\*[B-Font]pool\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]burst\f[]] [\f\*[B-Font]iburst\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]] [\f\*[B-Font]xmtnonce\f[]]
.TP 7
.NOP \f\*[B-Font]server\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]key\f[] \f\*[I-Font]key\f[] \f\*[I-Font]\&|\f[] \f\*[B-Font]autokey\f[]] [\f\*[B-Font]burst\f[]] [\f\*[B-Font]iburst\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]] [\f\*[B-Font]true\f[]]
.NOP \f\*[B-Font]server\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]key\f[] \f\*[I-Font]key\f[] \f\*[I-Font]\&|\f[] \f\*[B-Font]autokey\f[]] [\f\*[B-Font]burst\f[]] [\f\*[B-Font]iburst\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]] [\f\*[B-Font]true\f[]] [\f\*[B-Font]xmtnonce\f[]]
.TP 7
.NOP \f\*[B-Font]peer\f[] \f\*[I-Font]address\f[] [\f\*[B-Font]key\f[] \f\*[I-Font]key\f[] \f\*[I-Font]\&|\f[] \f\*[B-Font]autokey\f[]] [\f\*[B-Font]version\f[] \f\*[I-Font]version\f[]] [\f\*[B-Font]prefer\f[]] [\f\*[B-Font]minpoll\f[] \f\*[I-Font]minpoll\f[]] [\f\*[B-Font]maxpoll\f[] \f\*[I-Font]maxpoll\f[]] [\f\*[B-Font]true\f[]] [\f\*[B-Font]xleave\f[]]
.TP 7
@@ -352,10 +352,6 @@ The server is discarded by the selection algroithm.
.NOP \f\*[B-Font]preempt\f[]
Says the association can be preempted.
.TP 7
.NOP \f\*[B-Font]true\f[]
Marks the server as a truechimer.
Use this option only for testing.
.TP 7
.NOP \f\*[B-Font]prefer\f[]
Marks the server as preferred.
All other things being equal,
@@ -370,7 +366,8 @@ provided in
for further information.
.TP 7
.NOP \f\*[B-Font]true\f[]
Forces the association to always survive the selection and clustering algorithms.
Marks the server as a truechimer,
forcing the association to always survive the selection and clustering algorithms.
This option should almost certainly
\fIonly\f[]
be used while testing an association.
@@ -401,6 +398,13 @@ Valid in
and
\f\*[B-Font]broadcast\f[]
modes only, this flag enables interleave mode.
.TP 7
.NOP \f\*[B-Font]xmtnonce\f[]
Valid only for
\f\*[B-Font]server\f[]
and
\f\*[B-Font]pool\f[]
modes, this flag puts a random number in the packet's transmit timestamp.
.PP
.SS Auxiliary Commands
.TP 7
@@ -1838,6 +1842,11 @@ The
is considered more specific and
is sorted later in the list.
.TP 7
.NOP \f\*[B-Font]serverresponse fuzz\f[]
When reponding to server requests,
fuzz the low order bits of the
\f\*[B-Font]reftime\f[].
.TP 7
.NOP \f\*[B-Font]version\f[]
Deny packets that do not match the current NTP version.
.RE
@@ -3092,6 +3101,22 @@ one telephone number used to dial the telephone JJY service.
The Hayes command ATDT is normally prepended to the number.
The number can contain other modem control codes as well.
.TP 7
.NOP \f\*[B-Font]pollskewlist\f[] [\f\*[I-Font]poll\f[] \f\*[I-Font]value\f[] | \f\*[I-Font]value\f[]] \f\*[I-Font]...\f[] [\f\*[B-Font]default\f[] \f\*[I-Font]value\f[] | \f\*[I-Font]value\f[]]
Enable skewing of our poll requests to our servers.
\f\*[I-Font]poll\f[]
is a number between 3 and 17 inclusive, identifying a specific poll interval.
A poll interval is 2^n seconds in duration,
so a poll value of 3 corresponds to 8 seconds
and
a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one-half of the poll interval,
inclusive.
The first number specifies how early the poll may start,
while
the second number specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.
.TP 7
.NOP \f\*[B-Font]reset\f[] [\f\*[B-Font]allpeers\f[]] [\f\*[B-Font]auth\f[]] [\f\*[B-Font]ctl\f[]] [\f\*[B-Font]io\f[]] [\f\*[B-Font]mem\f[]] [\f\*[B-Font]sys\f[]] [\f\*[B-Font]timer\f[]]
Reset one or more groups of counters maintained by
\f\*[B-Font]ntpd\f[]
@@ -3424,7 +3449,7 @@ RFC5905
.SH "AUTHORS"
The University of Delaware and Network Time Foundation
.SH "COPYRIGHT"
Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.SH BUGS
The syntax checking is not picky; some combinations of
+42 -7
View File
@@ -1,9 +1,9 @@
.Dd February 20 2019
.Dd March 3 2020
.Dt NTP_CONF 5 File Formats
.Os
.\" EDIT THIS FILE WITH CAUTION (ntp.mdoc)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:34 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:40:53 PM by AutoGen 5.18.5
.\" From the definitions ntp.conf.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
@@ -144,6 +144,7 @@ equivalent classes for that address family.
.Op Cm prefer
.Op Cm minpoll Ar minpoll
.Op Cm maxpoll Ar maxpoll
.Op Cm xmtnonce
.Xc
.It Xo Ic server Ar address
.Op Cm key Ar key \&| Cm autokey
@@ -154,6 +155,7 @@ equivalent classes for that address family.
.Op Cm minpoll Ar minpoll
.Op Cm maxpoll Ar maxpoll
.Op Cm true
.Op Cm xmtnonce
.Xc
.It Xo Ic peer Ar address
.Op Cm key Ar key \&| Cm autokey
@@ -346,9 +348,6 @@ Marks the server as unused, except for display purposes.
The server is discarded by the selection algroithm.
.It Cm preempt
Says the association can be preempted.
.It Cm true
Marks the server as a truechimer.
Use this option only for testing.
.It Cm prefer
Marks the server as preferred.
All other things being equal,
@@ -362,7 +361,8 @@ provided in
.Pa /usr/share/doc/ntp )
for further information.
.It Cm true
Forces the association to always survive the selection and clustering algorithms.
Marks the server as a truechimer,
forcing the association to always survive the selection and clustering algorithms.
This option should almost certainly
.Em only
be used while testing an association.
@@ -390,6 +390,12 @@ Valid in
and
.Cm broadcast
modes only, this flag enables interleave mode.
.It Cm xmtnonce
Valid only for
.Cm server
and
.Cm pool
modes, this flag puts a random number in the packet's transmit timestamp.
.El
.Ss Auxiliary Commands
.Bl -tag -width indent
@@ -1694,6 +1700,10 @@ The
.Cm ntpport
is considered more specific and
is sorted later in the list.
.It Ic "serverresponse fuzz"
When reponding to server requests,
fuzz the low order bits of the
.Cm reftime .
.It Cm version
Deny packets that do not match the current NTP version.
.El
@@ -2919,6 +2929,31 @@ For the JJY driver (type 40 mode 100 \- 180), the argument is
one telephone number used to dial the telephone JJY service.
The Hayes command ATDT is normally prepended to the number.
The number can contain other modem control codes as well.
.It Xo Cm pollskewlist
.Oo
.Ar poll
.Ar value | value
.Oc
.Ar ...
.Oo
.Cm default
.Ar value | value
.Oc
.Xc
Enable skewing of our poll requests to our servers.
.Ar poll
is a number between 3 and 17 inclusive, identifying a specific poll interval.
A poll interval is 2^n seconds in duration,
so a poll value of 3 corresponds to 8 seconds
and
a poll interval of 17 corresponds to
131,072 seconds, or about a day and a half.
The next two numbers must be between 0 and one\-half of the poll interval,
inclusive.
The first number specifies how early the poll may start,
while
the second number specifies how late the poll may be delayed.
With no arguments, internally specified default values are chosen.
.It Xo Ic reset
.Oo
.Ic allpeers
@@ -3255,7 +3290,7 @@ A snapshot of this documentation is available in HTML format in
.Sh "AUTHORS"
The University of Delaware and Network Time Foundation
.Sh "COPYRIGHT"
Copyright (C) 1992\-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992\-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.Sh BUGS
The syntax checking is not picky; some combinations of
+3 -3
View File
@@ -1,8 +1,8 @@
.TH ntp.keys 5man "20 Feb 2019" "4.2.8p13" "File Formats"
.TH ntp.keys 5man "03 Mar 2020" "4.2.8p14" "File Formats"
.\"
.\" EDIT THIS FILE WITH CAUTION (ntp.man)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:44 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:41:04 PM by AutoGen 5.18.5
.\" From the definitions ntp.keys.def
.\" and the template file agman-file.tpl
.Sh NAME
@@ -176,7 +176,7 @@ the default name of the configuration file
.SH "AUTHORS"
The University of Delaware and Network Time Foundation
.SH "COPYRIGHT"
Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.SH "BUGS"
Please send bug reports to: http://bugs.ntp.org, [email protected]
+3 -3
View File
@@ -1,9 +1,9 @@
.Dd February 20 2019
.Dd March 3 2020
.Dt NTP_KEYS 5mdoc File Formats
.Os FreeBSD 11.2-RELEASE_SI
.\" EDIT THIS FILE WITH CAUTION (ntp.mdoc)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:35 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:40:54 PM by AutoGen 5.18.5
.\" From the definitions ntp.keys.def
.\" and the template file agmdoc-file.tpl
.Sh NAME
@@ -163,7 +163,7 @@ it to autogen\[email protected]. Thank you.
.Sh "AUTHORS"
The University of Delaware and Network Time Foundation
.Sh "COPYRIGHT"
Copyright (C) 1992\-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992\-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.Sh "BUGS"
Please send bug reports to: http://bugs.ntp.org, [email protected]
+1 -1
View File
@@ -61,7 +61,7 @@ Next: <a href="#ntp_002ekeys-Description" accesskey="n" rel="next">ntp.keys Desc
<p>This document describes the symmetric key file for the NTP Project&rsquo;s
<code>ntpd</code> program.
</p>
<p>This document applies to version 4.2.8p13 of <code>ntp.keys</code>.
<p>This document applies to version 4.2.8p14 of <code>ntp.keys</code>.
</p>
<a name="SEC_Overview"></a>
<h2 class="shortcontents-heading">Short Table of Contents</h2>
+3 -3
View File
@@ -1,8 +1,8 @@
.TH ntp.keys 5 "20 Feb 2019" "4.2.8p13" "File Formats"
.TH ntp.keys 5 "03 Mar 2020" "4.2.8p14" "File Formats"
.\"
.\" EDIT THIS FILE WITH CAUTION (ntp.man)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:44 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:41:04 PM by AutoGen 5.18.5
.\" From the definitions ntp.keys.def
.\" and the template file agman-file.tpl
.Sh NAME
@@ -176,7 +176,7 @@ the default name of the configuration file
.SH "AUTHORS"
The University of Delaware and Network Time Foundation
.SH "COPYRIGHT"
Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.SH "BUGS"
Please send bug reports to: http://bugs.ntp.org, [email protected]
+3 -3
View File
@@ -1,9 +1,9 @@
.Dd February 20 2019
.Dd March 3 2020
.Dt NTP_KEYS 5 File Formats
.Os FreeBSD 11.2-RELEASE_SI
.\" EDIT THIS FILE WITH CAUTION (ntp.mdoc)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:35 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:40:54 PM by AutoGen 5.18.5
.\" From the definitions ntp.keys.def
.\" and the template file agmdoc-file.tpl
.Sh NAME
@@ -163,7 +163,7 @@ it to autogen\[email protected]. Thank you.
.Sh "AUTHORS"
The University of Delaware and Network Time Foundation
.Sh "COPYRIGHT"
Copyright (C) 1992\-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992\-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.Sh "BUGS"
Please send bug reports to: http://bugs.ntp.org, [email protected]
+290 -42
View File
@@ -29,6 +29,7 @@
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
#include <time.h>
#include <isc/net.h>
#include <isc/result.h>
@@ -148,7 +149,7 @@ typedef struct peer_resolved_ctx_tag {
*/
extern int yydebug; /* ntp_parser.c (.y) */
config_tree cfgt; /* Parser output stored here */
struct config_tree_tag *cfg_tree_history; /* History of configs */
config_tree *cfg_tree_history; /* History of configs */
char * sys_phone[MAXPHONE] = {NULL}; /* ACTS phone numbers */
char default_keysdir[] = NTP_KEYSDIR;
char * keysdir = default_keysdir; /* crypto keys directory */
@@ -324,6 +325,7 @@ static void config_ntpdsim(config_tree *);
static void config_ntpd(config_tree *, int/*BOOL*/ input_from_file);
static void config_other_modes(config_tree *);
static void config_auth(config_tree *);
static void attrtopsl(int poll, attr_val *avp);
static void config_access(config_tree *);
static void config_mdnstries(config_tree *);
static void config_phone(config_tree *);
@@ -500,6 +502,13 @@ dump_all_config_trees(
{
config_tree * cfg_ptr;
int return_value;
time_t now = time(NULL);
struct tm tm = *localtime(&now);
fprintf(df, "#NTF:D %04d%02d%02d@%02d:%02d:%02d\n",
tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec);
fprintf(df, "#NTF:V %s\n", Version);
return_value = 0;
for (cfg_ptr = cfg_tree_history;
@@ -531,7 +540,6 @@ dump_config_tree(
setvar_node *setv_node;
nic_rule_node *rule_node;
int_node *i_n;
int_node *flag_tok_fifo;
int_node *counter_set;
string_node *str_node;
@@ -591,6 +599,11 @@ dump_config_tree(
atrv = atrv->link;
fprintf(df, " %s\n",
normal_dtoa(atrv->value.d));
} else if (T_Leapfile == atrv->attr) {
fputs((atrv->flag
? " checkhash\n"
: " ignorehash\n"),
df);
} else {
fprintf(df, "\n");
}
@@ -925,6 +938,21 @@ dump_config_tree(
fprintf(df, "\n");
}
atrv = HEAD_PFIFO(ptree->pollskewlist);
if (atrv != NULL) {
fprintf(df, "pollskewlist");
for ( ; atrv != NULL; atrv = atrv->link) {
if (-1 == atrv->attr) {
fprintf(df, " default");
} else {
fprintf(df, " %d", atrv->attr);
}
fprintf(df, " %d|%d",
atrv->value.r.first, atrv->value.r.last);
}
fprintf(df, "\n");
}
for (rest_node = HEAD_PFIFO(ptree->restrict_opts);
rest_node != NULL;
rest_node = rest_node->link) {
@@ -933,9 +961,10 @@ dump_config_tree(
if (NULL == rest_node->addr) {
s = "default";
/* Don't need to set is_default=1 here */
flag_tok_fifo = HEAD_PFIFO(rest_node->flag_tok_fifo);
for ( ; flag_tok_fifo != NULL; flag_tok_fifo = flag_tok_fifo->link) {
if (T_Source == flag_tok_fifo->i) {
atrv = HEAD_PFIFO(rest_node->flag_tok_fifo);
for ( ; atrv != NULL; atrv = atrv->link) {
if ( T_Integer == atrv->type
&& T_Source == atrv->attr) {
s = "source";
break;
}
@@ -967,11 +996,34 @@ dump_config_tree(
fprintf(df, " mask %s",
rest_node->mask->address);
fprintf(df, " ippeerlimit %d", rest_node->ippeerlimit);
flag_tok_fifo = HEAD_PFIFO(rest_node->flag_tok_fifo);
for ( ; flag_tok_fifo != NULL; flag_tok_fifo = flag_tok_fifo->link)
if (T_Source != flag_tok_fifo->i)
fprintf(df, " %s", keyword(flag_tok_fifo->i));
fprintf(df, "\n");
atrv = HEAD_PFIFO(rest_node->flag_tok_fifo);
for ( ; atrv != NULL; atrv = atrv->link) {
if ( T_Integer == atrv->type
&& T_Source != atrv->attr) {
fprintf(df, " %s", keyword(atrv->attr));
}
}
fprintf(df, "\n");
/**/
#if 0
msyslog(LOG_INFO, "Dumping flag_tok_fifo:");
atrv = HEAD_PFIFO(rest_node->flag_tok_fifo);
for ( ; atrv != NULL; atrv = atrv->link) {
msyslog(LOG_INFO, "- flag_tok_fifo: flags: %08x", atrv->flag);
switch(atrv->type) {
case T_Integer:
msyslog(LOG_INFO, "- T_Integer: attr <%s>/%d, value %d",
keyword(atrv->attr), atrv->attr, atrv->value.i);
break;
default:
msyslog(LOG_INFO, "- Other: attr <%s>/%d, value ???",
keyword(atrv->attr), atrv->attr);
break;
}
}
#endif
/**/
}
rule_node = HEAD_PFIFO(ptree->nic_rules);
@@ -1053,7 +1105,6 @@ dump_config_tree(
#endif /* SAVECONFIG */
/* generic fifo routines for structs linked by 1st member */
void *
append_gen_fifo(
@@ -1191,7 +1242,7 @@ create_attr_uval(
attr_val *
create_attr_rangeval(
create_attr_rval(
int attr,
int first,
int last
@@ -1480,8 +1531,8 @@ create_restrict_node(
address_node * addr,
address_node * mask,
short ippeerlimit,
int_fifo * flag_tok_fifo,
int line_no
attr_val_fifo * flag_tok_fifo,
int nline
)
{
restrict_node *my_node;
@@ -1491,7 +1542,7 @@ create_restrict_node(
my_node->mask = mask;
my_node->ippeerlimit = ippeerlimit;
my_node->flag_tok_fifo = flag_tok_fifo;
my_node->line_no = line_no;
my_node->line_no = nline;
return my_node;
}
@@ -1507,7 +1558,7 @@ destroy_restrict_node(
*/
destroy_address_node(my_node->addr);
destroy_address_node(my_node->mask);
destroy_int_fifo(my_node->flag_tok_fifo);
destroy_attr_val_fifo(my_node->flag_tok_fifo);
free(my_node);
}
@@ -2307,7 +2358,7 @@ config_monitor(
/* Set the statistics directory */
if (ptree->stats_dir)
stats_config(STATS_STATSDIR, ptree->stats_dir);
stats_config(STATS_STATSDIR, ptree->stats_dir, 0);
/* NOTE:
* Calling filegen_get is brain dead. Doing a string
@@ -2472,7 +2523,6 @@ config_access(
static int warned_signd;
attr_val * my_opt;
restrict_node * my_node;
int_node * curr_tok_fifo;
sockaddr_u addr;
sockaddr_u mask;
struct addrinfo hints;
@@ -2484,6 +2534,9 @@ config_access(
u_short mflags;
short ippeerlimit;
int range_err;
psl_item my_psl_item;
attr_val * atrv;
attr_val * dflt_psl_atr;
const char * signd_warning =
#ifdef HAVE_NTP_SIGND
"MS-SNTP signd operations currently block ntpd degrading service to all clients.";
@@ -2599,25 +2652,24 @@ config_access(
}
}
/* Configure the restrict options */
/* Configure each line of restrict options */
my_node = HEAD_PFIFO(ptree->restrict_opts);
for (; my_node != NULL; my_node = my_node->link) {
/* Grab the ippeerlmit */
ippeerlimit = my_node->ippeerlimit;
DPRINTF(1, ("config_access: top-level node %p: ippeerlimit %d\n", my_node, ippeerlimit));
/* Parse the flags */
rflags = 0;
mflags = 0;
curr_tok_fifo = HEAD_PFIFO(my_node->flag_tok_fifo);
for (; curr_tok_fifo != NULL; curr_tok_fifo = curr_tok_fifo->link) {
switch (curr_tok_fifo->i) {
my_opt = HEAD_PFIFO(my_node->flag_tok_fifo);
for (; my_opt != NULL; my_opt = my_opt->link) {
switch (my_opt->attr) {
default:
fatal_error("config_access: flag-type-token=%d", curr_tok_fifo->i);
fatal_error("config_access: Unknown flag-type-token=%s/%d", keyword(my_opt->attr), my_opt->attr);
case T_Ntpport:
mflags |= RESM_NTPONLY;
@@ -2639,10 +2691,6 @@ DPRINTF(1, ("config_access: top-level node %p: ippeerlimit %d\n", my_node, ippee
rflags |= RES_KOD;
break;
case T_Mssntp:
rflags |= RES_MSSNTP;
break;
case T_Limited:
rflags |= RES_LIMITED;
break;
@@ -2651,6 +2699,10 @@ DPRINTF(1, ("config_access: top-level node %p: ippeerlimit %d\n", my_node, ippee
rflags |= RES_LPTRAP;
break;
case T_Mssntp:
rflags |= RES_MSSNTP;
break;
case T_Nomodify:
rflags |= RES_NOMODIFY;
break;
@@ -2683,6 +2735,10 @@ DPRINTF(1, ("config_access: top-level node %p: ippeerlimit %d\n", my_node, ippee
rflags |= RES_DONTTRUST;
break;
case T_ServerresponseFuzz:
rflags |= RES_SRVRSPFUZ;
break;
case T_Version:
rflags |= RES_VERSION;
break;
@@ -2822,10 +2878,171 @@ DPRINTF(1, ("config_access: top-level node %p: ippeerlimit %d\n", my_node, ippee
if (ai_list != NULL)
freeaddrinfo(ai_list);
}
/* Deal with the Poll Skew List */
ZERO(psl);
ZERO(my_psl_item);
/*
* First, find the last default pollskewlist item.
* There should only be one of these with the current grammar,
* but better safe than sorry.
*/
dflt_psl_atr = NULL;
atrv = HEAD_PFIFO(ptree->pollskewlist);
for ( ; atrv != NULL; atrv = atrv->link) {
switch (atrv->attr) {
case -1: /* default */
dflt_psl_atr = atrv;
break;
case 3: /* Fall through */
case 4: /* Fall through */
case 5: /* Fall through */
case 6: /* Fall through */
case 7: /* Fall through */
case 8: /* Fall through */
case 9: /* Fall through */
case 10: /* Fall through */
case 11: /* Fall through */
case 12: /* Fall through */
case 13: /* Fall through */
case 14: /* Fall through */
case 15: /* Fall through */
case 16: /* Fall through */
case 17:
/* ignore */
break;
default:
msyslog(LOG_ERR,
"config_access: default PSL scan: ignoring unexpected poll value %d",
atrv->attr);
break;
}
}
/* If we have a nonzero default, initialize the PSL */
if ( dflt_psl_atr
&& ( 0 != dflt_psl_atr->value.r.first
|| 0 != dflt_psl_atr->value.r.last)) {
int i;
for (i = 3; i <= 17; ++i) {
attrtopsl(i, dflt_psl_atr);
}
}
/* Finally, update the PSL with any explicit entries */
atrv = HEAD_PFIFO(ptree->pollskewlist);
for ( ; atrv != NULL; atrv = atrv->link) {
switch (atrv->attr) {
case -1: /* default */
/* Ignore */
break;
case 3: /* Fall through */
case 4: /* Fall through */
case 5: /* Fall through */
case 6: /* Fall through */
case 7: /* Fall through */
case 8: /* Fall through */
case 9: /* Fall through */
case 10: /* Fall through */
case 11: /* Fall through */
case 12: /* Fall through */
case 13: /* Fall through */
case 14: /* Fall through */
case 15: /* Fall through */
case 16: /* Fall through */
case 17:
attrtopsl(atrv->attr, atrv);
break;
default:
break; /* Ignore - we reported this above */
}
}
#if 0
int p;
msyslog(LOG_INFO, "Dumping PSL:");
for (p = 3; p <= 17; ++p) {
psl_item psi;
if (0 == get_pollskew(p, &psi)) {
msyslog(LOG_INFO, "poll %d: sub %d, qty %d, msk %d",
p, psi.sub, psi.qty, psi.msk);
} else {
msyslog(LOG_ERR, "Dumping PSL: get_pollskew(%d) failed!", p);
}
}
#endif
}
void
attrtopsl(int poll, attr_val *avp)
{
DEBUG_INSIST((poll - 3) < sizeof psl);
if (poll < 3 || poll > 17) {
msyslog(LOG_ERR, "attrtopsl(%d, ...): Poll value is out of range - ignoring", poll);
} else {
int pao = poll - 3; /* poll array offset */
int lower = avp->value.r.first; /* a positive number */
int upper = avp->value.r.last;
int psmax = 1 << (poll - 1);
int qmsk;
if (lower > psmax) {
msyslog(LOG_WARNING, "attrtopsl: default: poll %d lower bound reduced from %d to %d",
poll, lower, psmax);
lower = psmax;
}
if (upper > psmax) {
msyslog(LOG_WARNING, "attrtopsl: default: poll %d upper bound reduced from %d to %d",
poll, upper, psmax);
upper = psmax;
}
psl[pao].sub = lower;
psl[pao].qty = lower + upper;
qmsk = 1;
while (qmsk < (lower + upper)) {
qmsk <<= 1;
qmsk |= 1;
};
psl[pao].msk = qmsk;
}
return;
}
#endif /* !SIM */
int
get_pollskew(
int p,
psl_item *rv
)
{
DEBUG_INSIST(3 <= p && 17 >= p);
if (3 <= p && 17 >= p) {
*rv = psl[p - 3];
return 0;
} else {
msyslog(LOG_ERR, "get_pollskew(%d): poll is not between 3 and 17!", p);
return -1;
}
/* NOTREACHED */
}
#ifdef FREE_CFG_T
static void
free_config_access(
@@ -3644,6 +3861,13 @@ config_fudge(
/* Parse all the options to the fudge command */
ZERO(clock_stat);
/* some things are not necessarily cleared by ZERO...*/
clock_stat.fudgeminjitter = 0.0;
clock_stat.fudgetime1 = 0.0;
clock_stat.fudgetime2 = 0.0;
clock_stat.p_lastcode = NULL;
clock_stat.clockdesc = NULL;
clock_stat.kv_list = NULL;
curr_opt = HEAD_PFIFO(curr_fudge->options);
for (; curr_opt != NULL; curr_opt = curr_opt->link) {
switch (curr_opt->attr) {
@@ -3665,10 +3889,9 @@ config_fudge(
case T_Refid:
clock_stat.haveflags |= CLK_HAVEVAL2;
clock_stat.fudgeval2 = 0;
memcpy(&clock_stat.fudgeval2,
curr_opt->value.s,
min(strlen(curr_opt->value.s), 4));
/* strncpy() does exactly what we want here: */
strncpy((char*)&clock_stat.fudgeval2,
curr_opt->value.s, 4);
break;
case T_Flag1:
@@ -3703,6 +3926,11 @@ config_fudge(
clock_stat.flags &= ~CLK_FLAG4;
break;
case T_Minjitter:
clock_stat.haveflags |= CLK_HAVEMINJIT;
clock_stat.fudgeminjitter = curr_opt->value.d;
break;
default:
msyslog(LOG_ERR,
"Unexpected fudge flag %s (%d) for %s",
@@ -3757,7 +3985,7 @@ config_vars(
stats_drift_file = 0;
msyslog(LOG_INFO, "config: driftfile disabled");
} else
stats_config(STATS_FREQ_FILE, curr_var->value.s);
stats_config(STATS_FREQ_FILE, curr_var->value.s, 0);
break;
case T_Dscp:
@@ -3775,7 +4003,7 @@ config_vars(
break;
case T_Leapfile:
stats_config(STATS_LEAP_FILE, curr_var->value.s);
stats_config(STATS_LEAP_FILE, curr_var->value.s, curr_var->flag);
break;
#ifdef LEAP_SMEAR
@@ -3786,7 +4014,7 @@ config_vars(
#endif
case T_Pidfile:
stats_config(STATS_PID_FILE, curr_var->value.s);
stats_config(STATS_PID_FILE, curr_var->value.s, 0);
break;
case T_Logfile:
@@ -3866,9 +4094,9 @@ is_sane_resolved_address(
return 0;
}
/*
* Shouldn't be able to specify multicast
* address for server/peer!
* and unicast address for manycastclient!
* Shouldn't be able to specify:
* - multicast address for server/peer!
* - unicast address for manycastclient!
*/
if ((T_Server == hmode || T_Peer == hmode || T_Pool == hmode)
&& IS_MCAST(peeraddr)) {
@@ -3928,9 +4156,12 @@ peerflag_bits(
{
int peerflags;
attr_val *option;
int hmode;
DEBUG_INSIST(pn);
/* translate peerflags options to bits */
peerflags = 0;
hmode = pn->host_mode;
option = HEAD_PFIFO(pn->peerflags);
for (; option != NULL; option = option->link) {
switch (option->value.i) {
@@ -3969,6 +4200,12 @@ peerflag_bits(
case T_Xleave:
peerflags |= FLAG_XLEAVE;
break;
case T_Xmtnonce:
if ( MODE_CLIENT == hmode ) {
peerflags |= FLAG_LOOPNONCE;
}
break;
}
}
@@ -5278,7 +5515,9 @@ ntp_rlimit(
char *
build_iflags(u_int32 iflags)
build_iflags(
u_int32 iflags
)
{
static char ifs[1024];
@@ -5351,7 +5590,9 @@ build_iflags(u_int32 iflags)
char *
build_mflags(u_short mflags)
build_mflags(
u_short mflags
)
{
static char mfs[1024];
@@ -5379,7 +5620,9 @@ build_mflags(u_short mflags)
char *
build_rflags(u_short rflags)
build_rflags(
u_short rflags
)
{
static char rfs[1024];
@@ -5455,6 +5698,11 @@ build_rflags(u_short rflags)
appendstr(rfs, sizeof rfs, "notrust");
}
if (rflags & RES_SRVRSPFUZ) {
rflags &= ~RES_SRVRSPFUZ;
appendstr(rfs, sizeof rfs, "srvrspfuz");
}
if (rflags & RES_VERSION) {
rflags &= ~RES_VERSION;
appendstr(rfs, sizeof rfs, "version");
+40 -30
View File
@@ -28,6 +28,8 @@
#include "ntp_leapsec.h"
#include "ntp_md5.h" /* provides OpenSSL digest API */
#include "lib_strbuf.h"
#include "timexsup.h"
#include <rc_cmdlength.h>
#ifdef KERNEL_PLL
# include "ntp_syscall.h"
@@ -327,7 +329,8 @@ static const struct ctl_proc control_codes[] = {
#define CC_FLAGS 11
#define CC_DEVICE 12
#define CC_VARLIST 13
#define CC_MAXCODE CC_VARLIST
#define CC_FUDGEMINJIT 14
#define CC_MAXCODE CC_FUDGEMINJIT
/*
* System variable values. The array can be indexed by the variable
@@ -625,7 +628,8 @@ static const struct ctl_var clock_var[] = {
{ CC_FLAGS, RO, "flags" }, /* 11 */
{ CC_DEVICE, RO, "device" }, /* 12 */
{ CC_VARLIST, RO, "clock_var_list" }, /* 13 */
{ 0, EOV, "" } /* 14 */
{ CC_FUDGEMINJIT, RO, "minjitter" }, /* 14 */
{ 0, EOV, "" } /* 15 */
};
@@ -640,6 +644,7 @@ static const u_char def_clock_var[] = {
CC_NOREPLY,
CC_BADFORMAT,
CC_BADDATA,
CC_FUDGEMINJIT,
CC_FUDGETIME1,
CC_FUDGETIME2,
CC_FUDGEVAL1,
@@ -1187,15 +1192,21 @@ process_control(
pkt = (struct ntp_control *)&rbufp->recv_pkt;
/*
* If the length is less than required for the header, or
* it is a response or a fragment, ignore this.
* If the length is less than required for the header,
* ignore it.
*/
if (rbufp->recv_length < (int)CTL_HEADER_LEN
|| (CTL_RESPONSE | CTL_MORE | CTL_ERROR) & pkt->r_m_e_op
if (rbufp->recv_length < (int)CTL_HEADER_LEN) {
DPRINTF(1, ("Short control packet\n"));
numctltooshort++;
return;
}
/*
* If this packet is a response or a fragment, ignore it.
*/
if ( (CTL_RESPONSE | CTL_MORE | CTL_ERROR) & pkt->r_m_e_op
|| pkt->offset != 0) {
DPRINTF(1, ("invalid format in control packet\n"));
if (rbufp->recv_length < (int)CTL_HEADER_LEN)
numctltooshort++;
if (CTL_RESPONSE & pkt->r_m_e_op)
numctlinputresp++;
if (CTL_MORE & pkt->r_m_e_op)
@@ -1206,6 +1217,7 @@ process_control(
numctlbadoffset++;
return;
}
res_version = PKT_VERSION(pkt->li_vn_mode);
if (res_version > NTP_VERSION || res_version < NTP_OLDVERSION) {
DPRINTF(1, ("unknown version %d in control packet\n",
@@ -1910,15 +1922,6 @@ ctl_putsys(
static struct timex ntx;
static u_long ntp_adjtime_time;
static const double to_ms_usec =
1.0e-3; /* usec to msec */
static const double to_ms_nusec =
# ifdef STA_NANO
1.0e-6; /* nsec to msec */
# else
to_ms_usec;
# endif
/*
* CS_K_* variables depend on up-to-date output of ntp_adjtime()
*/
@@ -2321,7 +2324,8 @@ ctl_putsys(
case CS_K_OFFSET:
CTL_IF_KERNLOOP(
ctl_putdblf,
(sys_var[varid].text, 0, -1, to_ms_nusec * ntx.offset)
(sys_var[varid].text, 0, -1,
1000 * dbl_from_var_long(ntx.offset, ntx.status))
);
break;
@@ -2336,7 +2340,7 @@ ctl_putsys(
CTL_IF_KERNLOOP(
ctl_putdblf,
(sys_var[varid].text, 0, 6,
to_ms_usec * ntx.maxerror)
1000 * dbl_from_usec_long(ntx.maxerror))
);
break;
@@ -2344,7 +2348,7 @@ ctl_putsys(
CTL_IF_KERNLOOP(
ctl_putdblf,
(sys_var[varid].text, 0, 6,
to_ms_usec * ntx.esterror)
1000 * dbl_from_usec_long(ntx.esterror))
);
break;
@@ -2368,7 +2372,7 @@ ctl_putsys(
CTL_IF_KERNLOOP(
ctl_putdblf,
(sys_var[varid].text, 0, 6,
to_ms_usec * ntx.precision)
1000 * dbl_from_var_long(ntx.precision, ntx.status))
);
break;
@@ -2396,7 +2400,8 @@ ctl_putsys(
case CS_K_PPS_JITTER:
CTL_IF_KERNPPS(
ctl_putdbl,
(sys_var[varid].text, to_ms_nusec * ntx.jitter)
(sys_var[varid].text,
1000 * dbl_from_var_long(ntx.jitter, ntx.status))
);
break;
@@ -2965,14 +2970,9 @@ ctl_putclock(
break;
case CC_FUDGEVAL2:
if (mustput || (pcs->haveflags & CLK_HAVEVAL2)) {
if (pcs->fudgeval1 > 1)
ctl_putadr(clock_var[id].text,
pcs->fudgeval2, NULL);
else
ctl_putrefid(clock_var[id].text,
pcs->fudgeval2);
}
/* RefID of clocks are always text even if stratum is fudged */
if (mustput || (pcs->haveflags & CLK_HAVEVAL2))
ctl_putrefid(clock_var[id].text, pcs->fudgeval2);
break;
case CC_FLAGS:
@@ -3045,6 +3045,16 @@ ctl_putclock(
*s = '\0';
ctl_putdata(buf, (unsigned)(s - buf), 0);
break;
case CC_FUDGEMINJIT:
if (mustput || (pcs->haveflags & CLK_HAVEMINJIT))
ctl_putdbl(clock_var[id].text,
pcs->fudgeminjitter * 1e3);
break;
default:
break;
}
}
#endif
+46 -32
View File
@@ -177,7 +177,7 @@ endpt * any_interface; /* wildcard ipv4 interface */
endpt * any6_interface; /* wildcard ipv6 interface */
endpt * loopback_interface; /* loopback ipv4 interface */
isc_boolean_t broadcast_client_enabled; /* is broadcast client enabled */
static isc_boolean_t broadcast_client_enabled; /* is broadcast client enabled */
u_int sys_ifnum; /* next .ifnum to assign */
int ninterfaces; /* Total number of interfaces */
@@ -2011,10 +2011,7 @@ update_interfaces(
*/
refresh_all_peerinterfaces();
if (broadcast_client_enabled)
io_setbclient();
if (sys_bclient)
if (broadcast_client_enabled || sys_bclient)
io_setbclient();
#ifdef MCAST
@@ -2343,11 +2340,12 @@ socket_broadcast_disable(
/*
* return the broadcast client flag value
*/
isc_boolean_t
/*isc_boolean_t
get_broadcastclient_flag(void)
{
return (broadcast_client_enabled);
}
*/
/*
* Check to see if the address is a multicast address
@@ -2605,32 +2603,38 @@ void
io_setbclient(void)
{
#ifdef OPEN_BCAST_SOCKET
struct interface * interf;
unsigned int nif;
endpt * ep;
unsigned int nif, ni4, ni6;
nif = 0;
nif = ni4 = ni6 = 0;
set_reuseaddr(1);
for (interf = ep_list;
interf != NULL;
interf = interf->elink) {
if (interf->flags & (INT_WILDCARD | INT_LOOPBACK))
for (ep = ep_list; ep != NULL; ep = ep->elink) {
/* count IPv6 vs IPv4 interfaces. Needed later to decide
* if we should log an error or not.
*/
switch (ep->family) {
case AF_INET : ++ni4; break;
case AF_INET6: ++ni6; break;
default : break;
}
if (ep->flags & (INT_WILDCARD | INT_LOOPBACK))
continue;
/* use only allowed addresses */
if (interf->ignore_packets)
if (ep->ignore_packets)
continue;
/* Need a broadcast-capable interface */
if (!(interf->flags & INT_BROADCAST))
if (!(ep->flags & INT_BROADCAST))
continue;
/* Only IPv4 addresses are valid for broadcast */
REQUIRE(IS_IPV4(&interf->bcast));
REQUIRE(IS_IPV4(&ep->bcast));
/* Do we already have the broadcast address open? */
if (interf->flags & INT_BCASTOPEN) {
if (ep->flags & INT_BCASTOPEN) {
/*
* account for already open interfaces to avoid
* misleading warning below
@@ -2642,19 +2646,19 @@ io_setbclient(void)
/*
* Try to open the broadcast address
*/
interf->family = AF_INET;
interf->bfd = open_socket(&interf->bcast, 1, 0, interf);
ep->family = AF_INET;
ep->bfd = open_socket(&ep->bcast, 1, 0, ep);
/*
* If we succeeded then we use it otherwise enable
* broadcast on the interface address
*/
if (interf->bfd != INVALID_SOCKET) {
if (ep->bfd != INVALID_SOCKET) {
nif++;
interf->flags |= INT_BCASTOPEN;
ep->flags |= INT_BCASTOPEN;
msyslog(LOG_INFO,
"Listen for broadcasts to %s on interface #%d %s",
stoa(&interf->bcast), interf->ifnum, interf->name);
stoa(&ep->bcast), ep->ifnum, ep->name);
} else switch (errno) {
/* Silently ignore EADDRINUSE as we probably
* opened the socket already for an address in
@@ -2668,8 +2672,8 @@ io_setbclient(void)
* regular socket, it's quite useless to try this
* again.
*/
if (interf->fd != INVALID_SOCKET) {
interf->flags |= INT_BCASTOPEN;
if (ep->fd != INVALID_SOCKET) {
ep->flags |= INT_BCASTOPEN;
nif++;
}
# endif
@@ -2678,7 +2682,7 @@ io_setbclient(void)
default:
msyslog(LOG_INFO,
"failed to listen for broadcasts to %s on interface #%d %s",
stoa(&interf->bcast), interf->ifnum, interf->name);
stoa(&ep->bcast), ep->ifnum, ep->name);
break;
}
}
@@ -2688,8 +2692,14 @@ io_setbclient(void)
DPRINTF(1, ("io_setbclient: listening to %d broadcast addresses\n", nif));
} else {
broadcast_client_enabled = ISC_FALSE;
msyslog(LOG_ERR,
"Unable to listen for broadcasts, no broadcast interfaces available");
/* This is expected when having only IPv6 interfaces
* and no IPv4 interfaces at all. We suppress the error
* log in that case... everything else should work!
*/
if (ni4 && !ni6) {
msyslog(LOG_ERR,
"Unable to listen for broadcasts, no broadcast interfaces available");
}
}
#else
msyslog(LOG_ERR,
@@ -3134,7 +3144,8 @@ sendpkt(
int rc;
u_char cttl;
l_fp fp_zero = { { 0 }, 0 };
l_fp org, rec, xmt;
ismcast = IS_MCAST(dest);
if (!ismcast)
src = ep;
@@ -3219,11 +3230,14 @@ sendpkt(
} while (ismcast && src != NULL);
/* HMS: pkt->rootdisp is usually random here */
NTOHL_FP(&pkt->org, &org);
NTOHL_FP(&pkt->rec, &rec);
NTOHL_FP(&pkt->xmt, &xmt);
record_raw_stats(src ? &src->sin : NULL, dest,
&pkt->org, &pkt->rec, &pkt->xmt, &fp_zero,
PKT_MODE(pkt->li_vn_mode),
PKT_VERSION(pkt->li_vn_mode),
&org, &rec, &xmt, &fp_zero,
PKT_LEAP(pkt->li_vn_mode),
PKT_VERSION(pkt->li_vn_mode),
PKT_MODE(pkt->li_vn_mode),
pkt->stratum,
pkt->ppoll, pkt->precision,
pkt->rootdelay, pkt->rootdisp, pkt->refid,
File diff suppressed because it is too large. Load diff
+36 -33
View File
@@ -422,7 +422,8 @@ int/*BOOL*/
leapsec_load_stream(
FILE * ifp ,
const char * fname,
int/*BOOL*/ logall)
int/*BOOL*/ logall,
int/*BOOL*/ vhash)
{
leap_table_t *pt;
int rcheck;
@@ -430,36 +431,37 @@ leapsec_load_stream(
if (NULL == fname)
fname = "<unknown>";
rcheck = leapsec_validate((leapsec_reader)getc, ifp);
if (logall)
switch (rcheck)
{
case LSVALID_GOODHASH:
msyslog(LOG_NOTICE, "%s ('%s'): good hash signature",
logPrefix, fname);
break;
case LSVALID_NOHASH:
msyslog(LOG_ERR, "%s ('%s'): no hash signature",
logPrefix, fname);
break;
case LSVALID_BADHASH:
msyslog(LOG_ERR, "%s ('%s'): signature mismatch",
logPrefix, fname);
break;
case LSVALID_BADFORMAT:
msyslog(LOG_ERR, "%s ('%s'): malformed hash signature",
logPrefix, fname);
break;
default:
msyslog(LOG_ERR, "%s ('%s'): unknown error code %d",
logPrefix, fname, rcheck);
break;
}
if (rcheck < 0)
return FALSE;
rewind(ifp);
if (vhash) {
rcheck = leapsec_validate((leapsec_reader)getc, ifp);
if (logall)
switch (rcheck)
{
case LSVALID_GOODHASH:
msyslog(LOG_NOTICE, "%s ('%s'): good hash signature",
logPrefix, fname);
break;
case LSVALID_NOHASH:
msyslog(LOG_ERR, "%s ('%s'): no hash signature",
logPrefix, fname);
break;
case LSVALID_BADHASH:
msyslog(LOG_ERR, "%s ('%s'): signature mismatch",
logPrefix, fname);
break;
case LSVALID_BADFORMAT:
msyslog(LOG_ERR, "%s ('%s'): malformed hash signature",
logPrefix, fname);
break;
default:
msyslog(LOG_ERR, "%s ('%s'): unknown error code %d",
logPrefix, fname, rcheck);
break;
}
if (rcheck < 0)
return FALSE;
rewind(ifp);
}
pt = leapsec_get_table(TRUE);
if (!leapsec_load(pt, (leapsec_reader)getc, ifp, TRUE)) {
switch (errno) {
@@ -498,7 +500,8 @@ leapsec_load_file(
const char * fname,
struct stat * sb_old,
int/*BOOL*/ force,
int/*BOOL*/ logall)
int/*BOOL*/ logall,
int/*BOOL*/ vhash)
{
FILE * fp;
struct stat sb_new;
@@ -551,7 +554,7 @@ leapsec_load_file(
return FALSE;
}
rc = leapsec_load_stream(fp, fname, logall);
rc = leapsec_load_stream(fp, fname, logall, vhash);
fclose(fp);
return rc;
}
+3 -2
View File
@@ -174,7 +174,7 @@ extern void leapsec_dump(const leap_table_t*, leapsec_dumper func, void *farg);
* around the generic load function, 'leapsec_load()'.
*/
extern int/*BOOL*/ leapsec_load_stream(FILE * fp, const char * fname,
int/*BOOL*/logall);
int/*BOOL*/logall, int/*BOOL*/vhash);
/* Read a leap second file from file. It checks that the file exists and
* (if 'force' is not applied) the ctime/mtime has changed since the
@@ -184,7 +184,8 @@ extern int/*BOOL*/ leapsec_load_stream(FILE * fp, const char * fname,
* otherwise. Uses 'leapsec_load_stream()' internally.
*/
extern int/*BOOL*/ leapsec_load_file(const char * fname, struct stat * sb,
int/*BOOL*/force, int/*BOOL*/logall);
int/*BOOL*/force, int/*BOOL*/logall,
int/*BOOL*/vhash);
/* Get the current leap data signature. This consists of the last
* ransition, the table expiration, and the total TAI difference at the
+41 -35
View File
@@ -15,6 +15,7 @@
#include "ntp_io.h"
#include "ntp_unixtime.h"
#include "ntp_stdlib.h"
#include "timexsup.h"
#include <limits.h>
#include <stdio.h>
@@ -167,6 +168,9 @@ u_char sys_poll; /* time constant/poll (log2 s) */
int tc_counter; /* jiggle counter */
double last_offset; /* last offset (s) */
u_int tc_twinlo; /* TC step down not before this time */
u_int tc_twinhi; /* TC step up not before this time */
/*
* Huff-n'-puff filter variables
*/
@@ -761,30 +765,21 @@ local_clock(
if (ext_enable) {
ntv.modes = MOD_STATUS;
} else {
#ifdef STA_NANO
ntv.modes = MOD_BITS | MOD_NANO;
#else /* STA_NANO */
ntv.modes = MOD_BITS;
#endif /* STA_NANO */
if (clock_offset < 0)
dtemp = -.5;
else
dtemp = .5;
ntv.offset = var_long_from_dbl(
clock_offset, &ntv.modes);
#ifdef STA_NANO
ntv.offset = (int32)(clock_offset * 1e9 +
dtemp);
ntv.constant = sys_poll;
#else /* STA_NANO */
ntv.offset = (int32)(clock_offset * 1e6 +
dtemp);
ntv.constant = sys_poll - 4;
#endif /* STA_NANO */
if (ntv.constant < 0)
ntv.constant = 0;
ntv.esterror = (u_int32)(clock_jitter * 1e6);
ntv.maxerror = (u_int32)((sys_rootdelay / 2 +
sys_rootdisp) * 1e6);
ntv.esterror = usec_long_from_dbl(
clock_jitter);
ntv.maxerror = usec_long_from_dbl(
sys_rootdelay / 2 + sys_rootdisp);
ntv.status = STA_PLL;
/*
@@ -823,22 +818,15 @@ local_clock(
ntp_adjtime_error_handler(__func__, &ntv, ntp_adj_ret, errno, hardpps_enable, 0, __LINE__ - 1);
}
pll_status = ntv.status;
#ifdef STA_NANO
clock_offset = ntv.offset / 1e9;
#else /* STA_NANO */
clock_offset = ntv.offset / 1e6;
#endif /* STA_NANO */
clock_offset = dbl_from_var_long(ntv.offset, ntv.status);
clock_frequency = FREQTOD(ntv.freq);
/*
* If the kernel PPS is lit, monitor its performance.
*/
if (ntv.status & STA_PPSTIME) {
#ifdef STA_NANO
clock_jitter = ntv.jitter / 1e9;
#else /* STA_NANO */
clock_jitter = ntv.jitter / 1e6;
#endif /* STA_NANO */
clock_jitter = dbl_from_var_long(
ntv.jitter, ntv.status);
}
#if defined(STA_NANO) && NTP_API == 4
@@ -888,34 +876,52 @@ local_clock(
* increased, otherwise it is decreased. A bit of hysteresis
* helps calm the dance. Works best using burst mode. Don't
* fiddle with the poll during the startup clamp period.
* [Bug 3615] also observe time gates to avoid eager stepping
*/
if (freq_cnt > 0) {
tc_counter = 0;
tc_twinlo = current_time;
tc_twinhi = current_time;
} else if (fabs(clock_offset) < CLOCK_PGATE * clock_jitter) {
tc_counter += sys_poll;
if (tc_counter > CLOCK_LIMIT) {
tc_counter = CLOCK_LIMIT;
if (sys_poll < peer->maxpoll) {
tc_counter = 0;
sys_poll++;
}
if (sys_poll < peer->maxpoll)
sys_poll += (current_time >= tc_twinhi);
}
} else {
tc_counter -= sys_poll << 1;
if (tc_counter < -CLOCK_LIMIT) {
tc_counter = -CLOCK_LIMIT;
if (sys_poll > peer->minpoll) {
tc_counter = 0;
sys_poll--;
}
if (sys_poll > peer->minpoll)
sys_poll -= (current_time >= tc_twinlo);
}
}
/*
* If the time constant has changed, update the poll variables.
*
* [bug 3615] also set new time gates
* The time limit for stepping down will be half the TC interval
* or 60 secs from now, whatever is bigger, and the step up time
* limit will be half the TC interval after the step down limit.
*
* The 'sys_poll' value affects the servo loop gain, and
* overshooting sys_poll slows it down unnecessarily. Stepping
* down too fast also has bad effects.
*
* The 'tc_counter' dance itself is something that *should*
* happen *once* every (1 << sys_poll) seconds, I think, but
* that's not how it works right now, and adding time guards
* seems the least intrusive way to handle this.
*/
if (osys_poll != sys_poll)
poll_update(peer, sys_poll);
if (osys_poll != sys_poll) {
u_int deadband = 1u << (sys_poll - 1);
tc_counter = 0;
tc_twinlo = current_time + max(deadband, 60);
tc_twinhi = tc_twinlo + deadband;
poll_update(peer, sys_poll, 0);
}
/*
* Yibbidy, yibbbidy, yibbidy; that'h all folks.
+1498 -1346
View File
File diff suppressed because it is too large. Load diff
+385 -367
View File
@@ -30,8 +30,8 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_YY_NTP_PARSER_H_INCLUDED
# define YY_YY_NTP_PARSER_H_INCLUDED
#ifndef YY_YY__NTPD_NTP_PARSER_H_INCLUDED
# define YY_YY__NTPD_NTP_PARSER_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
@@ -64,187 +64,196 @@ extern int yydebug;
T_Burst = 274,
T_Calibrate = 275,
T_Ceiling = 276,
T_Clockstats = 277,
T_Cohort = 278,
T_ControlKey = 279,
T_Crypto = 280,
T_Cryptostats = 281,
T_Ctl = 282,
T_Day = 283,
T_Default = 284,
T_Digest = 285,
T_Disable = 286,
T_Discard = 287,
T_Dispersion = 288,
T_Double = 289,
T_Driftfile = 290,
T_Drop = 291,
T_Dscp = 292,
T_Ellipsis = 293,
T_Enable = 294,
T_End = 295,
T_Epeer = 296,
T_False = 297,
T_File = 298,
T_Filegen = 299,
T_Filenum = 300,
T_Flag1 = 301,
T_Flag2 = 302,
T_Flag3 = 303,
T_Flag4 = 304,
T_Flake = 305,
T_Floor = 306,
T_Freq = 307,
T_Fudge = 308,
T_Host = 309,
T_Huffpuff = 310,
T_Iburst = 311,
T_Ident = 312,
T_Ignore = 313,
T_Incalloc = 314,
T_Incmem = 315,
T_Initalloc = 316,
T_Initmem = 317,
T_Includefile = 318,
T_Integer = 319,
T_Interface = 320,
T_Intrange = 321,
T_Io = 322,
T_Ippeerlimit = 323,
T_Ipv4 = 324,
T_Ipv4_flag = 325,
T_Ipv6 = 326,
T_Ipv6_flag = 327,
T_Kernel = 328,
T_Key = 329,
T_Keys = 330,
T_Keysdir = 331,
T_Kod = 332,
T_Mssntp = 333,
T_Leapfile = 334,
T_Leapsmearinterval = 335,
T_Limited = 336,
T_Link = 337,
T_Listen = 338,
T_Logconfig = 339,
T_Logfile = 340,
T_Loopstats = 341,
T_Lowpriotrap = 342,
T_Manycastclient = 343,
T_Manycastserver = 344,
T_Mask = 345,
T_Maxage = 346,
T_Maxclock = 347,
T_Maxdepth = 348,
T_Maxdist = 349,
T_Maxmem = 350,
T_Maxpoll = 351,
T_Mdnstries = 352,
T_Mem = 353,
T_Memlock = 354,
T_Minclock = 355,
T_Mindepth = 356,
T_Mindist = 357,
T_Minimum = 358,
T_Minpoll = 359,
T_Minsane = 360,
T_Mode = 361,
T_Mode7 = 362,
T_Monitor = 363,
T_Month = 364,
T_Mru = 365,
T_Multicastclient = 366,
T_Nic = 367,
T_Nolink = 368,
T_Nomodify = 369,
T_Nomrulist = 370,
T_None = 371,
T_Nonvolatile = 372,
T_Noepeer = 373,
T_Nopeer = 374,
T_Noquery = 375,
T_Noselect = 376,
T_Noserve = 377,
T_Notrap = 378,
T_Notrust = 379,
T_Ntp = 380,
T_Ntpport = 381,
T_NtpSignDsocket = 382,
T_Orphan = 383,
T_Orphanwait = 384,
T_PCEdigest = 385,
T_Panic = 386,
T_Peer = 387,
T_Peerstats = 388,
T_Phone = 389,
T_Pid = 390,
T_Pidfile = 391,
T_Pool = 392,
T_Port = 393,
T_Preempt = 394,
T_Prefer = 395,
T_Protostats = 396,
T_Pw = 397,
T_Randfile = 398,
T_Rawstats = 399,
T_Refid = 400,
T_Requestkey = 401,
T_Reset = 402,
T_Restrict = 403,
T_Revoke = 404,
T_Rlimit = 405,
T_Saveconfigdir = 406,
T_Server = 407,
T_Setvar = 408,
T_Source = 409,
T_Stacksize = 410,
T_Statistics = 411,
T_Stats = 412,
T_Statsdir = 413,
T_Step = 414,
T_Stepback = 415,
T_Stepfwd = 416,
T_Stepout = 417,
T_Stratum = 418,
T_String = 419,
T_Sys = 420,
T_Sysstats = 421,
T_Tick = 422,
T_Time1 = 423,
T_Time2 = 424,
T_Timer = 425,
T_Timingstats = 426,
T_Tinker = 427,
T_Tos = 428,
T_Trap = 429,
T_True = 430,
T_Trustedkey = 431,
T_Ttl = 432,
T_Type = 433,
T_U_int = 434,
T_UEcrypto = 435,
T_UEcryptonak = 436,
T_UEdigest = 437,
T_Unconfig = 438,
T_Unpeer = 439,
T_Version = 440,
T_WanderThreshold = 441,
T_Week = 442,
T_Wildcard = 443,
T_Xleave = 444,
T_Year = 445,
T_Flag = 446,
T_EOC = 447,
T_Simulate = 448,
T_Beep_Delay = 449,
T_Sim_Duration = 450,
T_Server_Offset = 451,
T_Duration = 452,
T_Freq_Offset = 453,
T_Wander = 454,
T_Jitter = 455,
T_Prop_Delay = 456,
T_Proc_Delay = 457
T_Checkhash = 277,
T_Clockstats = 278,
T_Cohort = 279,
T_ControlKey = 280,
T_Crypto = 281,
T_Cryptostats = 282,
T_Ctl = 283,
T_Day = 284,
T_Default = 285,
T_Digest = 286,
T_Disable = 287,
T_Discard = 288,
T_Dispersion = 289,
T_Double = 290,
T_Driftfile = 291,
T_Drop = 292,
T_Dscp = 293,
T_Ellipsis = 294,
T_Enable = 295,
T_End = 296,
T_Epeer = 297,
T_False = 298,
T_File = 299,
T_Filegen = 300,
T_Filenum = 301,
T_Flag1 = 302,
T_Flag2 = 303,
T_Flag3 = 304,
T_Flag4 = 305,
T_Flake = 306,
T_Floor = 307,
T_Freq = 308,
T_Fudge = 309,
T_Fuzz = 310,
T_Host = 311,
T_Huffpuff = 312,
T_Iburst = 313,
T_Ident = 314,
T_Ignore = 315,
T_Ignorehash = 316,
T_Incalloc = 317,
T_Incmem = 318,
T_Initalloc = 319,
T_Initmem = 320,
T_Includefile = 321,
T_Integer = 322,
T_Interface = 323,
T_Intrange = 324,
T_Io = 325,
T_Ippeerlimit = 326,
T_Ipv4 = 327,
T_Ipv4_flag = 328,
T_Ipv6 = 329,
T_Ipv6_flag = 330,
T_Kernel = 331,
T_Key = 332,
T_Keys = 333,
T_Keysdir = 334,
T_Kod = 335,
T_Leapfile = 336,
T_Leapsmearinterval = 337,
T_Limited = 338,
T_Link = 339,
T_Listen = 340,
T_Logconfig = 341,
T_Logfile = 342,
T_Loopstats = 343,
T_Lowpriotrap = 344,
T_Manycastclient = 345,
T_Manycastserver = 346,
T_Mask = 347,
T_Maxage = 348,
T_Maxclock = 349,
T_Maxdepth = 350,
T_Maxdist = 351,
T_Maxmem = 352,
T_Maxpoll = 353,
T_Mdnstries = 354,
T_Mem = 355,
T_Memlock = 356,
T_Minclock = 357,
T_Mindepth = 358,
T_Mindist = 359,
T_Minimum = 360,
T_Minjitter = 361,
T_Minpoll = 362,
T_Minsane = 363,
T_Mode = 364,
T_Mode7 = 365,
T_Monitor = 366,
T_Month = 367,
T_Mru = 368,
T_Mssntp = 369,
T_Multicastclient = 370,
T_Nic = 371,
T_Nolink = 372,
T_Nomodify = 373,
T_Nomrulist = 374,
T_None = 375,
T_Nonvolatile = 376,
T_Noepeer = 377,
T_Nopeer = 378,
T_Noquery = 379,
T_Noselect = 380,
T_Noserve = 381,
T_Notrap = 382,
T_Notrust = 383,
T_Ntp = 384,
T_Ntpport = 385,
T_NtpSignDsocket = 386,
T_Orphan = 387,
T_Orphanwait = 388,
T_PCEdigest = 389,
T_Panic = 390,
T_Peer = 391,
T_Peerstats = 392,
T_Phone = 393,
T_Pid = 394,
T_Pidfile = 395,
T_Poll = 396,
T_PollSkewList = 397,
T_Pool = 398,
T_Port = 399,
T_Preempt = 400,
T_Prefer = 401,
T_Protostats = 402,
T_Pw = 403,
T_Randfile = 404,
T_Rawstats = 405,
T_Refid = 406,
T_Requestkey = 407,
T_Reset = 408,
T_Restrict = 409,
T_Revoke = 410,
T_Rlimit = 411,
T_Saveconfigdir = 412,
T_Server = 413,
T_Serverresponse = 414,
T_ServerresponseFuzz = 415,
T_Setvar = 416,
T_Source = 417,
T_Stacksize = 418,
T_Statistics = 419,
T_Stats = 420,
T_Statsdir = 421,
T_Step = 422,
T_Stepback = 423,
T_Stepfwd = 424,
T_Stepout = 425,
T_Stratum = 426,
T_String = 427,
T_Sys = 428,
T_Sysstats = 429,
T_Tick = 430,
T_Time1 = 431,
T_Time2 = 432,
T_Timer = 433,
T_Timingstats = 434,
T_Tinker = 435,
T_Tos = 436,
T_Trap = 437,
T_True = 438,
T_Trustedkey = 439,
T_Ttl = 440,
T_Type = 441,
T_U_int = 442,
T_UEcrypto = 443,
T_UEcryptonak = 444,
T_UEdigest = 445,
T_Unconfig = 446,
T_Unpeer = 447,
T_Version = 448,
T_WanderThreshold = 449,
T_Week = 450,
T_Wildcard = 451,
T_Xleave = 452,
T_Xmtnonce = 453,
T_Year = 454,
T_Flag = 455,
T_EOC = 456,
T_Simulate = 457,
T_Beep_Delay = 458,
T_Sim_Duration = 459,
T_Server_Offset = 460,
T_Duration = 461,
T_Freq_Offset = 462,
T_Wander = 463,
T_Jitter = 464,
T_Prop_Delay = 465,
T_Proc_Delay = 466
};
#endif
/* Tokens. */
@@ -267,194 +276,203 @@ extern int yydebug;
#define T_Burst 274
#define T_Calibrate 275
#define T_Ceiling 276
#define T_Clockstats 277
#define T_Cohort 278
#define T_ControlKey 279
#define T_Crypto 280
#define T_Cryptostats 281
#define T_Ctl 282
#define T_Day 283
#define T_Default 284
#define T_Digest 285
#define T_Disable 286
#define T_Discard 287
#define T_Dispersion 288
#define T_Double 289
#define T_Driftfile 290
#define T_Drop 291
#define T_Dscp 292
#define T_Ellipsis 293
#define T_Enable 294
#define T_End 295
#define T_Epeer 296
#define T_False 297
#define T_File 298
#define T_Filegen 299
#define T_Filenum 300
#define T_Flag1 301
#define T_Flag2 302
#define T_Flag3 303
#define T_Flag4 304
#define T_Flake 305
#define T_Floor 306
#define T_Freq 307
#define T_Fudge 308
#define T_Host 309
#define T_Huffpuff 310
#define T_Iburst 311
#define T_Ident 312
#define T_Ignore 313
#define T_Incalloc 314
#define T_Incmem 315
#define T_Initalloc 316
#define T_Initmem 317
#define T_Includefile 318
#define T_Integer 319
#define T_Interface 320
#define T_Intrange 321
#define T_Io 322
#define T_Ippeerlimit 323
#define T_Ipv4 324
#define T_Ipv4_flag 325
#define T_Ipv6 326
#define T_Ipv6_flag 327
#define T_Kernel 328
#define T_Key 329
#define T_Keys 330
#define T_Keysdir 331
#define T_Kod 332
#define T_Mssntp 333
#define T_Leapfile 334
#define T_Leapsmearinterval 335
#define T_Limited 336
#define T_Link 337
#define T_Listen 338
#define T_Logconfig 339
#define T_Logfile 340
#define T_Loopstats 341
#define T_Lowpriotrap 342
#define T_Manycastclient 343
#define T_Manycastserver 344
#define T_Mask 345
#define T_Maxage 346
#define T_Maxclock 347
#define T_Maxdepth 348
#define T_Maxdist 349
#define T_Maxmem 350
#define T_Maxpoll 351
#define T_Mdnstries 352
#define T_Mem 353
#define T_Memlock 354
#define T_Minclock 355
#define T_Mindepth 356
#define T_Mindist 357
#define T_Minimum 358
#define T_Minpoll 359
#define T_Minsane 360
#define T_Mode 361
#define T_Mode7 362
#define T_Monitor 363
#define T_Month 364
#define T_Mru 365
#define T_Multicastclient 366
#define T_Nic 367
#define T_Nolink 368
#define T_Nomodify 369
#define T_Nomrulist 370
#define T_None 371
#define T_Nonvolatile 372
#define T_Noepeer 373
#define T_Nopeer 374
#define T_Noquery 375
#define T_Noselect 376
#define T_Noserve 377
#define T_Notrap 378
#define T_Notrust 379
#define T_Ntp 380
#define T_Ntpport 381
#define T_NtpSignDsocket 382
#define T_Orphan 383
#define T_Orphanwait 384
#define T_PCEdigest 385
#define T_Panic 386
#define T_Peer 387
#define T_Peerstats 388
#define T_Phone 389
#define T_Pid 390
#define T_Pidfile 391
#define T_Pool 392
#define T_Port 393
#define T_Preempt 394
#define T_Prefer 395
#define T_Protostats 396
#define T_Pw 397
#define T_Randfile 398
#define T_Rawstats 399
#define T_Refid 400
#define T_Requestkey 401
#define T_Reset 402
#define T_Restrict 403
#define T_Revoke 404
#define T_Rlimit 405
#define T_Saveconfigdir 406
#define T_Server 407
#define T_Setvar 408
#define T_Source 409
#define T_Stacksize 410
#define T_Statistics 411
#define T_Stats 412
#define T_Statsdir 413
#define T_Step 414
#define T_Stepback 415
#define T_Stepfwd 416
#define T_Stepout 417
#define T_Stratum 418
#define T_String 419
#define T_Sys 420
#define T_Sysstats 421
#define T_Tick 422
#define T_Time1 423
#define T_Time2 424
#define T_Timer 425
#define T_Timingstats 426
#define T_Tinker 427
#define T_Tos 428
#define T_Trap 429
#define T_True 430
#define T_Trustedkey 431
#define T_Ttl 432
#define T_Type 433
#define T_U_int 434
#define T_UEcrypto 435
#define T_UEcryptonak 436
#define T_UEdigest 437
#define T_Unconfig 438
#define T_Unpeer 439
#define T_Version 440
#define T_WanderThreshold 441
#define T_Week 442
#define T_Wildcard 443
#define T_Xleave 444
#define T_Year 445
#define T_Flag 446
#define T_EOC 447
#define T_Simulate 448
#define T_Beep_Delay 449
#define T_Sim_Duration 450
#define T_Server_Offset 451
#define T_Duration 452
#define T_Freq_Offset 453
#define T_Wander 454
#define T_Jitter 455
#define T_Prop_Delay 456
#define T_Proc_Delay 457
#define T_Checkhash 277
#define T_Clockstats 278
#define T_Cohort 279
#define T_ControlKey 280
#define T_Crypto 281
#define T_Cryptostats 282
#define T_Ctl 283
#define T_Day 284
#define T_Default 285
#define T_Digest 286
#define T_Disable 287
#define T_Discard 288
#define T_Dispersion 289
#define T_Double 290
#define T_Driftfile 291
#define T_Drop 292
#define T_Dscp 293
#define T_Ellipsis 294
#define T_Enable 295
#define T_End 296
#define T_Epeer 297
#define T_False 298
#define T_File 299
#define T_Filegen 300
#define T_Filenum 301
#define T_Flag1 302
#define T_Flag2 303
#define T_Flag3 304
#define T_Flag4 305
#define T_Flake 306
#define T_Floor 307
#define T_Freq 308
#define T_Fudge 309
#define T_Fuzz 310
#define T_Host 311
#define T_Huffpuff 312
#define T_Iburst 313
#define T_Ident 314
#define T_Ignore 315
#define T_Ignorehash 316
#define T_Incalloc 317
#define T_Incmem 318
#define T_Initalloc 319
#define T_Initmem 320
#define T_Includefile 321
#define T_Integer 322
#define T_Interface 323
#define T_Intrange 324
#define T_Io 325
#define T_Ippeerlimit 326
#define T_Ipv4 327
#define T_Ipv4_flag 328
#define T_Ipv6 329
#define T_Ipv6_flag 330
#define T_Kernel 331
#define T_Key 332
#define T_Keys 333
#define T_Keysdir 334
#define T_Kod 335
#define T_Leapfile 336
#define T_Leapsmearinterval 337
#define T_Limited 338
#define T_Link 339
#define T_Listen 340
#define T_Logconfig 341
#define T_Logfile 342
#define T_Loopstats 343
#define T_Lowpriotrap 344
#define T_Manycastclient 345
#define T_Manycastserver 346
#define T_Mask 347
#define T_Maxage 348
#define T_Maxclock 349
#define T_Maxdepth 350
#define T_Maxdist 351
#define T_Maxmem 352
#define T_Maxpoll 353
#define T_Mdnstries 354
#define T_Mem 355
#define T_Memlock 356
#define T_Minclock 357
#define T_Mindepth 358
#define T_Mindist 359
#define T_Minimum 360
#define T_Minjitter 361
#define T_Minpoll 362
#define T_Minsane 363
#define T_Mode 364
#define T_Mode7 365
#define T_Monitor 366
#define T_Month 367
#define T_Mru 368
#define T_Mssntp 369
#define T_Multicastclient 370
#define T_Nic 371
#define T_Nolink 372
#define T_Nomodify 373
#define T_Nomrulist 374
#define T_None 375
#define T_Nonvolatile 376
#define T_Noepeer 377
#define T_Nopeer 378
#define T_Noquery 379
#define T_Noselect 380
#define T_Noserve 381
#define T_Notrap 382
#define T_Notrust 383
#define T_Ntp 384
#define T_Ntpport 385
#define T_NtpSignDsocket 386
#define T_Orphan 387
#define T_Orphanwait 388
#define T_PCEdigest 389
#define T_Panic 390
#define T_Peer 391
#define T_Peerstats 392
#define T_Phone 393
#define T_Pid 394
#define T_Pidfile 395
#define T_Poll 396
#define T_PollSkewList 397
#define T_Pool 398
#define T_Port 399
#define T_Preempt 400
#define T_Prefer 401
#define T_Protostats 402
#define T_Pw 403
#define T_Randfile 404
#define T_Rawstats 405
#define T_Refid 406
#define T_Requestkey 407
#define T_Reset 408
#define T_Restrict 409
#define T_Revoke 410
#define T_Rlimit 411
#define T_Saveconfigdir 412
#define T_Server 413
#define T_Serverresponse 414
#define T_ServerresponseFuzz 415
#define T_Setvar 416
#define T_Source 417
#define T_Stacksize 418
#define T_Statistics 419
#define T_Stats 420
#define T_Statsdir 421
#define T_Step 422
#define T_Stepback 423
#define T_Stepfwd 424
#define T_Stepout 425
#define T_Stratum 426
#define T_String 427
#define T_Sys 428
#define T_Sysstats 429
#define T_Tick 430
#define T_Time1 431
#define T_Time2 432
#define T_Timer 433
#define T_Timingstats 434
#define T_Tinker 435
#define T_Tos 436
#define T_Trap 437
#define T_True 438
#define T_Trustedkey 439
#define T_Ttl 440
#define T_Type 441
#define T_U_int 442
#define T_UEcrypto 443
#define T_UEcryptonak 444
#define T_UEdigest 445
#define T_Unconfig 446
#define T_Unpeer 447
#define T_Version 448
#define T_WanderThreshold 449
#define T_Week 450
#define T_Wildcard 451
#define T_Xleave 452
#define T_Xmtnonce 453
#define T_Year 454
#define T_Flag 455
#define T_EOC 456
#define T_Simulate 457
#define T_Beep_Delay 458
#define T_Sim_Duration 459
#define T_Server_Offset 460
#define T_Duration 461
#define T_Freq_Offset 462
#define T_Wander 463
#define T_Jitter 464
#define T_Prop_Delay 465
#define T_Proc_Delay 466
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 52 "ntp_parser.y" /* yacc.c:1909 */
#line 52 "../../ntpd/ntp_parser.y" /* yacc.c:1909 */
char * String;
double Double;
@@ -473,7 +491,7 @@ union YYSTYPE
script_info * Sim_script;
script_info_fifo * Sim_script_fifo;
#line 477 "ntp_parser.h" /* yacc.c:1909 */
#line 495 "../../ntpd/ntp_parser.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;
@@ -486,4 +504,4 @@ extern YYSTYPE yylval;
int yyparse (void);
#endif /* !YY_YY_NTP_PARSER_H_INCLUDED */
#endif /* !YY_YY__NTPD_NTP_PARSER_H_INCLUDED */
+2
View File
@@ -844,11 +844,13 @@ newpeer(
return NULL;
}
#if 0
DPRINTF(1, ("newpeer(%s) found no existing and %d other associations\n",
(hostname)
? hostname
: stoa(srcadr),
ip_count));
#endif
/* Check ippeerlimit wrt ip_count */
if (ippeerlimit > -1) {
+252 -54
View File
@@ -15,6 +15,7 @@
#include "ntp_control.h"
#include "ntp_string.h"
#include "ntp_leapsec.h"
#include "ntp_psl.h"
#include "refidsmear.h"
#include "lib_strbuf.h"
@@ -31,6 +32,13 @@
# define BDELAY_DEFAULT (-0.050)
#endif
#define SRVFUZ_SHIFT 6 /* 64 seconds */
#define SRVRSP_FUZZ(x) \
do { \
x.l_uf &= 0; \
x.l_ui &= ~((1 << SRVFUZ_SHIFT) - 1U); \
} while(0)
/*
* This macro defines the authentication state. If x is 1 authentication
* is required; otherwise it is optional.
@@ -78,6 +86,11 @@ nak_error_codes {
*/
#define POOL_SOLICIT_WINDOW 8
/*
* flag bits propagated from pool to individual peers
*/
#define POOL_FLAG_PMASK (FLAG_IBURST | FLAG_NOSELECT)
/*
* peer_select groups statistics for a peer used by clock_select() and
* clock_cluster().
@@ -97,10 +110,16 @@ u_char sys_leap; /* system leap indicator, use set_sys_leap() to change this */
u_char xmt_leap; /* leap indicator sent in client requests, set up by set_sys_leap() */
u_char sys_stratum; /* system stratum */
s_char sys_precision; /* local clock precision (log2 s) */
double sys_rootdelay; /* roundtrip delay to primary source */
double sys_rootdisp; /* dispersion to primary source */
double sys_rootdelay; /* roundtrip delay to root (primary source) */
double sys_rootdisp; /* dispersion to root (primary source) */
double prev_rootdisp; /* previous root dispersion */
double p2_rootdisp; /* previous previous root dispersion */
u_int32 sys_refid; /* reference id (network byte order) */
l_fp sys_reftime; /* last update time */
l_fp prev_reftime; /* previous sys_reftime */
l_fp p2_reftime; /* previous previous sys_reftime */
u_long prev_time; /* "current_time" when saved prev_time */
u_long p2_time; /* previous prev_time */
struct peer *sys_peer; /* current peer */
#ifdef LEAP_SMEAR
@@ -337,11 +356,18 @@ valid_NAK(
/*
* The ORIGIN must match, or this cannot be a valid NAK, either.
*/
if (FLAG_LOOPNONCE & peer->flags) {
myorg = &peer->nonce;
} else {
if (peer->flip > 0) {
myorg = &peer->borg;
} else {
myorg = &peer->aorg;
}
}
NTOHL_FP(&rpkt->org, &p_org);
if (peer->flip > 0)
myorg = &peer->borg;
else
myorg = &peer->aorg;
if (L_ISZERO(&p_org) ||
L_ISZERO( myorg) ||
@@ -387,7 +413,7 @@ transmit(
*/
if (peer->cast_flags & (MDF_BCAST | MDF_MCAST)) {
peer->outdate = current_time;
poll_update(peer, hpoll);
poll_update(peer, hpoll, 0);
if (sys_leap != LEAP_NOTINSYNC)
peer_xmit(peer);
return;
@@ -408,7 +434,7 @@ transmit(
*/
if (peer->cast_flags & MDF_ACAST) {
peer->outdate = current_time;
poll_update(peer, hpoll);
poll_update(peer, hpoll, 0);
if (peer->unreach > sys_beacon) {
peer->unreach = 0;
peer->ttl = 0;
@@ -437,7 +463,7 @@ transmit(
*/
if (peer->cast_flags & MDF_POOL) {
peer->outdate = current_time;
poll_update(peer, hpoll);
poll_update(peer, hpoll, 0);
if ( (peer_associations <= 2 * sys_maxclock)
&& ( peer_associations < sys_maxclock
|| sys_survivors < sys_minclock))
@@ -549,7 +575,7 @@ transmit(
/*
* Do not transmit if in broadcast client mode.
*/
poll_update(peer, hpoll);
poll_update(peer, hpoll, (peer->hmode == MODE_CLIENT));
if (peer->hmode != MODE_BCLIENT)
peer_xmit(peer);
@@ -640,31 +666,20 @@ receive(
*/
/*
* Bogus port check is before anything, since it probably
* reveals a clogging attack.
* reveals a clogging attack. Likewise the mimimum packet size
* of 2 bytes (for mode 6/7) must be checked first.
*/
sys_received++;
if (0 == SRCPORT(&rbufp->recv_srcadr)) {
if (0 == SRCPORT(&rbufp->recv_srcadr) || rbufp->recv_length < 2) {
sys_badlength++;
return; /* bogus port */
return; /* bogus port / length */
}
restrictions(&rbufp->recv_srcadr, &r4a);
restrict_mask = r4a.rflags;
pkt = &rbufp->recv_pkt;
hisversion = PKT_VERSION(pkt->li_vn_mode);
hisleap = PKT_LEAP(pkt->li_vn_mode);
hismode = (int)PKT_MODE(pkt->li_vn_mode);
hisstratum = PKT_TO_STRATUM(pkt->stratum);
DPRINTF(1, ("receive: at %ld %s<-%s ippeerlimit %d mode %d iflags %s restrict %s org %#010x.%08x xmt %#010x.%08x\n",
current_time, stoa(&rbufp->dstadr->sin),
stoa(&rbufp->recv_srcadr), r4a.ippeerlimit, hismode,
build_iflags(rbufp->dstadr->flags),
build_rflags(restrict_mask),
ntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf),
ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf)));
/* See basic mode and broadcast checks, below */
INSIST(0 != hisstratum);
if (restrict_mask & RES_IGNORE) {
DPRINTF(2, ("receive: drop: RES_IGNORE\n"));
@@ -696,6 +711,30 @@ receive(
return; /* no time serve */
}
/* If we arrive here, we should have a standard NTP packet. We
* check that the minimum size is available and fetch some more
* items from the packet once we can be sure they are indeed
* there.
*/
if (rbufp->recv_length < LEN_PKT_NOMAC) {
sys_badlength++;
return; /* bogus length */
}
hisleap = PKT_LEAP(pkt->li_vn_mode);
hisstratum = PKT_TO_STRATUM(pkt->stratum);
INSIST(0 != hisstratum); /* paranoia check PKT_TO_STRATUM result */
DPRINTF(1, ("receive: at %ld %s<-%s ippeerlimit %d mode %d iflags %s "
"restrict %s org %#010x.%08x xmt %#010x.%08x\n",
current_time, stoa(&rbufp->dstadr->sin),
stoa(&rbufp->recv_srcadr), r4a.ippeerlimit, hismode,
build_iflags(rbufp->dstadr->flags),
build_rflags(restrict_mask),
ntohl(pkt->org.l_ui), ntohl(pkt->org.l_uf),
ntohl(pkt->xmt.l_ui), ntohl(pkt->xmt.l_uf)));
/*
* This is for testing. If restricted drop ten percent of
* surviving packets.
@@ -888,12 +927,13 @@ receive(
}
return; /* rate exceeded */
}
if (hismode == MODE_CLIENT)
if (hismode == MODE_CLIENT) {
fast_xmit(rbufp, MODE_SERVER, skeyid,
restrict_mask);
else
} else {
fast_xmit(rbufp, MODE_ACTIVE, skeyid,
restrict_mask);
}
return; /* rate exceeded */
}
restrict_mask &= ~RES_KOD;
@@ -1250,9 +1290,11 @@ receive(
if (AUTH(restrict_mask & RES_DONTTRUST,
is_authentic)) {
/* Bug 3596: Do we want to fuzz the reftime? */
fast_xmit(rbufp, MODE_SERVER, skeyid,
restrict_mask);
} else if (is_authentic == AUTH_ERROR) {
/* Bug 3596: Do we want to fuzz the reftime? */
fast_xmit(rbufp, MODE_SERVER, 0,
restrict_mask);
sys_badauth++;
@@ -1318,6 +1360,7 @@ receive(
pkt->refid,
rbufp->recv_length - MIN_V4_PKT_LEN, (u_char *)&pkt->exten);
/* Bug 3596: Do we want to fuzz the reftime? */
fast_xmit(rbufp, MODE_SERVER, skeyid,
restrict_mask);
}
@@ -1386,8 +1429,8 @@ receive(
peer = newpeer(&rbufp->recv_srcadr, NULL, rbufp->dstadr,
r4a.ippeerlimit, MODE_CLIENT, hisversion,
peer2->minpoll, peer2->maxpoll,
FLAG_PREEMPT | (FLAG_IBURST & peer2->flags),
MDF_UCAST | MDF_UCLNT, 0, skeyid, sys_ident);
(FLAG_PREEMPT | (POOL_FLAG_PMASK & peer2->flags)),
(MDF_UCAST | MDF_UCLNT), 0, skeyid, sys_ident);
if (NULL == peer) {
DPRINTF(2, ("receive: AM_MANYCAST drop: duplicate\n"));
sys_declined++;
@@ -1858,7 +1901,9 @@ receive(
* packet is a replay. This prevents the bad guys from replaying
* the most recent packet, authenticated or not.
*/
} else if (L_ISEQU(&peer->xmt, &p_xmt)) {
} else if ( ((FLAG_LOOPNONCE & peer->flags) && L_ISEQU(&peer->nonce, &p_xmt))
|| (!(FLAG_LOOPNONCE & peer->flags) && L_ISEQU(&peer->xmt, &p_xmt))
) {
DPRINTF(2, ("receive: drop: Duplicate xmit\n"));
peer->flash |= TEST1; /* duplicate */
peer->oldpkt++;
@@ -1958,6 +2003,10 @@ receive(
* We have earlier asserted that hisstratum cannot be 0.
* If hisstratum is STRATUM_UNSPEC, it means he's not sync'd.
*/
/* XXX: FLAG_LOOPNONCE */
DEBUG_INSIST(0 == (FLAG_LOOPNONCE & peer->flags));
} else if (peer->flip == 0) {
if (0) {
} else if (L_ISZERO(&p_org)) {
@@ -1967,6 +2016,7 @@ receive(
msyslog(LOG_INFO,
"receive: BUG 3361: Clearing peer->aorg ");
L_CLR(&peer->aorg);
/* Clear peer->nonce, too? */
#endif
/**/
switch (hismode) {
@@ -2020,6 +2070,7 @@ receive(
}
} else {
L_CLR(&peer->aorg);
/* XXX: FLAG_LOOPNONCE */
}
/*
@@ -2193,7 +2244,7 @@ receive(
peer->minpoll = peer->ppoll;
peer->burst = peer->retry = 0;
peer->throttle = (NTP_SHIFT + 1) * (1 << peer->minpoll);
poll_update(peer, pkt->ppoll);
poll_update(peer, pkt->ppoll, 0);
return; /* kiss-o'-death */
}
if (kissCode != NOKISS) {
@@ -2383,9 +2434,17 @@ receive(
/*
* The dance is complete and the flash bits have been lit. Toss
* the packet over the fence for processing, which may light up
* more flashers.
* more flashers. Leave if the packet is not good.
*/
process_packet(peer, pkt, rbufp->recv_length);
if (peer->flash & PKT_TEST_MASK)
return;
/* [bug 3592] Update poll. Ideally this should not happen in a
* receive branch, but too much is going on here... at least we
* do it only if the packet was good!
*/
poll_update(peer, peer->hpoll, (peer->hmode == MODE_CLIENT));
/*
* In interleaved mode update the state variables. Also adjust the
@@ -2465,7 +2524,10 @@ process_packet(
peer->seldisptoolarge++;
DPRINTF(1, ("packet: flash header %04x\n",
peer->flash));
poll_update(peer, peer->hpoll); /* ppoll updated? */
/* ppoll updated? */
/* XXX: Fuzz the poll? */
poll_update(peer, peer->hpoll, (peer->hmode == MODE_CLIENT));
return;
}
@@ -2509,7 +2571,7 @@ process_packet(
if (peer->burst > 0)
peer->nextdate = current_time;
}
poll_update(peer, peer->hpoll);
poll_update(peer, peer->hpoll, (peer->hmode == MODE_CLIENT));
/**/
@@ -2776,7 +2838,7 @@ clock_update(
sys_poll = peer->minpoll;
if (sys_poll > peer->maxpoll)
sys_poll = peer->maxpoll;
poll_update(peer, sys_poll);
poll_update(peer, sys_poll, 0);
sys_stratum = min(peer->stratum + 1, STRATUM_UNSPEC);
if ( peer->stratum == STRATUM_REFCLOCK
|| peer->stratum == STRATUM_UNSPEC)
@@ -2807,11 +2869,21 @@ clock_update(
+ clock_phi * (current_time - peer->update)
+ fabs(sys_offset);
p2_rootdisp = prev_rootdisp;
prev_rootdisp = sys_rootdisp;
if (dtemp > sys_mindisp)
sys_rootdisp = dtemp;
else
sys_rootdisp = sys_mindisp;
sys_rootdelay = peer->delay + peer->rootdelay;
p2_reftime = prev_reftime;
p2_time = prev_time;
prev_reftime = sys_reftime;
prev_time = current_time + 64 + (rand() & 0x3f); /* 64-127 s */
sys_reftime = peer->dst;
DPRINTF(1, ("clock_update: at %lu sample %lu associd %d\n",
@@ -2856,7 +2928,11 @@ clock_update(
sys_stratum = STRATUM_UNSPEC;
memcpy(&sys_refid, "STEP", 4);
sys_rootdelay = 0;
p2_rootdisp = 0;
prev_rootdisp = 0;
sys_rootdisp = 0;
L_CLR(&p2_reftime); /* Should we clear p2_reftime? */
L_CLR(&prev_reftime); /* Should we clear prev_reftime? */
L_CLR(&sys_reftime);
sys_jitter = LOGTOD(sys_precision);
leapsec_reset_frame();
@@ -2883,9 +2959,10 @@ clock_update(
* first clock sync, send them home satisfied.
*/
#ifdef HAVE_WORKING_FORK
if (waitsync_fd_to_close != -1) {
close(waitsync_fd_to_close);
waitsync_fd_to_close = -1;
if (daemon_pipe[1] != -1) {
write(daemon_pipe[1], "S\n", 2);
close(daemon_pipe[1]);
daemon_pipe[1] = -1;
DPRINTF(1, ("notified parent --wait-sync is done\n"));
}
#endif /* HAVE_WORKING_FORK */
@@ -2930,10 +3007,11 @@ clock_update(
void
poll_update(
struct peer *peer, /* peer structure pointer */
u_char mpoll
u_char mpoll,
u_char skewpoll
)
{
u_long next, utemp;
u_long next, utemp, limit;
u_char hpoll;
/*
@@ -2977,6 +3055,15 @@ poll_update(
*/
utemp = current_time + max(peer->throttle - (NTP_SHIFT - 1) *
(1 << peer->minpoll), ntp_minpkt);
/*[Bug 3592] avoid unlimited postpone of next poll */
limit = (2u << hpoll);
if (limit > 64)
limit -= (limit >> 2);
limit += peer->outdate;
if (limit < current_time)
limit = current_time;
if (peer->burst > 0) {
if (peer->nextdate > current_time)
return;
@@ -3022,6 +3109,29 @@ poll_update(
next = ((0x1000UL | (ntp_random() & 0x0ff)) <<
hpoll) >> 12;
next += peer->outdate;
/* XXX: bug3596: Deal with poll skew list? */
if (skewpoll) {
psl_item psi;
if (0 == get_pollskew(hpoll, &psi)) {
int sub = psi.sub;
int qty = psi.qty;
int msk = psi.msk;
int val;
if ( 0 != sub
|| 0 != qty) {
do {
val = ntp_random() & msk;
} while (val > qty);
next -= sub;
next += val;
}
} else {
/* get_pollskew() already logged this */
}
}
if (next > utemp)
peer->nextdate = next;
else
@@ -3029,6 +3139,13 @@ poll_update(
if (peer->throttle > (1 << peer->minpoll))
peer->nextdate += ntp_minpkt;
}
/*[Bug 3592] avoid unlimited postpone of next poll */
if (peer->nextdate > limit) {
DPRINTF(1, ("poll_update: clamp reached; limit %lu next %lu\n",
limit, peer->nextdate));
peer->nextdate = limit;
}
DPRINTF(2, ("poll_update: at %lu %s poll %d burst %d retry %d head %d early %lu next %lu\n",
current_time, ntoa(&peer->srcadr), peer->hpoll,
peer->burst, peer->retry, peer->throttle,
@@ -3953,6 +4070,7 @@ peer_xmit(
xpkt.refid = sys_refid;
xpkt.rootdelay = HTONS_FP(DTOFP(sys_rootdelay));
xpkt.rootdisp = HTONS_FP(DTOUFP(sys_rootdisp));
/* Use sys_reftime for peer exchanges */
HTONL_FP(&sys_reftime, &xpkt.reftime);
HTONL_FP(&peer->rec, &xpkt.org);
HTONL_FP(&peer->dst, &xpkt.rec);
@@ -4377,7 +4495,7 @@ leap_smear_add_offs(
static void
fast_xmit(
struct recvbuf *rbufp, /* receive packet pointer */
int xmode, /* receive mode */
int xmode, /* receive mode */ /* XXX: HMS: really? */
keyid_t xkeyid, /* transmit key ID */
int flags /* restrict mask */
)
@@ -4408,8 +4526,8 @@ fast_xmit(
/*
* If this is a kiss-o'-death (KoD) packet, show leap
* unsynchronized, stratum zero, reference ID the four-character
* kiss code and system root delay. Note we don't reveal the
* local time, so these packets can't be used for
* kiss code and (???) system root delay. Note we don't reveal
* the local time, so these packets can't be used for
* synchronization.
*/
if (flags & RES_KOD) {
@@ -4431,18 +4549,23 @@ fast_xmit(
* This is a normal packet. Use the system variables.
*/
} else {
double this_rootdisp;
l_fp this_ref_time;
#ifdef LEAP_SMEAR
/*
* Make copies of the variables which can be affected by smearing.
*/
l_fp this_ref_time;
l_fp this_recv_time;
#endif
/*
* If we are inside the leap smear interval we add the current smear offset to
* the packet receive time, to the packet transmit time, and eventually to the
* reftime to make sure the reftime isn't later than the transmit/receive times.
* If we are inside the leap smear interval we add
* the current smear offset to:
* - the packet receive time,
* - the packet transmit time,
* - and eventually to the reftime to make sure the
* reftime isn't later than the transmit/receive times.
*/
xpkt.li_vn_mode = PKT_LI_VN_MODE(xmt_leap,
PKT_VERSION(rpkt->li_vn_mode), xmode);
@@ -4452,25 +4575,77 @@ fast_xmit(
xpkt.precision = sys_precision;
xpkt.refid = sys_refid;
xpkt.rootdelay = HTONS_FP(DTOFP(sys_rootdelay));
xpkt.rootdisp = HTONS_FP(DTOUFP(sys_rootdisp));
/*
** Server Response Fuzzing
**
** Which values do we want to use for reftime and rootdisp?
*/
if ( MODE_SERVER == xmode
&& RES_SRVRSPFUZ & flags) {
if (current_time < p2_time) {
this_ref_time = p2_reftime;
this_rootdisp = p2_rootdisp;
} else if (current_time < prev_time) {
this_ref_time = prev_reftime;
this_rootdisp = prev_rootdisp;
} else {
this_ref_time = sys_reftime;
this_rootdisp = sys_rootdisp;
}
SRVRSP_FUZZ(this_ref_time);
} else {
this_ref_time = sys_reftime;
this_rootdisp = sys_rootdisp;
}
/*
** ROOT DISPERSION
*/
xpkt.rootdisp = HTONS_FP(DTOUFP(this_rootdisp));
/*
** REFTIME
*/
#ifdef LEAP_SMEAR
this_ref_time = sys_reftime;
if (leap_smear.in_progress) {
/* adjust the reftime by the same amount as the
* leap smear, as we don't want to risk the
* reftime being later than the transmit time.
*/
leap_smear_add_offs(&this_ref_time, NULL);
}
#endif
HTONL_FP(&this_ref_time, &xpkt.reftime);
/*
** REFID
*/
#ifdef LEAP_SMEAR
if (leap_smear.in_progress) {
xpkt.refid = convertLFPToRefID(leap_smear.offset);
DPRINTF(2, ("fast_xmit: leap_smear.in_progress: refid %8x, smear %s\n",
ntohl(xpkt.refid),
lfptoa(&leap_smear.offset, 8)
));
}
HTONL_FP(&this_ref_time, &xpkt.reftime);
#else
HTONL_FP(&sys_reftime, &xpkt.reftime);
#endif
/*
** ORIGIN
*/
xpkt.org = rpkt->xmt;
/*
** RECEIVE
*/
#ifdef LEAP_SMEAR
this_recv_time = rbufp->recv_time;
if (leap_smear.in_progress)
@@ -4480,6 +4655,10 @@ fast_xmit(
HTONL_FP(&rbufp->recv_time, &xpkt.rec);
#endif
/*
** TRANSMIT
*/
get_systime(&xmt_tx);
#ifdef LEAP_SMEAR
if (leap_smear.in_progress)
@@ -4580,10 +4759,11 @@ pool_xmit(
struct interface * lcladr;
sockaddr_u * rmtadr;
r4addr r4a;
int restrict_mask;
u_short restrict_mask;
struct peer * p;
l_fp xmt_tx;
DEBUG_REQUIRE(pool);
if (NULL == pool->ai) {
if (pool->addrs != NULL) {
/* free() is used with copy_addrinfo_list() */
@@ -4635,10 +4815,28 @@ pool_xmit(
xpkt.refid = sys_refid;
xpkt.rootdelay = HTONS_FP(DTOFP(sys_rootdelay));
xpkt.rootdisp = HTONS_FP(DTOUFP(sys_rootdisp));
/* Bug 3596: What are the pros/cons of using sys_reftime here? */
HTONL_FP(&sys_reftime, &xpkt.reftime);
/* HMS: the following is better done after the ntp_random() calls */
get_systime(&xmt_tx);
pool->aorg = xmt_tx;
HTONL_FP(&xmt_tx, &xpkt.xmt);
if (FLAG_LOOPNONCE & pool->flags) {
l_fp nonce;
do {
nonce.l_ui = ntp_random();
} while (0 == nonce.l_ui);
do {
nonce.l_uf = ntp_random();
} while (0 == nonce.l_uf);
pool->nonce = nonce;
HTONL_FP(&nonce, &xpkt.xmt);
} else {
L_CLR(&pool->nonce);
HTONL_FP(&xmt_tx, &xpkt.xmt);
}
sendpkt(rmtadr, lcladr,
sys_ttl[(pool->ttl >= sys_ttlmax) ? sys_ttlmax : pool->ttl],
&xpkt, LEN_PKT_NOMAC);
+406 -14
View File
@@ -12,6 +12,7 @@
#include "ntp_refclock.h"
#include "ntp_stdlib.h"
#include "ntp_assert.h"
#include "timespecops.h"
#include <stdio.h>
@@ -66,10 +67,81 @@ int cal_enable; /* enable refclock calibrate */
/*
* Forward declarations
*/
static int refclock_cmpl_fp (const void *, const void *);
static int refclock_sample (struct refclockproc *);
static int refclock_ioctl(int, u_int);
static int refclock_cmpl_fp (const void *, const void *);
static int refclock_sample (struct refclockproc *);
static int refclock_ioctl(int, u_int);
static void refclock_checkburst(struct peer *, struct refclockproc *);
/* circular buffer functions
*
* circular buffer management comes in two flovours:
* for powers of two, and all others.
*/
#if MAXSTAGE & (MAXSTAGE - 1)
static void clk_add_sample(
struct refclockproc * const pp,
double sv
)
{
pp->coderecv = (pp->coderecv + 1) % MAXSTAGE;
if (pp->coderecv == pp->codeproc)
pp->codeproc = (pp->codeproc + 1) % MAXSTAGE;
pp->filter[pp->coderecv] = sv;
}
static double clk_pop_sample(
struct refclockproc * const pp
)
{
if (pp->coderecv == pp->codeproc)
return 0; /* Maybe a NaN would be better? */
pp->codeproc = (pp->codeproc + 1) % MAXSTAGE;
return pp->filter[pp->codeproc];
}
static inline u_int clk_cnt_sample(
struct refclockproc * const pp
)
{
u_int retv = pp->coderecv - pp->codeproc;
if (retv > MAXSTAGE)
retv += MAXSTAGE;
return retv;
}
#else
static inline void clk_add_sample(
struct refclockproc * const pp,
double sv
)
{
pp->coderecv = (pp->coderecv + 1) & (MAXSTAGE - 1);
if (pp->coderecv == pp->codeproc)
pp->codeproc = (pp->codeproc + 1) & (MAXSTAGE - 1);
pp->filter[pp->coderecv] = sv;
}
static inline double clk_pop_sample(
struct refclockproc * const pp
)
{
if (pp->coderecv == pp->codeproc)
return 0; /* Maybe a NaN would be better? */
pp->codeproc = (pp->codeproc + 1) & (MAXSTAGE - 1);
return pp->filter[pp->codeproc];
}
static inline u_int clk_cnt_sample(
struct refclockproc * const pp
)
{
return (pp->coderecv - pp->codeproc) & (MAXSTAGE - 1);
}
#endif
/*
* refclock_report - note the occurance of an event
@@ -328,9 +400,10 @@ refclock_transmit(
} else {
peer->burst--;
}
peer->procptr->inpoll = TRUE;
if (refclock_conf[clktype]->clock_poll != noentry)
(refclock_conf[clktype]->clock_poll)(unit, peer);
poll_update(peer, peer->hpoll);
poll_update(peer, peer->hpoll, 0);
}
@@ -353,6 +426,65 @@ refclock_cmpl_fp(
return 0;
}
/*
* Get number of available samples
*/
int
refclock_samples_avail(
struct refclockproc const * pp
)
{
u_int na;
# if MAXSTAGE & (MAXSTAGE - 1)
na = pp->coderecv - pp->codeproc;
if (na > MAXSTAGE)
na += MAXSTAGE;
# else
na = (pp->coderecv - pp->codeproc) & (MAXSTAGE - 1);
# endif
return na;
}
/*
* Expire (remove) samples from the tail (oldest samples removed)
*
* Returns number of samples deleted
*/
int
refclock_samples_expire(
struct refclockproc * pp,
int nd
)
{
u_int na;
if (nd <= 0)
return 0;
# if MAXSTAGE & (MAXSTAGE - 1)
na = pp->coderecv - pp->codeproc;
if (na > MAXSTAGE)
na += MAXSTAGE;
if ((u_int)nd < na)
nd = na;
pp->codeproc = (pp->codeproc + nd) % MAXSTAGE;
# else
na = (pp->coderecv - pp->codeproc) & (MAXSTAGE - 1);
if ((u_int)nd > na)
nd = (int)na;
pp->codeproc = (pp->codeproc + nd) & (MAXSTAGE - 1);
# endif
return nd;
}
/*
* refclock_process_offset - update median filter
@@ -376,7 +508,8 @@ refclock_process_offset(
lftemp = lasttim;
L_SUB(&lftemp, &lastrec);
LFPTOD(&lftemp, doffset);
SAMPLE(doffset + fudge);
clk_add_sample(pp, doffset + fudge);
refclock_checkburst(pp->io.srcclock, pp);
}
@@ -388,7 +521,7 @@ refclock_process_offset(
* seconds and milliseconds/microseconds to internal timestamp format,
* then constructs a new entry in the median filter circular buffer.
* Return success (1) if the data are correct and consistent with the
* converntional calendar.
* conventional calendar.
*
* Important for PPS users: Normally, the pp->lastrec is set to the
* system time when the on-time character is received and the pp->year,
@@ -409,7 +542,7 @@ refclock_process_f(
* seconds and milliseconds/microseconds of the timecode. Use
* clocktime() for the aggregate seconds and the msec/usec for
* the fraction, when present. Note that this code relies on the
* filesystem time for the years and does not use the years of
* file system time for the years and does not use the years of
* the timecode.
*/
if (!clocktime(pp->day, pp->hour, pp->minute, pp->second, GMT,
@@ -457,11 +590,8 @@ refclock_sample(
* anything if the buffer is empty.
*/
n = 0;
while (pp->codeproc != pp->coderecv) {
pp->codeproc = (pp->codeproc + 1) % MAXSTAGE;
off[n] = pp->filter[pp->codeproc];
n++;
}
while (pp->codeproc != pp->coderecv)
off[n++] = clk_pop_sample(pp);
if (n == 0)
return (0);
@@ -494,6 +624,20 @@ refclock_sample(
}
pp->offset /= m;
pp->jitter = max(SQRT(pp->jitter / m), LOGTOD(sys_precision));
/*
* If the source has a jitter that cannot be estimated, because
* it is not statistic jitter, the source will be detected as
* falseticker sooner or later. Enforcing a minimal jitter value
* avoids a too low estimation while still detecting higher jitter.
*
* Note that this changes the refclock samples and ends up in the
* clock dispersion, not the clock jitter, despite being called
* jitter. To see the modified values, check the NTP clock variable
* "filtdisp", not "jitter".
*/
pp->jitter = max(pp->jitter, pp->fudgeminjitter);
#ifdef DEBUG
if (debug)
printf(
@@ -532,6 +676,7 @@ refclock_receive(
* filter.
*/
pp = peer->procptr;
pp->inpoll = FALSE;
peer->leap = pp->leap;
if (peer->leap == LEAP_NOTINSYNC)
return;
@@ -542,7 +687,7 @@ refclock_receive(
report_event(PEVNT_REACH, peer, NULL);
peer->timereachable = current_time;
}
peer->reach |= 1;
peer->reach = (peer->reach << (peer->reach & 1)) | 1;
peer->reftime = pp->lastref;
peer->aorg = pp->lastrec;
peer->rootdisp = pp->disp;
@@ -1080,6 +1225,8 @@ refclock_control(
pp->sloppyclockflag &= ~CLK_FLAG4;
pp->sloppyclockflag |= in->flags & CLK_FLAG4;
}
if (in->haveflags & CLK_HAVEMINJIT)
pp->fudgeminjitter = in->fudgeminjitter;
}
/*
@@ -1104,6 +1251,9 @@ refclock_control(
out->haveflags |= CLK_HAVEFLAG3;
if (CLK_FLAG4 & out->flags)
out->haveflags |= CLK_HAVEFLAG4;
out->fudgeminjitter = pp->fudgeminjitter;
if (0.0 != out->fudgeminjitter)
out->haveflags |= CLK_HAVEMINJIT;
out->timereset = current_time - pp->timestarted;
out->polls = pp->polls;
@@ -1367,7 +1517,8 @@ refclock_pps(
*/
pp->lastrec.l_ui = (u_int32)ap->ts.tv_sec + JAN_1970;
pp->lastrec.l_uf = (u_int32)(dtemp * FRAC);
SAMPLE(dcorr);
clk_add_sample(pp, dcorr);
refclock_checkburst(peer, pp);
#ifdef DEBUG
if (debug > 1)
@@ -1377,4 +1528,245 @@ refclock_pps(
return (1);
}
#endif /* HAVE_PPSAPI */
/*
* -------------------------------------------------------------------
* refclock_ppsaugment(...) -- correlate with PPS edge
*
* This function is used to correlate a receive time stamp with a PPS
* edge time stamp. It applies the necessary fudges and then tries to
* move the receive time stamp to the corresponding edge. This can warp
* into future, if a transmission delay of more than 500ms is not
* compensated with a corresponding fudge time2 value, because then the
* next PPS edge is nearer than the last. (Similiar to what the PPS ATOM
* driver does, but we deal with full time stamps here, not just phase
* shift information.) Likewise, a negative fudge time2 value must be
* used if the reference time stamp correlates with the *following* PPS
* pulse.
*
* Note that the receive time fudge value only needs to move the receive
* stamp near a PPS edge but that close proximity is not required;
* +/-100ms precision should be enough. But since the fudge value will
* probably also be used to compensate the transmission delay when no
* PPS edge can be related to the time stamp, it's best to get it as
* close as possible.
*
* It should also be noted that the typical use case is matching to the
* preceeding edge, as most units relate their sentences to the current
* second.
*
* The function returns FALSE if there is no correlation possible, TRUE
* otherwise. Reason for failures are:
*
* - no PPS/ATOM unit given
* - PPS stamp is stale (that is, the difference between the PPS stamp
* and the corrected time stamp would exceed two seconds)
* - The phase difference is too close to 0.5, and the decision wether
* to move up or down is too sensitive to noise.
*
* On output, the receive time stamp is updated with the 'fixed' receive
* time.
* -------------------------------------------------------------------
*/
int/*BOOL*/
refclock_ppsaugment(
const struct refclock_atom * ap , /* for PPS io */
l_fp * rcvtime ,
double rcvfudge, /* i/o read fudge */
double ppsfudge /* pps fudge */
)
{
l_fp delta[1];
#ifdef HAVE_PPSAPI
pps_info_t pps_info;
struct timespec timeout;
l_fp stamp[1];
uint32_t phase;
static const uint32_t s_plim_hi = UINT32_C(1932735284);
static const uint32_t s_plim_lo = UINT32_C(2362232013);
/* fixup receive time in case we have to bail out early */
DTOLFP(rcvfudge, delta);
L_SUB(rcvtime, delta);
if (NULL == ap)
return FALSE;
ZERO(timeout);
ZERO(pps_info);
/* fetch PPS stamp from ATOM block */
if (time_pps_fetch(ap->handle, PPS_TSFMT_TSPEC,
&pps_info, &timeout) < 0)
return FALSE; /* can't get time stamps */
/* get last active PPS edge before receive */
if (ap->pps_params.mode & PPS_CAPTUREASSERT)
timeout = pps_info.assert_timestamp;
else if (ap->pps_params.mode & PPS_CAPTURECLEAR)
timeout = pps_info.clear_timestamp;
else
return FALSE; /* WHICH edge, please?!? */
/* convert PPS stamp to l_fp and apply fudge */
*stamp = tspec_stamp_to_lfp(timeout);
DTOLFP(ppsfudge, delta);
L_SUB(stamp, delta);
/* Get difference between PPS stamp (--> yield) and receive time
* (--> base)
*/
*delta = *stamp;
L_SUB(delta, rcvtime);
/* check if either the PPS or the STAMP is stale in relation
* to each other. Bail if it is so...
*/
phase = delta->l_ui;
if (phase >= 2 && phase < (uint32_t)-2)
return FALSE; /* PPS is stale, don't use it */
/* If the phase is too close to 0.5, the decision whether to
* move up or down is becoming noise sensitive. That is, we
* might amplify usec noise between samples into seconds with a
* simple threshold. This can be solved by a Schmitt Trigger
* characteristic, but that would also require additional state
* where we could remember previous decisions. Easier to play
* dead duck and wait for the conditions to become clear.
*/
phase = delta->l_uf;
if (phase > s_plim_hi && phase < s_plim_lo)
return FALSE; /* we're in the noise lock gap */
/* sign-extend fraction into seconds */
delta->l_ui = UINT32_C(0) - ((phase >> 31) & 1);
/* add it up now */
L_ADD(rcvtime, delta);
return TRUE;
# else /* have no PPS support at all */
/* just fixup receive time and fail */
UNUSED_ARG(ap);
UNUSED_ARG(ppsfudge);
DTOLFP(rcvfudge, delta);
L_SUB(rcvtime, delta);
return FALSE;
# endif
}
/*
* -------------------------------------------------------------------
* check if it makes sense to schedule an 'early' poll to get the clock
* up fast after start or longer signal dropout.
*/
static void
refclock_checkburst(
struct peer * peer,
struct refclockproc * pp
)
{
uint32_t limit; /* when we should poll */
u_int needs; /* needed number of samples */
/* Paranoia: stop here if peer and clockproc don't match up.
* And when a poll is actually pending, we don't have to do
* anything, either. Likewise if the reach mask is full, of
* course, and if the filter has stabilized.
*/
if (pp->inpoll || (peer->procptr != pp) ||
((peer->reach == 0xFF) && (peer->disp <= MAXDISTANCE)))
return;
/* If the next poll is soon enough, bail out, too: */
limit = current_time + 1;
if (peer->nextdate <= limit)
return;
/* Derive the number of samples needed from the popcount of the
* reach mask. With less samples available, we break away.
*/
needs = peer->reach;
needs -= (needs >> 1) & 0x55;
needs = (needs & 0x33) + ((needs >> 2) & 0x33);
needs = (needs + (needs >> 4)) & 0x0F;
if (needs > 6)
needs = 6;
else if (needs < 3)
needs = 3;
if (clk_cnt_sample(pp) < needs)
return;
/* Get serious. Reduce the poll to minimum and schedule early.
* (Changing the peer poll is probably in vain, as it will be
* re-adjusted, but maybe some time the hint will work...)
*/
peer->hpoll = peer->minpoll;
peer->nextdate = limit;
}
/*
* -------------------------------------------------------------------
* Save the last timecode string, making sure it's properly truncated
* if necessary and NUL terminated in any case.
*/
void
refclock_save_lcode(
struct refclockproc * pp,
char const * tc,
size_t len
)
{
if (len == (size_t)-1)
len = strnlen(tc, sizeof(pp->a_lastcode) - 1);
else if (len >= sizeof(pp->a_lastcode))
len = sizeof(pp->a_lastcode) - 1;
pp->lencode = (u_short)len;
memcpy(pp->a_lastcode, tc, len);
pp->a_lastcode[len] = '\0';
}
/* format data into a_lastcode */
void
refclock_vformat_lcode(
struct refclockproc * pp,
char const * fmt,
va_list va
)
{
long len;
len = vsnprintf(pp->a_lastcode, sizeof(pp->a_lastcode), fmt, va);
if (len <= 0)
len = 0;
else if (len >= sizeof(pp->a_lastcode))
len = sizeof(pp->a_lastcode) - 1;
pp->lencode = (u_short)len;
pp->a_lastcode[len] = '\0';
/* !note! the NUL byte is needed in case vsnprintf() really fails */
}
void
refclock_format_lcode(
struct refclockproc * pp,
char const * fmt,
...
)
{
va_list va;
va_start(va, fmt);
refclock_vformat_lcode(pp, fmt, va);
va_end(va);
}
#endif /* REFCLOCK */
+3 -3
View File
@@ -841,7 +841,7 @@ peer_info (
pp = findexistingpeer(&addr, NULL, NULL, -1, 0, NULL);
if (NULL == pp)
continue;
if (IS_IPV6(srcadr)) {
if (IS_IPV6(&pp->srcadr)) {
if (pp->dstadr)
ip->dstadr6 =
(MDF_BCAST == pp->cast_flags)
@@ -1819,7 +1819,7 @@ do_restrict(
bad = 0;
while (items-- > 0 && !bad) {
memcpy(&cr, datap, item_sz);
cr.flags = ntohs(cr.flags);
cr.flags = ntohs(cr.flags); /* XXX */
cr.mflags = ntohs(cr.mflags);
if (~RESM_NTPONLY & cr.mflags)
bad |= 1;
@@ -1854,7 +1854,7 @@ do_restrict(
while (items-- > 0) {
memcpy(&cr, datap, item_sz);
cr.flags = ntohs(cr.flags);
cr.flags = ntohs(cr.flags); /* XXX: size */
cr.mflags = ntohs(cr.mflags);
cr.ippeerlimit = ntohs(cr.ippeerlimit);
if (client_v6_capable && cr.v6_flag) {
+5 -6
View File
@@ -96,7 +96,7 @@ static restrict_u restrict_def6;
* "restrict source ..." enabled knob and restriction bits.
*/
static int restrict_source_enabled;
static u_short restrict_source_rflags;
static u_int32 restrict_source_rflags;
static u_short restrict_source_mflags;
static short restrict_source_ippeerlimit;
@@ -141,7 +141,7 @@ dump_restrict(
inet_ntop(AF_INET, &sia, as, sizeof as);
inet_ntop(AF_INET, &sim, ms, sizeof ms);
}
mprintf("restrict node at %p: %s/%s count %d, rflags %05x, mflags %05x, ippeerlimit %d, expire %lu, next %p\n",
mprintf("restrict node at %p: %s/%s count %d, rflags %08x, mflags %04x, ippeerlimit %d, expire %lu, next %p\n",
res, as, ms, res->count, res->rflags, res->mflags,
res->ippeerlimit, res->expire, res->link);
return;
@@ -154,8 +154,6 @@ dump_restrict(
void
dump_restricts(void)
{
int defaultv4_done = 0;
int defaultv6_done = 0;
restrict_u * res;
restrict_u * next;
@@ -570,6 +568,7 @@ restrictions(
r4a->rflags = match->rflags;
r4a->ippeerlimit = match->ippeerlimit;
}
return;
}
@@ -795,8 +794,8 @@ restrict_source(
return;
hack_restrict(RESTRICT_FLAGS, addr, &onesmask,
restrict_source_ippeerlimit, restrict_source_mflags,
restrict_source_rflags, expire);
restrict_source_ippeerlimit,
restrict_source_mflags, restrict_source_rflags, expire);
DPRINTF(1, ("restrict_source: %s host restriction added\n",
stoa(addr)));
}
+16 -7
View File
@@ -73,17 +73,26 @@ keyword(
{
size_t i;
const char *text;
static char sbuf[64];
i = token - LOWEST_KEYWORD_ID;
if (i < COUNTOF(keyword_text))
text = keyword_text[i];
else
text = NULL;
switch (token) {
case T_ServerresponseFuzz:
text = "serverresponse fuzz";
break;
return (text != NULL)
? text
: "(keyword not found)";
default:
if (i < COUNTOF(keyword_text)) {
text = keyword_text[i];
} else {
snprintf(sbuf, sizeof sbuf,
"(keyword #%u not found)", token);
text = sbuf;
}
}
return text;
}
+20 -16
View File
@@ -58,6 +58,7 @@ static char *key_file_name; /* keys file name */
static char *leapfile_name; /* leapseconds file name */
static struct stat leapfile_stat; /* leapseconds file stat() buffer */
static int /*BOOL*/have_leapfile = FALSE;
static int /*BOOL*/chck_leaphash = TRUE;
char *stats_drift_file; /* frequency file name */
static char *stats_temp_file; /* temp frequency file name */
static double wander_resid; /* last frequency update */
@@ -87,7 +88,7 @@ static FILEGEN timingstats;
/*
* This controls whether stats are written to the fileset. Provided
* so that ntpdc can turn off stats when the file system fills up.
* so that ntpdc can turn off stats when the file system fills up.
*/
int stats_control;
@@ -103,7 +104,7 @@ static void record_sys_stats(void);
void ntpd_time_stepped(void);
static void check_leap_expiration(int, uint32_t, const time_t*);
/*
/*
* Prototypes
*/
#ifdef DEBUG
@@ -287,15 +288,15 @@ write_stats(void)
/* atomic */
#ifdef SYS_WINNT
if (_unlink(stats_drift_file)) /* rename semantics differ under NT */
msyslog(LOG_WARNING,
"Unable to remove prior drift file %s, %m",
msyslog(LOG_WARNING,
"Unable to remove prior drift file %s, %m",
stats_drift_file);
#endif /* SYS_WINNT */
#ifndef NO_RENAME
if (rename(stats_temp_file, stats_drift_file))
msyslog(LOG_WARNING,
"Unable to rename temp drift file %s to %s, %m",
msyslog(LOG_WARNING,
"Unable to rename temp drift file %s to %s, %m",
stats_temp_file, stats_drift_file);
#else
/* we have no rename NFS of ftp in use */
@@ -329,7 +330,8 @@ write_stats(void)
void
stats_config(
int item,
const char *invalue /* only one type so far */
const char *invalue, /* only one type so far */
int optflag
)
{
FILE *fp;
@@ -385,7 +387,7 @@ stats_config(
} else {
value = newvalue;
}
#else
#else
value = invalue;
#endif /* SYS_WINNT */
@@ -399,7 +401,7 @@ stats_config(
break;
stats_drift_file = erealloc(stats_drift_file, len + 1);
stats_temp_file = erealloc(stats_temp_file,
stats_temp_file = erealloc(stats_temp_file,
len + sizeof(".TEMP"));
memcpy(stats_drift_file, value, (size_t)(len+1));
memcpy(stats_temp_file, value, (size_t)len);
@@ -414,7 +416,7 @@ stats_config(
if (fscanf(fp, "%lf", &old_drift) != 1) {
msyslog(LOG_ERR,
"format error frequency file %s",
"format error frequency file %s",
stats_drift_file);
fclose(fp);
break;
@@ -483,9 +485,11 @@ stats_config(
leapfile_name = erealloc(leapfile_name, len + 1);
memcpy(leapfile_name, value, len + 1);
chck_leaphash = optflag;
if (leapsec_load_file(
leapfile_name, &leapfile_stat, TRUE, TRUE))
leapfile_name, &leapfile_stat,
TRUE, TRUE, chck_leaphash))
{
leap_signature_t lsig;
@@ -892,11 +896,11 @@ check_leap_file(
/* just do nothing if there is no leap file */
if ( ! (leapfile_name && *leapfile_name))
return;
/* try to load leapfile, force it if no leapfile loaded yet */
if (leapsec_load_file(
leapfile_name, &leapfile_stat,
!have_leapfile, is_daily_check))
!have_leapfile, is_daily_check, chck_leaphash))
have_leapfile = TRUE;
else if (!have_leapfile)
return;
@@ -921,7 +925,7 @@ check_leap_expiration(
* level and frequency (once/hour or once/day, depending on the
* state.
*/
rc = leapsec_daystolive(ntptime, systime);
rc = leapsec_daystolive(ntptime, systime);
if (rc == 0) {
msyslog(LOG_WARNING,
"%s ('%s'): will expire in less than one day",
@@ -929,7 +933,7 @@ check_leap_expiration(
} else if (is_daily_check && rc < 28) {
if (rc < 0)
msyslog(LOG_ERR,
"%s ('%s'): expired less than %d day%s ago",
"%s ('%s'): expired %d day%s ago",
logPrefix, leapfile_name, -rc, (rc == -1 ? "" : "s"));
else
msyslog(LOG_WARNING,
@@ -952,7 +956,7 @@ getauthkeys(
len = strlen(keyfile);
if (!len)
return;
#ifndef SYS_WINNT
key_file_name = erealloc(key_file_name, len + 1);
memcpy(key_file_name, keyfile, len + 1);
+10 -10
View File
@@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (ntpd-opts.c)
*
* It has been AutoGen-ed February 20, 2019 at 09:56:15 AM by AutoGen 5.18.5
* It has been AutoGen-ed March 3, 2020 at 05:40:30 PM by AutoGen 5.18.5
* From the definitions ntpd-opts.def
* and the template file options
*
@@ -18,7 +18,7 @@
* The ntpd program is copyrighted and licensed
* under the following terms:
*
* Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation, all rights reserved.
* Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation, all rights reserved.
* This is free software. It is licensed for use, modification and
* redistribution under the terms of the NTP License, copies of which
* can be seen at:
@@ -75,8 +75,8 @@ extern FILE * option_usage_fp;
* static const strings for ntpd options
*/
static char const ntpd_opt_strs[3132] =
/* 0 */ "ntpd 4.2.8p13\n"
"Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation, all rights reserved.\n"
/* 0 */ "ntpd 4.2.8p14\n"
"Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation, all rights reserved.\n"
"This is free software. It is licensed for use, modification and\n"
"redistribution under the terms of the NTP License, copies of which\n"
"can be seen at:\n"
@@ -205,12 +205,12 @@ static char const ntpd_opt_strs[3132] =
/* 2901 */ "output version information and exit\0"
/* 2937 */ "version\0"
/* 2945 */ "NTPD\0"
/* 2950 */ "ntpd - NTP daemon program - Ver. 4.2.8p13\n"
/* 2950 */ "ntpd - NTP daemon program - Ver. 4.2.8p14\n"
"Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n"
"\t\t[ <server1> ... <serverN> ]\n\0"
/* 3082 */ "http://bugs.ntp.org, [email protected]\0"
/* 3116 */ "\n\0"
/* 3118 */ "ntpd 4.2.8p13";
/* 3118 */ "ntpd 4.2.8p14";
/**
* ipv4 option description with
@@ -1529,8 +1529,8 @@ static void bogus_function(void) {
translate option names.
*/
/* referenced via ntpdOptions.pzCopyright */
puts(_("ntpd 4.2.8p13\n\
Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation, all rights reserved.\n\
puts(_("ntpd 4.2.8p14\n\
Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation, all rights reserved.\n\
This is free software. It is licensed for use, modification and\n\
redistribution under the terms of the NTP License, copies of which\n\
can be seen at:\n"));
@@ -1670,7 +1670,7 @@ implied warranty.\n"));
puts(_("output version information and exit"));
/* referenced via ntpdOptions.pzUsageTitle */
puts(_("ntpd - NTP daemon program - Ver. 4.2.8p13\n\
puts(_("ntpd - NTP daemon program - Ver. 4.2.8p14\n\
Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\
\t\t[ <server1> ... <serverN> ]\n"));
@@ -1678,7 +1678,7 @@ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\
puts(_("\n"));
/* referenced via ntpdOptions.pzFullVersion */
puts(_("ntpd 4.2.8p13"));
puts(_("ntpd 4.2.8p14"));
/* referenced via ntpdOptions.pzFullUsage */
puts(_("<<<NOT-FOUND>>>"));
+4 -4
View File
@@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (ntpd-opts.h)
*
* It has been AutoGen-ed February 20, 2019 at 09:56:15 AM by AutoGen 5.18.5
* It has been AutoGen-ed March 3, 2020 at 05:40:30 PM by AutoGen 5.18.5
* From the definitions ntpd-opts.def
* and the template file options
*
@@ -18,7 +18,7 @@
* The ntpd program is copyrighted and licensed
* under the following terms:
*
* Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation, all rights reserved.
* Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation, all rights reserved.
* This is free software. It is licensed for use, modification and
* redistribution under the terms of the NTP License, copies of which
* can be seen at:
@@ -106,9 +106,9 @@ typedef enum {
/** count of all options for ntpd */
#define OPTION_CT 38
/** ntpd version */
#define NTPD_VERSION "4.2.8p13"
#define NTPD_VERSION "4.2.8p14"
/** Full ntpd version text */
#define NTPD_FULL_VERSION "ntpd 4.2.8p13"
#define NTPD_FULL_VERSION "ntpd 4.2.8p14"
/**
* Interface defines for all options. Replace "n" with the UPPER_CASED
+3 -3
View File
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
.TH ntpd 1ntpdman "20 Feb 2019" "4.2.8p13" "User Commands"
.TH ntpd 1ntpdman "03 Mar 2020" "4.2.8p14" "User Commands"
.\"
.\" EDIT THIS FILE WITH CAUTION (in-mem file)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:46 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:41:05 PM by AutoGen 5.18.5
.\" From the definitions ntpd-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
@@ -979,7 +979,7 @@ RFC5908
.SH "AUTHORS"
The University of Delaware and Network Time Foundation
.SH "COPYRIGHT"
Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.SH BUGS
The
+3 -3
View File
@@ -1,9 +1,9 @@
.Dd February 20 2019
.Dd March 3 2020
.Dt NTPD 1ntpdmdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpd-opts.mdoc)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:37 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:40:55 PM by AutoGen 5.18.5
.\" From the definitions ntpd-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
@@ -886,7 +886,7 @@ A snapshot of this documentation is available in HTML format in
.Sh "AUTHORS"
The University of Delaware and Network Time Foundation
.Sh "COPYRIGHT"
Copyright (C) 1992\-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992\-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.Sh BUGS
The
+219 -82
View File
@@ -45,6 +45,9 @@
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
#endif
#include <stdio.h>
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
@@ -82,6 +85,10 @@
# include <sys/mman.h>
#endif
#ifdef HAVE_SYSEXITS_H
# include <sysexits.h>
#endif
#ifdef HAVE_TERMIOS_H
# include <termios.h>
#endif
@@ -138,11 +145,37 @@
# include <seccomp.h>
#endif /* LIBSECCOMP and KERN_SECCOMP */
#ifdef __FreeBSD__
#include <sys/procctl.h>
#ifndef PROC_STACKGAP_CTL
/*
* Even if we compile on an older system we can still run on a newer one.
*/
#define PROC_STACKGAP_CTL 17
#define PROC_STACKGAP_DISABLE 0x0002
#endif
#endif
#ifdef HAVE_DNSREGISTRATION
# include <dns_sd.h>
DNSServiceRef mdns;
#endif
/* In case 'sysexits.h' is unavailable, define some exit codes here: */
#ifndef EX_SOFTWARE
# define EX_SOFTWARE 70
#endif
#ifndef EX_OSERR
# define EX_OSERR 71
#endif
#ifndef EX_IOERR
# define EX_IOERR 74
#endif
#ifndef EX_PROTOCOL
#define EX_PROTOCOL 76
#endif
#ifdef HAVE_SETPGRP_0
# define ntp_setpgrp(x, y) setpgrp()
#else
@@ -181,6 +214,10 @@ int mdnsreg = FALSE;
int mdnstries = 5;
#endif /* HAVE_DNSREGISTRATION */
#ifdef HAVE_LINUX_CAPABILITIES
int have_caps; /* runtime check whether capabilities work */
#endif /* HAVE_LINUX_CAPABILITIES */
#ifdef HAVE_DROPROOT
int droproot;
int root_dropped;
@@ -194,7 +231,7 @@ struct passwd *pw;
#endif /* HAVE_DROPROOT */
#ifdef HAVE_WORKING_FORK
int waitsync_fd_to_close = -1; /* -w/--wait-sync */
int daemon_pipe[2] = { -1, -1 };
#endif
/*
@@ -224,7 +261,8 @@ static RETSIGTYPE finish (int);
#endif
#if !defined(SIM) && defined(HAVE_WORKING_FORK)
static int wait_child_sync_if (int, long);
static int wait_child_sync_if (int, unsigned long);
static int wait_child_exit_if (pid_t, int);
#endif
#if !defined(SIM) && !defined(SYS_WINNT)
@@ -391,22 +429,30 @@ main(
return ntpsim(argc, argv);
}
#else /* !SIM follows */
#ifdef NO_MAIN_ALLOWED
#elif defined(NO_MAIN_ALLOWED)
CALL(ntpd,"ntpd",ntpdmain);
#else /* !NO_MAIN_ALLOWED follows */
#ifndef SYS_WINNT
#elif !defined(SYS_WINNT)
int
main(
int argc,
char *argv[]
)
{
# ifdef __FreeBSD__
{
/*
* We Must disable ASLR stack gap on FreeBSD to avoid a
* segfault. See PR/241421 and PR/241960.
*/
int aslr_var = PROC_STACKGAP_DISABLE;
pid_t my_pid = getpid();
procctl(P_PID, my_pid, PROC_STACKGAP_CTL, &aslr_var);
}
# endif
return ntpdmain(argc, argv);
}
#endif /* !SYS_WINNT */
#endif /* !NO_MAIN_ALLOWED */
#endif /* !SIM */
#ifdef _AIX
/*
@@ -537,13 +583,13 @@ set_process_priority(void)
# ifdef HAVE_WORKING_FORK
static void
detach_from_terminal(
int pipe_fds[2],
int pipe[2],
long wait_sync,
const char *logfilename
)
{
int rc;
int exit_code;
pid_t cpid;
int exit_code;
# if !defined(HAVE_SETSID) && !defined (HAVE_SETPGID) && defined(TIOCNOTTY)
int fid;
# endif
@@ -551,16 +597,28 @@ detach_from_terminal(
struct sigaction sa;
# endif
rc = fork();
if (-1 == rc) {
exit_code = (errno) ? errno : -1;
msyslog(LOG_ERR, "fork: %m");
exit(exit_code);
}
if (rc > 0) {
cpid = fork();
if (0 != cpid) {
/* parent */
exit_code = wait_child_sync_if(pipe_fds[0],
wait_sync);
if (-1 == cpid) {
msyslog(LOG_ERR, "fork: %m");
exit_code = EX_OSERR;
} else {
close(pipe[1]);
pipe[1] = -1;
exit_code = wait_child_sync_if(
pipe[0], wait_sync);
DPRINTF(1, ("sync_if: rc=%d\n", exit_code));
if (exit_code <= 0) {
/* probe daemon exit code -- wait for
* child process if we have an unexpected
* EOF on the monitor pipe.
*/
exit_code = wait_child_exit_if(
cpid, (exit_code < 0));
DPRINTF(1, ("exit_if: rc=%d\n", exit_code));
}
}
exit(exit_code);
}
@@ -575,7 +633,8 @@ detach_from_terminal(
syslog_file = NULL;
syslogit = TRUE;
}
close_all_except(waitsync_fd_to_close);
close_all_except(pipe[1]);
pipe[0] = -1;
INSIST(0 == open("/dev/null", 0) && 1 == dup2(0, 1) \
&& 2 == dup2(0, 2));
@@ -782,9 +841,6 @@ ntpdmain(
# endif
# if defined(HAVE_WORKING_FORK)
long wait_sync = 0;
int pipe_fds[2];
int rc;
int exit_code;
# endif /* HAVE_WORKING_FORK*/
# ifdef SCO5_CLOCK
int fd;
@@ -850,9 +906,16 @@ ntpdmain(
" %s", saved_argv[i]);
cp += strlen(cp);
}
msyslog(LOG_INFO, "%s", buf);
msyslog(LOG_NOTICE, "%s", buf);
}
msyslog(LOG_NOTICE, "----------------------------------------------------");
msyslog(LOG_NOTICE, "ntp-4 is maintained by Network Time Foundation,");
msyslog(LOG_NOTICE, "Inc. (NTF), a non-profit 501(c)(3) public-benefit");
msyslog(LOG_NOTICE, "corporation. Support and training for ntp-4 are");
msyslog(LOG_NOTICE, "available at https://www.nwtime.org/support");
msyslog(LOG_NOTICE, "----------------------------------------------------");
/*
* Install trap handlers to log errors and assertion failures.
* Default handlers print to stderr which doesn't work if detached.
@@ -927,27 +990,24 @@ ntpdmain(
# endif
# ifdef HAVE_WORKING_FORK
/* make sure the FDs are initialised */
pipe_fds[0] = -1;
pipe_fds[1] = -1;
do { /* 'loop' once */
if (!HAVE_OPT( WAIT_SYNC ))
break;
/* make sure the FDs are initialised
*
* note: if WAIT_SYNC is requested, we *have* to fork. This will
* overide any '-n' (nofork) or '-d' (debug) option presented on
* the command line!
*/
if (HAVE_OPT(WAIT_SYNC)) {
wait_sync = OPT_VALUE_WAIT_SYNC;
if (wait_sync <= 0) {
if (wait_sync <= 0)
wait_sync = 0;
break;
}
/* -w requires a fork() even with debug > 0 */
nofork = FALSE;
if (pipe(pipe_fds)) {
exit_code = (errno) ? errno : -1;
msyslog(LOG_ERR,
"Pipe creation failed for --wait-sync: %m");
exit(exit_code);
}
waitsync_fd_to_close = pipe_fds[1];
} while (0); /* 'loop' once */
else
nofork = FALSE;
}
if ( !nofork && pipe(daemon_pipe)) {
msyslog(LOG_ERR,
"Pipe creation failed for --wait-sync/daemon: %m");
exit(EX_OSERR);
}
# endif /* HAVE_WORKING_FORK */
init_lib();
@@ -973,12 +1033,11 @@ ntpdmain(
/*
* Detach us from the terminal. May need an #ifndef GIZMO.
*/
if (!nofork) {
# ifdef HAVE_WORKING_FORK
detach_from_terminal(pipe_fds, wait_sync, logfilename);
# endif /* HAVE_WORKING_FORK */
if (!nofork) {
detach_from_terminal(daemon_pipe, wait_sync, logfilename);
}
# endif /* HAVE_WORKING_FORK */
# ifdef SCO5_CLOCK
/*
@@ -1123,12 +1182,33 @@ ntpdmain(
report_event(EVNT_SYSRESTART, NULL, NULL);
initializing = FALSE;
# ifdef HAVE_DROPROOT
if (droproot) {
# ifdef HAVE_LINUX_CAPABILITIES
{
/* Check that setting capabilities actually works; we might be
* run on a kernel with disabled capabilities. We must not
* drop privileges in this case.
*/
cap_t caps;
caps = cap_from_text("cap_sys_time,cap_setuid,cap_setgid,cap_sys_chroot,cap_net_bind_service=pe");
if ( ! caps) {
msyslog( LOG_ERR, "cap_from_text() failed: %m" );
exit(-1);
}
have_caps = (cap_set_proc(caps) == 0);
cap_free(caps); /* caps not NULL here! */
}
# endif /* HAVE_LINUX_CAPABILITIES */
#ifdef NEED_EARLY_FORK
# ifdef HAVE_DROPROOT
# ifdef HAVE_LINUX_CAPABILITIES
if (droproot && have_caps) {
# else
if (droproot) {
# endif /*HAVE_LINUX_CAPABILITIES*/
# ifdef NEED_EARLY_FORK
fork_nonchroot_worker();
#endif
# endif
/* Drop super-user privileges and chroot now if the OS supports this */
@@ -1364,28 +1444,28 @@ int scmp_sc[] = {
}
#endif /* LIBSECCOMP and KERN_SECCOMP */
#ifdef SYS_WINNT
#if defined(SYS_WINNT)
ntservice_isup();
#endif
# ifdef HAVE_IO_COMPLETION_PORT
for (;;) {
#if !defined(SIM) && defined(SIGDIE1)
if (signalled)
finish_safe(signo);
#endif
GetReceivedBuffers();
# else /* normal I/O */
#elif defined(HAVE_WORKING_FORK)
if (daemon_pipe[1] != -1) {
write(daemon_pipe[1], "R\n", 2);
}
#endif /* HAVE_WORKING_FORK */
# ifndef HAVE_IO_COMPLETION_PORT
BLOCK_IO_AND_ALARM();
was_alarmed = FALSE;
# endif
for (;;) {
#if !defined(SIM) && defined(SIGDIE1)
if (signalled)
finish_safe(signo);
#endif
#endif
# ifdef HAVE_IO_COMPLETION_PORT
GetReceivedBuffers();
# else /* normal I/O */
if (alarm_flag) { /* alarmed? */
was_alarmed = TRUE;
alarm_flag = FALSE;
@@ -1550,26 +1630,30 @@ finish(
* wait_child_sync_if - implements parent side of -w/--wait-sync
*/
# ifdef HAVE_WORKING_FORK
static int
wait_child_sync_if(
int pipe_read_fd,
long wait_sync
int pipe_read_fd,
unsigned long wait_sync
)
{
int rc;
int exit_code;
char ch;
time_t wait_end_time;
time_t cur_time;
time_t wait_rem;
fd_set readset;
struct timeval wtimeout;
if (0 == wait_sync)
return 0;
/* we wait a bit for the child in *any* case, because on failure
* of the child we have to get and inspect the exit code!
*/
wait_end_time = time(NULL);
if (wait_sync)
wait_end_time += wait_sync;
else
wait_end_time += 30;
/* waitsync_fd_to_close used solely by child */
close(waitsync_fd_to_close);
wait_end_time = time(NULL) + wait_sync;
do {
cur_time = time(NULL);
wait_rem = (wait_end_time > cur_time)
@@ -1584,10 +1668,9 @@ wait_child_sync_if(
if (-1 == rc) {
if (EINTR == errno)
continue;
exit_code = (errno) ? errno : -1;
msyslog(LOG_ERR,
"--wait-sync select failed: %m");
return exit_code;
"daemon startup: select failed: %m");
return EX_IOERR;
}
if (0 == rc) {
/*
@@ -1604,16 +1687,70 @@ wait_child_sync_if(
NULL, &wtimeout);
if (0 == rc) /* select() timeout */
break;
else /* readable */
}
rc = read(pipe_read_fd, &ch, 1);
if (rc == 0) {
DPRINTF(2, ("daemon control: got EOF\n"));
return -1; /* unexpected EOF, check daemon */
} else if (rc == 1) {
DPRINTF(2, ("daemon control: got '%c'\n",
(ch >= ' ' ? ch : '.')));
if (ch == 'R' && !wait_sync)
return 0;
} else /* readable */
return 0;
if (ch == 'S' && wait_sync)
return 0;
} else {
DPRINTF(2, ("daemon control: read 1 char failed: %s\n",
strerror(errno)));
return EX_IOERR;
}
} while (wait_rem > 0);
fprintf(stderr, "%s: -w/--wait-sync %ld timed out.\n",
progname, wait_sync);
return ETIMEDOUT;
if (wait_sync) {
fprintf(stderr, "%s: -w/--wait-sync %ld timed out.\n",
progname, wait_sync);
return EX_PROTOCOL;
} else {
fprintf(stderr, "%s: daemon startup monitoring timed out.\n",
progname);
return 0;
}
}
static int
wait_child_exit_if(
pid_t cpid,
int blocking
)
{
# ifdef HAVE_WAITPID
int rc = 0;
int wstatus;
if (cpid == waitpid(cpid, &wstatus, (blocking ? 0 : WNOHANG))) {
DPRINTF(1, ("child (pid=%d) dead now\n", cpid));
if (WIFEXITED(wstatus)) {
rc = WEXITSTATUS(wstatus);
msyslog(LOG_ERR, "daemon child exited with code %d",
rc);
} else if (WIFSIGNALED(wstatus)) {
rc = EX_SOFTWARE;
msyslog(LOG_ERR, "daemon child died with signal %d",
WTERMSIG(wstatus));
} else {
rc = EX_SOFTWARE;
msyslog(LOG_ERR, "daemon child died with unknown cause");
}
} else {
DPRINTF(1, ("child (pid=%d) still alive\n", cpid));
}
return rc;
# else
UNUSED_ARG(cpid);
return 0;
# endif
}
# endif /* HAVE_WORKING_FORK */
+4 -4
View File
@@ -67,7 +67,7 @@ The program can operate in any of several modes, including client/server,
symmetric and broadcast modes, and with both symmetric-key and public-key
cryptography.
</p>
<p>This document applies to version 4.2.8p13 of <code>ntpd</code>.
<p>This document applies to version 4.2.8p14 of <code>ntpd</code>.
</p>
<a name="SEC_Overview"></a>
<h2 class="shortcontents-heading">Short Table of Contents</h2>
@@ -309,7 +309,7 @@ used to select the program, defaulting to <samp>more</samp>. Both will exit
with a status code of 0.
</p>
<div class="example">
<pre class="example">ntpd - NTP daemon program - Ver. 4.2.8p12
<pre class="example">ntpd - NTP daemon program - Ver. 4.2.8p14
Usage: ntpd [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... \
[ &lt;server1&gt; ... &lt;serverN&gt; ]
Flg Arg Option-Name Description
@@ -331,7 +331,7 @@ Usage: ntpd [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ].
-g no panicgate Allow the first adjustment to be Big
- may appear multiple times
-G no force-step-once Step any initial offset correction.
-i Str jaildir Jail directory
-i --- jaildir built without --enable-clockctl or --enable-linuxcaps or --enable-solarisprivs
-I Str interface Listen on an interface name or address
- may appear multiple times
-k Str keyfile path to symmetric keys
@@ -354,7 +354,7 @@ Usage: ntpd [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ].
-s Str statsdir Statistics file location
-t Str trustedkey Trusted key number
- may appear multiple times
-u Str user Run as userid (or userid:groupid)
-u --- user built without --enable-clockctl or --enable-linuxcaps or --enable-solarisprivs
-U Num updateinterval interval in seconds between scans for new or dropped interfaces
Str var make ARG an ntp variable (RW)
- may appear multiple times
+3 -3
View File
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
.TH ntpd @NTPD_MS@ "20 Feb 2019" "4.2.8p13" "User Commands"
.TH ntpd @NTPD_MS@ "03 Mar 2020" "4.2.8p14" "User Commands"
.\"
.\" EDIT THIS FILE WITH CAUTION (in-mem file)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:46 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:41:05 PM by AutoGen 5.18.5
.\" From the definitions ntpd-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
@@ -979,7 +979,7 @@ RFC5908
.SH "AUTHORS"
The University of Delaware and Network Time Foundation
.SH "COPYRIGHT"
Copyright (C) 1992-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.SH BUGS
The
+3 -3
View File
@@ -1,9 +1,9 @@
.Dd February 20 2019
.Dd March 3 2020
.Dt NTPD @NTPD_MS@ User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpd-opts.mdoc)
.\"
.\" It has been AutoGen-ed February 20, 2019 at 09:56:37 AM by AutoGen 5.18.5
.\" It has been AutoGen-ed March 3, 2020 at 05:40:55 PM by AutoGen 5.18.5
.\" From the definitions ntpd-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
@@ -886,7 +886,7 @@ A snapshot of this documentation is available in HTML format in
.Sh "AUTHORS"
The University of Delaware and Network Time Foundation
.Sh "COPYRIGHT"
Copyright (C) 1992\-2017 The University of Delaware and Network Time Foundation all rights reserved.
Copyright (C) 1992\-2020 The University of Delaware and Network Time Foundation all rights reserved.
This program is released under the terms of the NTP license, <http://ntp.org/license>.
.Sh BUGS
The
Loaded 100 of 719 files, more files were not shown because too many files have changed in this diff. Show more