# New NTP error after upgrade

## hanj

Hello

I just upgraded ntp to 4.2.4-r1 and I'm starting to see some errors in the logs.

```
Mar  5 07:20:09 comp ntpd[7181]: kernel time sync error 0001

Mar  5 07:54:18 comp ntpd[7181]: kernel time sync error 0001
```

Can anyone shed some light on this? Let me know if I can provide any additional information.

Here are my USE flags:

```
net-misc/ntp-4.2.4-r1  USE="caps ssl -debug -ipv6 -openntpd -parse-clocks (-selinux)"
```

Thanks!

hanji

----------

## wynn

It is a bug in 4.2.4 (apparently) see https://ntp.isc.org/bugs/show_bug.cgi?id=780. The last message is 26 February but, without reading and understanding the exchanges, it it not clear whether it has been resolved.

----------

## hanj

I see what you mean. Thanks for posting that!

hanji

----------

## deoren

Thanks wynn for directing me to this post.  Also thanks for your sig because now I've added that movie to my todo list.   :Wink: 

In case anyone doesn't know, one possible workaround is to downgrade to net-misc/ntp-4.2.2_p3 until the problem is worked out upstream.

This can be accomplished by adding the following:

```
# http://forums.gentoo.org/viewtopic-t-544792.html

=net-misc/ntp-4.2.4-r1
```

to your /etc/portage/package.mask file and running 

```
emerge -vpD ntp
```

This should show you that net-misc/ntp-4.2.2_p3 will be installed.

Hope that helps someone.

----------

## overkll

Funny, I'm not experiencing ANY errors with ntp-4.2.4-r1.

----------

## AllanS

I just upgraded and now ntpd will not start:

```
ntpd[5607]: ntpd 4.2.4@1.1437-o Thu Mar  8 21:55:16 UTC 2007 (1)

ntpd[5608]: precision = 1.000 usec

ntpd[5608]: Listening on interface #0 wildcard, 0.0.0.0#123 Disabled

ntpd[5608]: Listening on interface #1 eth0, 192.169.1.42#123 Enabled

ntpd[5608]: Listening on interface #2 lo, 127.0.0.1#123 Enabled

ntpd[5608]: kernel time sync status 0040

rc-scripts: Failed to start ntpd

```

```
uname -a

Linux galactica 2.6.19-gentoo-r5 #1 PREEMPT Thu Mar 1 15:50:51 EST 2007 i686 AMD Athlon(TM) XP1600+ AuthenticAMD GNU/Linux
```

This is after a "emerge --update --ask --deep --newuse world" and "revdep-rebuild". etc-update was done as well.

----------

## AllanS

I just downgraded my ntpd and it still does not work:

```
ntpd[19270]: ntpd 4.2.2p3@1.1577-o Fri Mar  9 15:01:22 UTC 2007 (1)

ntpd[19271]: precision = 1.000 usec

ntpd[19271]: Listening on interface wildcard, 0.0.0.0#123 Disabled

ntpd[19271]: Listening on interface eth0, 192.169.1.42#123 Enabled

ntpd[19271]: Listening on interface lo, 127.0.0.1#123 Enabled

ntpd[19271]: kernel time sync status 0040

rc-scripts: Failed to start ntpd
```

Any other ideas?

----------

## overkll

Allan, what's your /etc/ntp.conf and /etc/conf.d/ntpd contain?

Are you using dhcp to get an IP address?

----------

## AllanS

I use a static IP through a DSL router. The router gets its IP address from my ISP. Network connectivity, name resolution, etc., all work fine. I can ping my NTP server and using the "ntp-client" during startup works fine as well (to the same server). All this worked before the upgrade.

/etc/conf.d/ntpd :

```
# /etc/conf.d/ntpd

# Options to pass to the ntpd process

# Most people should leave this line alone ...

# however, if you know what you're doing, feel free to tweak

NTPD_OPTS="-u ntp:ntp"
```

Non-comment sections of /etc/ntp.conf:

```
server timex.peachnet.edu

driftfile       /var/lib/ntp/ntp.drift

restrict default nomodify nopeer

restrict 127.0.0.1

restrict 192.169.0.0 mask 255.255.255.0 nomodify nopeer notrap
```

I am happy to be a guinea pig to figure this out, but I'm not sure which direction I should go in. What other information would be helpful? I am back using ntpd 4.2.4 but since the older version did not work, I am wondering if there is another library or package that is interfering with this.

