Skip to content

ACP: Unix socket ancillary data v2 #284

Closed
@jmillikin

Description

@jmillikin

Proposal

Problem statement

The current unstable support for Unix socket ancillary data (feature unix_socket_ancillary_data) has several known issues and cannot be stabilized in its current form (see comments by @m-ou-se on rust-lang/rust#76915).

@m-ou-se suggested that there needs to be an RFC for Unix socket API ancillary data, which I've started a draft of at rust-lang/rfcs#3430 (rendered).

On Zulip, @pitaj suggested that filing an ACP might also be appropriate.

Motivating examples or use cases

I would like to be able to transfer file descriptors via SCM_RIGHTS ancillary data on platforms that support that functionality (Linux, *BSD, most Unix-ish).

I would also like to be able to obtain platform-specific socket metadata such as Linux's high-resolution packet timestamps.

Solution sketch

The linked RFC 3430 (rendered) contains a draft API for representing ancillary data, including file descriptor ownership and extension points so that third-party libraries can provide platform-specific logic.

I have a local branch that implements that RFC's proposed API. Once the RFC seems to be moving towards stability, I'll add docs + tests to my branch and push it to provide better context as we work out the implementation details.

Alternatives

  1. Do nothing, keep the current perma-unstable API until a better solution can be designed.
  2. Remove ancillary data support from stdlib and leave it to third-party libraries such as https://github.com/nix-rust/nix.
  3. Instead of providing a high-level API, expose more of the underlying BSD sockets API (CMSG_* macros and friends) and let third-party libraries provide wrappers.
  4. Expose simple functions for SCM_RIGHTS only, analogous to Python's socket.send_fds() and socket.recv_fds() functions.

None of these are particularly appealing to me, though if anyone does have ideas on an even better API then I'd be happy to see it.

Links and related work

What happens now?

This issue contains an API change proposal (or ACP) and is part of the libs-api team feature lifecycle. Once this issue is filed, the libs-api team will review open proposals as capability becomes available. Current response times do not have a clear estimate, but may be up to several months.

Possible responses

The libs team may respond in various different ways. First, the team will consider the problem (this doesn't require any concrete solution or alternatives to have been proposed):

  • We think this problem seems worth solving, and the standard library might be the right place to solve it.
  • We think that this probably doesn't belong in the standard library.

Second, if there's a concrete solution:

  • We think this specific solution looks roughly right, approved, you or someone else should implement this. (Further review will still happen on the subsequent implementation PR.)
  • We're not sure this is the right solution, and the alternatives or other materials don't give us enough information to be sure about that. Here are some questions we have that aren't answered, or rough ideas about alternatives we'd want to see discussed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ACP-acceptedAPI Change Proposal is accepted (seconded with no objections)T-libs-apiapi-change-proposalA proposal to add or alter unstable APIs in the standard libraries

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions