zhhyu7 opened a new pull request, #21517:
URL: https://github.com/apache/nuttx/pull/21517
## Summary
A series of improvements and fixes for the `AF_PACKET` (raw packet)
socket implementation in `net/pkt`: receive-size limiting, multi-socket
delivery for sockets bound to the same protocol, source-address
reporting on `recvfrom()`, a read-back mechanism, a loopback packet-loss
fix, a send-path deadlock fix, and raw packet support over the TUN
driver.
The series (7 commits, oldest to newest):
1. **net/pkt: add recv size limit when NET_RECV_BUFSIZE > 0** — enforces
the per-socket receive buffer limit (`SO_RCVBUF` /
`CONFIG_NET_RECV_BUFSIZE`) when queuing received packets.
2. **net/pkt: deliver data into multiple pkt conn bound to same
protocol** — when several packet sockets are bound to the same
protocol, deliver the received frame to each of them instead of only
one connection.
3. **net/pkt: add the sender's address information with recvfrom** —
fills in the source link-layer address so `recvfrom()` returns the
sender information, standardizing the receive path.
4. **net/pkt: config pkt socket read back mechanism** — adds a read-back
mechanism for packet sockets (new fields in `include/nuttx/net/pkt.h`
and `net/pkt`, with a small `netdev_upperhalf` adjustment) so locally
transmitted frames can be observed by the socket as configured.
5. **net/pkt: fix issue for pkt loopback** — the stack did not clear
`conn->pendiob` after sending; if that IOB was reused when receiving
from the lowerhalf, the frame was dropped, causing packet loss. Adds a
guard condition to avoid the drop.
6. **net/pkt: fix dead lock issue and optimize performance** — minimizes
the lock/unlock window on the buffered send path: it first tries to
acquire resources, and only when acquisition fails in blocking mode
does it unlock before waiting, avoiding a deadlock.
7. **pkt: support raw pkt in tun driver** — enables raw packet sockets
over the TUN driver and fixes a related code-logic error.
## Impact
- New/changed public interface in `include/nuttx/net/pkt.h` (read-back
mechanism, commit 4).
- Minor change to `drivers/net/netdev_upperhalf.c` to support read-back.
- Behavioral change: frames are now delivered to all packet sockets
bound to the same protocol (commit 2), and loopback frames are no
longer dropped (commit 5).
- No change to non-packet socket families.
## Testing
TODO:
--
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]