diff options
author | Ron Yorston <rmy@pobox.com> | 2017-01-08 08:56:43 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2017-01-08 08:56:43 +0000 |
commit | 3ef86d069577b8a44ebe3aa890c6e97ea31d0d56 (patch) | |
tree | 064587c9b2080dba963bf8d93861b8019cb306ed /networking | |
parent | c66975af0b5335b9cdd156206767756237bd814b (diff) | |
parent | 86584e134eec1a81298149f8c04c77727f6dccb9 (diff) | |
download | busybox-w32-3ef86d069577b8a44ebe3aa890c6e97ea31d0d56.tar.gz busybox-w32-3ef86d069577b8a44ebe3aa890c6e97ea31d0d56.tar.bz2 busybox-w32-3ef86d069577b8a44ebe3aa890c6e97ea31d0d56.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'networking')
-rw-r--r-- | networking/ntpd.c | 73 | ||||
-rw-r--r-- | networking/udhcp/Config.src | 54 | ||||
-rw-r--r-- | networking/udhcp/d6_dhcpc.c | 2 |
3 files changed, 62 insertions, 67 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c index b7fa5dce9..bfd5705fc 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c | |||
@@ -155,6 +155,7 @@ | |||
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 | 159 | ||
159 | /* Step threshold (sec). std ntpd uses 0.128. | 160 | /* Step threshold (sec). std ntpd uses 0.128. |
160 | */ | 161 | */ |
@@ -790,28 +791,20 @@ reset_peer_stats(peer_t *p, double offset) | |||
790 | VERB6 bb_error_msg("%s->lastpkt_recv_time=%f", p->p_dotted, p->lastpkt_recv_time); | 791 | VERB6 bb_error_msg("%s->lastpkt_recv_time=%f", p->p_dotted, p->lastpkt_recv_time); |
791 | } | 792 | } |
792 | 793 | ||
793 | static void | 794 | static len_and_sockaddr* |
794 | resolve_peer_hostname(peer_t *p, int loop_on_fail) | 795 | resolve_peer_hostname(peer_t *p) |
795 | { | 796 | { |
796 | len_and_sockaddr *lsa; | 797 | len_and_sockaddr *lsa = host2sockaddr(p->p_hostname, 123); |
797 | 798 | if (lsa) { | |
798 | again: | 799 | free(p->p_lsa); |
799 | lsa = host2sockaddr(p->p_hostname, 123); | 800 | free(p->p_dotted); |
800 | if (!lsa) { | 801 | p->p_lsa = lsa; |
801 | /* error message already emitted by host2sockaddr() */ | 802 | p->p_dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa); |
802 | if (!loop_on_fail) | 803 | } else { |
803 | return; | 804 | /* error message is emitted by host2sockaddr() */ |
804 | //FIXME: do this to avoid infinite looping on typo in a hostname? | 805 | set_next(p, HOSTNAME_INTERVAL); |
805 | //well... in which case, what is a good value for loop_on_fail? | ||
806 | //if (--loop_on_fail == 0) | ||
807 | // xfunc_die(); | ||
808 | sleep(5); | ||
809 | goto again; | ||
810 | } | 806 | } |
811 | free(p->p_lsa); | 807 | return lsa; |
812 | free(p->p_dotted); | ||
813 | p->p_lsa = lsa; | ||
814 | p->p_dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa); | ||
815 | } | 808 | } |
816 | 809 | ||
817 | static void | 810 | static void |
@@ -822,28 +815,28 @@ add_peers(const char *s) | |||
822 | 815 | ||
823 | p = xzalloc(sizeof(*p) + strlen(s)); | 816 | p = xzalloc(sizeof(*p) + strlen(s)); |
824 | strcpy(p->p_hostname, s); | 817 | strcpy(p->p_hostname, s); |
825 | resolve_peer_hostname(p, /*loop_on_fail=*/ 1); | 818 | p->p_fd = -1; |
819 | p->p_xmt_msg.m_status = MODE_CLIENT | (NTP_VERSION << 3); | ||
820 | p->next_action_time = G.cur_time; /* = set_next(p, 0); */ | ||
821 | reset_peer_stats(p, STEP_THRESHOLD); | ||
826 | 822 | ||
827 | /* Names like N.<country2chars>.pool.ntp.org are randomly resolved | 823 | /* Names like N.<country2chars>.pool.ntp.org are randomly resolved |
828 | * to a pool of machines. Sometimes different N's resolve to the same IP. | 824 | * to a pool of machines. Sometimes different N's resolve to the same IP. |
829 | * It is not useful to have two peers with same IP. We skip duplicates. | 825 | * It is not useful to have two peers with same IP. We skip duplicates. |
830 | */ | 826 | */ |
831 | for (item = G.ntp_peers; item != NULL; item = item->link) { | 827 | if (resolve_peer_hostname(p)) { |
832 | peer_t *pp = (peer_t *) item->data; | 828 | for (item = G.ntp_peers; item != NULL; item = item->link) { |
833 | if (strcmp(p->p_dotted, pp->p_dotted) == 0) { | 829 | peer_t *pp = (peer_t *) item->data; |
834 | bb_error_msg("duplicate peer %s (%s)", s, p->p_dotted); | 830 | if (pp->p_dotted && strcmp(p->p_dotted, pp->p_dotted) == 0) { |
835 | free(p->p_lsa); | 831 | bb_error_msg("duplicate peer %s (%s)", s, p->p_dotted); |
836 | free(p->p_dotted); | 832 | free(p->p_lsa); |
837 | free(p); | 833 | free(p->p_dotted); |
838 | return; | 834 | free(p); |
835 | return; | ||
836 | } | ||
839 | } | 837 | } |
840 | } | 838 | } |
841 | 839 | ||
842 | p->p_fd = -1; | ||
843 | p->p_xmt_msg.m_status = MODE_CLIENT | (NTP_VERSION << 3); | ||
844 | p->next_action_time = G.cur_time; /* = set_next(p, 0); */ | ||
845 | reset_peer_stats(p, STEP_THRESHOLD); | ||
846 | |||
847 | llist_add_to(&G.ntp_peers, p); | 840 | llist_add_to(&G.ntp_peers, p); |
848 | G.peer_cnt++; | 841 | G.peer_cnt++; |
849 | } | 842 | } |
@@ -871,6 +864,11 @@ do_sendto(int fd, | |||
871 | static void | 864 | static void |
872 | send_query_to_peer(peer_t *p) | 865 | send_query_to_peer(peer_t *p) |
873 | { | 866 | { |
867 | if (!p->p_lsa) { | ||
868 | if (!resolve_peer_hostname(p)) | ||
869 | return; | ||
870 | } | ||
871 | |||
874 | /* Why do we need to bind()? | 872 | /* Why do we need to bind()? |
875 | * See what happens when we don't bind: | 873 | * See what happens when we don't bind: |
876 | * | 874 | * |
@@ -2238,7 +2236,7 @@ static NOINLINE void ntp_init(char **argv) | |||
2238 | IF_FEATURE_NTPD_SERVER("I:") /* compat */ | 2236 | IF_FEATURE_NTPD_SERVER("I:") /* compat */ |
2239 | "d" /* compat */ | 2237 | "d" /* compat */ |
2240 | "46aAbgL", /* compat, ignored */ | 2238 | "46aAbgL", /* compat, ignored */ |
2241 | &peers,&G.script_name, | 2239 | &peers, &G.script_name, |
2242 | #if ENABLE_FEATURE_NTPD_SERVER | 2240 | #if ENABLE_FEATURE_NTPD_SERVER |
2243 | &G.if_name, | 2241 | &G.if_name, |
2244 | #endif | 2242 | #endif |
@@ -2263,9 +2261,6 @@ static NOINLINE void ntp_init(char **argv) | |||
2263 | if (opts & OPT_N) | 2261 | if (opts & OPT_N) |
2264 | setpriority(PRIO_PROCESS, 0, -15); | 2262 | setpriority(PRIO_PROCESS, 0, -15); |
2265 | 2263 | ||
2266 | /* add_peers() calls can retry DNS resolution (possibly forever). | ||
2267 | * Daemonize before them, or else boot can stall forever. | ||
2268 | */ | ||
2269 | if (!(opts & OPT_n)) { | 2264 | if (!(opts & OPT_n)) { |
2270 | bb_daemonize_or_rexec(DAEMON_DEVNULL_STDIO, argv); | 2265 | bb_daemonize_or_rexec(DAEMON_DEVNULL_STDIO, argv); |
2271 | logmode = LOGMODE_NONE; | 2266 | logmode = LOGMODE_NONE; |
@@ -2400,7 +2395,7 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv) | |||
2400 | 2395 | ||
2401 | /* What if don't see it because it changed its IP? */ | 2396 | /* What if don't see it because it changed its IP? */ |
2402 | if (p->reachable_bits == 0) | 2397 | if (p->reachable_bits == 0) |
2403 | resolve_peer_hostname(p, /*loop_on_fail=*/ 0); | 2398 | resolve_peer_hostname(p); |
2404 | 2399 | ||
2405 | set_next(p, timeout); | 2400 | set_next(p, timeout); |
2406 | } | 2401 | } |
diff --git a/networking/udhcp/Config.src b/networking/udhcp/Config.src index 90fb313b5..7bc13a719 100644 --- a/networking/udhcp/Config.src +++ b/networking/udhcp/Config.src | |||
@@ -6,29 +6,13 @@ | |||
6 | INSERT | 6 | INSERT |
7 | 7 | ||
8 | config UDHCPD | 8 | config UDHCPD |
9 | bool "udhcp server (udhcpd)" | 9 | bool "udhcpd (DHCP server)" |
10 | default y | 10 | default y |
11 | select PLATFORM_LINUX | 11 | select PLATFORM_LINUX |
12 | help | 12 | help |
13 | udhcpd is a DHCP server geared primarily toward embedded systems, | 13 | udhcpd is a DHCP server geared primarily toward embedded systems, |
14 | while striving to be fully functional and RFC compliant. | 14 | while striving to be fully functional and RFC compliant. |
15 | 15 | ||
16 | config DHCPRELAY | ||
17 | bool "dhcprelay" | ||
18 | default y | ||
19 | help | ||
20 | dhcprelay listens for dhcp requests on one or more interfaces | ||
21 | and forwards these requests to a different interface or dhcp | ||
22 | server. | ||
23 | |||
24 | config DUMPLEASES | ||
25 | bool "Lease display utility (dumpleases)" | ||
26 | default y | ||
27 | help | ||
28 | dumpleases displays the leases written out by the udhcpd server. | ||
29 | Lease times are stored in the file by time remaining in lease, or | ||
30 | by the absolute time that it expires in seconds from epoch. | ||
31 | |||
32 | config FEATURE_UDHCPD_WRITE_LEASES_EARLY | 16 | config FEATURE_UDHCPD_WRITE_LEASES_EARLY |
33 | bool "Rewrite the lease file at every new acknowledge" | 17 | bool "Rewrite the lease file at every new acknowledge" |
34 | default y | 18 | default y |
@@ -61,8 +45,24 @@ config DHCPD_LEASES_FILE | |||
61 | udhcpd stores addresses in a lease file. This is the absolute path | 45 | udhcpd stores addresses in a lease file. This is the absolute path |
62 | of the file. Normally it is safe to leave it untouched. | 46 | of the file. Normally it is safe to leave it untouched. |
63 | 47 | ||
48 | config DUMPLEASES | ||
49 | bool "dumpleases" | ||
50 | default y | ||
51 | help | ||
52 | dumpleases displays the leases written out by the udhcpd. | ||
53 | Lease times are stored in the file by time remaining in lease, or | ||
54 | by the absolute time that it expires in seconds from epoch. | ||
55 | |||
56 | config DHCPRELAY | ||
57 | bool "dhcprelay" | ||
58 | default y | ||
59 | help | ||
60 | dhcprelay listens for dhcp requests on one or more interfaces | ||
61 | and forwards these requests to a different interface or dhcp | ||
62 | server. | ||
63 | |||
64 | config UDHCPC | 64 | config UDHCPC |
65 | bool "udhcp client (udhcpc)" | 65 | bool "udhcpc (DHCP client)" |
66 | default y | 66 | default y |
67 | select PLATFORM_LINUX | 67 | select PLATFORM_LINUX |
68 | help | 68 | help |
@@ -93,6 +93,15 @@ config FEATURE_UDHCPC_SANITIZEOPT | |||
93 | they will be replaced with string "bad" when exporting | 93 | they will be replaced with string "bad" when exporting |
94 | to the environment. | 94 | to the environment. |
95 | 95 | ||
96 | config UDHCPC_DEFAULT_SCRIPT | ||
97 | string "Absolute path to config script" | ||
98 | default "/usr/share/udhcpc/default.script" | ||
99 | depends on UDHCPC | ||
100 | help | ||
101 | This script is called after udhcpc receives an answer. See | ||
102 | examples/udhcp for a working example. Normally it is safe | ||
103 | to leave this untouched. | ||
104 | |||
96 | config FEATURE_UDHCP_PORT | 105 | config FEATURE_UDHCP_PORT |
97 | bool "Enable '-P port' option for udhcpd and udhcpc" | 106 | bool "Enable '-P port' option for udhcpd and udhcpc" |
98 | default n | 107 | default n |
@@ -130,15 +139,6 @@ config FEATURE_UDHCP_8021Q | |||
130 | If selected, both client and server will support passing of VLAN | 139 | If selected, both client and server will support passing of VLAN |
131 | ID and priority via options 132 and 133 as per 802.1Q. | 140 | ID and priority via options 132 and 133 as per 802.1Q. |
132 | 141 | ||
133 | config UDHCPC_DEFAULT_SCRIPT | ||
134 | string "Absolute path to config script" | ||
135 | default "/usr/share/udhcpc/default.script" | ||
136 | depends on UDHCPC | ||
137 | help | ||
138 | This script is called after udhcpc receives an answer. See | ||
139 | examples/udhcp for a working example. Normally it is safe | ||
140 | to leave this untouched. | ||
141 | |||
142 | config UDHCPC_SLACK_FOR_BUGGY_SERVERS | 142 | config UDHCPC_SLACK_FOR_BUGGY_SERVERS |
143 | int "DHCP options slack buffer size" | 143 | int "DHCP options slack buffer size" |
144 | default 80 | 144 | default 80 |
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index ddf3412a0..64339c9b5 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c | |||
@@ -12,7 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | //config:config UDHCPC6 | 14 | //config:config UDHCPC6 |
15 | //config: bool "udhcp client for DHCPv6 (udhcpc6)" | 15 | //config: bool "udhcpc6 (DHCPv6 client, NOT READY)" |
16 | //config: default n # not yet ready | 16 | //config: default n # not yet ready |
17 | //config: depends on FEATURE_IPV6 | 17 | //config: depends on FEATURE_IPV6 |
18 | //config: help | 18 | //config: help |