daniel-p-carvalho opened a new pull request, #20172:
URL: https://github.com/apache/nuttx/pull/20172

   ## Summary
   
   In `devif_poll_pkt_connections()`, `pkt_poll()` records the outgoing IOB in 
`pkt_conn->pendiob` so that any synchronous TX tap or loopback executed during 
the driver callback can skip delivering the packet back to the sending socket.
   
   Previously, `pendiob` was never cleared upon TX completion and would linger 
across transmissions as a dangling pointer. Because the IOB pool is small and 
recycled quickly (LIFO), a subsequent incoming packet from the network 
frequently reused the same IOB buffer address, causing `pkt_in()` to falsely 
match `conn->pendiob == dev->d_iob` and drop legitimate RX packets as 
self-echoes.
   
   This PR drops the `pendiob` reference immediately after `callback(dev)` 
returns in `devif_poll_pkt_connections()`, ensuring the pointer never outlives 
the transmission cycle and cannot falsely suppress future incoming packets.
   
   Also fixes a pre-existing `nxstyle` alignment issue in `devif_poll.c` IPv6 
version-check block (unrelated `nerr()` call), ensuring zero checkpatch errors 
on touched files.
   
   Suggested-by: @zhhyu7
   
   ## Impact
   
   - Bug fix in packet socket (`AF_PACKET` / `CONFIG_NET_PKT`) receive path.
   - Prevents random / silent packet drops on high-throughput or low-memory 
systems where IOB buffers are recycled rapidly.
   - No ABI or user-visible API changes.
   
   ## Testing
   
   1. Verified with `tools/checkpatch.sh -g HEAD`: 100% checks pass.
   2. Verified on physical hardware (STM32H753, RMII Ethernet):
      - Firmware running with `CONFIG_NET_PKT=y` and the updated `devif_poll.c`.
      - Tested bidirectional ICMP ping traffic between Linux host and the board 
continuously with 0% packet loss and clean IOB buffer recycling.
   3. Verified on physical hardware (STM32F407, RMII Ethernet with PTP IEEE 
1588):
      - High-rate packet socket exchanges (`Pdelay_Req` / `Pdelay_Resp`) run 
continuously without false self-echo drops.


-- 
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]

Reply via email to