maxikrie opened a new pull request, #21021:
URL: https://github.com/apache/nuttx/pull/21021

   ## Summary
   
   `sendto()` on a UDP socket that was never bound blocks forever when the
   packet goes out over 6LoWPAN.
   
   `psock_6lowpan_udp_sendto()` builds the packet with `conn->lport` as the
   source port but, unlike `psock_udp_sendto()` (via `udp_connect()`), never
   gives an unbound socket a port. `udp_poll()` only serves connections
   with a local port, so `sixlowpan_send()` waits on its semaphore for a
   poll that never comes. `examples/udp` binds its client socket, so it
   doesn't hit this.
   
   The fix selects a free port with `udp_select_port()` when `lport` is 0,
   the same code `udp_connect()` and the buffered UDP send path use.
   
   ## Impact
   
   UDP over 6LoWPAN (IEEE 802.15.4 and packet radio) from sockets that
   send without `bind()`. No change for bound sockets or for plain UDP.
   
   ## Testing
   
   Two nRF52840-DKs, `nrf52840-dk:ieee802154_6lowpan` (CMake) plus
   `NET_ICMPv6`, `NET_ICMPv6_SOCKET`, `SYSTEM_PING6` and a small test app:
   one board receives on a bound socket, the other sends from an unbound
   `socket(AF_INET6, SOCK_DGRAM, 0)` at a fixed rate, with a sequence
   number and payload checked on receipt. Master b9d1d6a834:
   
   | | master | this PR |
   |---|---|---|
   | 32-byte datagrams, 100 Hz, 10 s | first `sendto()` never returns, nothing 
received | 1000 sent, 1000 received, 0 lost/corrupt |
   | 300-byte datagrams, 25 Hz, 4 s | — | 100 sent, 100 received, 0 
lost/corrupt |
   
   `tools/checkpatch.sh -f net/sixlowpan/sixlowpan_udpsend.c` passes.
   


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