summaryrefslogtreecommitdiff
path: root/usr.sbin/ntpd
diff options
context:
space:
mode:
authorKevin Steves <stevesk@cvs.openbsd.org>2009-03-04 18:46:45 +0000
committerKevin Steves <stevesk@cvs.openbsd.org>2009-03-04 18:46:45 +0000
commit7708ae5fde66bd76b3c499be93095730da14c2d1 (patch)
tree58e32c14170c750b1b9c2ee4b5cece23bb133e6c /usr.sbin/ntpd
parent48c8a212672c4e9915090f6a6b5c4eb236c74a68 (diff)
log reason when not synced; ok henning@
Diffstat (limited to 'usr.sbin/ntpd')
-rw-r--r--usr.sbin/ntpd/client.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/usr.sbin/ntpd/client.c b/usr.sbin/ntpd/client.c
index bf374510bea..0f9ca4b4620 100644
--- a/usr.sbin/ntpd/client.c
+++ b/usr.sbin/ntpd/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.81 2008/06/10 03:51:53 naddy Exp $ */
+/* $OpenBSD: client.c,v 1.82 2009/03/04 18:46:44 stevesk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -20,6 +20,7 @@
#include <sys/param.h>
#include <errno.h>
#include <md5.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -218,10 +219,25 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime)
if ((msg.status & LI_ALARM) == LI_ALARM || msg.stratum == 0 ||
msg.stratum > NTP_MAXSTRATUM) {
+ char s[16];
+
+ if ((msg.status & LI_ALARM) == LI_ALARM) {
+ strlcpy(s, "alarm", sizeof(s));
+ } else if (msg.stratum == 0) {
+ /* Kiss-o'-Death (KoD) packet */
+ if (msg.refid != 0)
+ snprintf(s, sizeof(s), "KoD %.4s",
+ (char *)&msg.refid);
+ else
+ strlcpy(s, "KoD", sizeof(s));
+ } else if (msg.stratum > NTP_MAXSTRATUM) {
+ snprintf(s, sizeof(s), "stratum %d", msg.stratum);
+ }
interval = error_interval();
set_next(p, interval);
- log_info("reply from %s: not synced, next query %ds",
- log_sockaddr((struct sockaddr *)&p->addr->ss), interval);
+ log_info("reply from %s: not synced (%s), next query %ds",
+ log_sockaddr((struct sockaddr *)&p->addr->ss), s,
+ interval);
return (0);
}