Skip to content

Commit 9c98f3f

Browse files
committed
lwip: Increased DHCP timeout to 60 seconds
This matches the timeout used in linux: https://linux.die.net/man/5/dhclient.conf This resolves several issues noticed during testing when we have a very large number of devices that try to get an IP address around the same time.
1 parent d55b3cf commit 9c98f3f

File tree

14 files changed

+16
-16
lines changed

14 files changed

+16
-16
lines changed

features/FEATURE_LWIP/TESTS/mbedmicro-net/connectivity/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void test_bring_up_down() {
5252
// Test setup
5353
utest::v1::status_t test_setup(const size_t number_of_cases) {
5454
char uuid[48] = {0};
55-
GREENTEA_SETUP_UUID(60, "default_auto", uuid, 48);
55+
GREENTEA_SETUP_UUID(120, "default_auto", uuid, 48);
5656
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
5757
return verbose_test_setup_handler(number_of_cases);
5858
}

features/FEATURE_LWIP/TESTS/mbedmicro-net/gethostbyname/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void test_dns_literal_pref() {
9292
// Test setup
9393
utest::v1::status_t test_setup(const size_t number_of_cases) {
9494
char uuid[48] = {0};
95-
GREENTEA_SETUP_UUID(60, "default_auto", uuid, 48);
95+
GREENTEA_SETUP_UUID(120, "default_auto", uuid, 48);
9696
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
9797
net_bringup();
9898
return verbose_test_setup_handler(number_of_cases);

features/FEATURE_LWIP/TESTS/mbedmicro-net/tcp_echo/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void prep_buffer(char *tx_buffer, size_t tx_size) {
3030

3131
int main() {
3232
char uuid[48] = {0};
33-
GREENTEA_SETUP_UUID(60, "tcp_echo", uuid, 48);
33+
GREENTEA_SETUP_UUID(120, "tcp_echo", uuid, 48);
3434
mbed_set_mac_address(uuid, /*coerce control bits TRUE */ 1);
3535
EthernetInterface eth;
3636
int err = eth.connect();

features/FEATURE_LWIP/TESTS/mbedmicro-net/tcp_echo_parallel/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Echo echoers[MBED_CFG_TCP_CLIENT_ECHO_THREADS];
8989

9090
int main() {
9191
char uuid[48] = {0};
92-
GREENTEA_SETUP_UUID(60, "tcp_echo", uuid, 48);
92+
GREENTEA_SETUP_UUID(120, "tcp_echo", uuid, 48);
9393
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
9494

9595
int err = net.connect();

features/FEATURE_LWIP/TESTS/mbedmicro-net/tcp_hello_world/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ bool find_substring(const char *first, const char *last, const char *s_first, co
3737

3838
int main() {
3939
char uuid[48] = {0};
40-
GREENTEA_SETUP_UUID(60, "default_auto", uuid, 48);
40+
GREENTEA_SETUP_UUID(120, "default_auto", uuid, 48);
4141
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
4242

4343
bool result = false;

features/FEATURE_LWIP/TESTS/mbedmicro-net/tcp_packet_pressure/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void generate_buffer(uint8_t **buffer, size_t *size, size_t min, size_t max) {
109109

110110
int main() {
111111
char uuid[48] = {0};
112-
GREENTEA_SETUP_UUID(60, "tcp_echo", uuid, 48);
112+
GREENTEA_SETUP_UUID(120, "tcp_echo", uuid, 48);
113113
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
114114

115115
generate_buffer(&buffer, &buffer_size,

features/FEATURE_LWIP/TESTS/mbedmicro-net/tcp_packet_pressure_parallel/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ PressureTest *pressure_tests[MBED_CFG_TCP_CLIENT_PACKET_PRESSURE_THREADS];
226226

227227
int main() {
228228
char uuid[48] = {0};
229-
GREENTEA_SETUP_UUID(60, "tcp_echo", uuid, 48);
229+
GREENTEA_SETUP_UUID(120, "tcp_echo", uuid, 48);
230230
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
231231

232232
uint8_t *buffer;

features/FEATURE_LWIP/TESTS/mbedmicro-net/udp_dtls_handshake/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const int udp_dtls_handshake_count = sizeof(udp_dtls_handshake_pattern) / sizeof
2929

3030
int main() {
3131
char uuid[48] = {0};
32-
GREENTEA_SETUP_UUID(60, "udp_shotgun", uuid, 48);
32+
GREENTEA_SETUP_UUID(120, "udp_shotgun", uuid, 48);
3333
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
3434

3535
EthernetInterface eth;

features/FEATURE_LWIP/TESTS/mbedmicro-net/udp_echo/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void prep_buffer(char *uuid_buffer, size_t uuid_len, char *tx_buffer, size_t tx_
4343

4444
int main() {
4545
char uuid[48] = {0};
46-
GREENTEA_SETUP_UUID(60, "udp_echo", uuid, 48);
46+
GREENTEA_SETUP_UUID(120, "udp_echo", uuid, 48);
4747
printf("Got a uuid of %s\r\n", uuid);
4848
size_t uuid_len = strlen(uuid);
4949
EthernetInterface eth;

features/FEATURE_LWIP/TESTS/mbedmicro-net/udp_echo_parallel/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Echo echoers[MBED_CFG_UDP_CLIENT_ECHO_THREADS];
147147

148148
int main() {
149149
char uuid[48] = {0};
150-
GREENTEA_SETUP_UUID(60, "udp_echo", uuid, 48);
150+
GREENTEA_SETUP_UUID(120, "udp_echo", uuid, 48);
151151
printf("Got a uuid of %s\r\n", uuid);
152152
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
153153

features/FEATURE_LWIP/TESTS/mbedmicro-net/udp_packet_pressure/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void generate_buffer(uint8_t **buffer, size_t *size, size_t min, size_t max) {
112112

113113
int main() {
114114
char uuid[48] = {0};
115-
GREENTEA_SETUP_UUID(60, "udp_echo", uuid, 48);
115+
GREENTEA_SETUP_UUID(120, "udp_echo", uuid, 48);
116116
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
117117

118118
generate_buffer(&buffer, &buffer_size,

features/FEATURE_LWIP/TESTS/mbedmicro-net/udp_packet_pressure_parallel/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ PressureTest *pressure_tests[MBED_CFG_UDP_CLIENT_PACKET_PRESSURE_THREADS];
251251

252252
int main() {
253253
char uuid[48] = {0};
254-
GREENTEA_SETUP_UUID(2*60, "udp_echo", uuid, 48);
254+
GREENTEA_SETUP_UUID(120, "udp_echo", uuid, 48);
255255
mbed_set_mac_address(uuid, /*coerce control bits*/ 1);
256256

257257
uint8_t *buffer;

features/FEATURE_LWIP/lwip-interface/lwip_stack.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
#define MBED_NETIF_INIT_FN eth_arch_enetif_init
4242
#endif
4343

44-
#define DHCP_TIMEOUT 15000
45-
4644
/* Static arena of sockets */
4745
static struct lwip_socket {
4846
bool in_use;
@@ -463,7 +461,7 @@ nsapi_error_t mbed_lwip_bringup(bool dhcp, const char *ip, const char *netmask,
463461
u32_t ret;
464462

465463
if (!netif_is_link_up(&lwip_netif)) {
466-
ret = sys_arch_sem_wait(&lwip_netif_linked, 15000);
464+
ret = sys_arch_sem_wait(&lwip_netif_linked, DHCP_TIMEOUT * 1000);
467465

468466
if (ret == SYS_ARCH_TIMEOUT) {
469467
return NSAPI_ERROR_NO_CONNECTION;
@@ -502,7 +500,7 @@ nsapi_error_t mbed_lwip_bringup(bool dhcp, const char *ip, const char *netmask,
502500

503501
// If doesn't have address
504502
if (!mbed_lwip_get_ip_addr(true, &lwip_netif)) {
505-
ret = sys_arch_sem_wait(&lwip_netif_has_addr, 15000);
503+
ret = sys_arch_sem_wait(&lwip_netif_has_addr, DHCP_TIMEOUT * 1000);
506504
if (ret == SYS_ARCH_TIMEOUT) {
507505
return NSAPI_ERROR_DHCP_FAILURE;
508506
}

features/FEATURE_LWIP/lwip-interface/lwipopts.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
#define ADDR_TIMEOUT 0
5353
#endif
5454

55+
#define DHCP_TIMEOUT 60
56+
5557
#define PREF_IPV4 1
5658
#define PREF_IPV6 2
5759

0 commit comments

Comments
 (0)