Hello, On Wed, Feb 17, 2021 at 07:40:45PM +0100, [email protected] wrote: > Am 16.02.2021 um 15:55 schrieb matt swindell: > > Hello, > > > > > > > > I am new to LWIP currently I am using LWIP 2.1.2 with no OS (NO_SYS = 1) > > in lwipopts.h. > > > > > > > > My question is about the connection/disconnection from the DHCP server. > > Using Wireshark I am able to see the initial DHCP request and properly > > receive an IP address, followed by ARP announcements. The device seems > > to survive an initial disconnect, sending a Request to validate it’s IP > > and an ACK from the DHCP server once reconnected. However, further > > disconnects and reconnections appear to confuse the device. > > > > > > > > I have a PHY interrupt callback which calls netif_set_link_down() and > > netif_set_link_up() when the PHY link status changes. Since the dhcp > > state was bound dhcp_reboot() is called from dhcp_network_changed(). > > This all seems to work fine until we hit the dhcp_timeout() and my dhcp > > tries are greater than or equal to REBOOT_TRIES, at which point it calls > > dhcp_discover() and I get stuck in a loop where the device sends a > > discovery message and is offered an IP address back but it gets ignored. > > > > > > > > By increasing REBOOT_TRIES I am able to get a few more reconnections > > without problem, but at some point it always seems to get stuck in that > > dhcp discovery loop. > > > > > > > > I am unsure if I have done something incorrectly or if I am confusing > > the DHCP state machine, but from everything I have read with regards to > > LWIP > 2.x.x > > > > calling netif_set_link_up/down() should be sufficient for maintaining > > DHCP once dhcp_start() has been called. > > > > > > > > Any help would be greatly appreciated. > > I'm not aware of a bug here, but I'm not sure. It would probably be best > if you could reproduce this with a unit test?
I am not sure it is the problem but at least from the description it looks like netif_set_link_down() and netif_set_link_up() are being called in interrupt context, which is probably wrong unless the lwIP main loop is guarded by a huge and ugly critical section. Sylvain
signature.asc
Description: Digital signature
_______________________________________________ lwip-users mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/lwip-users
