aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2014-05-06 20:41:10 +0100
committerRon Yorston <rmy@pobox.com>2014-05-06 20:41:10 +0100
commitd3bef66324a8ca5eed9ad7c15ead3a1cc9a9151e (patch)
tree4b364ba4b6b9e96c2629fe382fef0248d76833dd /networking
parent7905d97aeece18da362a5a1e066abff2d2e5c16b (diff)
parentd257608a8429b64e1a04c7cb6d99975eeb2c3955 (diff)
downloadbusybox-w32-d3bef66324a8ca5eed9ad7c15ead3a1cc9a9151e.tar.gz
busybox-w32-d3bef66324a8ca5eed9ad7c15ead3a1cc9a9151e.tar.bz2
busybox-w32-d3bef66324a8ca5eed9ad7c15ead3a1cc9a9151e.zip
Merge branch 'busybox' into merge
Conflicts: debianutils/which.c editors/vi.c libbb/executable.c
Diffstat (limited to 'networking')
-rw-r--r--networking/Config.src8
-rw-r--r--networking/ifupdown.c4
-rw-r--r--networking/ntpd.c72
-rw-r--r--networking/wget.c5
4 files changed, 65 insertions, 24 deletions
diff --git a/networking/Config.src b/networking/Config.src
index ca0ddcdd9..fbad7ecb2 100644
--- a/networking/Config.src
+++ b/networking/Config.src
@@ -664,6 +664,14 @@ config FEATURE_NTPD_SERVER
664 Make ntpd usable as a NTP server. If you disable this option 664 Make ntpd usable as a NTP server. If you disable this option
665 ntpd will be usable only as a NTP client. 665 ntpd will be usable only as a NTP client.
666 666
667config FEATURE_NTPD_CONF
668 bool "Make ntpd understand /etc/ntp.conf"
669 default y
670 depends on NTPD
671 help
672 Make ntpd look in /etc/ntp.conf for peers. Only "server address"
673 is supported.
674
667config PSCAN 675config PSCAN
668 bool "pscan" 676 bool "pscan"
669 default y 677 default y
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index e1ea351a4..c35d97a1a 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -555,7 +555,7 @@ static int FAST_FUNC dhcp_up(struct interface_defn_t *ifd, execfn *exec)
555 return 0; 555 return 0;
556# endif 556# endif
557 for (i = 0; i < ARRAY_SIZE(ext_dhcp_clients); i++) { 557 for (i = 0; i < ARRAY_SIZE(ext_dhcp_clients); i++) {
558 if (exists_execable(ext_dhcp_clients[i].name)) 558 if (executable_exists(ext_dhcp_clients[i].name))
559 return execute(ext_dhcp_clients[i].startcmd, ifd, exec); 559 return execute(ext_dhcp_clients[i].startcmd, ifd, exec);
560 } 560 }
561 bb_error_msg("no dhcp clients found"); 561 bb_error_msg("no dhcp clients found");
@@ -592,7 +592,7 @@ static int FAST_FUNC dhcp_down(struct interface_defn_t *ifd, execfn *exec)
592 unsigned i; 592 unsigned i;
593 593
594 for (i = 0; i < ARRAY_SIZE(ext_dhcp_clients); i++) { 594 for (i = 0; i < ARRAY_SIZE(ext_dhcp_clients); i++) {
595 if (exists_execable(ext_dhcp_clients[i].name)) { 595 if (executable_exists(ext_dhcp_clients[i].name)) {
596 result = execute(ext_dhcp_clients[i].stopcmd, ifd, exec); 596 result = execute(ext_dhcp_clients[i].stopcmd, ifd, exec);
597 if (result) 597 if (result)
598 break; 598 break;
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 44592ce54..59607ed23 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -42,6 +42,13 @@
42//usage: ) 42//usage: )
43//usage: "\n -S PROG Run PROG after stepping time, stratum change, and every 11 mins" 43//usage: "\n -S PROG Run PROG after stepping time, stratum change, and every 11 mins"
44//usage: "\n -p PEER Obtain time from PEER (may be repeated)" 44//usage: "\n -p PEER Obtain time from PEER (may be repeated)"
45//usage: IF_FEATURE_NTPD_CONF(
46//usage: "\n If -p is not given, read /etc/ntp.conf"
47//usage: )
48
49// -l and -p options are not compatible with "standard" ntpd:
50// it has them as "-l logfile" and "-p pidfile".
51// -S and -w are not compat either, "standard" ntpd has no such opts.
45 52
46#include "libbb.h" 53#include "libbb.h"
47#include <math.h> 54#include <math.h>
@@ -245,6 +252,9 @@ typedef struct {
245 * or when receive times out (if p_fd >= 0): */ 252 * or when receive times out (if p_fd >= 0): */
246 double next_action_time; 253 double next_action_time;
247 double p_xmttime; 254 double p_xmttime;
255 double p_raw_delay;
256 /* p_raw_delay is set even by "high delay" packets */
257 /* lastpkt_delay isn't */
248 double lastpkt_recv_time; 258 double lastpkt_recv_time;
249 double lastpkt_delay; 259 double lastpkt_delay;
250 double lastpkt_rootdelay; 260 double lastpkt_rootdelay;
@@ -730,7 +740,7 @@ reset_peer_stats(peer_t *p, double offset)
730} 740}
731 741
732static void 742static void
733add_peers(char *s) 743add_peers(const char *s)
734{ 744{
735 peer_t *p; 745 peer_t *p;
736 746
@@ -1678,7 +1688,8 @@ recv_and_process_peer_pkt(peer_t *p)
1678 ssize_t size; 1688 ssize_t size;
1679 msg_t msg; 1689 msg_t msg;
1680 double T1, T2, T3, T4; 1690 double T1, T2, T3, T4;
1681 double dv, offset; 1691 double offset;
1692 double prev_delay, delay;
1682 unsigned interval; 1693 unsigned interval;
1683 datapoint_t *datapoint; 1694 datapoint_t *datapoint;
1684 peer_t *q; 1695 peer_t *q;
@@ -1738,12 +1749,6 @@ recv_and_process_peer_pkt(peer_t *p)
1738// if (msg.m_rootdelay / 2 + msg.m_rootdisp >= MAXDISP || p->lastpkt_reftime > msg.m_xmt) 1749// if (msg.m_rootdelay / 2 + msg.m_rootdisp >= MAXDISP || p->lastpkt_reftime > msg.m_xmt)
1739// return; /* invalid header values */ 1750// return; /* invalid header values */
1740 1751
1741 p->lastpkt_status = msg.m_status;
1742 p->lastpkt_stratum = msg.m_stratum;
1743 p->lastpkt_rootdelay = sfp_to_d(msg.m_rootdelay);
1744 p->lastpkt_rootdisp = sfp_to_d(msg.m_rootdisp);
1745 p->lastpkt_refid = msg.m_refid;
1746
1747 /* 1752 /*
1748 * From RFC 2030 (with a correction to the delay math): 1753 * From RFC 2030 (with a correction to the delay math):
1749 * 1754 *
@@ -1763,28 +1768,35 @@ recv_and_process_peer_pkt(peer_t *p)
1763 T3 = lfp_to_d(msg.m_xmttime); 1768 T3 = lfp_to_d(msg.m_xmttime);
1764 T4 = G.cur_time; 1769 T4 = G.cur_time;
1765 1770
1766 p->lastpkt_recv_time = T4;
1767 VERB6 bb_error_msg("%s->lastpkt_recv_time=%f", p->p_dotted, p->lastpkt_recv_time);
1768
1769 /* The delay calculation is a special case. In cases where the 1771 /* The delay calculation is a special case. In cases where the
1770 * server and client clocks are running at different rates and 1772 * server and client clocks are running at different rates and
1771 * with very fast networks, the delay can appear negative. In 1773 * with very fast networks, the delay can appear negative. In
1772 * order to avoid violating the Principle of Least Astonishment, 1774 * order to avoid violating the Principle of Least Astonishment,
1773 * the delay is clamped not less than the system precision. 1775 * the delay is clamped not less than the system precision.
1774 */ 1776 */
1775 dv = p->lastpkt_delay; 1777 delay = (T4 - T1) - (T3 - T2);
1776 p->lastpkt_delay = (T4 - T1) - (T3 - T2); 1778 if (delay < G_precision_sec)
1777 if (p->lastpkt_delay < G_precision_sec) 1779 delay = G_precision_sec;
1778 p->lastpkt_delay = G_precision_sec;
1779 /* 1780 /*
1780 * If this packet's delay is much bigger than the last one, 1781 * If this packet's delay is much bigger than the last one,
1781 * it's better to just ignore it than use its much less precise value. 1782 * it's better to just ignore it than use its much less precise value.
1782 */ 1783 */
1783 if (p->reachable_bits && p->lastpkt_delay > dv * BAD_DELAY_GROWTH) { 1784 prev_delay = p->p_raw_delay;
1784 bb_error_msg("reply from %s: delay %f is too high, ignoring", p->p_dotted, p->lastpkt_delay); 1785 p->p_raw_delay = delay;
1786 if (p->reachable_bits && delay > prev_delay * BAD_DELAY_GROWTH) {
1787 bb_error_msg("reply from %s: delay %f is too high, ignoring", p->p_dotted, delay);
1785 goto pick_normal_interval; 1788 goto pick_normal_interval;
1786 } 1789 }
1787 1790
1791 p->lastpkt_delay = delay;
1792 p->lastpkt_recv_time = T4;
1793 VERB6 bb_error_msg("%s->lastpkt_recv_time=%f", p->p_dotted, p->lastpkt_recv_time);
1794 p->lastpkt_status = msg.m_status;
1795 p->lastpkt_stratum = msg.m_stratum;
1796 p->lastpkt_rootdelay = sfp_to_d(msg.m_rootdelay);
1797 p->lastpkt_rootdisp = sfp_to_d(msg.m_rootdisp);
1798 p->lastpkt_refid = msg.m_refid;
1799
1788 p->datapoint_idx = p->reachable_bits ? (p->datapoint_idx + 1) % NUM_DATAPOINTS : 0; 1800 p->datapoint_idx = p->reachable_bits ? (p->datapoint_idx + 1) % NUM_DATAPOINTS : 0;
1789 datapoint = &p->filter_datapoint[p->datapoint_idx]; 1801 datapoint = &p->filter_datapoint[p->datapoint_idx];
1790 datapoint->d_recv_time = T4; 1802 datapoint->d_recv_time = T4;
@@ -2087,14 +2099,34 @@ static NOINLINE void ntp_init(char **argv)
2087 "d" /* compat */ 2099 "d" /* compat */
2088 "46aAbgL", /* compat, ignored */ 2100 "46aAbgL", /* compat, ignored */
2089 &peers, &G.script_name, &G.verbose); 2101 &peers, &G.script_name, &G.verbose);
2090 if (!(opts & (OPT_p|OPT_l))) 2102
2091 bb_show_usage();
2092// if (opts & OPT_x) /* disable stepping, only slew is allowed */ 2103// if (opts & OPT_x) /* disable stepping, only slew is allowed */
2093// G.time_was_stepped = 1; 2104// G.time_was_stepped = 1;
2094 if (peers) { 2105 if (peers) {
2095 while (peers) 2106 while (peers)
2096 add_peers(llist_pop(&peers)); 2107 add_peers(llist_pop(&peers));
2097 } else { 2108 }
2109#if ENABLE_FEATURE_NTPD_CONF
2110 else {
2111 parser_t *parser;
2112 char *token[3];
2113
2114 parser = config_open("/etc/ntp.conf");
2115 while (config_read(parser, token, 3, 1, "# \t", PARSE_NORMAL)) {
2116 if (strcmp(token[0], "server") == 0 && token[1]) {
2117 add_peers(token[1]);
2118 continue;
2119 }
2120 bb_error_msg("skipping %s:%u: unimplemented command '%s'",
2121 "/etc/ntp.conf", parser->lineno, token[0]
2122 );
2123 }
2124 config_close(parser);
2125 }
2126#endif
2127 if (G.peer_cnt == 0) {
2128 if (!(opts & OPT_l))
2129 bb_show_usage();
2098 /* -l but no peers: "stratum 1 server" mode */ 2130 /* -l but no peers: "stratum 1 server" mode */
2099 G.stratum = 1; 2131 G.stratum = 1;
2100 } 2132 }
diff --git a/networking/wget.c b/networking/wget.c
index f13ca1c74..774accf7a 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -650,7 +650,7 @@ static void NOINLINE retrieve_file_data(FILE *dfp)
650#if ENABLE_FEATURE_WGET_TIMEOUT 650#if ENABLE_FEATURE_WGET_TIMEOUT
651 second_cnt = G.timeout_seconds; 651 second_cnt = G.timeout_seconds;
652#endif 652#endif
653 continue; 653 goto bump;
654 } 654 }
655 655
656 /* n <= 0. 656 /* n <= 0.
@@ -683,11 +683,12 @@ static void NOINLINE retrieve_file_data(FILE *dfp)
683 * to try reading anyway. 683 * to try reading anyway.
684 */ 684 */
685 } 685 }
686#endif
687 bump:
686 /* Need to do it _every_ second for "stalled" indicator 688 /* Need to do it _every_ second for "stalled" indicator
687 * to be shown properly. 689 * to be shown properly.
688 */ 690 */
689 progress_meter(PROGRESS_BUMP); 691 progress_meter(PROGRESS_BUMP);
690#endif
691 } /* while (reading data) */ 692 } /* while (reading data) */
692 693
693#if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT 694#if ENABLE_FEATURE_WGET_STATUSBAR || ENABLE_FEATURE_WGET_TIMEOUT