I also recently emerged cdrkit which required cmake and libcap (libcap is now version 1.10-r9, but I think it was already at that version, so maybe a IUSE change?).

I checked for other applications binding to port 123 (ntp) and found none.

----------

## doctorofcomputers

*edit*Last edited by doctorofcomputers on Sat Mar 10, 2007 7:00 pm; edited 1 time in total

----------

## AllanS

Well, in the spirit of "What the heck", I tried it. Full removal and then full install.

It didn't work for me.

----------

## wynn

ntpd will fail to start if the difference between the time on your box and the server time is over 1000 seconds, could this be the case?

You should be able to see messages in /var/log/messages showing what went on.

ntpdate (run by ntp-client) will timeout if it can't get a server response in 1 second (default) and may not, therefore, have corrected the BIOS time.

----------

## AllanS

I do not believe that is the case. The current date on my box is very close to other computers and matches the wall clock (within a minute or so). It is well within the range of 1000 seconds.

I just ran ntpdate manually against my normal server and it replied that I was 0.122 seconds off. This shows that ntpdate works and so does the server.

The time is correct (via ntp-client), but ntpd will not start.

This seems to be specific to ntpd, but not just this version but the last as well. Since the last version used to work I am thinking that it is a recent library or supporting function that ntpd uses. A quick "ldd -v /usr/sbin/ntpd" shows:

```
linux-gate.so.1 =>  (0xffffe000)

libm.so.6 => /lib/libm.so.6 (0xb7f16000)

libcrypto.so.0.9.8 => /usr/lib/libcrypto.so.0.9.8 (0xb7dde000

libc.so.6 => /lib/libc.so.6 (0xb7cb7000)

/lib/ld-linux.so.2 (0xb7f60000)

libdl.so.2 => /lib/libdl.so.2 (0xb7cb3000)

Version information:

/usr/sbin/ntpd:

        libm.so.6 (GLIBC_2.0) => /lib/libm.so.6

        libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6

        libc.so.6 (GLIBC_2.3) => /lib/libc.so.6

        libc.so.6 (GLIBC_2.1) => /lib/libc.so.6

        libc.so.6 (GLIBC_2.3.4) => /lib/libc.so.6

        libc.so.6 (GLIBC_2.0) => /lib/libc.so.6

/lib/libm.so.6:

        ld-linux.so.2 (GLIBC_PRIVATE) => /lib/ld-linux.so.2

        libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6

        libc.so.6 (GLIBC_2.0) => /lib/libc.so.6

/usr/lib/libcrypto.so.0.9.8:

        libdl.so.2 (GLIBC_2.1) => /lib/libdl.so.2

        libdl.so.2 (GLIBC_2.0) => /lib/libdl.so.2

        libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6

        libc.so.6 (GLIBC_2.1) => /lib/libc.so.6

        libc.so.6 (GLIBC_2.3) => /lib/libc.so.6

        libc.so.6 (GLIBC_2.0) => /lib/libc.so.6

/lib/libc.so.6:

        ld-linux.so.2 (GLIBC_2.1) => /lib/ld-linux.so.2

        ld-linux.so.2 (GLIBC_2.3) => /lib/ld-linux.so.2

        ld-linux.so.2 (GLIBC_PRIVATE) => /lib/ld-linux.so.2

/lib/libdl.so.2:

        libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6

        libc.so.6 (GLIBC_2.1) => /lib/libc.so.6

        libc.so.6 (GLIBC_2.0) => /lib/libc.so.6

        libc.so.6 (GLIBC_PRIVATE) => /lib/libc.so.6

        ld-linux.so.2 (GLIBC_PRIVATE) => /lib/ld-linux.so.2
```

All of these were compiled around 22-Feb-2007, but the ntpd was working after that. Only libcap was comiled on 07-Mar-2007, so that is why I suspect it.

----------

## overkll

Have you tried fiddling with /etc/ntpd.conf?  Try commenting out everything except for the server and the driftfile location, save and restart.

----------

## AllanS

No joy. I haven't touch that file in months. So I am not surprised that did not fix it.

