Skip to content

LWIP: make MEMP_NUM_NETBUF and MEMP_NUM_PBUF configurable #11681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

leszekgrzegorek
Copy link

Description

This change makes the MEMP_NUM_NETBUF and MEMP_NUM_PBUF values of lwIP stack configurable to let the applications to operate correctly on higher network loads.

Pull request type

[X] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

@leszekgrzegorek
Copy link
Author

leszekgrzegorek commented Oct 14, 2019

BTW - during testing K64F with higher number of netbufs a few times I encountered the behaviour that even if there were netbufs free (4 of 16 used), netbuf_new() was returning NULL (and UDPSock::sendto() returned NSAPI_ERROR_PARAMETER). It turned out that during runtime memp->next suddenly points to somewhere in lwip_ram_heap() (instead of free netbuf memp list element). Upon choosing such netbuf element to return, its next pointer points to NULL and this way during next netbuf_new() call the NULL is returned.
I wonder if such behaviour of unexpected next pointer change to points somewhere outside of memp netbufs list is correct ? After brief debug session with focus on memp_alloc() and memp_free(), it looks like none of these functions make this value to be set - this value is simply already there as some other code wrote it there. Unfortunately conditional hw watchpoints do not work and sw ones are too slow to spot the culprit in reasonable time. One more idea comes to mind - use MPU and read-only lock/unlock netbufs list in mentioned functions, however I haven't had time to do it yet. If you have any other idea how to spot this issue, please share it with me. Many thanks !

Here is the brief log I collected :

memp_init_pool() for MEMP_NETBUF with 16 netbufs set :

MEMP_NETBUF[0] 0x2001caa0 (next 0x0)
MEMP_NETBUF[1] 0x2001cab0 (next 0x2001caa0)
MEMP_NETBUF[2] 0x2001cac0 (next 0x2001cab0)
MEMP_NETBUF[3] 0x2001cad0 (next 0x2001cac0)
MEMP_NETBUF[4] 0x2001cae0 (next 0x2001cad0)
MEMP_NETBUF[5] 0x2001caf0 (next 0x2001cae0)
MEMP_NETBUF[6] 0x2001cb00 (next 0x2001caf0)
MEMP_NETBUF[7] 0x2001cb10 (next 0x2001cb00)
MEMP_NETBUF[8] 0x2001cb20 (next 0x2001cb10)
MEMP_NETBUF[9] 0x2001cb30 (next 0x2001cb20)
MEMP_NETBUF[10] 0x2001cb40 (next 0x2001cb30)
MEMP_NETBUF[11] 0x2001cb50 (next 0x2001cb40)
MEMP_NETBUF[12] 0x2001cb60 (next 0x2001cb50)
MEMP_NETBUF[13] 0x2001cb70 (next 0x2001cb60)
MEMP_NETBUF[14] 0x2001cb80 (next 0x2001cb70)
MEMP_NETBUF[15] 0x2001cb90 (next 0x2001cb80)

and during intensive ~1100 UDP frames exchanging (~750 bytes in size) :

....
allocated 0x2001cb00 (next 0x20015d54)
NETBUF deallocate 0x2001cb00 (next 0x20015d54)
allocated 0x2001cb00 (next 0x20015d54)
allocated 0x20015d54 (next 0x0)
MEMP_NETBUF 4 of 16 (max 16) used
ERROR: Socket send error: -3003

@ciarmcom ciarmcom requested review from a team October 14, 2019 11:00
@ciarmcom
Copy link
Member

@leszekgrzegorek, thank you for your changes.
@ARMmbed/mbed-os-ipcore @ARMmbed/mbed-os-maintainers please review.

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 21, 2019

Thanks for your contribution, this was fixed via #11586

To your question: please ask on forum

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants