[Git][NTPsec/ntpsec][master] 4 commits: Add peer depricated message
Hal Murray
gitlab at mg.gitlab.com
Mon May 15 00:20:17 UTC 2017
Hal Murray pushed to branch master at NTPsec / ntpsec
Commits:
ef8d7146 by Hal Murray at 2017-05-14T17:17:53-07:00
Add peer depricated message
- - - - -
308d067a by Hal Murray at 2017-05-14T17:17:53-07:00
Tweak comment in ntp_monitor, Issue #281
- - - - -
daa9139f by Hal Murray at 2017-05-14T17:17:53-07:00
Implement ENABLE_DNS_LOOKUP
- - - - -
7c40c676 by Hal Murray at 2017-05-14T17:17:53-07:00
DNS bug fixing/cleanups
pool mode now creates the peer slot before
it sends the first packet.
- - - - -
7 changed files:
- libntp/ntp_dns.c
- ntpd/ntp_config.c
- ntpd/ntp_io.c
- ntpd/ntp_monitor.c
- ntpd/ntp_peer.c
- ntpd/ntp_proto.c
- ntpd/ntpd.c
Changes:
=====================================
libntp/ntp_dns.c
=====================================
--- a/libntp/ntp_dns.c
+++ b/libntp/ntp_dns.c
@@ -7,6 +7,8 @@
#include "config.h"
+#ifdef ENABLE_DNS_LOOKUP
+
#include <signal.h>
#include <pthread.h>
#include <sys/types.h>
@@ -79,7 +81,7 @@ void dns_check(void)
return; /* leaves active set */
}
if (0 != gai_rc) {
- msyslog(LOG_INFO, "dns_check: join failed %s",
+ msyslog(LOG_INFO, "dns_check: DNS error %s",
gai_strerror(gai_rc));
/* FIXME-DNS callback with null? */
active = NULL;
@@ -122,3 +124,6 @@ static void* dns_lookup(void* arg)
};
+
+#endif /* ENABLE_DNS_LOOKUP */
+
=====================================
ntpd/ntp_config.c
=====================================
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -2559,6 +2559,13 @@ peer_config(
uint8_t cast_flags;
uint8_t hmode;
+#ifndef ENABLE_DNS_LOOKUP
+ if (NULL != hostname) {
+ msyslog(LOG_ERR, "hostnames need DNS lookup: %s", hostname);
+ return NULL;
+ }
+#endif
+
/*
* We do a dirty little jig to figure the cast flags. This is
* probably not the best place to do this, at least until the
@@ -2576,6 +2583,10 @@ peer_config(
ctl->flags &= ~FLAG_PREEMPT;
break;
+ case T_Peer:
+ msyslog(LOG_ERR, "peer depricated, treated as server: %s",
+ NULL != hostname? hostname : socktoa(srcadr) );
+ FALLTHRU
case T_Server:
cast_flags = MDF_UCAST;
hmode = MODE_CLIENT;
@@ -2584,7 +2595,7 @@ peer_config(
break;
default:
-msyslog(LOG_ERR, "peer_config, strange htype: %d", htype);
+ msyslog(LOG_ERR, "peer_config, strange htype: %d", htype);
cast_flags = MDF_UCAST;
hmode = MODE_CLIENT;
}
=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -261,7 +261,11 @@ static int read_refclock_packet (SOCKET, struct refclockio *, l_fp);
*/
volatile bool sawALRM = false;
volatile bool sawHUP = false;
+#ifdef ENABLE_DNS_LOOKUP
volatile bool sawDNS = false;
+#else
+# define sawDNS false
+#endif
volatile bool sawQuit = false; /* SIGQUIT, SIGINT, SIGTERM */
sigset_t blockMask;
=====================================
ntpd/ntp_monitor.c
=====================================
--- a/ntpd/ntp_monitor.c
+++ b/ntpd/ntp_monitor.c
@@ -421,7 +421,7 @@ ntp_monitor(
* limit on the total number of entries.
* - mru_maxage ("mru maxage") is a ceiling on the age in
* seconds of entries. Entries older than this are
- * reclaimed once mon_mindepth is exceeded. 64s default.
+ * reclaimed once mon_mindepth is exceeded. 3600s default.
* Note that entries older than this can easily survive
* as they are reclaimed only as needed.
* - mru_maxdepth ("mru maxdepth") is a hard limit on the
=====================================
ntpd/ntp_peer.c
=====================================
--- a/ntpd/ntp_peer.c
+++ b/ntpd/ntp_peer.c
@@ -9,7 +9,6 @@
#include "ntpd.h"
#include "ntp_lists.h"
#include "ntp_stdlib.h"
-#include "ntp_dns.h"
/*
* Table of valid association combinations
@@ -629,8 +628,8 @@ newpeer(
struct peer * peer;
u_int hash;
-msyslog(LOG_INFO, "newpeer: addr:%s, name:%s, flags:%x",
- socktoa(srcadr), hostname, cast_flags);
+msyslog(LOG_INFO, "newpeer: addr:%s, name:%s, cast_flags:%x, flags:%x",
+ socktoa(srcadr), hostname, cast_flags, flags);
/*
* First search from the beginning for an association with given
@@ -752,11 +751,8 @@ msyslog(LOG_INFO, "newpeer: addr:%s, name:%s, flags:%x",
/*
* Put the new peer in the hash tables.
*/
- if (FLAG_DNS && flags) {
- hash = NTP_HASH_ADDR(&peer->srcadr);
- LINK_SLIST(peer_hash[hash], peer, adr_link);
- peer_hash_count[hash]++;
- }
+ if ((MDF_UCAST & cast_flags) && !(FLAG_DNS & flags))
+ peer_update_hash(peer);
hash = peer->associd & NTP_HASH_MASK;
LINK_SLIST(assoc_hash[hash], peer, aid_link);
assoc_hash_count[hash]++;
=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -894,6 +894,7 @@ transmit(
* This was observed testing with pool, where sys_maxclock == 12
* resulted in 60 associations without the hard limit.
*/
+#ifdef ENABLE_DNS_LOOKUP
if (peer->cast_flags & MDF_POOL) {
/* FIXME-DNS turn on FLAG_DNS for pool */
peer->outdate = current_time;
@@ -914,7 +915,7 @@ transmit(
poll_update(peer, hpoll);
return;
}
-
+#endif
/*
* In unicast modes the dance is much more intricate. It is
@@ -2461,18 +2462,16 @@ pool_take_dns(
struct addrinfo *ai /* answer from getaddrinfo */
)
{
- struct pkt xpkt; /* transmit packet structure */
- endpt * lcladr;
sockaddr_u * rmtadr;
+ struct peer * peer;
int restrict_mask;
- struct peer * p;
- l_fp xmt_tx;
+ endpt * lcladr;
for ( ; NULL != ai; ai = ai->ai_next) {
rmtadr = (sockaddr_u *)(void *)ai->ai_addr;
msyslog(LOG_INFO, "Pool checking: %s", socktoa(rmtadr));
- p = findexistingpeer(rmtadr, NULL, NULL, MODE_CLIENT);
- if (NULL != p) continue; /* already in use */
+ peer = findexistingpeer(rmtadr, NULL, NULL, MODE_CLIENT);
+ if (NULL != peer) continue; /* already in use */
msyslog(LOG_INFO, "Pool trying: %s", socktoa(rmtadr));
restrict_mask = restrictions(rmtadr);
@@ -2480,7 +2479,17 @@ msyslog(LOG_INFO, "Pool trying: %s", socktoa(rmtadr));
if (RES_FLAGS & restrict_mask)
restrict_source(rmtadr, false,
current_time + POOL_SOLICIT_WINDOW + 1);
+
lcladr = findinterface(rmtadr);
+ peer = newpeer(rmtadr, NULL, lcladr,
+ MODE_CLIENT, pool->version,
+ pool->minpoll, pool->maxpoll,
+ FLAG_PREEMPT | (FLAG_IBURST & pool->flags),
+ MDF_UCAST | MDF_UCLNT, 0, 0, false);
+ peer_xmit(peer);
+ poll_update(peer, peer->hpoll);
+
+#if 0
memset(&xpkt, 0, sizeof(xpkt));
xpkt.li_vn_mode = PKT_LI_VN_MODE(sys_leap, pool->version,
MODE_CLIENT);
@@ -2497,6 +2506,7 @@ msyslog(LOG_INFO, "Pool trying: %s", socktoa(rmtadr));
sendpkt(rmtadr, lcladr, &xpkt, LEN_PKT_NOMAC);
pool->sent++;
pool->throttle += (1 << pool->minpoll) - 2;
+#endif
DPRINTF(1, ("transmit: at %lu %s->%s pool\n",
current_time, latoa(lcladr), socktoa(rmtadr)));
=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -12,7 +12,9 @@
#include "ntp_config.h"
#include "ntp_syslog.h"
#include "ntp_assert.h"
+#ifdef ENABLE_DNS_LOOKUP
#include "ntp_dns.h"
+#endif
#include "isc/error.h"
#include "isc/formatcheck.h"
@@ -96,7 +98,9 @@ static int wait_child_sync_if (int, long);
#endif
static void catchHUP (int);
+#ifdef ENABLE_DNS_LOOKUP
static void catchDNS (int);
+#endif
# ifdef DEBUG
static void moredebug (int);
@@ -654,7 +658,9 @@ ntpdmain(
signal_no_reset(SIGTERM, catchQuit);
signal_no_reset(SIGHUP, catchHUP);
signal_no_reset(SIGBUS, catchQuit); /* FIXME: It's broken, can't continue. */
+#ifdef ENABLE_DNS_LOOKUP
signal_no_reset(SIGDNS, catchDNS);
+#endif
# ifdef DEBUG
(void) signal_no_reset(MOREDEBUGSIG, moredebug);
@@ -946,10 +952,12 @@ static void mainloop(void)
timer();
}
+#ifdef ENABLE_DNS_LOOKUP
if (sawDNS) {
sawDNS = false;
dns_check();
}
+#endif
# ifdef ENABLE_DEBUG_TIMING
{
@@ -1084,6 +1092,8 @@ static void catchHUP(int sig)
UNUSED_ARG(sig);
sawHUP = true;
}
+
+#ifdef ENABLE_DNS_LOOKUP
/*
* catchDNS - set flag to process answer DNS lookup
*/
@@ -1092,7 +1102,7 @@ static void catchDNS(int sig)
UNUSED_ARG(sig);
sawDNS = true;
}
-
+#endif
/*
* wait_child_sync_if - implements parent side of -w/--wait-sync
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/382b70e0cab580bda5fed298976fc1a5ff074228...7c40c676f210fc8d5365931ec1fd537b71989381
---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/382b70e0cab580bda5fed298976fc1a5ff074228...7c40c676f210fc8d5365931ec1fd537b71989381
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170515/df7a32dd/attachment.html>
More information about the vc
mailing list