I looked into the kernel code (ntp.c) and see that the status listed above (in my log: 0x0040) is STA_UNSYNC - this is the default error status. I did recently upgrade my kernel from 2.6.18-gentoo-r6 to 2.6.19-gentoo-r5 and I am beginning to think it is associated with that. In the older kernel the default error status was 0x0000. In going to the new kernel, all the ntp-related functions in time.c and timer.c were moved to a new ntp.c and that is where the default status is set.

Can someone in the kernel team look there and see if I am interpreting this correctly? It may be that ntpd just needs to ignore that status at that time of the process and just continue on.

----------

## wynn

ldd -v /usr/sbin/ntpd showed exactly the same output as you have â libpcap isn't there though: ntpd opens an ordinary socket pair to send and receive messages on UDP port 123, not like tcpdump which wants to get everything.

What do you find in /var/log/messages? ntpd should say why it is stopping and this will give us a clue as to where to concentrate our efforts.

Are you running it in a chroot jail and it can't get at its ntp.conf?

Does your /etc/ntp.drift look reasonable? This is what it has here

```
# cat /var/lib/ntp/ntp.drift

46.298
```

for a working 4.2.4-r1.

http://www.ee.udel.edu/~mills/ntp/html/debug.html says you can run ntpd in debugging mode with the "-d" flag â but it doesn't work.

[Edit] It needs to be emerge'd with the "debug" USE flag. You should get something like this

```
ntpd -d

ntpd 4.2.4@1.1437-o Sat Mar 10 16:00:06 UTC 2007 (1)

addto_syslog: precision = 1.000 usec

addto_syslog: ntp_io: estimated max descriptors: 1024, initial socket boundary:

16

addto_syslog: Listening on interface #0 wildcard, 0.0.0.0#123 Disabled

addto_syslog: no IPv6 interfaces found

addto_syslog: no IPv6 interfaces found

addto_syslog: Listening on interface #1 lo, 127.0.0.1#123 Enabled

addto_syslog: Listening on interface #2 eth0, 192.168.1.37#123 Enabled

addto_syslog: Listening on interface #3 ath0, 192.168.0.100#123 Enabled

local_clock: time 0 offset 0.000000 freq 0.000 state 0

addto_syslog: kernel time sync status 0040

...

newpeer: 192.168.1.37->194.106.50.10 mode 3 vers 4 poll 6 10 flags 0x1 0x1 ttl 0 key 00000000

...
```

and so on. "newpeer" should have the IP address of your server and the "addto_syslog" are the entries which go into /var/log/messages â unless your syslog.conf/syslog-ng.conf arranges for them to go somewhere else.

----------

## wynn

 *AllanS wrote:*   

