Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Dec 2006 22:04:39 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Judah Levine <jlevine@boulder.nist.gov>
Cc:        freebsd-bugs@freebsd.org, freebsd-gnats-submit@freebsd.org
Subject:   Re: kern/106726: ntp functions return wrong values
Message-ID:  <20061215213617.C3744@besplex.bde.org>
In-Reply-To: <200612141923.kBEJNSXf009545@www.freebsd.org>
References:  <200612141923.kBEJNSXf009545@www.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20061215213617.C3744>