Sarthak-Pandey opened a new pull request, #20622: URL: https://github.com/apache/nuttx/pull/20622
## Summary Fixes cross-deadlock (ABBA) between network devices under full-duplex forwarding / NAT (#20619). ### Problem In full-duplex forwarding / NAT scenarios between two network devices (such as SoftAP + Station mode with `wlan0` and `wlan1`), both netdev RX worker threads deadlock: 1. `netdev-wlan0` holds `netdev_lock(wlan0)` during packet reception and forward processing. When forwarding to `wlan1`, it invokes `netdev_txnotify_dev(wlan1)` -> `wlan1->d_txavail()`. `netdev_upper_txavail()` was unconditionally calling `netdev_upper_txavail_work(upper)` synchronously, attempting to acquire `netdev_lock(wlan1)`. 2. Simultaneously, `netdev-wlan1` holds `netdev_lock(wlan1)` and forwards a packet to `wlan0`, attempting to synchronously acquire `netdev_lock(wlan0)`. 3. This creates a classic ABBA deadlock where both worker threads wait on each other's device lock permanently. ### Solution In `netdev_upper_txavail()`, inspect `upper->lower->rxtype`: - If `rxtype == NETDEV_RX_DIRECT`, invoke `netdev_upper_txavail_work(upper)` directly. - Otherwise (`NETDEV_RX_THREAD`, `NETDEV_RX_THREAD_RSS`, `NETDEV_RX_WORK`), delegate via `netdev_upper_queue_work(dev)`. This asynchronously notifies the target device worker via semaphore post (`nxsem_post`), avoiding synchronous cross-device mutex contention. Fixes: #20619 ## Impact - **Users**: Resolves network freeze/wedge under bi-directional / full-duplex traffic through NAT / IP forwarding across two network interfaces. - **Compatibility**: No API change or breaking change; aligns with the pattern used in `netdev_lower_txdone()`. - **Security / Safety**: Eliminates cross-thread deadlock vulnerability. ## Testing - Build host: Ubuntu / Windows (riscv32-esp-elf-gcc / CMake) - Target: ESP32-C3 SuperMini (esp32c3-supermini:nsh) with `CONFIG_NET_IPFORWARD=y`, `CONFIG_NET_NAT=y`, `ESPRESSIF_WIFI_STATION_SOFTAP=y`. - Verified code structure and coding style adherence with NuttX standards. -- 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]
