kern/106726: ntp functions return wrong values

Bruce Evans bde at zeta.org.au
Fri Dec 15 03:10:14 PST 2006


The following reply was made to PR kern/106726; it has been noted by GNATS.

From: Bruce Evans <bde at zeta.org.au>
To: Judah Levine <jlevine at boulder.nist.gov>
Cc: freebsd-gnats-submit at freebsd.org, freebsd-bugs at freebsd.org
Subject: Re: kern/106726: ntp functions return wrong values
Date: Fri, 15 Dec 2006 22:04:39 +1100 (EST)

 On Thu, 14 Dec 2006, Judah Levine wrote:
 
 >> Description:
 > The system calls ntp_gettime() and ntp_adjtime() return incorrect values. This problem is new to 6.1 -- the same subroutines called from the identical user program worked correctly in 5.1, the previous version that I was using.
 
 The API certainly changed.
 
 > I am prepared to try and fix the problem myself, but I think the problem is in ntp_gettime(), which I think is in libc. I have all of the CDs but I can't find the source code for libc. Can you tell me where this code is located?
 
 net_gettime(2) is now a syscall so it is in the kernel (kern_ntptime.c).
 This syscall is normal -- it just copies out the result and returns 0
 on success and -1/errno on error.  This behaviour is documented.
 
 I can't find any documentation for the old library function ntp_gettoime(3).
 It returns tv.time_state on success and TIME_ERROR on error.  This API is
 bogus:
 - there is no need to return tv.time_state on success since the whole tv
    is returned then
 - TIME_ERROR is a strange error code.  It is 5.
 - the error may be a sysctl error that is unrelated to ntp.
 I hope nothing requires this.
 
 >> How-To-Repeat:
 > A call to ntp_gettime will return the status of the call rather than the status of the clock, which is how it is supposed to work. the return status is -1 with an errno of 55.
 
 Really -1/55?  -1 indicates coplete failure, and 55 is ENOBUFS.  The
 possible errnos for the syscall version are undocumented, but I think
 they don't include ENOBUFS.  I think the only possible errors are
 ENOSYS if the syscall is missing and EFAULT if the user address is
 invalid.
 
 Old binaries using the old library version should still work, since
 the sysctl used by the old library version is still supported.  They
 work for me.  I use a not-so-old userland with certain old library
 calls including ntp_gettime(3), with kernels between RELENG_4 and
 -current, and the not-so-old ntpd works for all of these with no
 problems.
 
 Bruce


More information about the freebsd-bugs mailing list