-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse IPv6 zone identifiers #476
Comments
I didn't see any obvious length restriction in the RFC, and for a type in Or were you thinking with
that it could just be an unsigned integer of some kind? Though your example doesn't work with that. But even then, it no longer being just 128-bit feels like it'd be a surprise to a bunch of people, and potentially bad. TL/DR it feels like this should be a different type, not part of |
I think the ToSocketAddrs should be extended to recognize @scottmcm if we follow C's |
Using an unsigned integer would work if converting interface names to interface indexes as @kennytm already noted.
A scope identifier is part of an IPv6 address and I feel it more surprising that valid IPv6 addresses are not properly parsed. I don't see how a different type would solve the issue properly.
Parsing interface names in |
I don't think it makes sense to produce a different answer for |
That is a fair argument. I think this could be solved with a trait, similar to |
Oh also, while the zone ID is required to disambiguate non-global IPv6 address, it is never sent on the wire. An IPv6 packet does not contain the So I think it does make sense that |
I think there's now multiple definitions of "address" and having those in different types would make sense. Because if you look at what an IPv6 packet header calls an address, there's no zone identifier. If I look at a I think that even if the type does get the field, the back compat you mention still probably often won't happen, as the docs say "IPv6 addresses are defined as 128-bit integers" and it wouldn't surprise me at all to have people passing them around via EDIT: maybe @kennytm just said this better as we typed at the same time. |
Not send on the wire but parsed before by e.g. the Linux kernel to determine on which interface to send it out.
Bad example in my opinion, if the peer is a link-local from the 2. interface it is a very important information. The zone identifier is explicitly passed with link-locals and multicast addresses, otherwise it is implicitly 0. If proper Ipv6 parsing is only added to |
No this works: use std::net::ToSocketAddrs as _;
fn main() {
let socket_addr = ("fe80::1%3", 0).to_socket_addrs().unwrap().next().unwrap();
dbg!(socket_addr);
// socket_addr = [fe80::1%3]:0
} |
Proposal
Extend the
Ipv6Addr
struct with support for zone identifiers (interface indexes and interface names) including string parsing.Problem statement
Ipv6 addresses have zone identifiers (
<address>%<zone_id>
) for e.g. link-local and multicast addresses as per RFC4007. This is currently not supported by thecore
andstd
implementations of anIpv6Addr
.Motivating examples or use cases
Use cases include addressing multicast IP addresses on specific interfaces for e.g. wake on LAN when the default route does not exit into the local network where devices are located or neighbor discovery over multicast on specific interfaces for dynamic routing protocols.
Other expected uses actively break when trying to parse a file that contains an Ipv6 address scoped using an interface name (e.g. hickory DNS and
/etc/resolv.conf
containingnameserver fe80::2a0:57ff:fe6f:42ee%wlp3s0
).Solution sketch
SocketAddrV6
toIpv6Addr
libc::if_nametoindex
wrappers to platform specific APIs instd
core::net::parser
Ipv6 parser with custom zone identifier parsersstd
Alternatives
SocketAddrV6
instd
Links and related work
https://datatracker.ietf.org/doc/html/rfc3513
https://datatracker.ietf.org/doc/html/rfc4007
https://datatracker.ietf.org/doc/html/rfc3493
rust-lang/rust#65976
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):
Second, if there's a concrete solution:
The text was updated successfully, but these errors were encountered: