lwipthread stops MAC input processing when PBUF allocation fails Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
iggarpe
Posts: 129
Joined: Sun Sep 30, 2012 8:32 pm

lwipthread stops MAC input processing when PBUF allocation fails  Topic is solved

Postby iggarpe » Sun Feb 19, 2017 6:36 pm

I've found this bug in lwipthread.c when working with other drivers and I'm pretty sure it's present too in ChibiOS examples that use MAC.

The problem is as follows: lwipthread listens on the receive events broadcasted by the MAC driver. When a receive event is detected lwipthread proceeds to read packets from the MAC input queue until it's empty. The latter is very important because if, for example, three packets were received and the receive event broadcasted three times before lwipthread was woken up, processing only one packet would leave two in the MAC input queue unprocessed.

The problem is that the packet processing loop will stop as soon as low_level_input() returns NULL, which happens if:

1- The MAC input queue is empty [CORRECT]
2- A PBUF could not be allocated [WRONG]

Thus if a PBUF could not be allocated the packet processing loop stops leaving packets in the MAC input queue. Best case the input queue is not full and the next packet reception will process also those packets, worst case the input queue is full and no more reception events are signaled. MAC reception stops forever.

The attached patch modifies low_level_input() to return a boolean representing whether the MAC input queue is empty, and that is the only condition used in the thread to stop processing input packets. In addition, a pbuf is returned that MAY BE NULL if pbuf allocation failed, and the packet processing loop just skips that packet, but keeps processing packets until the input queue is empty.
Attachments
pbuf_alloc_error_stops_mac_input_processing.zip
(1.41 KiB) Downloaded 188 times

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: lwipthread stops MAC input processing when PBUF allocation fails

Postby Giovanni » Fri Jul 27, 2018 2:52 pm

bump

steved
Posts: 825
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Re: lwipthread stops MAC input processing when PBUF allocation fails

Postby steved » Fri Jul 27, 2018 5:05 pm

Pretty confident this was incorporated along with the other updates a while back

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: lwipthread stops MAC input processing when PBUF allocation fails

Postby Giovanni » Fri Jul 27, 2018 9:10 pm

Thanks, closing then.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 7 guests