aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2016-05-27 10:09:59 +0300
committerTimo Teräs <timo.teras@iki.fi>2016-05-27 10:25:03 +0300
commite4c5349a4ab2851deaf7794ef9d469f4ec9f4ff2 (patch)
tree7c4c7ce499182fe53b49f17afecd886d448e3119
parent3737eae3be7c465f3b0ef9c5c87b2a21024fd19e (diff)
downloadaports-e4c5349a4ab2851deaf7794ef9d469f4ec9f4ff2.tar.bz2
aports-e4c5349a4ab2851deaf7794ef9d469f4ec9f4ff2.tar.xz
main/busybox: cherry-pick ntpd fixes from master and mailing list
-rw-r--r--main/busybox/4001-ntpd-step-when-offset-1-sec-not-0.125-sec.patch153
-rw-r--r--main/busybox/4002-ntpd-shorter-message.patch26
-rw-r--r--main/busybox/4003-ntpd-print-packet-delay-in-clock-update-message.patch37
-rw-r--r--main/busybox/4004-ntpd-more-informative-poll-lowering-message.patch28
-rw-r--r--main/busybox/4005-ntpd-do-not-use-a-peer-more-than-once-say-if-two-pee.patch57
-rw-r--r--main/busybox/4006-ntpd-if-peer-does-not-reply-anymore-try-re-resolving.patch67
-rw-r--r--main/busybox/4007-ntpd-postpone-hostname-resolution-if-fails-on-startu.patch171
-rw-r--r--main/busybox/APKBUILD31
8 files changed, 569 insertions, 1 deletions
diff --git a/main/busybox/4001-ntpd-step-when-offset-1-sec-not-0.125-sec.patch b/main/busybox/4001-ntpd-step-when-offset-1-sec-not-0.125-sec.patch
new file mode 100644
index 0000000000..a2b6688fc6
--- /dev/null
+++ b/main/busybox/4001-ntpd-step-when-offset-1-sec-not-0.125-sec.patch
@@ -0,0 +1,153 @@
+From fc47fcefb6401605b142c30025c597dc4d110087 Mon Sep 17 00:00:00 2001
+From: Denys Vlasenko <vda.linux@googlemail.com>
+Date: Wed, 10 Feb 2016 06:55:07 +0100
+Subject: [PATCH 4001/4007] ntpd: step when |offset| > 1 sec, not 0.125 sec
+
+update_local_clock 769 820 +51
+recv_and_process_peer_pkt 838 862 +24
+reset_peer_stats 137 133 -4
+------------------------------------------------------------------------------
+(add/remove: 0/0 grow/shrink: 2/1 up/down: 75/-4) Total: 71 bytes
+
+Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
+---
+ networking/ntpd.c | 54 ++++++++++++++++++++++++++++++++++++------------------
+ 1 file changed, 36 insertions(+), 18 deletions(-)
+
+diff --git a/networking/ntpd.c b/networking/ntpd.c
+index 9732c9b..32590a1 100644
+--- a/networking/ntpd.c
++++ b/networking/ntpd.c
+@@ -112,7 +112,7 @@
+ *
+ * Made some changes to speed up re-syncing after our clock goes bad
+ * (tested with suspending my laptop):
+- * - if largish offset (>= STEP_THRESHOLD * 8 == 1 sec) is seen
++ * - if largish offset (>= STEP_THRESHOLD == 1 sec) is seen
+ * from a peer, schedule next query for this peer soon
+ * without drastically lowering poll interval for everybody.
+ * This makes us collect enough data for step much faster:
+@@ -131,11 +131,14 @@
+ #define RESPONSE_INTERVAL 16 /* wait for reply up to N secs */
+
+ /* Step threshold (sec). std ntpd uses 0.128.
++ */
++#define STEP_THRESHOLD 1
++/* Slew threshold (sec): adjtimex() won't accept offsets larger than this.
+ * Using exact power of 2 (1/8) results in smaller code
+ */
+-#define STEP_THRESHOLD 0.125
++#define SLEW_THRESHOLD 0.125
+ /* Stepout threshold (sec). std ntpd uses 900 (11 mins (!)) */
+-#define WATCH_THRESHOLD 128
++#define WATCH_THRESHOLD 128
+ /* NB: set WATCH_THRESHOLD to ~60 when debugging to save time) */
+ //UNUSED: #define PANIC_THRESHOLD 1000 /* panic threshold (sec) */
+
+@@ -143,7 +146,7 @@
+ * If we got |offset| > BIGOFF from a peer, cap next query interval
+ * for this peer by this many seconds:
+ */
+-#define BIGOFF (STEP_THRESHOLD * 8)
++#define BIGOFF STEP_THRESHOLD
+ #define BIGOFF_INTERVAL (1 << 7) /* 128 s */
+
+ #define FREQ_TOLERANCE 0.000015 /* frequency tolerance (15 PPM) */
+@@ -157,10 +160,10 @@
+ #define MAXPOLL 12 /* maximum poll interval (12: 1.1h, 17: 36.4h). std ntpd uses 17 */
+ /*
+ * Actively lower poll when we see such big offsets.
+- * With STEP_THRESHOLD = 0.125, it means we try to sync more aggressively
++ * With SLEW_THRESHOLD = 0.125, it means we try to sync more aggressively
+ * if offset increases over ~0.04 sec
+ */
+-//#define POLLDOWN_OFFSET (STEP_THRESHOLD / 3)
++//#define POLLDOWN_OFFSET (SLEW_THRESHOLD / 3)
+ #define MINDISP 0.01 /* minimum dispersion (sec) */
+ #define MAXDISP 16 /* maximum dispersion (sec) */
+ #define MAXSTRAT 16 /* maximum stratum (infinity metric) */
+@@ -720,7 +723,7 @@ static void
+ reset_peer_stats(peer_t *p, double offset)
+ {
+ int i;
+- bool small_ofs = fabs(offset) < 16 * STEP_THRESHOLD;
++ bool small_ofs = fabs(offset) < STEP_THRESHOLD;
+
+ /* Used to set p->filter_datapoint[i].d_dispersion = MAXDISP
+ * and clear reachable bits, but this proved to be too agressive:
+@@ -771,7 +774,7 @@ add_peers(const char *s)
+ p->p_fd = -1;
+ p->p_xmt_msg.m_status = MODE_CLIENT | (NTP_VERSION << 3);
+ p->next_action_time = G.cur_time; /* = set_next(p, 0); */
+- reset_peer_stats(p, 16 * STEP_THRESHOLD);
++ reset_peer_stats(p, STEP_THRESHOLD);
+
+ llist_add_to(&G.ntp_peers, p);
+ G.peer_cnt++;
+@@ -1638,14 +1641,7 @@ update_local_clock(peer_t *p)
+ tmx.freq = G.discipline_freq_drift * 65536e6;
+ #endif
+ tmx.modes = ADJ_OFFSET | ADJ_STATUS | ADJ_TIMECONST;// | ADJ_MAXERROR | ADJ_ESTERROR;
+- tmx.offset = (offset * 1000000); /* usec */
+- tmx.status = STA_PLL;
+- if (G.ntp_status & LI_PLUSSEC)
+- tmx.status |= STA_INS;
+- if (G.ntp_status & LI_MINUSSEC)
+- tmx.status |= STA_DEL;
+-
+- tmx.constant = (int)G.poll_exp - 4 > 0 ? (int)G.poll_exp - 4 : 0;
++ tmx.constant = (int)G.poll_exp - 4;
+ /* EXPERIMENTAL.
+ * The below if statement should be unnecessary, but...
+ * It looks like Linux kernel's PLL is far too gentle in changing
+@@ -1656,8 +1652,27 @@ update_local_clock(peer_t *p)
+ * To be on a safe side, let's do it only if offset is significantly
+ * larger than jitter.
+ */
+- if (tmx.constant > 0 && G.offset_to_jitter_ratio >= TIMECONST_HACK_GATE)
++ if (G.offset_to_jitter_ratio >= TIMECONST_HACK_GATE)
+ tmx.constant--;
++ tmx.offset = (long)(offset * 1000000); /* usec */
++ if (SLEW_THRESHOLD < STEP_THRESHOLD) {
++ if (tmx.offset > (long)(SLEW_THRESHOLD * 1000000)) {
++ tmx.offset = (long)(SLEW_THRESHOLD * 1000000);
++ tmx.constant--;
++ }
++ if (tmx.offset < -(long)(SLEW_THRESHOLD * 1000000)) {
++ tmx.offset = -(long)(SLEW_THRESHOLD * 1000000);
++ tmx.constant--;
++ }
++ }
++ if (tmx.constant < 0)
++ tmx.constant = 0;
++
++ tmx.status = STA_PLL;
++ if (G.ntp_status & LI_PLUSSEC)
++ tmx.status |= STA_INS;
++ if (G.ntp_status & LI_MINUSSEC)
++ tmx.status |= STA_DEL;
+
+ //tmx.esterror = (uint32_t)(clock_jitter * 1e6);
+ //tmx.maxerror = (uint32_t)((sys_rootdelay / 2 + sys_rootdisp) * 1e6);
+@@ -1931,6 +1946,9 @@ recv_and_process_peer_pkt(peer_t *p)
+ increase_interval:
+ adjust_poll(MINPOLL);
+ } else {
++ VERB3 if (rc > 0)
++ bb_error_msg("want smaller poll interval: offset/jitter ratio > %u",
++ POLLADJ_GATE);
+ adjust_poll(-G.poll_exp * 2);
+ }
+ }
+@@ -1939,7 +1957,7 @@ recv_and_process_peer_pkt(peer_t *p)
+ pick_normal_interval:
+ interval = poll_interval(INT_MAX);
+ if (fabs(offset) >= BIGOFF && interval > BIGOFF_INTERVAL) {
+- /* If we are synced, offsets are less than STEP_THRESHOLD,
++ /* If we are synced, offsets are less than SLEW_THRESHOLD,
+ * or at the very least not much larger than it.
+ * Now we see a largish one.
+ * Either this peer is feeling bad, or packet got corrupted,
+--
+2.8.3
+
diff --git a/main/busybox/4002-ntpd-shorter-message.patch b/main/busybox/4002-ntpd-shorter-message.patch
new file mode 100644
index 0000000000..fddf0ca624
--- /dev/null
+++ b/main/busybox/4002-ntpd-shorter-message.patch
@@ -0,0 +1,26 @@
+From 383201e7258c3c1646f6d5cab4e813b5c3b3ecd0 Mon Sep 17 00:00:00 2001
+From: Denys Vlasenko <vda.linux@googlemail.com>
+Date: Wed, 10 Feb 2016 07:06:31 +0100
+Subject: [PATCH 4002/4007] ntpd: shorter message
+
+Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
+---
+ networking/ntpd.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/networking/ntpd.c b/networking/ntpd.c
+index 32590a1..1651670 100644
+--- a/networking/ntpd.c
++++ b/networking/ntpd.c
+@@ -1947,7 +1947,7 @@ recv_and_process_peer_pkt(peer_t *p)
+ adjust_poll(MINPOLL);
+ } else {
+ VERB3 if (rc > 0)
+- bb_error_msg("want smaller poll interval: offset/jitter ratio > %u",
++ bb_error_msg("want smaller poll interval: offset/jitter > %u",
+ POLLADJ_GATE);
+ adjust_poll(-G.poll_exp * 2);
+ }
+--
+2.8.3
+
diff --git a/main/busybox/4003-ntpd-print-packet-delay-in-clock-update-message.patch b/main/busybox/4003-ntpd-print-packet-delay-in-clock-update-message.patch
new file mode 100644
index 0000000000..e07c940ced
--- /dev/null
+++ b/main/busybox/4003-ntpd-print-packet-delay-in-clock-update-message.patch
@@ -0,0 +1,37 @@
+From 03718bb2743fbd772732a2c57c76c1c56fa9cd37 Mon Sep 17 00:00:00 2001
+From: Denys Vlasenko <vda.linux@googlemail.com>
+Date: Wed, 24 Feb 2016 01:22:45 +0100
+Subject: [PATCH 4003/4007] ntpd: print packet delay in clock update message
+
+function old new delta
+update_local_clock 820 826 +6
+
+Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
+---
+ networking/ntpd.c | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/networking/ntpd.c b/networking/ntpd.c
+index 1651670..2a96ddb 100644
+--- a/networking/ntpd.c
++++ b/networking/ntpd.c
+@@ -1685,8 +1685,14 @@ update_local_clock(peer_t *p)
+ VERB4 bb_error_msg("adjtimex:%d freq:%ld offset:%+ld status:0x%x",
+ rc, tmx.freq, tmx.offset, tmx.status);
+ G.kernel_freq_drift = tmx.freq / 65536;
+- VERB2 bb_error_msg("update from:%s offset:%+f jitter:%f clock drift:%+.3fppm tc:%d",
+- p->p_dotted, offset, G.discipline_jitter, (double)tmx.freq / 65536, (int)tmx.constant);
++ VERB2 bb_error_msg("update from:%s offset:%+f delay:%f jitter:%f clock drift:%+.3fppm tc:%d",
++ p->p_dotted,
++ offset,
++ p->lastpkt_delay,
++ G.discipline_jitter,
++ (double)tmx.freq / 65536,
++ (int)tmx.constant
++ );
+
+ return 1; /* "ok to increase poll interval" */
+ }
+--
+2.8.3
+
diff --git a/main/busybox/4004-ntpd-more-informative-poll-lowering-message.patch b/main/busybox/4004-ntpd-more-informative-poll-lowering-message.patch
new file mode 100644
index 0000000000..721e731610
--- /dev/null
+++ b/main/busybox/4004-ntpd-more-informative-poll-lowering-message.patch
@@ -0,0 +1,28 @@
+From 4c48a6474701d8b396a14213ebcc979a49187faf Mon Sep 17 00:00:00 2001
+From: Denys Vlasenko <vda.linux@googlemail.com>
+Date: Thu, 3 Mar 2016 22:01:23 +0100
+Subject: [PATCH 4004/4007] ntpd: more informative poll lowering message
+
+Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
+---
+ networking/ntpd.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/networking/ntpd.c b/networking/ntpd.c
+index 2a96ddb..4695c33 100644
+--- a/networking/ntpd.c
++++ b/networking/ntpd.c
+@@ -1953,8 +1953,8 @@ recv_and_process_peer_pkt(peer_t *p)
+ adjust_poll(MINPOLL);
+ } else {
+ VERB3 if (rc > 0)
+- bb_error_msg("want smaller poll interval: offset/jitter > %u",
+- POLLADJ_GATE);
++ bb_error_msg("want smaller interval: offset/jitter = %u",
++ G.offset_to_jitter_ratio);
+ adjust_poll(-G.poll_exp * 2);
+ }
+ }
+--
+2.8.3
+
diff --git a/main/busybox/4005-ntpd-do-not-use-a-peer-more-than-once-say-if-two-pee.patch b/main/busybox/4005-ntpd-do-not-use-a-peer-more-than-once-say-if-two-pee.patch
new file mode 100644
index 0000000000..ccad842507
--- /dev/null
+++ b/main/busybox/4005-ntpd-do-not-use-a-peer-more-than-once-say-if-two-pee.patch
@@ -0,0 +1,57 @@
+From f37f28199f508f5fee44753d320f044a91e76e39 Mon Sep 17 00:00:00 2001
+From: Denys Vlasenko <vda.linux@googlemail.com>
+Date: Fri, 4 Mar 2016 07:06:53 +0100
+Subject: [PATCH 4005/4007] ntpd: do not use a peer more than once (say, if two
+ peers resolve to the same IP)
+
+function old new delta
+add_peers 98 166 +68
+
+Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
+---
+ networking/ntpd.c | 17 ++++++++++++++++-
+ 1 file changed, 16 insertions(+), 1 deletion(-)
+
+diff --git a/networking/ntpd.c b/networking/ntpd.c
+index 4695c33..517806e 100644
+--- a/networking/ntpd.c
++++ b/networking/ntpd.c
+@@ -727,7 +727,7 @@ reset_peer_stats(peer_t *p, double offset)
+
+ /* Used to set p->filter_datapoint[i].d_dispersion = MAXDISP
+ * and clear reachable bits, but this proved to be too agressive:
+- * after step (tested with suspinding laptop for ~30 secs),
++ * after step (tested with suspending laptop for ~30 secs),
+ * this caused all previous data to be considered invalid,
+ * making us needing to collect full ~8 datapoins per peer
+ * after step in order to start trusting them.
+@@ -766,11 +766,26 @@ reset_peer_stats(peer_t *p, double offset)
+ static void
+ add_peers(const char *s)
+ {
++ llist_t *item;
+ peer_t *p;
+
+ p = xzalloc(sizeof(*p));
+ p->p_lsa = xhost2sockaddr(s, 123);
+ p->p_dotted = xmalloc_sockaddr2dotted_noport(&p->p_lsa->u.sa);
++
++ /* Names like N.<country2chars>.pool.ntp.org are randomly resolved
++ * to a pool of machines. Sometimes different N's resolve to the same IP.
++ * It is not useful to have two peers with same IP. We skip duplicates.
++ */
++ for (item = G.ntp_peers; item != NULL; item = item->link) {
++ peer_t *pp = (peer_t *) item->data;
++ if (strcmp(p->p_dotted, pp->p_dotted) == 0) {
++ bb_error_msg("duplicate peer %s (%s)", s, p->p_dotted);
++ free(p);
++ return;
++ }
++ }
++
+ p->p_fd = -1;
+ p->p_xmt_msg.m_status = MODE_CLIENT | (NTP_VERSION << 3);
+ p->next_action_time = G.cur_time; /* = set_next(p, 0); */
+--
+2.8.3
+
diff --git a/main/busybox/4006-ntpd-if-peer-does-not-reply-anymore-try-re-resolving.patch b/main/busybox/4006-ntpd-if-peer-does-not-reply-anymore-try-re-resolving.patch
new file mode 100644
index 0000000000..8791b97351
--- /dev/null
+++ b/main/busybox/4006-ntpd-if-peer-does-not-reply-anymore-try-re-resolving.patch
@@ -0,0 +1,67 @@
+From c8641962e4cbde48108ddfc1c105e3320778190d Mon Sep 17 00:00:00 2001
+From: Denys Vlasenko <vda.linux@googlemail.com>
+Date: Fri, 4 Mar 2016 07:26:08 +0100
+Subject: [PATCH 4006/4007] ntpd: if peer does not reply anymore, try
+ re-resolving its hostname
+
+function old new delta
+ntpd_main 1053 1130 +77
+add_peers 166 195 +29
+
+Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
+---
+ networking/ntpd.c | 19 +++++++++++++++++++
+ 1 file changed, 19 insertions(+)
+
+diff --git a/networking/ntpd.c b/networking/ntpd.c
+index 517806e..4103189 100644
+--- a/networking/ntpd.c
++++ b/networking/ntpd.c
+@@ -267,6 +267,7 @@ typedef struct {
+
+ typedef struct {
+ len_and_sockaddr *p_lsa;
++ char *p_hostname;
+ char *p_dotted;
+ int p_fd;
+ int datapoint_idx;
+@@ -781,11 +782,14 @@ add_peers(const char *s)
+ peer_t *pp = (peer_t *) item->data;
+ if (strcmp(p->p_dotted, pp->p_dotted) == 0) {
+ bb_error_msg("duplicate peer %s (%s)", s, p->p_dotted);
++ free(p->p_lsa);
++ free(p->p_dotted);
+ free(p);
+ return;
+ }
+ }
+
++ p->p_hostname = xstrdup(s);
+ p->p_fd = -1;
+ p->p_xmt_msg.m_status = MODE_CLIENT | (NTP_VERSION << 3);
+ p->next_action_time = G.cur_time; /* = set_next(p, 0); */
+@@ -2332,6 +2336,21 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv)
+ timeout = poll_interval(NOREPLY_INTERVAL);
+ bb_error_msg("timed out waiting for %s, reach 0x%02x, next query in %us",
+ p->p_dotted, p->reachable_bits, timeout);
++
++ /* What if don't see it because it changed its IP? */
++ if (p->reachable_bits == 0) {
++ len_and_sockaddr *lsa = host2sockaddr(p->p_hostname, 123);
++ if (lsa) {
++ char *dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa);
++ //if (strcmp(dotted, p->p_dotted) != 0)
++ // bb_error_msg("peer IP changed");
++ free(p->p_lsa);
++ free(p->p_dotted);
++ p->p_lsa = lsa;
++ p->p_dotted = dotted;
++ }
++ }
++
+ set_next(p, timeout);
+ }
+ }
+--
+2.8.3
+
diff --git a/main/busybox/4007-ntpd-postpone-hostname-resolution-if-fails-on-startu.patch b/main/busybox/4007-ntpd-postpone-hostname-resolution-if-fails-on-startu.patch
new file mode 100644
index 0000000000..81f4ef8c92
--- /dev/null
+++ b/main/busybox/4007-ntpd-postpone-hostname-resolution-if-fails-on-startu.patch
@@ -0,0 +1,171 @@
+From 52278b8df9433b2e32d2d842637024b42fcf1a94 Mon Sep 17 00:00:00 2001
+From: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
+Date: Fri, 13 May 2016 00:00:11 +0300
+Subject: [PATCH 4007/4007] ntpd: postpone hostname resolution if fails on
+ startup
+
+Signed-off-by: Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>
+---
+ networking/ntpd.c | 116 +++++++++++++++++++++++++++++-------------------------
+ 1 file changed, 63 insertions(+), 53 deletions(-)
+
+diff --git a/networking/ntpd.c b/networking/ntpd.c
+index 4103189..7f7d69e 100644
+--- a/networking/ntpd.c
++++ b/networking/ntpd.c
+@@ -765,34 +765,48 @@ reset_peer_stats(peer_t *p, double offset)
+ }
+
+ static void
++resolve_peer_hostname(peer_t *p) {
++ len_and_sockaddr *lsa = host2sockaddr(p->p_hostname, 123);
++ if (lsa) {
++ if (p->p_lsa) {
++ free(p->p_lsa);
++ free(p->p_dotted);
++ }
++ p->p_lsa = lsa;
++ p->p_dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa);
++ }
++ set_next(p, lsa ? 0 : RETRY_INTERVAL);
++}
++
++static void
+ add_peers(const char *s)
+ {
+ llist_t *item;
+ peer_t *p;
+
+ p = xzalloc(sizeof(*p));
+- p->p_lsa = xhost2sockaddr(s, 123);
+- p->p_dotted = xmalloc_sockaddr2dotted_noport(&p->p_lsa->u.sa);
++ p->p_hostname = xstrdup(s);
++ resolve_peer_hostname(p);
+
+ /* Names like N.<country2chars>.pool.ntp.org are randomly resolved
+ * to a pool of machines. Sometimes different N's resolve to the same IP.
+ * It is not useful to have two peers with same IP. We skip duplicates.
+ */
+- for (item = G.ntp_peers; item != NULL; item = item->link) {
+- peer_t *pp = (peer_t *) item->data;
+- if (strcmp(p->p_dotted, pp->p_dotted) == 0) {
+- bb_error_msg("duplicate peer %s (%s)", s, p->p_dotted);
+- free(p->p_lsa);
+- free(p->p_dotted);
+- free(p);
+- return;
++ if (p->p_lsa)
++ for (item = G.ntp_peers; item != NULL; item = item->link) {
++ peer_t *pp = (peer_t *) item->data;
++ if (pp->p_lsa && strcmp(p->p_dotted, pp->p_dotted) == 0) {
++ bb_error_msg("duplicate peer %s (%s)", s, p->p_dotted);
++ free(p->p_hostname);
++ free(p->p_lsa);
++ free(p->p_dotted);
++ free(p);
++ return;
++ }
+ }
+- }
+
+- p->p_hostname = xstrdup(s);
+ p->p_fd = -1;
+ p->p_xmt_msg.m_status = MODE_CLIENT | (NTP_VERSION << 3);
+- p->next_action_time = G.cur_time; /* = set_next(p, 0); */
+ reset_peer_stats(p, STEP_THRESHOLD);
+
+ llist_add_to(&G.ntp_peers, p);
+@@ -2317,54 +2331,50 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv)
+ for (item = G.ntp_peers; item != NULL; item = item->link) {
+ peer_t *p = (peer_t *) item->data;
+
+- if (p->next_action_time <= G.cur_time) {
+- if (p->p_fd == -1) {
+- /* Time to send new req */
+- if (--cnt == 0) {
+- VERB4 bb_error_msg("disabling burst mode");
+- G.polladj_count = 0;
+- G.poll_exp = MINPOLL;
+- }
+- send_query_to_peer(p);
+- } else {
+- /* Timed out waiting for reply */
+- close(p->p_fd);
+- p->p_fd = -1;
+- /* If poll interval is small, increase it */
+- if (G.poll_exp < BIGPOLL)
+- adjust_poll(MINPOLL);
+- timeout = poll_interval(NOREPLY_INTERVAL);
+- bb_error_msg("timed out waiting for %s, reach 0x%02x, next query in %us",
+- p->p_dotted, p->reachable_bits, timeout);
+-
+- /* What if don't see it because it changed its IP? */
+- if (p->reachable_bits == 0) {
+- len_and_sockaddr *lsa = host2sockaddr(p->p_hostname, 123);
+- if (lsa) {
+- char *dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa);
+- //if (strcmp(dotted, p->p_dotted) != 0)
+- // bb_error_msg("peer IP changed");
+- free(p->p_lsa);
+- free(p->p_dotted);
+- p->p_lsa = lsa;
+- p->p_dotted = dotted;
++ if (p->p_lsa) {
++
++ if (p->next_action_time <= G.cur_time) {
++ if (p->p_fd == -1) {
++ /* Time to send new req */
++ if (--cnt == 0) {
++ VERB4 bb_error_msg("disabling burst mode");
++ G.polladj_count = 0;
++ G.poll_exp = MINPOLL;
+ }
++ send_query_to_peer(p);
++ } else {
++ /* Timed out waiting for reply */
++ close(p->p_fd);
++ p->p_fd = -1;
++ /* If poll interval is small, increase it */
++ if (G.poll_exp < BIGPOLL)
++ adjust_poll(MINPOLL);
++ timeout = poll_interval(NOREPLY_INTERVAL);
++ bb_error_msg("timed out waiting for %s, reach 0x%02x, next query in %us",
++ p->p_dotted, p->reachable_bits, timeout);
++
++ /* What if don't see it because it changed its IP? */
++ if (p->reachable_bits == 0)
++ resolve_peer_hostname(p);
++
++ set_next(p, timeout);
+ }
++ }
+
+- set_next(p, timeout);
++ if (p->p_fd >= 0) {
++ /* Wait for reply from this peer */
++ pfd[i].fd = p->p_fd;
++ pfd[i].events = POLLIN;
++ idx2peer[i] = p;
++ i++;
+ }
+- }
++
++ } else
++ resolve_peer_hostname(p);
+
+ if (p->next_action_time < nextaction)
+ nextaction = p->next_action_time;
+
+- if (p->p_fd >= 0) {
+- /* Wait for reply from this peer */
+- pfd[i].fd = p->p_fd;
+- pfd[i].events = POLLIN;
+- idx2peer[i] = p;
+- i++;
+- }
+ }
+
+ timeout = nextaction - G.cur_time;
+--
+2.8.3
+
diff --git a/main/busybox/APKBUILD b/main/busybox/APKBUILD
index 2468fe41ae..4ec81de07d 100644
--- a/main/busybox/APKBUILD
+++ b/main/busybox/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=busybox
pkgver=1.24.2
-pkgrel=5
+pkgrel=6
pkgdesc="Size optimized toolbox of many common UNIX utilities"
url=http://busybox.net
arch="all"
@@ -42,6 +42,14 @@ source="http://busybox.net/downloads/$pkgname-$pkgver.tar.bz2
3002-libbb-allow_blank-argument-for-ask_and_check_passwor.patch
3003-su-FEATURE_SU_NULLOK_SECURE.patch
+ 4001-ntpd-step-when-offset-1-sec-not-0.125-sec.patch
+ 4002-ntpd-shorter-message.patch
+ 4003-ntpd-print-packet-delay-in-clock-update-message.patch
+ 4004-ntpd-more-informative-poll-lowering-message.patch
+ 4005-ntpd-do-not-use-a-peer-more-than-once-say-if-two-pee.patch
+ 4006-ntpd-if-peer-does-not-reply-anymore-try-re-resolving.patch
+ 4007-ntpd-postpone-hostname-resolution-if-fails-on-startu.patch
+
0001-ash-backport-fix-for-here-document-issues.patch
0001-ash-fix-error-during-recursive-processing-of-here-do.patch
@@ -180,6 +188,13 @@ ad908fc45563148d9f22b50c6e78e0d4 2001-modutils-merge-module_entry-and-module_in
94ab8b7b930df2f8f04da0e69da258da 3001-login-move-check_securetty-to-libbb.patch
f7c45568bdb0d2295c43108691e78a40 3002-libbb-allow_blank-argument-for-ask_and_check_passwor.patch
f82d49c891c02516462db3cda29ccca7 3003-su-FEATURE_SU_NULLOK_SECURE.patch
+574ba81293941dda3910a3d43699a53b 4001-ntpd-step-when-offset-1-sec-not-0.125-sec.patch
+84bc3bc18532032c35553cc4d67810bf 4002-ntpd-shorter-message.patch
+e891282cda76773643dd23077fc574e7 4003-ntpd-print-packet-delay-in-clock-update-message.patch
+5fc2eb488f6c2a87b8eb8aa4948ae2c1 4004-ntpd-more-informative-poll-lowering-message.patch
+f5adc07a1937c4ee36e231f32799515e 4005-ntpd-do-not-use-a-peer-more-than-once-say-if-two-pee.patch
+95479321232337dac85ff1d073ab0830 4006-ntpd-if-peer-does-not-reply-anymore-try-re-resolving.patch
+56af31d2b311983059f6ac8ebf84a5a3 4007-ntpd-postpone-hostname-resolution-if-fails-on-startu.patch
5f03ee6f3e93bbc6aedff0777b227810 0001-ash-backport-fix-for-here-document-issues.patch
a4d1cf64fd1835a284ccc6dbc78e3ce0 0001-ash-fix-error-during-recursive-processing-of-here-do.patch
ab539a54dcd1c23eb0963e17e768fef7 0001-libbb-fix-time-parsing-of-CC-YY-MMDDhhmm-.SS.patch
@@ -208,6 +223,13 @@ ea589dcd25037e3fefd2f3d6ac801a2a4a61a5cfd2d765785ea5558ed3937776 2003-modinfo-f
34c694cc2ac69ee2d6bbfe45a20c68036b6299ad7e4a1a8df9bf1ce0a4637bd7 3001-login-move-check_securetty-to-libbb.patch
ce24e38be870c90bdcb90e7b0445067adf7be0fac6b1154d2364a4db9ee3a9d8 3002-libbb-allow_blank-argument-for-ask_and_check_passwor.patch
d7b18672334ddeee7fbd6c0e92f26c5d2ef49ddefebf0b7f6eff8dc1ad8d3f7e 3003-su-FEATURE_SU_NULLOK_SECURE.patch
+d77cf90aa6e4b69ada75f8b26df3baecc0be7f7b6a4e7825d77b76ef2cad7cc1 4001-ntpd-step-when-offset-1-sec-not-0.125-sec.patch
+38c194685b40501d0806cf992f74904b408d3e2033aaeb4d82d72c0f5f6bd60f 4002-ntpd-shorter-message.patch
+c9e2973410af407f87e225630c977f2222d2ee35748a67b7cb87ecd20f4412db 4003-ntpd-print-packet-delay-in-clock-update-message.patch
+f04199c1593e4f3e073b358b5cf550e9b0d9ac5d2d88f2953fa12d682f7af14c 4004-ntpd-more-informative-poll-lowering-message.patch
+b32097ee018d4ccdc77a12572e25a9082d4f2b0d6fb48afacdb23b3c4c438687 4005-ntpd-do-not-use-a-peer-more-than-once-say-if-two-pee.patch
+2ddecb01475adf86fc2e5fe835bead109ffebc83480cfcc3da650249d8e99793 4006-ntpd-if-peer-does-not-reply-anymore-try-re-resolving.patch
+c4dca6fcef3de0ed5beb1716a3fd229dd29996a90da95eec898a13e0d9d85041 4007-ntpd-postpone-hostname-resolution-if-fails-on-startu.patch
f712ce190ce86084d56977e125d1561615394f3d9b840e926537868260e19d79 0001-ash-backport-fix-for-here-document-issues.patch
1d3f8f7b6d0972f8e56437fce8efbafe70e2d869fbe82f06eba11e0103fce224 0001-ash-fix-error-during-recursive-processing-of-here-do.patch
97dfec94c94f00b628a702ad81b235414af611e011bfc26c29be46c67063c101 0001-libbb-fix-time-parsing-of-CC-YY-MMDDhhmm-.SS.patch
@@ -236,6 +258,13 @@ daadb1b255a8d30f2a13b84c2120427998d8173cf10754b9117e19a6fea8926d1820005f4d99a4a6
1832d2a09625cb60998c54330a751f13dec97da2c4133db29c10f77fa3314fd2ef2002a45eab7215ed1a0dd8b84a8a4c7d4c1d225b5ee012fe357a8777707a17 3001-login-move-check_securetty-to-libbb.patch
ed8d060b85d4da1681eb35ba64c5b249391e6a7edbeb55b8952897f08fe9bafac33593992772d80a6df42dd3af0e175ce9575ee51c49fbc875008ad0ac2f6f06 3002-libbb-allow_blank-argument-for-ask_and_check_passwor.patch
c6579970450e7c711461ab1953f534ae855c4a355b4a452b3fc52a286355c87e41f8951b1b5217d0f659e3173ace8718d42dad3dcc878899cf9decdf4d3fe238 3003-su-FEATURE_SU_NULLOK_SECURE.patch
+4675882f0b255ca73e88b9b4c9ef8b19c0141b8d1a92ea6fd3758c284b9835ac97bf0340f2ce629160c4cb8e5783f32d315187e00596c00d59f1f9cf6d83241d 4001-ntpd-step-when-offset-1-sec-not-0.125-sec.patch
+b5a22fb015e45231b9a4d827d2ef3ecea1f6c56c401d4ed228e5ce0fc6c282fe692da57ecbb31fbe25058a80d310e6058d2ee59b0a32b187a7b76051a1736f24 4002-ntpd-shorter-message.patch
+9a4462dbb1bb9976c72adde30597455602110bc6cb992fbad1e3374d9bb806912d549084c5ee096d95345c23cc59e7dc7ab102a83272f66a0d1898399f5b4640 4003-ntpd-print-packet-delay-in-clock-update-message.patch
+0fd4554b5f2752e6989772bbafb0360df3a79bb7a6828e5026c2b7adbdb474e20d82a5e6b32a52f1acb899e27b3d6329f61fa706d35ccf05977c58aeb2d39754 4004-ntpd-more-informative-poll-lowering-message.patch
+e27e4d07cc1d13d8eb8e04ab282fa89bf7511c2ed1cdeb35721e6dbe14756c20486a462bf5f5b5caced4a2ad3de79780c5ea59ce1a7d7639aea21c9afe929699 4005-ntpd-do-not-use-a-peer-more-than-once-say-if-two-pee.patch
+71cdd9e06cdf670c249177408ef66c1de8590a82bdfe616fa002f0f2385c043876d1529bf8352e8da834f0e68807650c531975f70a28ec82f2b16fc596271351 4006-ntpd-if-peer-does-not-reply-anymore-try-re-resolving.patch
+2241d12663cd3479e29080a680dd0d22f30db15a672b5143433ce6fdf249ab18fd0edfcc34dafd65308db49f1c7cbd77066050d8b8920871ecb5c7b5a77ba035 4007-ntpd-postpone-hostname-resolution-if-fails-on-startu.patch
d55cab6ed08434e2a278edf1be6171b921bcaee47598988e4de6b390a01569e10394c54d5d4a27e6eba251ce68df5cc1ece358be32a9c31bdf1f7e9147cf5180 0001-ash-backport-fix-for-here-document-issues.patch
c14a632f9477c13ea99b24a73c81c9c44ead8b536970acd758e739b43a6260860039674341192ce7bb20a9204ee7d93dcd9541e526f2437d4d2d88637b400867 0001-ash-fix-error-during-recursive-processing-of-here-do.patch
6fc77e0edcbb61a64c179b0259e0634a82362ac0ca9a77f305eb75f6a89a10395e8a37cbcef925821b428c00237a0a3575af2c3ef194933f52ad55b0eb0dd6f2 0001-libbb-fix-time-parsing-of-CC-YY-MMDDhhmm-.SS.patch