aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2016-02-22 10:00:45 +0000
committerRon Yorston <rmy@pobox.com>2016-02-22 10:00:45 +0000
commit371c20c008254a36e7157df6c13dc2e4cf87d6fd (patch)
treea214c03f6617dffa60df2192b312a46c93b7c19f /networking
parentab879a41ab674129ef1593cda181cc8b64d0dadf (diff)
parent3a5cc989025eefe03fda0552b253a4a8f015a761 (diff)
downloadbusybox-w32-371c20c008254a36e7157df6c13dc2e4cf87d6fd.tar.gz
busybox-w32-371c20c008254a36e7157df6c13dc2e4cf87d6fd.tar.bz2
busybox-w32-371c20c008254a36e7157df6c13dc2e4cf87d6fd.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'networking')
-rw-r--r--networking/interface.c1
-rw-r--r--networking/libiproute/iproute.c52
-rw-r--r--networking/ntpd.c54
-rw-r--r--networking/udhcp/dhcpc.c2
4 files changed, 72 insertions, 37 deletions
diff --git a/networking/interface.c b/networking/interface.c
index 24bd13c57..e5723b428 100644
--- a/networking/interface.c
+++ b/networking/interface.c
@@ -881,6 +881,7 @@ static void ife_print6(struct interface *ptr)
881 sprintf(addr6, "%s:%s:%s:%s:%s:%s:%s:%s", 881 sprintf(addr6, "%s:%s:%s:%s:%s:%s:%s:%s",
882 addr6p[0], addr6p[1], addr6p[2], addr6p[3], 882 addr6p[0], addr6p[1], addr6p[2], addr6p[3],
883 addr6p[4], addr6p[5], addr6p[6], addr6p[7]); 883 addr6p[4], addr6p[5], addr6p[6], addr6p[7]);
884 memset(&sap, 0, sizeof(sap));
884 inet_pton(AF_INET6, addr6, 885 inet_pton(AF_INET6, addr6,
885 (struct sockaddr *) &sap.sin6_addr); 886 (struct sockaddr *) &sap.sin6_addr);
886 sap.sin6_family = AF_INET6; 887 sap.sin6_family = AF_INET6;
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c
index d232ee6fd..82827488f 100644
--- a/networking/libiproute/iproute.c
+++ b/networking/libiproute/iproute.c
@@ -313,12 +313,13 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM,
313static int iproute_modify(int cmd, unsigned flags, char **argv) 313static int iproute_modify(int cmd, unsigned flags, char **argv)
314{ 314{
315 static const char keywords[] ALIGN1 = 315 static const char keywords[] ALIGN1 =
316 "src\0""via\0""mtu\0""lock\0""protocol\0"IF_FEATURE_IP_RULE("table\0") 316 "src\0""via\0""mtu\0""lock\0""scope\0""protocol\0"IF_FEATURE_IP_RULE("table\0")
317 "dev\0""oif\0""to\0""metric\0""onlink\0"; 317 "dev\0""oif\0""to\0""metric\0""onlink\0";
318 enum { 318 enum {
319 ARG_src, 319 ARG_src,
320 ARG_via, 320 ARG_via,
321 ARG_mtu, PARM_lock, 321 ARG_mtu, PARM_lock,
322 ARG_scope,
322 ARG_protocol, 323 ARG_protocol,
323IF_FEATURE_IP_RULE(ARG_table,) 324IF_FEATURE_IP_RULE(ARG_table,)
324 ARG_dev, 325 ARG_dev,
@@ -344,6 +345,7 @@ IF_FEATURE_IP_RULE(ARG_table,)
344 unsigned mxlock = 0; 345 unsigned mxlock = 0;
345 char *d = NULL; 346 char *d = NULL;
346 smalluint ok = 0; 347 smalluint ok = 0;
348 smalluint scope_ok = 0;
347 int arg; 349 int arg;
348 350
349 memset(&req, 0, sizeof(req)); 351 memset(&req, 0, sizeof(req));
@@ -352,15 +354,18 @@ IF_FEATURE_IP_RULE(ARG_table,)
352 req.n.nlmsg_flags = NLM_F_REQUEST | flags; 354 req.n.nlmsg_flags = NLM_F_REQUEST | flags;
353 req.n.nlmsg_type = cmd; 355 req.n.nlmsg_type = cmd;
354 req.r.rtm_family = preferred_family; 356 req.r.rtm_family = preferred_family;
355 if (RT_TABLE_MAIN) /* if it is zero, memset already did it */ 357 if (RT_TABLE_MAIN != 0) /* if it is zero, memset already did it */
356 req.r.rtm_table = RT_TABLE_MAIN; 358 req.r.rtm_table = RT_TABLE_MAIN;
357 if (RT_SCOPE_NOWHERE) 359 if (RT_SCOPE_NOWHERE != 0)
358 req.r.rtm_scope = RT_SCOPE_NOWHERE; 360 req.r.rtm_scope = RT_SCOPE_NOWHERE;
359 361
360 if (cmd != RTM_DELROUTE) { 362 if (cmd != RTM_DELROUTE) {
361 req.r.rtm_protocol = RTPROT_BOOT; 363 if (RTPROT_BOOT != 0)
362 req.r.rtm_scope = RT_SCOPE_UNIVERSE; 364 req.r.rtm_protocol = RTPROT_BOOT;
363 req.r.rtm_type = RTN_UNICAST; 365 if (RT_SCOPE_UNIVERSE != 0)
366 req.r.rtm_scope = RT_SCOPE_UNIVERSE;
367 if (RTN_UNICAST != 0)
368 req.r.rtm_type = RTN_UNICAST;
364 } 369 }
365 370
366 mxrta->rta_type = RTA_METRICS; 371 mxrta->rta_type = RTA_METRICS;
@@ -393,6 +398,13 @@ IF_FEATURE_IP_RULE(ARG_table,)
393 } 398 }
394 mtu = get_unsigned(*argv, "mtu"); 399 mtu = get_unsigned(*argv, "mtu");
395 rta_addattr32(mxrta, sizeof(mxbuf), RTAX_MTU, mtu); 400 rta_addattr32(mxrta, sizeof(mxbuf), RTAX_MTU, mtu);
401 } else if (arg == ARG_scope) {
402 uint32_t scope;
403 NEXT_ARG();
404 if (rtnl_rtscope_a2n(&scope, *argv))
405 invarg_1_to_2(*argv, "scope");
406 req.r.rtm_scope = scope;
407 scope_ok = 1;
396 } else if (arg == ARG_protocol) { 408 } else if (arg == ARG_protocol) {
397 uint32_t prot; 409 uint32_t prot;
398 NEXT_ARG(); 410 NEXT_ARG();
@@ -469,20 +481,22 @@ IF_FEATURE_IP_RULE(ARG_table,)
469 addattr_l(&req.n, sizeof(req), RTA_METRICS, RTA_DATA(mxrta), RTA_PAYLOAD(mxrta)); 481 addattr_l(&req.n, sizeof(req), RTA_METRICS, RTA_DATA(mxrta), RTA_PAYLOAD(mxrta));
470 } 482 }
471 483
472 if (req.r.rtm_type == RTN_LOCAL || req.r.rtm_type == RTN_NAT) 484 if (!scope_ok) {
473 req.r.rtm_scope = RT_SCOPE_HOST; 485 if (req.r.rtm_type == RTN_LOCAL || req.r.rtm_type == RTN_NAT)
474 else 486 req.r.rtm_scope = RT_SCOPE_HOST;
475 if (req.r.rtm_type == RTN_BROADCAST 487 else
476 || req.r.rtm_type == RTN_MULTICAST 488 if (req.r.rtm_type == RTN_BROADCAST
477 || req.r.rtm_type == RTN_ANYCAST 489 || req.r.rtm_type == RTN_MULTICAST
478 ) { 490 || req.r.rtm_type == RTN_ANYCAST
479 req.r.rtm_scope = RT_SCOPE_LINK; 491 ) {
480 }
481 else if (req.r.rtm_type == RTN_UNICAST || req.r.rtm_type == RTN_UNSPEC) {
482 if (cmd == RTM_DELROUTE)
483 req.r.rtm_scope = RT_SCOPE_NOWHERE;
484 else if (!(ok & gw_ok))
485 req.r.rtm_scope = RT_SCOPE_LINK; 492 req.r.rtm_scope = RT_SCOPE_LINK;
493 }
494 else if (req.r.rtm_type == RTN_UNICAST || req.r.rtm_type == RTN_UNSPEC) {
495 if (cmd == RTM_DELROUTE)
496 req.r.rtm_scope = RT_SCOPE_NOWHERE;
497 else if (!(ok & gw_ok))
498 req.r.rtm_scope = RT_SCOPE_LINK;
499 }
486 } 500 }
487 501
488 if (req.r.rtm_family == AF_UNSPEC) { 502 if (req.r.rtm_family == AF_UNSPEC) {
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 9732c9b1a..1651670d9 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -112,7 +112,7 @@
112 * 112 *
113 * Made some changes to speed up re-syncing after our clock goes bad 113 * Made some changes to speed up re-syncing after our clock goes bad
114 * (tested with suspending my laptop): 114 * (tested with suspending my laptop):
115 * - if largish offset (>= STEP_THRESHOLD * 8 == 1 sec) is seen 115 * - if largish offset (>= STEP_THRESHOLD == 1 sec) is seen
116 * from a peer, schedule next query for this peer soon 116 * from a peer, schedule next query for this peer soon
117 * without drastically lowering poll interval for everybody. 117 * without drastically lowering poll interval for everybody.
118 * This makes us collect enough data for step much faster: 118 * This makes us collect enough data for step much faster:
@@ -131,11 +131,14 @@
131#define RESPONSE_INTERVAL 16 /* wait for reply up to N secs */ 131#define RESPONSE_INTERVAL 16 /* wait for reply up to N secs */
132 132
133/* Step threshold (sec). std ntpd uses 0.128. 133/* Step threshold (sec). std ntpd uses 0.128.
134 */
135#define STEP_THRESHOLD 1
136/* Slew threshold (sec): adjtimex() won't accept offsets larger than this.
134 * Using exact power of 2 (1/8) results in smaller code 137 * Using exact power of 2 (1/8) results in smaller code
135 */ 138 */
136#define STEP_THRESHOLD 0.125 139#define SLEW_THRESHOLD 0.125
137/* Stepout threshold (sec). std ntpd uses 900 (11 mins (!)) */ 140/* Stepout threshold (sec). std ntpd uses 900 (11 mins (!)) */
138#define WATCH_THRESHOLD 128 141#define WATCH_THRESHOLD 128
139/* NB: set WATCH_THRESHOLD to ~60 when debugging to save time) */ 142/* NB: set WATCH_THRESHOLD to ~60 when debugging to save time) */
140//UNUSED: #define PANIC_THRESHOLD 1000 /* panic threshold (sec) */ 143//UNUSED: #define PANIC_THRESHOLD 1000 /* panic threshold (sec) */
141 144
@@ -143,7 +146,7 @@
143 * If we got |offset| > BIGOFF from a peer, cap next query interval 146 * If we got |offset| > BIGOFF from a peer, cap next query interval
144 * for this peer by this many seconds: 147 * for this peer by this many seconds:
145 */ 148 */
146#define BIGOFF (STEP_THRESHOLD * 8) 149#define BIGOFF STEP_THRESHOLD
147#define BIGOFF_INTERVAL (1 << 7) /* 128 s */ 150#define BIGOFF_INTERVAL (1 << 7) /* 128 s */
148 151
149#define FREQ_TOLERANCE 0.000015 /* frequency tolerance (15 PPM) */ 152#define FREQ_TOLERANCE 0.000015 /* frequency tolerance (15 PPM) */
@@ -157,10 +160,10 @@
157#define MAXPOLL 12 /* maximum poll interval (12: 1.1h, 17: 36.4h). std ntpd uses 17 */ 160#define MAXPOLL 12 /* maximum poll interval (12: 1.1h, 17: 36.4h). std ntpd uses 17 */
158/* 161/*
159 * Actively lower poll when we see such big offsets. 162 * Actively lower poll when we see such big offsets.
160 * With STEP_THRESHOLD = 0.125, it means we try to sync more aggressively 163 * With SLEW_THRESHOLD = 0.125, it means we try to sync more aggressively
161 * if offset increases over ~0.04 sec 164 * if offset increases over ~0.04 sec
162 */ 165 */
163//#define POLLDOWN_OFFSET (STEP_THRESHOLD / 3) 166//#define POLLDOWN_OFFSET (SLEW_THRESHOLD / 3)
164#define MINDISP 0.01 /* minimum dispersion (sec) */ 167#define MINDISP 0.01 /* minimum dispersion (sec) */
165#define MAXDISP 16 /* maximum dispersion (sec) */ 168#define MAXDISP 16 /* maximum dispersion (sec) */
166#define MAXSTRAT 16 /* maximum stratum (infinity metric) */ 169#define MAXSTRAT 16 /* maximum stratum (infinity metric) */
@@ -720,7 +723,7 @@ static void
720reset_peer_stats(peer_t *p, double offset) 723reset_peer_stats(peer_t *p, double offset)
721{ 724{
722 int i; 725 int i;
723 bool small_ofs = fabs(offset) < 16 * STEP_THRESHOLD; 726 bool small_ofs = fabs(offset) < STEP_THRESHOLD;
724 727
725 /* Used to set p->filter_datapoint[i].d_dispersion = MAXDISP 728 /* Used to set p->filter_datapoint[i].d_dispersion = MAXDISP
726 * and clear reachable bits, but this proved to be too agressive: 729 * and clear reachable bits, but this proved to be too agressive:
@@ -771,7 +774,7 @@ add_peers(const char *s)
771 p->p_fd = -1; 774 p->p_fd = -1;
772 p->p_xmt_msg.m_status = MODE_CLIENT | (NTP_VERSION << 3); 775 p->p_xmt_msg.m_status = MODE_CLIENT | (NTP_VERSION << 3);
773 p->next_action_time = G.cur_time; /* = set_next(p, 0); */ 776 p->next_action_time = G.cur_time; /* = set_next(p, 0); */
774 reset_peer_stats(p, 16 * STEP_THRESHOLD); 777 reset_peer_stats(p, STEP_THRESHOLD);
775 778
776 llist_add_to(&G.ntp_peers, p); 779 llist_add_to(&G.ntp_peers, p);
777 G.peer_cnt++; 780 G.peer_cnt++;
@@ -1638,14 +1641,7 @@ update_local_clock(peer_t *p)
1638 tmx.freq = G.discipline_freq_drift * 65536e6; 1641 tmx.freq = G.discipline_freq_drift * 65536e6;
1639#endif 1642#endif
1640 tmx.modes = ADJ_OFFSET | ADJ_STATUS | ADJ_TIMECONST;// | ADJ_MAXERROR | ADJ_ESTERROR; 1643 tmx.modes = ADJ_OFFSET | ADJ_STATUS | ADJ_TIMECONST;// | ADJ_MAXERROR | ADJ_ESTERROR;
1641 tmx.offset = (offset * 1000000); /* usec */ 1644 tmx.constant = (int)G.poll_exp - 4;
1642 tmx.status = STA_PLL;
1643 if (G.ntp_status & LI_PLUSSEC)
1644 tmx.status |= STA_INS;
1645 if (G.ntp_status & LI_MINUSSEC)
1646 tmx.status |= STA_DEL;
1647
1648 tmx.constant = (int)G.poll_exp - 4 > 0 ? (int)G.poll_exp - 4 : 0;
1649 /* EXPERIMENTAL. 1645 /* EXPERIMENTAL.
1650 * The below if statement should be unnecessary, but... 1646 * The below if statement should be unnecessary, but...
1651 * It looks like Linux kernel's PLL is far too gentle in changing 1647 * It looks like Linux kernel's PLL is far too gentle in changing
@@ -1656,8 +1652,27 @@ update_local_clock(peer_t *p)
1656 * To be on a safe side, let's do it only if offset is significantly 1652 * To be on a safe side, let's do it only if offset is significantly
1657 * larger than jitter. 1653 * larger than jitter.
1658 */ 1654 */
1659 if (tmx.constant > 0 && G.offset_to_jitter_ratio >= TIMECONST_HACK_GATE) 1655 if (G.offset_to_jitter_ratio >= TIMECONST_HACK_GATE)
1660 tmx.constant--; 1656 tmx.constant--;
1657 tmx.offset = (long)(offset * 1000000); /* usec */
1658 if (SLEW_THRESHOLD < STEP_THRESHOLD) {
1659 if (tmx.offset > (long)(SLEW_THRESHOLD * 1000000)) {
1660 tmx.offset = (long)(SLEW_THRESHOLD * 1000000);
1661 tmx.constant--;
1662 }
1663 if (tmx.offset < -(long)(SLEW_THRESHOLD * 1000000)) {
1664 tmx.offset = -(long)(SLEW_THRESHOLD * 1000000);
1665 tmx.constant--;
1666 }
1667 }
1668 if (tmx.constant < 0)
1669 tmx.constant = 0;
1670
1671 tmx.status = STA_PLL;
1672 if (G.ntp_status & LI_PLUSSEC)
1673 tmx.status |= STA_INS;
1674 if (G.ntp_status & LI_MINUSSEC)
1675 tmx.status |= STA_DEL;
1661 1676
1662 //tmx.esterror = (uint32_t)(clock_jitter * 1e6); 1677 //tmx.esterror = (uint32_t)(clock_jitter * 1e6);
1663 //tmx.maxerror = (uint32_t)((sys_rootdelay / 2 + sys_rootdisp) * 1e6); 1678 //tmx.maxerror = (uint32_t)((sys_rootdelay / 2 + sys_rootdisp) * 1e6);
@@ -1931,6 +1946,9 @@ recv_and_process_peer_pkt(peer_t *p)
1931 increase_interval: 1946 increase_interval:
1932 adjust_poll(MINPOLL); 1947 adjust_poll(MINPOLL);
1933 } else { 1948 } else {
1949 VERB3 if (rc > 0)
1950 bb_error_msg("want smaller poll interval: offset/jitter > %u",
1951 POLLADJ_GATE);
1934 adjust_poll(-G.poll_exp * 2); 1952 adjust_poll(-G.poll_exp * 2);
1935 } 1953 }
1936 } 1954 }
@@ -1939,7 +1957,7 @@ recv_and_process_peer_pkt(peer_t *p)
1939 pick_normal_interval: 1957 pick_normal_interval:
1940 interval = poll_interval(INT_MAX); 1958 interval = poll_interval(INT_MAX);
1941 if (fabs(offset) >= BIGOFF && interval > BIGOFF_INTERVAL) { 1959 if (fabs(offset) >= BIGOFF && interval > BIGOFF_INTERVAL) {
1942 /* If we are synced, offsets are less than STEP_THRESHOLD, 1960 /* If we are synced, offsets are less than SLEW_THRESHOLD,
1943 * or at the very least not much larger than it. 1961 * or at the very least not much larger than it.
1944 * Now we see a largish one. 1962 * Now we see a largish one.
1945 * Either this peer is feeling bad, or packet got corrupted, 1963 * Either this peer is feeling bad, or packet got corrupted,
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 915f65935..48097bc24 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -201,6 +201,8 @@ static int good_hostname(const char *name)
201 //Do we want this? 201 //Do we want this?
202 //return ((name - start) < 1025); /* NS_MAXDNAME */ 202 //return ((name - start) < 1025); /* NS_MAXDNAME */
203 name++; 203 name++;
204 if (*name == '\0')
205 return 1; // We allow trailing dot too
204 } 206 }
205} 207}
206#else 208#else