lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Handle a broadcast storm


From: address@hidden
Subject: Re: [lwip-users] Handle a broadcast storm
Date: Mon, 25 Mar 2019 08:53:32 -0700 (MST)

dear all,
thanks a lot for your support. Reading the answers and the different
suggestions, considering STM32 can only disable/enable broadcast messages I
decided to:
1 -  limit the number of frame processed in Irq: as I wrote, in my setup I
have 3 rx buffer defined but I was able cycle many times in the ethernet Irq
because in the meantime I read an Rx buffer it was filled again. With the
protection I added I can limit that amount
2 - based on Patrick and Simon suggestions I modified ethernetif_input and
low_level_input to return the first frame byte in order to use it to
understand the type of frame received
3 - If I'm filled by broadcast frames I disable broadcast reception and I
re-enable it after (in the link status task I have)
This solution is currently running: I verified broadcast disable and I
verified sometimes my protection is triggered.
Thanks again
Michele



#define LWIP_MAX_IRQ_RX_FRAME    10u

static void LwIP_SendSem( void )
{
   U32 zFrameCounter = NULL_U32;
   U8 zFrameType;
   U32 zFrameTypeCounter[eMaxFrameType] = {0u,0u,0u};

   while ( HalEth_IsRxPktValid() && (zFrameCounter < LWIP_MAX_IRQ_RX_FRAME))
   {
      zFrameType = ethernetif_input( &gNetIf[0] );
      zFrameCounter++;
      if (zFrameType == (U8)0xFF)
      {
         zFrameTypeCounter[eBroadcast]++;
      }
      else if (zFrameType == (U8)0x01)
      {
         zFrameTypeCounter[eMulticast]++;
      }
      else
      {
         zFrameTypeCounter[eUnicast]++;
      }
   }

   if (zFrameTypeCounter[eBroadcast] == LWIP_MAX_IRQ_RX_FRAME )
   {
      EnableBroadcastRx(FALSE);
   }
}

void EnableBroadcastRx(BOOL zEnable)
{
   if (zEnable == TRUE)
   {
      ETH->MACFFR &= ~ETH_MACFFR_BFD;
   }
   else
   {
      ETH->MACFFR |= ETH_MACFFR_BFD;
   }
}




--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]