Skip to content

Tracking Issue for abstract namespaces in Unix domain sockets #85410

Closed

Description

@mdaverde

Feature gate: #![feature(unix_socket_abstract)]

This is a tracking issue for adding abstract namespace support for Unix domain sockets on Linux.

Traditionally, Unix domain sockets (UDS) use a file to coordinate socket binding and connecting. On Linux, though, a specific extension exists to allow domain sockets to be created from a namespace which does not use the filesystem. With these changes, we extend Rust's UDS support to create sockets directly from a SocketAddr which can be itself used to create an abstract namespace.

More information

Previous discussion: #42048
Linux man page: unix(7)

Public API

Non-platform specific additions

UnixListener::bind_addr(&SocketAddr) -> Result<UnixListener>

UnixStream::connect_addr(&SocketAddr) -> Result<()>

UnixDatagram::bind_addr(&SocketAddr) -> Result<UnixDatagram>

UnixDatagram::connect_addr(&SocketAddr) -> Result<()>

UnixDatagram::send_to_addr(&self, &[u8], &SocketAddr) -> Result<usize>

Platform-specific (Linux) additions

SocketAddrExt::from_abstract_name(&[u8]) -> Result<SocketAddr>

SockerAddrExt::as_abstract_name(&self) -> Option<&[u8]>

Example

#![feature(unix_socket_abstract)]
use std::os::unix::net::{UnixListener, SocketAddr};
use std::os::linux::net::SocketAddrExt;

fn main() -> std::io::Result<()> {
    let addr = SocketAddr::from_abstract_namespace(b"namespace")?; // Linux only
    let listener = match UnixListener::bind_addr(&addr) {
        Ok(sock) => sock,
        Err(err) => {
            println!("Couldn't bind: {:?}", err);
            return Err(err);
        }
    };
    Ok(())
}

Steps / History

Unresolved Questions

  • None yet.

Activity

  1. added
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    T-libs-api[DEPRECATED; DO NOT USE]
    on May 17, 2021
  2. added a commit that references this issue on May 18, 2021
  3. added a commit that references this issue on May 18, 2021
  4. added a commit that references this issue on Oct 15, 2021
  5. mexus commented on Nov 17, 2021

    @mexus

    Is there anything else that needs to be done? 🤔

    Seems like the PR from the first message has been already merged, so isn't it time for the FCP? :)

    Also it seems kinda strange that there's no assignees in this issue.

  6. DataTriny commented on Dec 21, 2021

    @DataTriny

    Hi @mdaverde ,

    Thank you so much for taking care of this.

    I am already using the API added on #85379 for AccessKit and I haven't encountered any issue so far.

    @joshtriplett you were the one reviewing the PR. Isn't it time for the FCP now?

  7. the8472 commented on May 9, 2022

    @the8472
    Member

    If I understand #76915 (comment) correctly then the methods on os::unix::SocketAddr shouldn't be cfg(any(doc, target_os = "android", target_os = "linux",)) and instead should go into the os::linux and os::android modules as extension traits.

  8. krisnova commented on Sep 9, 2022

    @krisnova

    Following up on this and this is my first time engaging with the Rust community so forgive me if I make any careless mistakes.

    If I understand correctly this proposal needs to move to a final commenting period (FCP) until the feature reaches stabilization.

    Is there anything I can do to contribute and help carry this feature forward? This is a feature is important to myself as well as most folks coming to Rust looking for support for Linux userspace feature implementation in a language other than C.

    Thank you for your consideration.

  9. the8472 commented on Sep 9, 2022

    @the8472
    Member

    A remaining issue is that the methods are in the wrong place, they need to be moved to the os::linux module since they're linux specific and not available on other unixes.

  10. krisnova commented on Sep 9, 2022

    @krisnova

    Thank you for the context. I'll see if I can't make a contribution to move them to the Linux specific module.

    Do you know if there are any other outstanding items that would need to be addressed before this can move to FCP?

  11. jmillikin commented on Sep 18, 2022

    @jmillikin
    Contributor

    I'm also interested in seeing this feature stabilized, and made an attempt at moving the API into SocketAddrExt: #101967

  12. joshtriplett commented on Nov 14, 2022

    @joshtriplett
    Member

    I've reviewed and approved #101967, which moves the Linux-specific methods into an extension trait.

    With that merged, I don't think there are any other blockers here.

    So, let's see if we have consensus to stabilize UNIX socket abstract namespace support.

    @rfcbot merge

  13. 27 remaining items

  14. removed
    proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
    on Mar 17, 2023
  15. JohnTitor commented on Mar 17, 2023

    @JohnTitor
    Member

    Dropped the "proposed" label to reflect the status, FCP was done here.

  16. added a commit that references this issue on Mar 18, 2023
  17. jmillikin commented on Mar 18, 2023

    @jmillikin
    Contributor

    Thanks! Stabilization PR is #109288

  18. joshtriplett commented on Mar 18, 2023

    @joshtriplett
    Member

    @rfcbot resolved wait-for-106441

  19. added
    proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
    final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.
    and removed
    proposed-final-comment-periodProposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off.
    on Mar 18, 2023
  20. rfcbot commented on Mar 18, 2023

    @rfcbot

    🔔 This is now entering its final comment period, as per the review above. 🔔

  21. added a commit that references this issue on Mar 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-api[DEPRECATED; DO NOT USE]disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.finished-final-comment-periodThe final comment period is finished for this PR / Issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions