aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networking/ntpd.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 517806e75..410318979 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -267,6 +267,7 @@ typedef struct {
267 267
268typedef struct { 268typedef struct {
269 len_and_sockaddr *p_lsa; 269 len_and_sockaddr *p_lsa;
270 char *p_hostname;
270 char *p_dotted; 271 char *p_dotted;
271 int p_fd; 272 int p_fd;
272 int datapoint_idx; 273 int datapoint_idx;
@@ -781,11 +782,14 @@ add_peers(const char *s)
781 peer_t *pp = (peer_t *) item->data; 782 peer_t *pp = (peer_t *) item->data;
782 if (strcmp(p->p_dotted, pp->p_dotted) == 0) { 783 if (strcmp(p->p_dotted, pp->p_dotted) == 0) {
783 bb_error_msg("duplicate peer %s (%s)", s, p->p_dotted); 784 bb_error_msg("duplicate peer %s (%s)", s, p->p_dotted);
785 free(p->p_lsa);
786 free(p->p_dotted);
784 free(p); 787 free(p);
785 return; 788 return;
786 } 789 }
787 } 790 }
788 791
792 p->p_hostname = xstrdup(s);
789 p->p_fd = -1; 793 p->p_fd = -1;
790 p->p_xmt_msg.m_status = MODE_CLIENT | (NTP_VERSION << 3); 794 p->p_xmt_msg.m_status = MODE_CLIENT | (NTP_VERSION << 3);
791 p->next_action_time = G.cur_time; /* = set_next(p, 0); */ 795 p->next_action_time = G.cur_time; /* = set_next(p, 0); */
@@ -2332,6 +2336,21 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv)
2332 timeout = poll_interval(NOREPLY_INTERVAL); 2336 timeout = poll_interval(NOREPLY_INTERVAL);
2333 bb_error_msg("timed out waiting for %s, reach 0x%02x, next query in %us", 2337 bb_error_msg("timed out waiting for %s, reach 0x%02x, next query in %us",
2334 p->p_dotted, p->reachable_bits, timeout); 2338 p->p_dotted, p->reachable_bits, timeout);
2339
2340 /* What if don't see it because it changed its IP? */
2341 if (p->reachable_bits == 0) {
2342 len_and_sockaddr *lsa = host2sockaddr(p->p_hostname, 123);
2343 if (lsa) {
2344 char *dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa);
2345 //if (strcmp(dotted, p->p_dotted) != 0)
2346 // bb_error_msg("peer IP changed");
2347 free(p->p_lsa);
2348 free(p->p_dotted);
2349 p->p_lsa = lsa;
2350 p->p_dotted = dotted;
2351 }
2352 }
2353
2335 set_next(p, timeout); 2354 set_next(p, timeout);
2336 } 2355 }
2337 } 2356 }