From owner-freebsd-bugs@FreeBSD.ORG Fri Dec 15 11:10:14 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7A41416A416 for ; Fri, 15 Dec 2006 11:10:14 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.FreeBSD.org (Postfix) with ESMTP id C5D3F43CB2 for ; Fri, 15 Dec 2006 11:08:32 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id kBFBA7Xg013924 for ; Fri, 15 Dec 2006 11:10:07 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id kBFBA7Rg013923; Fri, 15 Dec 2006 11:10:07 GMT (envelope-from gnats) Date: Fri, 15 Dec 2006 11:10:07 GMT Message-Id: <200612151110.kBFBA7Rg013923@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Bruce Evans Cc: Subject: Re: kern/106726: ntp functions return wrong values X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Bruce Evans List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Dec 2006 11:10:14 -0000 The following reply was made to PR kern/106726; it has been noted by GNATS. From: Bruce Evans To: Judah Levine Cc: freebsd-gnats-submit@freebsd.org, freebsd-bugs@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