aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networking/ntpd.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 4695c3366..517806e75 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -727,7 +727,7 @@ reset_peer_stats(peer_t *p, double offset)
727 727
728 /* Used to set p->filter_datapoint[i].d_dispersion = MAXDISP 728 /* Used to set p->filter_datapoint[i].d_dispersion = MAXDISP
729 * and clear reachable bits, but this proved to be too agressive: 729 * and clear reachable bits, but this proved to be too agressive:
730 * after step (tested with suspinding laptop for ~30 secs), 730 * after step (tested with suspending laptop for ~30 secs),
731 * this caused all previous data to be considered invalid, 731 * this caused all previous data to be considered invalid,
732 * making us needing to collect full ~8 datapoins per peer 732 * making us needing to collect full ~8 datapoins per peer
733 * after step in order to start trusting them. 733 * after step in order to start trusting them.
@@ -766,11 +766,26 @@ reset_peer_stats(peer_t *p, double offset)
766static void 766static void
767add_peers(const char *s) 767add_peers(const char *s)
768{ 768{
769 llist_t *item;
769 peer_t *p; 770 peer_t *p;
770 771
771 p = xzalloc(sizeof(*p)); 772 p = xzalloc(sizeof(*p));
772 p->p_lsa = xhost2sockaddr(s, 123); 773 p->p_lsa = xhost2sockaddr(s, 123);
773 p->p_dotted = xmalloc_sockaddr2dotted_noport(&p->p_lsa->u.sa); 774 p->p_dotted = xmalloc_sockaddr2dotted_noport(&p->p_lsa->u.sa);
775
776 /* Names like N.<country2chars>.pool.ntp.org are randomly resolved
777 * to a pool of machines. Sometimes different N's resolve to the same IP.
778 * It is not useful to have two peers with same IP. We skip duplicates.
779 */
780 for (item = G.ntp_peers; item != NULL; item = item->link) {
781 peer_t *pp = (peer_t *) item->data;
782 if (strcmp(p->p_dotted, pp->p_dotted) == 0) {
783 bb_error_msg("duplicate peer %s (%s)", s, p->p_dotted);
784 free(p);
785 return;
786 }
787 }
788
774 p->p_fd = -1; 789 p->p_fd = -1;
775 p->p_xmt_msg.m_status = MODE_CLIENT | (NTP_VERSION << 3); 790 p->p_xmt_msg.m_status = MODE_CLIENT | (NTP_VERSION << 3);
776 p->next_action_time = G.cur_time; /* = set_next(p, 0); */ 791 p->next_action_time = G.cur_time; /* = set_next(p, 0); */