diff options
author | Ron Yorston <rmy@pobox.com> | 2017-11-03 14:16:08 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2017-11-03 14:16:08 +0000 |
commit | d6ce08aeb85b3698ddaa281016b70e16aeb9fb35 (patch) | |
tree | 02ad9bc0684859515fe891f3d6b0a1086e0db156 /networking | |
parent | ab450021a99ba66126cc6d668fb06ec3829a572b (diff) | |
parent | a5060b8364faa7c677c8950f1315c451403b0660 (diff) | |
download | busybox-w32-d6ce08aeb85b3698ddaa281016b70e16aeb9fb35.tar.gz busybox-w32-d6ce08aeb85b3698ddaa281016b70e16aeb9fb35.tar.bz2 busybox-w32-d6ce08aeb85b3698ddaa281016b70e16aeb9fb35.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'networking')
30 files changed, 176 insertions, 88 deletions
diff --git a/networking/ifconfig.c b/networking/ifconfig.c index d1e9c58dc..61d91788a 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c | |||
@@ -1,18 +1,17 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* ifconfig | 2 | /* |
3 | * ifconfig | ||
3 | * | 4 | * |
4 | * Similar to the standard Unix ifconfig, but with only the necessary | 5 | * Similar to the standard Unix ifconfig, but with only the necessary |
5 | * parts for AF_INET, and without any printing of if info (for now). | 6 | * parts for AF_INET, and without any printing of if info (for now). |
6 | * | 7 | * |
7 | * Bjorn Wesen, Axis Communications AB | 8 | * Bjorn Wesen, Axis Communications AB |
8 | * | 9 | * |
9 | * | ||
10 | * Authors of the original ifconfig was: | 10 | * Authors of the original ifconfig was: |
11 | * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> | 11 | * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> |
12 | * | 12 | * |
13 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 13 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
14 | */ | 14 | */ |
15 | |||
16 | /* | 15 | /* |
17 | * Heavily modified by Manuel Novoa III Mar 6, 2001 | 16 | * Heavily modified by Manuel Novoa III Mar 6, 2001 |
18 | * | 17 | * |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 5521e8a5a..534c9f0c7 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -1,18 +1,18 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * ifup/ifdown for busybox | 3 | * ifup/ifdown for busybox |
4 | * Copyright (c) 2002 Glenn McGrath | 4 | * Copyright (c) 2002 Glenn McGrath |
5 | * Copyright (c) 2003-2004 Erik Andersen <andersen@codepoet.org> | 5 | * Copyright (c) 2003-2004 Erik Andersen <andersen@codepoet.org> |
6 | * | 6 | * |
7 | * Based on ifupdown v 0.6.4 by Anthony Towns | 7 | * Based on ifupdown v 0.6.4 by Anthony Towns |
8 | * Copyright (c) 1999 Anthony Towns <aj@azure.humbug.org.au> | 8 | * Copyright (c) 1999 Anthony Towns <aj@azure.humbug.org.au> |
9 | * | 9 | * |
10 | * Changes to upstream version | 10 | * Changes to upstream version |
11 | * Remove checks for kernel version, assume kernel version 2.2.0 or better. | 11 | * Remove checks for kernel version, assume kernel version 2.2.0 or better. |
12 | * Lines in the interfaces file cannot wrap. | 12 | * Lines in the interfaces file cannot wrap. |
13 | * To adhere to the FHS, the default state file is /var/run/ifstate | 13 | * To adhere to the FHS, the default state file is /var/run/ifstate |
14 | * (defined via CONFIG_IFUPDOWN_IFSTATE_PATH) and can be overridden by build | 14 | * (defined via CONFIG_IFUPDOWN_IFSTATE_PATH) and can be overridden by build |
15 | * configuration. | 15 | * configuration. |
16 | * | 16 | * |
17 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 17 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
18 | */ | 18 | */ |
diff --git a/networking/interface.c b/networking/interface.c index 119185881..89427f2f4 100644 --- a/networking/interface.c +++ b/networking/interface.c | |||
@@ -30,7 +30,6 @@ | |||
30 | * 20001008 - Bernd Eckenfels, Patch from RH for setting mtu | 30 | * 20001008 - Bernd Eckenfels, Patch from RH for setting mtu |
31 | * (default AF was wrong) | 31 | * (default AF was wrong) |
32 | */ | 32 | */ |
33 | |||
34 | #include "libbb.h" | 33 | #include "libbb.h" |
35 | #include "inet_common.h" | 34 | #include "inet_common.h" |
36 | #include <net/if.h> | 35 | #include <net/if.h> |
diff --git a/networking/libiproute/ip_parse_common_args.c b/networking/libiproute/ip_parse_common_args.c index 1a298f738..d693c54fa 100644 --- a/networking/libiproute/ip_parse_common_args.c +++ b/networking/libiproute/ip_parse_common_args.c | |||
@@ -11,7 +11,6 @@ | |||
11 | * | 11 | * |
12 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses | 12 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses |
13 | */ | 13 | */ |
14 | |||
15 | #include "ip_common.h" /* #include "libbb.h" is inside */ | 14 | #include "ip_common.h" /* #include "libbb.h" is inside */ |
16 | #include "utils.h" | 15 | #include "utils.h" |
17 | 16 | ||
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index 36d6b65c6..921ecf0d9 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c | |||
@@ -7,7 +7,6 @@ | |||
7 | * Changes: | 7 | * Changes: |
8 | * Laszlo Valko <valko@linux.karinthy.hu> 990223: address label must be zero terminated | 8 | * Laszlo Valko <valko@linux.karinthy.hu> 990223: address label must be zero terminated |
9 | */ | 9 | */ |
10 | |||
11 | #include <fnmatch.h> | 10 | #include <fnmatch.h> |
12 | #include <net/if.h> | 11 | #include <net/if.h> |
13 | #include <net/if_arp.h> | 12 | #include <net/if_arp.h> |
diff --git a/networking/libiproute/ipneigh.c b/networking/libiproute/ipneigh.c index 2a1c20e20..1cd90d707 100644 --- a/networking/libiproute/ipneigh.c +++ b/networking/libiproute/ipneigh.c | |||
@@ -6,7 +6,6 @@ | |||
6 | * | 6 | * |
7 | * Ported to Busybox by: Curt Brune <curt@cumulusnetworks.com> | 7 | * Ported to Busybox by: Curt Brune <curt@cumulusnetworks.com> |
8 | */ | 8 | */ |
9 | |||
10 | #include "ip_common.h" /* #include "libbb.h" is inside */ | 9 | #include "ip_common.h" /* #include "libbb.h" is inside */ |
11 | #include "common_bufsiz.h" | 10 | #include "common_bufsiz.h" |
12 | #include "rt_names.h" | 11 | #include "rt_names.h" |
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index 6a41b8331..95dafe183 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c | |||
@@ -9,12 +9,16 @@ | |||
9 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses | 9 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses |
10 | * Kunihiro Ishiguro <kunihiro@zebra.org> 001102: rtnh_ifindex was not initialized | 10 | * Kunihiro Ishiguro <kunihiro@zebra.org> 001102: rtnh_ifindex was not initialized |
11 | */ | 11 | */ |
12 | |||
13 | #include "ip_common.h" /* #include "libbb.h" is inside */ | 12 | #include "ip_common.h" /* #include "libbb.h" is inside */ |
14 | #include "common_bufsiz.h" | 13 | #include "common_bufsiz.h" |
15 | #include "rt_names.h" | 14 | #include "rt_names.h" |
16 | #include "utils.h" | 15 | #include "utils.h" |
17 | 16 | ||
17 | #include <linux/version.h> | ||
18 | /* RTA_TABLE is not a define, can't test with ifdef. */ | ||
19 | /* As a proxy, test which kernels toolchain expects: */ | ||
20 | #define HAVE_RTA_TABLE (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) | ||
21 | |||
18 | #ifndef RTAX_RTTVAR | 22 | #ifndef RTAX_RTTVAR |
19 | #define RTAX_RTTVAR RTAX_HOPS | 23 | #define RTAX_RTTVAR RTAX_HOPS |
20 | #endif | 24 | #endif |
@@ -82,9 +86,11 @@ static int FAST_FUNC print_route(const struct sockaddr_nl *who UNUSED_PARAM, | |||
82 | memset(tb, 0, sizeof(tb)); | 86 | memset(tb, 0, sizeof(tb)); |
83 | parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len); | 87 | parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len); |
84 | 88 | ||
89 | #if HAVE_RTA_TABLE | ||
85 | if (tb[RTA_TABLE]) | 90 | if (tb[RTA_TABLE]) |
86 | tid = *(uint32_t *)RTA_DATA(tb[RTA_TABLE]); | 91 | tid = *(uint32_t *)RTA_DATA(tb[RTA_TABLE]); |
87 | else | 92 | else |
93 | #endif | ||
88 | tid = r->rtm_table; | 94 | tid = r->rtm_table; |
89 | 95 | ||
90 | if (r->rtm_family == AF_INET6) | 96 | if (r->rtm_family == AF_INET6) |
@@ -460,12 +466,13 @@ IF_FEATURE_IP_RULE(ARG_table,) | |||
460 | NEXT_ARG(); | 466 | NEXT_ARG(); |
461 | if (rtnl_rttable_a2n(&tid, *argv)) | 467 | if (rtnl_rttable_a2n(&tid, *argv)) |
462 | invarg_1_to_2(*argv, keyword_table); | 468 | invarg_1_to_2(*argv, keyword_table); |
463 | if (tid < 256) | 469 | #if HAVE_RTA_TABLE |
464 | req.r.rtm_table = tid; | 470 | if (tid > 255) { |
465 | else { | ||
466 | req.r.rtm_table = RT_TABLE_UNSPEC; | 471 | req.r.rtm_table = RT_TABLE_UNSPEC; |
467 | addattr32(&req.n, sizeof(req), RTA_TABLE, tid); | 472 | addattr32(&req.n, sizeof(req), RTA_TABLE, tid); |
468 | } | 473 | } else |
474 | #endif | ||
475 | req.r.rtm_table = tid; | ||
469 | #endif | 476 | #endif |
470 | } else if (arg == ARG_dev || arg == ARG_oif) { | 477 | } else if (arg == ARG_dev || arg == ARG_oif) { |
471 | NEXT_ARG(); | 478 | NEXT_ARG(); |
diff --git a/networking/libiproute/iprule.c b/networking/libiproute/iprule.c index 1bb5e759e..53b11e16c 100644 --- a/networking/libiproute/iprule.c +++ b/networking/libiproute/iprule.c | |||
@@ -12,7 +12,6 @@ | |||
12 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses | 12 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses |
13 | * initially integrated into busybox by Bernhard Reutner-Fischer | 13 | * initially integrated into busybox by Bernhard Reutner-Fischer |
14 | */ | 14 | */ |
15 | |||
16 | #include <netinet/in.h> | 15 | #include <netinet/in.h> |
17 | #include <netinet/ip.h> | 16 | #include <netinet/ip.h> |
18 | #include <arpa/inet.h> | 17 | #include <arpa/inet.h> |
@@ -25,6 +24,11 @@ | |||
25 | #include "rt_names.h" | 24 | #include "rt_names.h" |
26 | #include "utils.h" | 25 | #include "utils.h" |
27 | 26 | ||
27 | #include <linux/version.h> | ||
28 | /* RTA_TABLE is not a define, can't test with ifdef. */ | ||
29 | /* As a proxy, test which kernels toolchain expects: */ | ||
30 | #define HAVE_RTA_TABLE (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) | ||
31 | |||
28 | /* If you add stuff here, update iprule_full_usage */ | 32 | /* If you add stuff here, update iprule_full_usage */ |
29 | static const char keywords[] ALIGN1 = | 33 | static const char keywords[] ALIGN1 = |
30 | "from\0""to\0""preference\0""order\0""priority\0" | 34 | "from\0""to\0""preference\0""order\0""priority\0" |
@@ -121,9 +125,12 @@ static int FAST_FUNC print_rule(const struct sockaddr_nl *who UNUSED_PARAM, | |||
121 | printf("iif %s ", (char*)RTA_DATA(tb[RTA_IIF])); | 125 | printf("iif %s ", (char*)RTA_DATA(tb[RTA_IIF])); |
122 | } | 126 | } |
123 | 127 | ||
128 | #if HAVE_RTA_TABLE | ||
124 | if (tb[RTA_TABLE]) | 129 | if (tb[RTA_TABLE]) |
125 | printf("lookup %s ", rtnl_rttable_n2a(*(uint32_t*)RTA_DATA(tb[RTA_TABLE]))); | 130 | printf("lookup %s ", rtnl_rttable_n2a(*(uint32_t*)RTA_DATA(tb[RTA_TABLE]))); |
126 | else if (r->rtm_table) | 131 | else |
132 | #endif | ||
133 | if (r->rtm_table) | ||
127 | printf("lookup %s ", rtnl_rttable_n2a(r->rtm_table)); | 134 | printf("lookup %s ", rtnl_rttable_n2a(r->rtm_table)); |
128 | 135 | ||
129 | if (tb[FRA_SUPPRESS_PREFIXLEN]) { | 136 | if (tb[FRA_SUPPRESS_PREFIXLEN]) { |
@@ -267,12 +274,15 @@ static int iprule_modify(int cmd, char **argv) | |||
267 | NEXT_ARG(); | 274 | NEXT_ARG(); |
268 | if (rtnl_rttable_a2n(&tid, *argv)) | 275 | if (rtnl_rttable_a2n(&tid, *argv)) |
269 | invarg_1_to_2(*argv, "table ID"); | 276 | invarg_1_to_2(*argv, "table ID"); |
270 | if (tid < 256) | 277 | |
271 | req.r.rtm_table = tid; | 278 | #if HAVE_RTA_TABLE |
272 | else { | 279 | if (tid > 255) { |
273 | req.r.rtm_table = RT_TABLE_UNSPEC; | 280 | req.r.rtm_table = RT_TABLE_UNSPEC; |
274 | addattr32(&req.n, sizeof(req), RTA_TABLE, tid); | 281 | addattr32(&req.n, sizeof(req), RTA_TABLE, tid); |
275 | } | 282 | } else |
283 | #endif | ||
284 | req.r.rtm_table = tid; | ||
285 | |||
276 | table_ok = 1; | 286 | table_ok = 1; |
277 | } else if (key == ARG_suppress_prefixlength) { | 287 | } else if (key == ARG_suppress_prefixlength) { |
278 | int prefix_length; | 288 | int prefix_length; |
diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c index eb136e435..4002feb78 100644 --- a/networking/libiproute/iptunnel.c +++ b/networking/libiproute/iptunnel.c | |||
@@ -10,7 +10,6 @@ | |||
10 | * Rani Assaf <rani@magic.metawire.com> 980930: do not allow key for ipip/sit | 10 | * Rani Assaf <rani@magic.metawire.com> 980930: do not allow key for ipip/sit |
11 | * Phil Karn <karn@ka9q.ampr.org> 990408: "pmtudisc" flag | 11 | * Phil Karn <karn@ka9q.ampr.org> 990408: "pmtudisc" flag |
12 | */ | 12 | */ |
13 | |||
14 | #include <netinet/ip.h> | 13 | #include <netinet/ip.h> |
15 | #include <net/if.h> | 14 | #include <net/if.h> |
16 | #include <net/if_arp.h> | 15 | #include <net/if_arp.h> |
diff --git a/networking/libiproute/libnetlink.c b/networking/libiproute/libnetlink.c index 7e0ff1b6c..3f0f70326 100644 --- a/networking/libiproute/libnetlink.c +++ b/networking/libiproute/libnetlink.c | |||
@@ -7,7 +7,6 @@ | |||
7 | * | 7 | * |
8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
9 | */ | 9 | */ |
10 | |||
11 | #include <sys/socket.h> | 10 | #include <sys/socket.h> |
12 | #include <sys/uio.h> | 11 | #include <sys/uio.h> |
13 | 12 | ||
diff --git a/networking/libiproute/ll_addr.c b/networking/libiproute/ll_addr.c index 33a54ea6c..afdd81ffb 100644 --- a/networking/libiproute/ll_addr.c +++ b/networking/libiproute/ll_addr.c | |||
@@ -7,14 +7,12 @@ | |||
7 | * | 7 | * |
8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
9 | */ | 9 | */ |
10 | |||
11 | #include <net/if_arp.h> | 10 | #include <net/if_arp.h> |
12 | 11 | ||
13 | #include "libbb.h" | 12 | #include "libbb.h" |
14 | #include "rt_names.h" | 13 | #include "rt_names.h" |
15 | #include "utils.h" | 14 | #include "utils.h" |
16 | 15 | ||
17 | |||
18 | const char* FAST_FUNC ll_addr_n2a(unsigned char *addr, int alen, int type, char *buf, int blen) | 16 | const char* FAST_FUNC ll_addr_n2a(unsigned char *addr, int alen, int type, char *buf, int blen) |
19 | { | 17 | { |
20 | int i; | 18 | int i; |
diff --git a/networking/libiproute/ll_map.c b/networking/libiproute/ll_map.c index af9eb46f7..be88a04e8 100644 --- a/networking/libiproute/ll_map.c +++ b/networking/libiproute/ll_map.c | |||
@@ -7,7 +7,6 @@ | |||
7 | * | 7 | * |
8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
9 | */ | 9 | */ |
10 | |||
11 | #include <net/if.h> /* struct ifreq and co. */ | 10 | #include <net/if.h> /* struct ifreq and co. */ |
12 | 11 | ||
13 | #include "libbb.h" | 12 | #include "libbb.h" |
diff --git a/networking/libiproute/ll_proto.c b/networking/libiproute/ll_proto.c index 4c32ae574..7d46221ac 100644 --- a/networking/libiproute/ll_proto.c +++ b/networking/libiproute/ll_proto.c | |||
@@ -7,7 +7,6 @@ | |||
7 | * | 7 | * |
8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
9 | */ | 9 | */ |
10 | |||
11 | #include "libbb.h" | 10 | #include "libbb.h" |
12 | #include "rt_names.h" | 11 | #include "rt_names.h" |
13 | #include "utils.h" | 12 | #include "utils.h" |
diff --git a/networking/libiproute/rtm_map.c b/networking/libiproute/rtm_map.c index c763da049..e94c99ab6 100644 --- a/networking/libiproute/rtm_map.c +++ b/networking/libiproute/rtm_map.c | |||
@@ -7,7 +7,6 @@ | |||
7 | * | 7 | * |
8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
9 | */ | 9 | */ |
10 | |||
11 | #include "libbb.h" | 10 | #include "libbb.h" |
12 | #include "rt_names.h" | 11 | #include "rt_names.h" |
13 | #include "utils.h" | 12 | #include "utils.h" |
@@ -44,7 +43,6 @@ const char* FAST_FUNC rtnl_rtntype_n2a(int id) | |||
44 | } | 43 | } |
45 | } | 44 | } |
46 | 45 | ||
47 | |||
48 | int FAST_FUNC rtnl_rtntype_a2n(int *id, char *arg) | 46 | int FAST_FUNC rtnl_rtntype_a2n(int *id, char *arg) |
49 | { | 47 | { |
50 | static const char keywords[] ALIGN1 = | 48 | static const char keywords[] ALIGN1 = |
diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c index fca167ac6..bf053a54b 100644 --- a/networking/libiproute/utils.c +++ b/networking/libiproute/utils.c | |||
@@ -8,7 +8,6 @@ | |||
8 | * | 8 | * |
9 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses | 9 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses |
10 | */ | 10 | */ |
11 | |||
12 | #include "libbb.h" | 11 | #include "libbb.h" |
13 | #include "utils.h" | 12 | #include "utils.h" |
14 | #include "inet_common.h" | 13 | #include "inet_common.h" |
diff --git a/networking/nc.c b/networking/nc.c index 4b8f9c13a..de02ccc9d 100644 --- a/networking/nc.c +++ b/networking/nc.c | |||
@@ -1,5 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* nc: mini-netcat - built from the ground up for LRP | 2 | /* |
3 | * nc: mini-netcat - built from the ground up for LRP | ||
3 | * | 4 | * |
4 | * Copyright (C) 1998, 1999 Charles P. Wright | 5 | * Copyright (C) 1998, 1999 Charles P. Wright |
5 | * Copyright (C) 1998 Dave Cinege | 6 | * Copyright (C) 1998 Dave Cinege |
diff --git a/networking/ntpd.c b/networking/ntpd.c index 4f881eaf9..0b60d003b 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c | |||
@@ -71,7 +71,7 @@ | |||
71 | //usage: "[-dnqNw"IF_FEATURE_NTPD_SERVER("l -I IFACE")"] [-S PROG] [-p PEER]..." | 71 | //usage: "[-dnqNw"IF_FEATURE_NTPD_SERVER("l -I IFACE")"] [-S PROG] [-p PEER]..." |
72 | //usage:#define ntpd_full_usage "\n\n" | 72 | //usage:#define ntpd_full_usage "\n\n" |
73 | //usage: "NTP client/server\n" | 73 | //usage: "NTP client/server\n" |
74 | //usage: "\n -d Verbose" | 74 | //usage: "\n -d Verbose (may be repeated)" |
75 | //usage: "\n -n Do not daemonize" | 75 | //usage: "\n -n Do not daemonize" |
76 | //usage: "\n -q Quit after clock is set" | 76 | //usage: "\n -q Quit after clock is set" |
77 | //usage: "\n -N Run at high priority" | 77 | //usage: "\n -N Run at high priority" |
@@ -155,7 +155,8 @@ | |||
155 | #define RETRY_INTERVAL 32 /* on send/recv error, retry in N secs (need to be power of 2) */ | 155 | #define RETRY_INTERVAL 32 /* on send/recv error, retry in N secs (need to be power of 2) */ |
156 | #define NOREPLY_INTERVAL 512 /* sent, but got no reply: cap next query by this many seconds */ | 156 | #define NOREPLY_INTERVAL 512 /* sent, but got no reply: cap next query by this many seconds */ |
157 | #define RESPONSE_INTERVAL 16 /* wait for reply up to N secs */ | 157 | #define RESPONSE_INTERVAL 16 /* wait for reply up to N secs */ |
158 | #define HOSTNAME_INTERVAL 5 /* hostname lookup failed. Wait N secs for next try */ | 158 | #define HOSTNAME_INTERVAL 4 /* hostname lookup failed. Wait N * peer->dns_errors secs for next try */ |
159 | #define DNS_ERRORS_CAP 0x3f /* peer->dns_errors is in [0..63] */ | ||
159 | 160 | ||
160 | /* Step threshold (sec). std ntpd uses 0.128. | 161 | /* Step threshold (sec). std ntpd uses 0.128. |
161 | */ | 162 | */ |
@@ -301,6 +302,7 @@ typedef struct { | |||
301 | uint8_t lastpkt_status; | 302 | uint8_t lastpkt_status; |
302 | uint8_t lastpkt_stratum; | 303 | uint8_t lastpkt_stratum; |
303 | uint8_t reachable_bits; | 304 | uint8_t reachable_bits; |
305 | uint8_t dns_errors; | ||
304 | /* when to send new query (if p_fd == -1) | 306 | /* when to send new query (if p_fd == -1) |
305 | * or when receive times out (if p_fd >= 0): */ | 307 | * or when receive times out (if p_fd >= 0): */ |
306 | double next_action_time; | 308 | double next_action_time; |
@@ -802,10 +804,10 @@ resolve_peer_hostname(peer_t *p) | |||
802 | p->p_dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa); | 804 | p->p_dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa); |
803 | VERB1 if (strcmp(p->p_hostname, p->p_dotted) != 0) | 805 | VERB1 if (strcmp(p->p_hostname, p->p_dotted) != 0) |
804 | bb_error_msg("'%s' is %s", p->p_hostname, p->p_dotted); | 806 | bb_error_msg("'%s' is %s", p->p_hostname, p->p_dotted); |
805 | } else { | 807 | p->dns_errors = 0; |
806 | /* error message is emitted by host2sockaddr() */ | 808 | return lsa; |
807 | set_next(p, HOSTNAME_INTERVAL); | ||
808 | } | 809 | } |
810 | p->dns_errors = ((p->dns_errors << 1) | 1) & DNS_ERRORS_CAP; | ||
809 | return lsa; | 811 | return lsa; |
810 | } | 812 | } |
811 | 813 | ||
@@ -866,10 +868,8 @@ do_sendto(int fd, | |||
866 | static void | 868 | static void |
867 | send_query_to_peer(peer_t *p) | 869 | send_query_to_peer(peer_t *p) |
868 | { | 870 | { |
869 | if (!p->p_lsa) { | 871 | if (!p->p_lsa) |
870 | if (!resolve_peer_hostname(p)) | 872 | return; |
871 | return; | ||
872 | } | ||
873 | 873 | ||
874 | /* Why do we need to bind()? | 874 | /* Why do we need to bind()? |
875 | * See what happens when we don't bind: | 875 | * See what happens when we don't bind: |
@@ -2441,13 +2441,42 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv) | |||
2441 | did_poll: | 2441 | did_poll: |
2442 | gettime1900d(); /* sets G.cur_time */ | 2442 | gettime1900d(); /* sets G.cur_time */ |
2443 | if (nfds <= 0) { | 2443 | if (nfds <= 0) { |
2444 | if (!bb_got_signal /* poll wasn't interrupted by a signal */ | 2444 | double ct; |
2445 | && G.cur_time - G.last_script_run > 11*60 | 2445 | int dns_error; |
2446 | ) { | 2446 | |
2447 | if (bb_got_signal) | ||
2448 | break; /* poll was interrupted by a signal */ | ||
2449 | |||
2450 | if (G.cur_time - G.last_script_run > 11*60) { | ||
2447 | /* Useful for updating battery-backed RTC and such */ | 2451 | /* Useful for updating battery-backed RTC and such */ |
2448 | run_script("periodic", G.last_update_offset); | 2452 | run_script("periodic", G.last_update_offset); |
2449 | gettime1900d(); /* sets G.cur_time */ | 2453 | gettime1900d(); /* sets G.cur_time */ |
2450 | } | 2454 | } |
2455 | |||
2456 | /* Resolve peer names to IPs, if not resolved yet. | ||
2457 | * We do it only when poll timed out: | ||
2458 | * this way, we almost never overlap DNS resolution with | ||
2459 | * "request-reply" packet round trip. | ||
2460 | */ | ||
2461 | dns_error = 0; | ||
2462 | ct = G.cur_time; | ||
2463 | for (item = G.ntp_peers; item != NULL; item = item->link) { | ||
2464 | peer_t *p = (peer_t *) item->data; | ||
2465 | if (p->next_action_time <= ct && !p->p_lsa) { | ||
2466 | /* This can take up to ~10 sec per each DNS query */ | ||
2467 | dns_error |= (!resolve_peer_hostname(p)); | ||
2468 | } | ||
2469 | } | ||
2470 | if (!dns_error) | ||
2471 | goto check_unsync; | ||
2472 | /* Set next time for those which are still not resolved */ | ||
2473 | gettime1900d(); /* sets G.cur_time (needed for set_next()) */ | ||
2474 | for (item = G.ntp_peers; item != NULL; item = item->link) { | ||
2475 | peer_t *p = (peer_t *) item->data; | ||
2476 | if (p->next_action_time <= ct && !p->p_lsa) { | ||
2477 | set_next(p, HOSTNAME_INTERVAL * p->dns_errors); | ||
2478 | } | ||
2479 | } | ||
2451 | goto check_unsync; | 2480 | goto check_unsync; |
2452 | } | 2481 | } |
2453 | 2482 | ||
diff --git a/networking/ping.c b/networking/ping.c index 774f8f3e0..d1d59d545 100644 --- a/networking/ping.c +++ b/networking/ping.c | |||
@@ -135,6 +135,14 @@ | |||
135 | # define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */ | 135 | # define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */ |
136 | #endif | 136 | #endif |
137 | 137 | ||
138 | /* Some operating systems, like GNU/Hurd, don't define SOL_RAW, but do have | ||
139 | * IPPROTO_RAW. Since the IPPROTO definitions are also valid to use for | ||
140 | * setsockopt (and take the same value as their corresponding SOL definitions, | ||
141 | * if they exist), we can just fall back on IPPROTO_RAW. */ | ||
142 | #ifndef SOL_RAW | ||
143 | # define SOL_RAW IPPROTO_RAW | ||
144 | #endif | ||
145 | |||
138 | #if ENABLE_PING6 | 146 | #if ENABLE_PING6 |
139 | # include <netinet/icmp6.h> | 147 | # include <netinet/icmp6.h> |
140 | /* I see RENUMBERED constants in bits/in.h - !!? | 148 | /* I see RENUMBERED constants in bits/in.h - !!? |
diff --git a/networking/route.c b/networking/route.c index 32789eecc..6edc0f6d7 100644 --- a/networking/route.c +++ b/networking/route.c | |||
@@ -1,5 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* route | 2 | /* |
3 | * route | ||
3 | * | 4 | * |
4 | * Similar to the standard Unix route, but with only the necessary | 5 | * Similar to the standard Unix route, but with only the necessary |
5 | * parts for AF_INET and AF_INET6 | 6 | * parts for AF_INET and AF_INET6 |
@@ -18,7 +19,6 @@ | |||
18 | * | 19 | * |
19 | * IPV6 support added by Bart Visscher <magick@linux-fan.com> | 20 | * IPV6 support added by Bart Visscher <magick@linux-fan.com> |
20 | */ | 21 | */ |
21 | |||
22 | /* 2004/03/09 Manuel Novoa III <mjn3@codepoet.org> | 22 | /* 2004/03/09 Manuel Novoa III <mjn3@codepoet.org> |
23 | * | 23 | * |
24 | * Rewritten to fix several bugs, add additional error checking, and | 24 | * Rewritten to fix several bugs, add additional error checking, and |
diff --git a/networking/telnet.c b/networking/telnet.c index 1f8a44466..8b0df7f5c 100644 --- a/networking/telnet.c +++ b/networking/telnet.c | |||
@@ -18,7 +18,6 @@ | |||
18 | * <jam@ltsp.org> | 18 | * <jam@ltsp.org> |
19 | * Modified 2004/02/11 to add ability to pass the USER variable to remote host | 19 | * Modified 2004/02/11 to add ability to pass the USER variable to remote host |
20 | * by Fernando Silveira <swrh@gmx.net> | 20 | * by Fernando Silveira <swrh@gmx.net> |
21 | * | ||
22 | */ | 21 | */ |
23 | //config:config TELNET | 22 | //config:config TELNET |
24 | //config: bool "telnet (8.7 kb)" | 23 | //config: bool "telnet (8.7 kb)" |
diff --git a/networking/traceroute.c b/networking/traceroute.c index 8b6247482..a027b928a 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -311,6 +311,9 @@ | |||
311 | # ifndef SOL_IPV6 | 311 | # ifndef SOL_IPV6 |
312 | # define SOL_IPV6 IPPROTO_IPV6 | 312 | # define SOL_IPV6 IPPROTO_IPV6 |
313 | # endif | 313 | # endif |
314 | # if defined(IPV6_PKTINFO) && !defined(IPV6_RECVPKTINFO) | ||
315 | # define IPV6_RECVPKTINFO IPV6_PKTINFO | ||
316 | # endif | ||
314 | #endif | 317 | #endif |
315 | 318 | ||
316 | #include "libbb.h" | 319 | #include "libbb.h" |
@@ -323,6 +326,14 @@ | |||
323 | # define IPPROTO_IP 0 | 326 | # define IPPROTO_IP 0 |
324 | #endif | 327 | #endif |
325 | 328 | ||
329 | /* Some operating systems, like GNU/Hurd, don't define SOL_RAW, but do have | ||
330 | * IPPROTO_RAW. Since the IPPROTO definitions are also valid to use for | ||
331 | * setsockopt (and take the same value as their corresponding SOL definitions, | ||
332 | * if they exist), we can just fall back on IPPROTO_RAW. */ | ||
333 | #ifndef SOL_RAW | ||
334 | # define SOL_RAW IPPROTO_RAW | ||
335 | #endif | ||
336 | |||
326 | 337 | ||
327 | #define OPT_STRING \ | 338 | #define OPT_STRING \ |
328 | "FIlnrdvxt:i:m:p:q:s:w:z:f:" \ | 339 | "FIlnrdvxt:i:m:p:q:s:w:z:f:" \ |
@@ -698,6 +709,9 @@ packet_ok(int read_len, len_and_sockaddr *from_lsa, | |||
698 | 709 | ||
699 | # if ENABLE_FEATURE_TRACEROUTE_VERBOSE | 710 | # if ENABLE_FEATURE_TRACEROUTE_VERBOSE |
700 | if (verbose) { | 711 | if (verbose) { |
712 | # ifndef MAXHOSTNAMELEN | ||
713 | # define MAXHOSTNAMELEN 80 | ||
714 | # endif | ||
701 | unsigned char *p; | 715 | unsigned char *p; |
702 | char pa1[MAXHOSTNAMELEN]; | 716 | char pa1[MAXHOSTNAMELEN]; |
703 | char pa2[MAXHOSTNAMELEN]; | 717 | char pa2[MAXHOSTNAMELEN]; |
@@ -903,12 +917,7 @@ common_traceroute_main(int op, char **argv) | |||
903 | #if ENABLE_TRACEROUTE6 | 917 | #if ENABLE_TRACEROUTE6 |
904 | if (af == AF_INET6) { | 918 | if (af == AF_INET6) { |
905 | xmove_fd(xsocket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6), rcvsock); | 919 | xmove_fd(xsocket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6), rcvsock); |
906 | # ifdef IPV6_RECVPKTINFO | ||
907 | setsockopt_1(rcvsock, SOL_IPV6, IPV6_RECVPKTINFO); | 920 | setsockopt_1(rcvsock, SOL_IPV6, IPV6_RECVPKTINFO); |
908 | setsockopt_1(rcvsock, SOL_IPV6, IPV6_2292PKTINFO); | ||
909 | # else | ||
910 | setsockopt_1(rcvsock, SOL_IPV6, IPV6_PKTINFO); | ||
911 | # endif | ||
912 | } else | 921 | } else |
913 | #endif | 922 | #endif |
914 | { | 923 | { |
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index a9c23a186..04939e707 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h | |||
@@ -308,7 +308,9 @@ int udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt, | |||
308 | 308 | ||
309 | int udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt, | 309 | int udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt, |
310 | uint32_t source_nip, int source_port, | 310 | uint32_t source_nip, int source_port, |
311 | uint32_t dest_nip, int dest_port) FAST_FUNC; | 311 | uint32_t dest_nip, int dest_port, |
312 | int send_flags | ||
313 | ) FAST_FUNC; | ||
312 | 314 | ||
313 | void udhcp_sp_setup(void) FAST_FUNC; | 315 | void udhcp_sp_setup(void) FAST_FUNC; |
314 | void udhcp_sp_fd_set(struct pollfd *pfds, int extra_fd) FAST_FUNC; | 316 | void udhcp_sp_fd_set(struct pollfd *pfds, int extra_fd) FAST_FUNC; |
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index 714555fa8..37ffd064d 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c | |||
@@ -702,13 +702,15 @@ static NOINLINE int send_d6_renew(uint32_t xid, struct in6_addr *server_ipv6, st | |||
702 | opt_ptr = add_d6_client_options(opt_ptr); | 702 | opt_ptr = add_d6_client_options(opt_ptr); |
703 | 703 | ||
704 | bb_error_msg("sending %s", "renew"); | 704 | bb_error_msg("sending %s", "renew"); |
705 | if (server_ipv6) | 705 | if (server_ipv6) { |
706 | return d6_send_kernel_packet( | 706 | return d6_send_kernel_packet( |
707 | &packet, (opt_ptr - (uint8_t*) &packet), | 707 | &packet, (opt_ptr - (uint8_t*) &packet), |
708 | our_cur_ipv6, CLIENT_PORT6, | 708 | our_cur_ipv6, CLIENT_PORT6, |
709 | server_ipv6, SERVER_PORT6, | 709 | server_ipv6, SERVER_PORT6, |
710 | client_config.ifindex | 710 | client_config.ifindex |
711 | /* TODO? send_flags: MSG_DONTROUTE (see IPv4 code for reason why) */ | ||
711 | ); | 712 | ); |
713 | } | ||
712 | return d6_mcast_from_client_config_ifindex(&packet, opt_ptr); | 714 | return d6_mcast_from_client_config_ifindex(&packet, opt_ptr); |
713 | } | 715 | } |
714 | 716 | ||
@@ -881,9 +883,14 @@ static int d6_raw_socket(int ifindex) | |||
881 | fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IPV6)); | 883 | fd = xsocket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IPV6)); |
882 | log2("got raw socket fd %d", fd); | 884 | log2("got raw socket fd %d", fd); |
883 | 885 | ||
886 | memset(&sock, 0, sizeof(sock)); /* let's be deterministic */ | ||
884 | sock.sll_family = AF_PACKET; | 887 | sock.sll_family = AF_PACKET; |
885 | sock.sll_protocol = htons(ETH_P_IPV6); | 888 | sock.sll_protocol = htons(ETH_P_IPV6); |
886 | sock.sll_ifindex = ifindex; | 889 | sock.sll_ifindex = ifindex; |
890 | /*sock.sll_hatype = ARPHRD_???;*/ | ||
891 | /*sock.sll_pkttype = PACKET_???;*/ | ||
892 | /*sock.sll_halen = ???;*/ | ||
893 | /*sock.sll_addr[8] = ???;*/ | ||
887 | xbind(fd, (struct sockaddr *) &sock, sizeof(sock)); | 894 | xbind(fd, (struct sockaddr *) &sock, sizeof(sock)); |
888 | 895 | ||
889 | #if 0 | 896 | #if 0 |
@@ -1425,7 +1432,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
1425 | len = d6_recv_raw_packet(&srv6_buf, &packet, sockfd); | 1432 | len = d6_recv_raw_packet(&srv6_buf, &packet, sockfd); |
1426 | if (len == -1) { | 1433 | if (len == -1) { |
1427 | /* Error is severe, reopen socket */ | 1434 | /* Error is severe, reopen socket */ |
1428 | bb_error_msg("read error: %s, reopening socket", strerror(errno)); | 1435 | bb_error_msg("read error: "STRERROR_FMT", reopening socket" STRERROR_ERRNO); |
1429 | sleep(discover_timeout); /* 3 seconds by default */ | 1436 | sleep(discover_timeout); /* 3 seconds by default */ |
1430 | change_listen_mode(listen_mode); /* just close and reopen */ | 1437 | change_listen_mode(listen_mode); /* just close and reopen */ |
1431 | } | 1438 | } |
diff --git a/networking/udhcp/d6_packet.c b/networking/udhcp/d6_packet.c index 79a0ac8a8..493943d72 100644 --- a/networking/udhcp/d6_packet.c +++ b/networking/udhcp/d6_packet.c | |||
@@ -18,7 +18,7 @@ void FAST_FUNC d6_dump_packet(struct d6_packet *packet) | |||
18 | return; | 18 | return; |
19 | 19 | ||
20 | bb_error_msg( | 20 | bb_error_msg( |
21 | "xid %x" | 21 | " xid %x" |
22 | , packet->d6_xid32 | 22 | , packet->d6_xid32 |
23 | ); | 23 | ); |
24 | //*bin2hex(buf, (void *) packet->chaddr, sizeof(packet->chaddr)) = '\0'; | 24 | //*bin2hex(buf, (void *) packet->chaddr, sizeof(packet->chaddr)) = '\0'; |
@@ -75,6 +75,8 @@ int FAST_FUNC d6_send_raw_packet( | |||
75 | dest_sll.sll_family = AF_PACKET; | 75 | dest_sll.sll_family = AF_PACKET; |
76 | dest_sll.sll_protocol = htons(ETH_P_IPV6); | 76 | dest_sll.sll_protocol = htons(ETH_P_IPV6); |
77 | dest_sll.sll_ifindex = ifindex; | 77 | dest_sll.sll_ifindex = ifindex; |
78 | /*dest_sll.sll_hatype = ARPHRD_???;*/ | ||
79 | /*dest_sll.sll_pkttype = PACKET_???;*/ | ||
78 | dest_sll.sll_halen = 6; | 80 | dest_sll.sll_halen = 6; |
79 | memcpy(dest_sll.sll_addr, dest_arp, 6); | 81 | memcpy(dest_sll.sll_addr, dest_arp, 6); |
80 | 82 | ||
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 99d91bf70..55f21c187 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -1,7 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * udhcp client | 3 | * udhcp client |
4 | * | ||
5 | * Russ Dill <Russ.Dill@asu.edu> July 2001 | 4 | * Russ Dill <Russ.Dill@asu.edu> July 2001 |
6 | * | 5 | * |
7 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
@@ -694,10 +693,16 @@ static int raw_bcast_from_client_config_ifindex(struct dhcp_packet *packet, uint | |||
694 | 693 | ||
695 | static int bcast_or_ucast(struct dhcp_packet *packet, uint32_t ciaddr, uint32_t server) | 694 | static int bcast_or_ucast(struct dhcp_packet *packet, uint32_t ciaddr, uint32_t server) |
696 | { | 695 | { |
697 | if (server) | 696 | if (server) { |
697 | /* Without MSG_DONTROUTE, the packet was seen routed over | ||
698 | * _other interface_ if server ID is bogus (example: 1.1.1.1). | ||
699 | */ | ||
698 | return udhcp_send_kernel_packet(packet, | 700 | return udhcp_send_kernel_packet(packet, |
699 | ciaddr, CLIENT_PORT, | 701 | ciaddr, CLIENT_PORT, |
700 | server, SERVER_PORT); | 702 | server, SERVER_PORT, |
703 | /*send_flags: "to hosts only on directly connected networks" */ MSG_DONTROUTE | ||
704 | ); | ||
705 | } | ||
701 | return raw_bcast_from_client_config_ifindex(packet, ciaddr); | 706 | return raw_bcast_from_client_config_ifindex(packet, ciaddr); |
702 | } | 707 | } |
703 | 708 | ||
@@ -735,7 +740,7 @@ static NOINLINE int send_discover(uint32_t xid, uint32_t requested) | |||
735 | static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requested) | 740 | static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requested) |
736 | { | 741 | { |
737 | struct dhcp_packet packet; | 742 | struct dhcp_packet packet; |
738 | struct in_addr addr; | 743 | struct in_addr temp_addr; |
739 | 744 | ||
740 | /* | 745 | /* |
741 | * RFC 2131 4.3.2 DHCPREQUEST message | 746 | * RFC 2131 4.3.2 DHCPREQUEST message |
@@ -766,8 +771,8 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste | |||
766 | */ | 771 | */ |
767 | add_client_options(&packet); | 772 | add_client_options(&packet); |
768 | 773 | ||
769 | addr.s_addr = requested; | 774 | temp_addr.s_addr = requested; |
770 | bb_error_msg("sending select for %s", inet_ntoa(addr)); | 775 | bb_error_msg("sending select for %s", inet_ntoa(temp_addr)); |
771 | return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY); | 776 | return raw_bcast_from_client_config_ifindex(&packet, INADDR_ANY); |
772 | } | 777 | } |
773 | 778 | ||
@@ -776,6 +781,7 @@ static NOINLINE int send_select(uint32_t xid, uint32_t server, uint32_t requeste | |||
776 | static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr) | 781 | static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr) |
777 | { | 782 | { |
778 | struct dhcp_packet packet; | 783 | struct dhcp_packet packet; |
784 | struct in_addr temp_addr; | ||
779 | 785 | ||
780 | /* | 786 | /* |
781 | * RFC 2131 4.3.2 DHCPREQUEST message | 787 | * RFC 2131 4.3.2 DHCPREQUEST message |
@@ -806,7 +812,8 @@ static NOINLINE int send_renew(uint32_t xid, uint32_t server, uint32_t ciaddr) | |||
806 | */ | 812 | */ |
807 | add_client_options(&packet); | 813 | add_client_options(&packet); |
808 | 814 | ||
809 | bb_error_msg("sending %s", "renew"); | 815 | temp_addr.s_addr = server; |
816 | bb_error_msg("sending renew to %s", inet_ntoa(temp_addr)); | ||
810 | return bcast_or_ucast(&packet, ciaddr, server); | 817 | return bcast_or_ucast(&packet, ciaddr, server); |
811 | } | 818 | } |
812 | 819 | ||
@@ -1010,9 +1017,14 @@ static int udhcp_raw_socket(int ifindex) | |||
1010 | */ | 1017 | */ |
1011 | log2("got raw socket fd"); | 1018 | log2("got raw socket fd"); |
1012 | 1019 | ||
1020 | memset(&sock, 0, sizeof(sock)); /* let's be deterministic */ | ||
1013 | sock.sll_family = AF_PACKET; | 1021 | sock.sll_family = AF_PACKET; |
1014 | sock.sll_protocol = htons(ETH_P_IP); | 1022 | sock.sll_protocol = htons(ETH_P_IP); |
1015 | sock.sll_ifindex = ifindex; | 1023 | sock.sll_ifindex = ifindex; |
1024 | /*sock.sll_hatype = ARPHRD_???;*/ | ||
1025 | /*sock.sll_pkttype = PACKET_???;*/ | ||
1026 | /*sock.sll_halen = ???;*/ | ||
1027 | /*sock.sll_addr[8] = ???;*/ | ||
1016 | xbind(fd, (struct sockaddr *) &sock, sizeof(sock)); | 1028 | xbind(fd, (struct sockaddr *) &sock, sizeof(sock)); |
1017 | 1029 | ||
1018 | #if 0 /* Several users reported breakage when BPF filter is used */ | 1030 | #if 0 /* Several users reported breakage when BPF filter is used */ |
@@ -1519,11 +1531,24 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1519 | * Anyway, it does recover by eventually failing through | 1531 | * Anyway, it does recover by eventually failing through |
1520 | * into INIT_SELECTING state. | 1532 | * into INIT_SELECTING state. |
1521 | */ | 1533 | */ |
1522 | send_renew(xid, server_addr, requested_ip); | 1534 | if (send_renew(xid, server_addr, requested_ip) >= 0) { |
1523 | timeout >>= 1; | 1535 | timeout >>= 1; |
1524 | continue; | 1536 | //TODO: the timeout to receive an answer for our renew should not be selected |
1537 | //with "timeout = lease_seconds / 2; ...; timeout = timeout / 2": it is often huge. | ||
1538 | //Waiting e.g. 4*3600 seconds for a reply does not make sense | ||
1539 | //(if reply isn't coming, we keep an open socket for hours), | ||
1540 | //it should be something like 10 seconds. | ||
1541 | //Also, it's probably best to try sending renew in kernel mode a few (3-5) times | ||
1542 | //and fall back to raw mode if it does not work. | ||
1543 | continue; | ||
1544 | } | ||
1545 | /* else: error sending. | ||
1546 | * example: ENETUNREACH seen with server | ||
1547 | * which gave us bogus server ID 1.1.1.1 | ||
1548 | * which wasn't reachable (and probably did not exist). | ||
1549 | */ | ||
1525 | } | 1550 | } |
1526 | /* Timed out, enter rebinding state */ | 1551 | /* Timed out or error, enter rebinding state */ |
1527 | log1("entering rebinding state"); | 1552 | log1("entering rebinding state"); |
1528 | state = REBINDING; | 1553 | state = REBINDING; |
1529 | /* fall right through */ | 1554 | /* fall right through */ |
@@ -1605,7 +1630,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1605 | len = udhcp_recv_raw_packet(&packet, sockfd); | 1630 | len = udhcp_recv_raw_packet(&packet, sockfd); |
1606 | if (len == -1) { | 1631 | if (len == -1) { |
1607 | /* Error is severe, reopen socket */ | 1632 | /* Error is severe, reopen socket */ |
1608 | bb_error_msg("read error: %s, reopening socket", strerror(errno)); | 1633 | bb_error_msg("read error: "STRERROR_FMT", reopening socket" STRERROR_ERRNO); |
1609 | sleep(discover_timeout); /* 3 seconds by default */ | 1634 | sleep(discover_timeout); /* 3 seconds by default */ |
1610 | change_listen_mode(listen_mode); /* just close and reopen */ | 1635 | change_listen_mode(listen_mode); /* just close and reopen */ |
1611 | } | 1636 | } |
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c index 05ddc8649..238542bb0 100644 --- a/networking/udhcp/dhcpd.c +++ b/networking/udhcp/dhcpd.c | |||
@@ -588,7 +588,9 @@ static void send_packet_to_relay(struct dhcp_packet *dhcp_pkt) | |||
588 | 588 | ||
589 | udhcp_send_kernel_packet(dhcp_pkt, | 589 | udhcp_send_kernel_packet(dhcp_pkt, |
590 | server_config.server_nip, SERVER_PORT, | 590 | server_config.server_nip, SERVER_PORT, |
591 | dhcp_pkt->gateway_nip, SERVER_PORT); | 591 | dhcp_pkt->gateway_nip, SERVER_PORT, |
592 | /*send_flags:*/ 0 | ||
593 | ); | ||
592 | } | 594 | } |
593 | 595 | ||
594 | static void send_packet(struct dhcp_packet *dhcp_pkt, int force_broadcast) | 596 | static void send_packet(struct dhcp_packet *dhcp_pkt, int force_broadcast) |
@@ -946,7 +948,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) | |||
946 | if (bytes < 0) { | 948 | if (bytes < 0) { |
947 | /* bytes can also be -2 ("bad packet data") */ | 949 | /* bytes can also be -2 ("bad packet data") */ |
948 | if (bytes == -1 && errno != EINTR) { | 950 | if (bytes == -1 && errno != EINTR) { |
949 | log1("read error: %s, reopening socket", strerror(errno)); | 951 | log1("read error: "STRERROR_FMT", reopening socket" STRERROR_ERRNO); |
950 | close(server_socket); | 952 | close(server_socket); |
951 | server_socket = -1; | 953 | server_socket = -1; |
952 | } | 954 | } |
diff --git a/networking/udhcp/dhcprelay.c b/networking/udhcp/dhcprelay.c index ea84c0dd7..4d5644093 100644 --- a/networking/udhcp/dhcprelay.c +++ b/networking/udhcp/dhcprelay.c | |||
@@ -1,5 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* Port to Busybox Copyright (C) 2006 Jesse Dutton <jessedutton@gmail.com> | 2 | /* |
3 | * Port to Busybox Copyright (C) 2006 Jesse Dutton <jessedutton@gmail.com> | ||
3 | * | 4 | * |
4 | * Licensed under GPLv2, see file LICENSE in this source tree. | 5 | * Licensed under GPLv2, see file LICENSE in this source tree. |
5 | * | 6 | * |
diff --git a/networking/udhcp/domain_codec.c b/networking/udhcp/domain_codec.c index 5a923cc2c..b7a3a5353 100644 --- a/networking/udhcp/domain_codec.c +++ b/networking/udhcp/domain_codec.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | 2 | /* | |
3 | /* RFC1035 domain compression routines (C) 2007 Gabriel Somlo <somlo at cmu.edu> | 3 | * RFC1035 domain compression routines (C) 2007 Gabriel Somlo <somlo at cmu.edu> |
4 | * | 4 | * |
5 | * Loosely based on the isc-dhcpd implementation by dhankins@isc.org | 5 | * Loosely based on the isc-dhcpd implementation by dhankins@isc.org |
6 | * | 6 | * |
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c index 9e1b46d2f..fc2bb5416 100644 --- a/networking/udhcp/packet.c +++ b/networking/udhcp/packet.c | |||
@@ -41,7 +41,7 @@ void FAST_FUNC udhcp_dump_packet(struct dhcp_packet *packet) | |||
41 | return; | 41 | return; |
42 | 42 | ||
43 | bb_error_msg( | 43 | bb_error_msg( |
44 | //"op %x" | 44 | //" op %x" |
45 | //" htype %x" | 45 | //" htype %x" |
46 | " hlen %x" | 46 | " hlen %x" |
47 | //" hops %x" | 47 | //" hops %x" |
@@ -52,7 +52,6 @@ void FAST_FUNC udhcp_dump_packet(struct dhcp_packet *packet) | |||
52 | " yiaddr %x" | 52 | " yiaddr %x" |
53 | " siaddr %x" | 53 | " siaddr %x" |
54 | " giaddr %x" | 54 | " giaddr %x" |
55 | //" chaddr %s" | ||
56 | //" sname %s" | 55 | //" sname %s" |
57 | //" file %s" | 56 | //" file %s" |
58 | //" cookie %x" | 57 | //" cookie %x" |
@@ -68,14 +67,13 @@ void FAST_FUNC udhcp_dump_packet(struct dhcp_packet *packet) | |||
68 | , packet->yiaddr | 67 | , packet->yiaddr |
69 | , packet->siaddr_nip | 68 | , packet->siaddr_nip |
70 | , packet->gateway_nip | 69 | , packet->gateway_nip |
71 | //, packet->chaddr[16] | ||
72 | //, packet->sname[64] | 70 | //, packet->sname[64] |
73 | //, packet->file[128] | 71 | //, packet->file[128] |
74 | //, packet->cookie | 72 | //, packet->cookie |
75 | //, packet->options[] | 73 | //, packet->options[] |
76 | ); | 74 | ); |
77 | *bin2hex(buf, (void *) packet->chaddr, sizeof(packet->chaddr)) = '\0'; | 75 | *bin2hex(buf, (void *) packet->chaddr, sizeof(packet->chaddr)) = '\0'; |
78 | bb_error_msg("chaddr %s", buf); | 76 | bb_error_msg(" chaddr %s", buf); |
79 | } | 77 | } |
80 | #endif | 78 | #endif |
81 | 79 | ||
@@ -129,6 +127,8 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt, | |||
129 | dest_sll.sll_family = AF_PACKET; | 127 | dest_sll.sll_family = AF_PACKET; |
130 | dest_sll.sll_protocol = htons(ETH_P_IP); | 128 | dest_sll.sll_protocol = htons(ETH_P_IP); |
131 | dest_sll.sll_ifindex = ifindex; | 129 | dest_sll.sll_ifindex = ifindex; |
130 | /*dest_sll.sll_hatype = ARPHRD_???;*/ | ||
131 | /*dest_sll.sll_pkttype = PACKET_???;*/ | ||
132 | dest_sll.sll_halen = 6; | 132 | dest_sll.sll_halen = 6; |
133 | memcpy(dest_sll.sll_addr, dest_arp, 6); | 133 | memcpy(dest_sll.sll_addr, dest_arp, 6); |
134 | 134 | ||
@@ -189,7 +189,8 @@ int FAST_FUNC udhcp_send_raw_packet(struct dhcp_packet *dhcp_pkt, | |||
189 | /* Let the kernel do all the work for packet generation */ | 189 | /* Let the kernel do all the work for packet generation */ |
190 | int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt, | 190 | int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt, |
191 | uint32_t source_nip, int source_port, | 191 | uint32_t source_nip, int source_port, |
192 | uint32_t dest_nip, int dest_port) | 192 | uint32_t dest_nip, int dest_port, |
193 | int send_flags) | ||
193 | { | 194 | { |
194 | struct sockaddr_in sa; | 195 | struct sockaddr_in sa; |
195 | unsigned padding; | 196 | unsigned padding; |
@@ -226,8 +227,8 @@ int FAST_FUNC udhcp_send_kernel_packet(struct dhcp_packet *dhcp_pkt, | |||
226 | padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(dhcp_pkt->options); | 227 | padding = DHCP_OPTIONS_BUFSIZE - 1 - udhcp_end_option(dhcp_pkt->options); |
227 | if (padding > DHCP_SIZE - 300) | 228 | if (padding > DHCP_SIZE - 300) |
228 | padding = DHCP_SIZE - 300; | 229 | padding = DHCP_SIZE - 300; |
229 | result = safe_write(fd, dhcp_pkt, DHCP_SIZE - padding); | 230 | result = send(fd, dhcp_pkt, DHCP_SIZE - padding, send_flags); |
230 | msg = "write"; | 231 | msg = "send"; |
231 | ret_close: | 232 | ret_close: |
232 | close(fd); | 233 | close(fd); |
233 | if (result < 0) { | 234 | if (result < 0) { |
diff --git a/networking/zcip.c b/networking/zcip.c index 55440285f..94e49adcb 100644 --- a/networking/zcip.c +++ b/networking/zcip.c | |||
@@ -8,7 +8,6 @@ | |||
8 | * | 8 | * |
9 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 9 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
10 | */ | 10 | */ |
11 | |||
12 | /* | 11 | /* |
13 | * ZCIP just manages the 169.254.*.* addresses. That network is not | 12 | * ZCIP just manages the 169.254.*.* addresses. That network is not |
14 | * routed at the IP level, though various proxies or bridges can | 13 | * routed at the IP level, though various proxies or bridges can |