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

   ## Summary
   
   `socketpair()` gives each end an internal name: "socketpair" and a number. 
The name only names the FIFOs of the pair, but `getsockname()` and 
`getpeername()` of an end gave it to the program, and `recvfrom()` of a stream 
pair gave it as the source address. A program that prints or compares the 
address got a name that no `bind()` made.
   
   Linux gives an unnamed address for the ends of a socket pair: only 
`sun_family`, with an address length of `sizeof(sa_family_t)`. An unbound local 
socket already gets this address in NuttX. Now `getsockname()`, `getpeername()` 
and the source address of `recvfrom()` give it for a socket pair too 
(`lc_pair`). A datagram pair already sends an empty source name, so its 
`recvfrom()` does not change.
   
   The pair keeps its internal name for its FIFOs: only the address that the 
program sees changes.
   
   ## Impact
   
   Programs that read the address of a socket pair end now get an unnamed 
address. No in-tree program depends on the internal name (grep of nuttx and 
nuttx-apps; libuv expects the Linux address). No API, ABI or Kconfig change. 
The same in all build modes and on all architectures.
   
   ## Testing
   
   New case `test_local_dgram_pair_name` in `cmocka_net_local_dgram` (it will 
follow in a separate apps PR): for a datagram and a stream pair, 
`getsockname()`, `getpeername()` and the source address of `recvfrom()` of each 
end. On qemu-armv8a:nsh (flat) with local stream and datagram sockets, CI 
image, QEMU TCG:
   
   | | master | this PR |
   |---|---|---|
   | test_local_dgram_pair_name | FAILED (the internal name) | PASSED |
   | the other cases of cmocka_net_local_dgram and cmocka_net_udp | 91 + 24 
PASSED | 91 + 24 PASSED |
   
   Builds with `-Werror` in the CI image, with local stream and datagram 
sockets: qemu-armv8a:nsh (flat), qemu-armv8a:knsh (kernel, with the apps), 
rv-virt:netnsh64 (flat), rv-virt:knetnsh64 (kernel, with the apps).
   


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

  • [PR] net/local: Give the ends... casaroli (via GitHub) via commits

Reply via email to