zhhyu7 opened a new pull request, #21985:
URL: https://github.com/apache/nuttx/pull/21985
## Summary
- The ICMP, ICMPv6, PKT, NetLink and UDP connection pools, the UDP
write-buffer pool, the forward-structure pool, the IPv4/IPv6 RAM route pools
and the devif callback pool all used net_bufpool. Several of
them borrowed the net_bufpool lock to protect not only the pool but also a
separate list: the per-protocol active connection list, or the RAM routing
table.
- Switch every pool to the common MEMPOOL_DEFINE, whose
mempool_allocate()/mempool_release() are internally locked. Give each list that
previously relied on the pool lock its own rmutex (the active
connection lists and the route tables). The pool macros map directly:
NET_BUFPOOL_TRYALLOC/TIMEDALLOC/ALLOC → mempool_allocate, NET_BUFPOOL_FREE →
mempool_release, NET_BUFPOOL_TEST → mempool_navail.
- No functional change for callers. net_bufpool itself is kept, since the
CAN, Bluetooth, IEEE 802.15.4, TCP and usrsock pools still use it.
## Impact
- New feature: NO. Internal pool/lock refactor.
- Impact on user: NO.
- Impact on build: NO new config.
- Impact on hardware: NO.
- Impact on documentation: NO.
- Impact on security: pool and list accounting are now protected by
distinct, well-defined locks instead of overloading the pool lock.
- Impact on compatibility: NO API change.
- Anything else: arp_send and the CAN pools are intentionally left on
net_bufpool and will be converted separately.
## Testing
Build Host: Ubuntu 22.04.5 x86_64, gcc 13.4.0
Target: sim:nettest (+ loopback, UDP, ICMP/ICMPv6 sockets, PKT,
NetLink, IPv4/IPv6 RAM routes)
Baseline: parent commit (still using NET_BUFPOOL)
Build: links clean. Also built with CONFIG_DEBUG_FEATURES=y to cover
the devif callback double-free debug path (now reading mempool's queue).
Runtime: a loopback self-test exercised every converted pool:
- UDP: 200 rounds of open / bind / sendto-self / recvfrom / close
- ICMP, ICMPv6, NetLink, PKT: socket open-close cycles
- RAM route: 200 rounds of route add/del (g_ipv4routes)
Baseline and patched produce byte-identical output; neither shows any
assert, panic or backtrace. Route add/del 200/200 and all UDP I/O
succeed, confirming the new per-list rmutex and mempool alloc/free
recycle correctly across repeated churn.
This is an equivalence / regression test: it shows behaviour is
unchanged and nothing leaks or crashes under churn. It does not
reproduce a specific prior bug, and the single-core sim does not
exercise multi-core lock contention.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]