pkg/lwip: Start DHCP early for all Ethernet netifs

Netifs without link status support will keep sending discover
messages with increasing time between.

Netifs that support link status will wait for the link to be up,
and then start sending.

Netifs that support link status but send no link status events
will continue to not work (unless link status is up from the
first check when setting it up).
This commit is contained in:
Erik Ekman 2021-03-24 22:59:26 +01:00
parent 9cad382dc8
commit 6b89f4f34b
2 changed files with 13 additions and 15 deletions

View File

@ -15,12 +15,10 @@
#include "kernel_defines.h" #include "kernel_defines.h"
#if IS_USED(MODULE_LWIP_DHCP_AUTO)
#include "lwip/dhcp.h"
#endif
#include "lwip/tcpip.h" #include "lwip/tcpip.h"
#include "lwip/netif/netdev.h" #include "lwip/netif/netdev.h"
#include "lwip/netif.h" #include "lwip/netif.h"
#include "lwip/netifapi.h"
#include "netif/lowpan6.h" #include "netif/lowpan6.h"
#ifdef MODULE_NETDEV_TAP #ifdef MODULE_NETDEV_TAP
@ -279,12 +277,17 @@ void lwip_bootstrap(void)
#endif #endif
/* also allow for external interface definition */ /* also allow for external interface definition */
tcpip_init(NULL, NULL); tcpip_init(NULL, NULL);
#if IS_USED(MODULE_LWIP_DHCP_AUTO) && IS_USED(MODULE_NETDEV_TAP) #if IS_USED(MODULE_LWIP_DHCP_AUTO)
/* XXX: Hack to get DHCP with IPv4 with `netdev_tap`, as it does {
* not emit a `NETDEV_EVENT_LINK_UP` event. Remove, once it does /* Start DHCP on all supported netifs. Interfaces that support
* at an appropriate point. * link status events will reset DHCP retries when link comes up. */
* (see https://github.com/RIOT-OS/RIOT/pull/14150) */ struct netif *n = NULL;
dhcp_start(netif); NETIF_FOREACH(n) {
if (netif_is_flag_set(n, NETIF_FLAG_ETHERNET)) {
netifapi_dhcp_start(netif);
}
}
}
#endif #endif
} }

View File

@ -17,9 +17,6 @@
#include <sys/uio.h> #include <sys/uio.h>
#include <inttypes.h> #include <inttypes.h>
#if MODULE_LWIP_DHCP_AUTO
#include "lwip/dhcp.h"
#endif
#include "lwip/err.h" #include "lwip/err.h"
#include "lwip/ethip6.h" #include "lwip/ethip6.h"
#include "lwip/netif.h" #include "lwip/netif.h"
@ -297,10 +294,8 @@ static void _event_cb(netdev_t *dev, netdev_event_t event)
break; break;
} }
case NETDEV_EVENT_LINK_UP: { case NETDEV_EVENT_LINK_UP: {
/* Will wake up DHCP state machine */
netifapi_netif_set_link_up(netif); netifapi_netif_set_link_up(netif);
#ifdef MODULE_LWIP_DHCP_AUTO
netifapi_dhcp_start(netif);
#endif
break; break;
} }
case NETDEV_EVENT_LINK_DOWN: { case NETDEV_EVENT_LINK_DOWN: {