Repository navigation
Tracking Issue for abstract namespaces in Unix domain sockets #85410
Description
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
- Implementation: Add abstract namespace support for Unix domain sockets #85379
- Rework to use an extension trait: Move
unix_socket_abstractfeature API toSocketAddrExt. #101967 - Final commenting period (FCP)
- Stabilization PR
Unresolved Questions
- None yet.
Activity
Rollup merge of rust-lang#85379 - mdaverde:uds-abstract, r=joshtriplett
Rollup merge of rust-lang#85379 - mdaverde:uds-abstract, r=joshtriple…
Auto merge of rust-lang#85379 - mdaverde:uds-abstract, r=joshtriplett
mexus commentedon Nov 17, 2021
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.
DataTriny commentedon Dec 21, 2021
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?
the8472 commentedon May 9, 2022
If I understand #76915 (comment) correctly then the methods on
os::unix::SocketAddrshouldn't becfg(any(doc, target_os = "android", target_os = "linux",))and instead should go into theos::linuxandos::androidmodules as extension traits.krisnova commentedon Sep 9, 2022
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.
the8472 commentedon Sep 9, 2022
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.
krisnova commentedon Sep 9, 2022
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?
jmillikin commentedon Sep 18, 2022
I'm also interested in seeing this feature stabilized, and made an attempt at moving the API into
SocketAddrExt: #101967joshtriplett commentedon Nov 14, 2022
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
27 remaining items
JohnTitor commentedon Mar 17, 2023
Dropped the "proposed" label to reflect the status, FCP was done here.
Stabilise `unix_socket_abstract`
jmillikin commentedon Mar 18, 2023
Thanks! Stabilization PR is #109288
joshtriplett commentedon Mar 18, 2023
@rfcbot resolved wait-for-106441
rfcbot commentedon Mar 18, 2023
🔔 This is now entering its final comment period, as per the review above. 🔔
Rollup merge of rust-lang#109288 - jmillikin:linux-abstract-socket-ad…
Rollup merge of #109288 - jmillikin:linux-abstract-socket-addr, r=jos…
Rollup merge of #106441 - mllken:abstract-socket-noref, r=joshtriplett
Stabilise `unix_socket_abstract`
Rollup merge of #109288 - jmillikin:linux-abstract-socket-addr, r=jos…