Open
Description
Tracking issue for feature(unix_socket_ancillary_data)
to extend UnixStream
and UnixDatagram
to send and receive ancillary data. For example file descriptors.
Unresolved Questions
- Review the
SocketAncillary
struct before stabilization to ensure it is compatible with all OSes. fuchsia
,haiku
,illumos
,ios
,macos
andsolaris
does not haveMSG_CMSG_CLOEXEC
constant inlibc
fuchsia
anduclibc
(x86_64
) does not havecmsghdr
struct inlibc
- The current version of rust
libc
does not haveucred
struct for the target OSemscripten
, butemscripten
has this struct in the standard C library
Known bugs/issues
Implementation history
- unix: Extend UnixStream and UnixDatagram to send and receive file descriptors #69864
- unix: Non-mutable bufs in send_vectored_with_ancillary_to #82589
- unix: Fix feature(unix_socket_ancillary_data) on macos and other BSDs #83374
- Add types for inspecting control messages in Unix socket ancillary data #117196
Metadata
Metadata
Assignees
Labels
Area: `std::io`, `std::fs`, `std::net` and `std::path`Category: An issue tracking the progress of sth. like the implementation of an RFC`#![feature(unix_socket_ancillary_data)]`Libs issues that are tracked on the team's project board.Operating system: Unix-likeRelevant to the library API team, which will review and decide on the PR/issue.
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
tadeokondrak commentedon Feb 25, 2021
send_vectored_with_ancillary
should switch to non-mutable references for its parameters, sincesendmsg
doesn't write through them.#79753 changes just the
bufs
parameter, but it was closed for inactivity.(Edit: Hmm, actually changing the ancillary data too would require both a SocketAncillary and SocketAncillaryMut, like IoSlice. Probably not worth it there)
LinkTed commentedon Feb 27, 2021
@tadeokondrak I open a new PR #82589.
LinkTed commentedon Mar 7, 2021
I create a new PR to send and receive TTL for UdpSocket from the ancillary interface. #82858
reyk commentedon Mar 26, 2021
Hi @LinkTed, I posted a fix in #83374 for macOS, OpenBSD, and possibly other BSDs.
Rollup merge of rust-lang#83374 - reyk:fix/bsd-ancillary, r=joshtriplett
LinkTed commentedon Apr 4, 2021
What has to be done to stabilize this API?
the8472 commentedon Apr 15, 2021
I think the API still needs polish. All those niche socket features are tricky and right now it's probably not extensible enough for 3rd party libraries to fill platform-specific gaps such as flags or cmsgs only supported on one particular OS. These basically are wrappers for the
recvmsg
andsndmsg
syscalls, we should expose them in a way that's forwards-compatible so we don't have to addrecv_vectored_with_ancillary_from_with_flags
or something like that in the future.Before stabilizing we should consider whether
recv_vectored_with_ancillary_from
should gain another argument. I would recommend adding aReceiveOptions
argument that allows one to specify flags, similar toOpenOptions
. The options could then be used to set linux'MSG_DONTWAIT
,MSG_PEEK
orMSG_ERRQUEUE
for example, maybe viacustom_flags()
similar toOpenOptions
. That way we don't have to support all OS-specific peculiarities.Or we could put the flags into
SocketAncillary
or at least reserve the right to do that in the future, but in that case the struct would need to be renamed because it would serve several purposes at once.Similar could be done for sending.
Additionally the
AncillaryData
enum should be marked as#[non_exhaustive]
and maybe gain aUnknown
variant for things that the standard library doesn't support. And a way to get the raw ancillary message. That way one could for example decodestruct sock_extended_err
in a 3rd party crate without waiting for std to implement it.LinkTed commentedon Apr 17, 2021
@the8472 Thank you for your feedback. If this PR request is #82858 merged I will start implementing your suggestions.
108 remaining items