From 41d74ba7918bfd96d28d2e8eb3e7da54d04b8f78 Mon Sep 17 00:00:00 2001 From: stevesk <> Date: Wed, 4 Mar 2009 18:46:44 +0000 Subject: [PATCH] log reason when not synced; ok henning@ --- src/usr.sbin/ntpd/client.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/usr.sbin/ntpd/client.c b/src/usr.sbin/ntpd/client.c index bf374510..0f9ca4b4 100644 --- a/src/usr.sbin/ntpd/client.c +++ b/src/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 @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -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); }