STM32F407 LWIP : IP stack stop working during TCP port scanning from vulnerabilities test tool
Hello,
We have implemented LWIP with FreeRTOS on a STM32F407VE with a LAN8720A PHY.
Everything worked fine until our client submit our card to a IP vulnerabilities tester : during the test the card stop responding to ping.
The test consists to try a connection on random TCP ports, about hundreds time each seconds... Please see below wireshark screen shot.

By looking deeply in the source code, it appears that ETH_IRQHandler() is no longer generated in that case. So ethernetif.c/ethernetif_input() stay blocked on osSemaphoreWait() call indefintly.
All code was generated with STM32cubeMX (5.3)/Atollic TRuestudio with RTOS 10.0.1 and LwIP 2.0.3.
I have found a workaroud by adding a timeout in osSemaphoreWait() of ethernetif_input() loop. When timeout occurs low_level_reinit() is called and everything run well.
void ethernetif_input( void const * argument )
{
struct pbuf *p;
struct netif *netif = (struct netif *) argument;
for( ;; )
{
if (osSemaphoreWait( s_xSemaphore, 5000/*TIME_WAITING_FOR_INPUT*/)==osOK)
{
do
{
p = low_level_input( netif );
if (p != NULL)
{
if (netif->input( p, netif) != ERR_OK )
{
pbuf_free(p);
}
}
} while(p!=NULL);
}
else
{
if (netif_is_link_up(netif) == 1)
{
low_level_init(netif);
}
}
}
}I also modified low_level_init() to avoid multiple creation of semaphore and thread:
static void low_level_init(struct netif *netif)
{
......
if (s_xSemaphore == NULL)
{
osSemaphoreDef(SEM);
s_xSemaphore = osSemaphoreCreate(osSemaphore(SEM) , 1 );
/* create the task that handles the ETH_MAC */
osThreadDef(EthIf, ethernetif_input, osPriorityRealtime, 0, INTERFACE_THREAD_STACK_SIZE);
osThreadCreate (osThread(EthIf), netif);
}
....
}I wonder if there is a better way to do or if I have done a mistake elsewhere ?
I thank you for your help,
Fabien.