> No joy. I haven't touch that file in months. So I am not surprised that did not fix it.
> 
> I looked into the kernel code (ntp.c) and see that the status listed above (in my log: 0x0040) is STA_UNSYNC - this is the default error status. I did recently upgrade my kernel from 2.6.18-gentoo-r6 to 2.6.19-gentoo-r5 and I am beginning to think it is associated with that. In the older kernel the default error status was 0x0000. In going to the new kernel, all the ntp-related functions in time.c and timer.c were moved to a new ntp.c and that is where the default status is set.
> 
> Can someone in the kernel team look there and see if I am interpreting this correctly? It may be that ntpd just needs to ignore that status at that time of the process and just continue on.

 It will always start as unsynchronized, ntpd has to do quite a bit of work (file:///usr/share/doc/ntp-4.2.4-r1/html/debug.html) before setting the clock *Quote:*   

> Note that the daemon requires at least four packet exchanges when first started in any case. This is required in order for the mitigation algorithms to insure valid and accurate measurements and defend against network delay spikes and accidental or malicious errors induced by the servers selected in the configuration file. It normally takes less than four minutes to set the clock when first started, but this can be reduced to less than ten seconds with the iburst configuration option.

 The startup messages in /var/log/messages show this

```
Mar 10 16:07:12 lightfoot ntpd[31372]: kernel time sync status 0040

Mar 10 16:07:12 lightfoot ntpd[31372]: frequency initialized 52.003 PPM from /var/lib/ntp/ntp.drift

Mar 10 16:11:28 lightfoot ntpd[31372]: synchronized to 212.13.197.135, stratum 2

Mar 10 16:11:28 lightfoot ntpd[31372]: kernel time sync status change 0001
```

starting with your STA_UNSYNC and then changing after it has found a server it can trust.

----------

## overkll

Maybe it is kernel related.  I'm using ck-sources and have no errors.

----------

## wynn

Well, ntpd works without trouble on 2.6.18-gentoo-r3, 2.6.19-gentoo-r5 and 2.6.10-gentoo-r2 (the late compilation timestamp "Sat Mar 10 16:00:06 UTC 2007" is because I emerge'd it again with debugging).

2.6.18-gentoo-r3

```
Mar 10 17:21:08 lightfoot ntpd[6902]: ntpd 4.2.4@1.1437-o Sat Mar 10 16:00:06 UTC 2007 (1)

Mar 10 17:21:08 lightfoot ntpd[6903]: precision = 1.000 usec

Mar 10 17:21:08 lightfoot ntpd[6903]: Listening on interface #0 wildcard, 0.0.0.0#123 Disabled

Mar 10 17:21:08 lightfoot ntpd[6903]: Listening on interface #1 lo, 127.0.0.1#123 Enabled

Mar 10 17:21:08 lightfoot ntpd[6903]: kernel time sync status 0040

Mar 10 17:21:08 lightfoot ntpd[6903]: frequency initialized 57.084 PPM from /var/lib/ntp/ntp.drift

Mar 10 17:21:09 lightfoot ntpd[6903]: Listening on interface #2 eth0, 192.168.1.37#123 Enabled

Mar 10 17:25:41 lightfoot ntpd[6903]: synchronized to 194.153.168.75, stratum 2

Mar 10 17:25:41 lightfoot ntpd[6903]: time reset -0.476615 s

Mar 10 17:25:41 lightfoot ntpd[6903]: kernel time sync status change 0001
```

2.6.19-gentoo-r5

```
Mar 10 17:28:29 lightfoot ntpd[7148]: ntpd 4.2.4@1.1437-o Sat Mar 10 16:00:06 UTC 2007 (1)

Mar 10 17:28:29 lightfoot ntpd[7153]: precision = 1.000 usec

Mar 10 17:28:29 lightfoot ntpd[7153]: Listening on interface #0 wildcard, 0.0.0.0#123 Disabled

Mar 10 17:28:29 lightfoot ntpd[7153]: Listening on interface #1 lo, 127.0.0.1#123 Enabled

Mar 10 17:28:29 lightfoot ntpd[7153]: Listening on interface #2 eth0, 192.168.1.37#123 Enabled

Mar 10 17:28:29 lightfoot ntpd[7153]: kernel time sync status 0040

Mar 10 17:28:29 lightfoot ntpd[7153]: frequency initialized 57.084 PPM from /var/lib/ntp/ntp.drift

Mar 10 17:32:48 lightfoot ntpd[7153]: synchronized to 195.177.253.180, stratum 3

Mar 10 17:32:47 lightfoot ntpd[7153]: time reset -0.503255 s

Mar 10 17:32:47 lightfoot ntpd[7153]: kernel time sync status change 0001
```

and 2.6.20-gentoo-r2

```
Mar 10 17:39:17 lightfoot ntpd[6814]: ntpd 4.2.4@1.1437-o Sat Mar 10 16:00:06 UTC 2007 (1)

Mar 10 17:39:17 lightfoot ntpd[6815]: precision = 1.000 usec

Mar 10 17:39:17 lightfoot ntpd[6815]: Listening on interface #0 wildcard, 0.0.0.0#123 Disabled

Mar 10 17:39:17 lightfoot ntpd[6815]: Listening on interface #1 lo, 127.0.0.1#123 Enabled

Mar 10 17:39:17 lightfoot ntpd[6815]: kernel time sync status 0040

Mar 10 17:39:17 lightfoot ntpd[6815]: frequency initialized 57.088 PPM from /var/lib/ntp/ntp.drift

Mar 10 17:39:18 lightfoot ntpd[6815]: Listening on interface #2 eth0, 192.168.1.37#123 Enabled

Mar 10 17:44:17 lightfoot ntpd[6815]: synchronized to 193.201.200.74, stratum 4

Mar 10 17:44:16 lightfoot ntpd[6815]: time reset -0.501546 s

Mar 10 17:44:16 lightfoot ntpd[6815]: kernel time sync status change 0001
```

----------

## cmmalone

Add 

```

net-misc/ntp    caps

```

to your package.use, maybe?

----------

## AaronPPC

Yup.  It's fixed here, thanks.  I've been watching this thread with great interest.

----------

## blaize

My ntp exited in daemon mode, but with options "ntp -n" worked fine.

I emerged it with USE="caps" and it is ok with daemon mode now.

Thanks.  :Smile: 

PS: uname -a: Linux blaize 2.6.15-gentoo-r7-gds #1 SMP Sun Apr 9 14:01:52 MSD 2006 x86_64 Intel(R) Xeon(TM) CPU 2.80GHz GenuineIntel GNU/Linux

----------

## snIP3r

hi!

i got the same error. but after switching back to 4.2.2p3 everything runs as normal!

hope the next version of ntp will fix this error...

HTH

snIP3r

----------

## AllanS

Adding "debug" to USE did not add any information to the problem - ntpd still failed to start.

However, adding "caps" to my USE did fix my problem and now ntpd starts up and works. A subtle solution to a strange problem - nicely caught!

Thanks!

----------

## deoren

Anyone still having problems?  

I tried the recent stable release of net-misc/ntp-4.2.4_p0 and the problem resurfaced for me.

With the recent removal of net-misc/ntp-4.2.2_p3 from the portage tree (and my 'inability' to actually make sure I had a downgrade path) it looks like an upgrade from the 2.4 kernel series may be in order.

Upstream has marked this as a kernel error and the Gentoo bug entry for this shows it resolved upstream.

Anyone know what that final resolution is?

Thanks.

----------

## deoren

 *AllanS wrote:*   

> Adding "debug" to USE did not add any information to the problem - ntpd still failed to start.
> 
> However, adding "caps" to my USE did fix my problem and now ntpd starts up and works. A subtle solution to a strange problem - nicely caught!
> 
> Thanks!

 

Oh yeah, I also tried the caps use flag and didn't have any luck.

----------

## snIP3r

 *deoren wrote:*   

> Anyone still having problems?  
> 
> I tried the recent stable release of net-misc/ntp-4.2.4_p0 and the problem resurfaced for me.
> 
> With the recent removal of net-misc/ntp-4.2.2_p3 from the portage tree (and my 'inability' to actually make sure I had a downgrade path) it looks like an upgrade from the 2.4 kernel series may be in order.
> ...

 

hi deoren!

i had this problem too, also the same problem with the removal of ntp 4.2.2.

4.2.4 was not running properly on my older kernel 2.6.18. after i upgraded to 2.6.20-gentoo-r8 everything runs perfect now.

perhaps you should also upgrade your kernel...

HTH

snIP3r

----------

## deoren

Thanks for your reply snIP3r.  I was planning on a 2.4->2.6 kernel upgrade but didn't realize it would sneak up on me so quickly.  At least it's working with a recent kernel.   :Smile: 

----------

## deoren

As others have experienced, my current setup no longer experiences these issues with the latest updates.

For reference:

net-misc/ntp-4.2.4_p0

sys-kernel/gentoo-sources-2.6.21-r4

Thanks again snIP3r.

----------

## snIP3r

 *deoren wrote:*   

> As others have experienced, my current setup no longer experiences these issues with the latest updates.
> 
> For reference:
> 
> net-misc/ntp-4.2.4_p0
> ...

 

nop, u'r welcome

----------

## arantius

 *cmmalone wrote:*   

> Add 
> 
> ```
> 
> net-misc/ntp    caps
> ...

 

I tried this, kernel 2.6.18 hardened-sources.  Does not help.  Guess it's time for a kernel upgrade.

----------

## lazyleopard

I just stated seeing these in my logs after upgrading to net-misc/ntp-4.2.4_p6 from _p5.

```
Jan 20 12:05:43 chui ntpd[5107]: kernel time sync status change 4001

Jan 20 12:22:47 chui ntpd[5107]: kernel time sync status change 0001

Jan 20 12:46:58 duma ntpd[5144]: kernel time sync status change 4001

Jan 20 13:04:03 duma ntpd[5144]: kernel time sync status change 0001

Jan 20 13:12:51 paka ntpd[14950]: kernel time sync status change 0001
```

There's an old bug ( https://bugs.gentoo.org/171119 ) dating from March 2007 marked "resolved upstream". It looks as if the net-misc/ntp-4.2.4_p6 ( https://bugs.gentoo.org/254098 ? ) might have un-fixed something. Anyone else seeing this?

(Kernel from sys-kernel/gentoo-sources-2.6.27-r7 did not show problems with net-misc/ntp-4.2.4_p5.)

----------

