-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Commit to not supporting IPv4-in-IPv6 addresses #86335
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
/// Returns [`true`] if this is the [loopback address] (`::1`), | ||
/// as defined in [IETF RFC 4291 section 2.5.3]. | ||
/// | ||
/// This property is defined in [IETF RFC 4291]. | ||
/// Contrary to IPv4, in IPv6 there is only one loopback address. | ||
/// | ||
/// [IETF RFC 4291]: https://tools.ietf.org/html/rfc4291 | ||
/// [loopback address]: Ipv6Addr::LOCALHOST | ||
/// [IETF RFC 4291 section 2.5.3]: https://tools.ietf.org/html/rfc4291#section-2.5.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should methods like is_loopback
explicitly mention that they don't consider IPv4-mapped and IPv4-compatible addresses? That is what is proposed as an alternative in #69772, but I'm worried that adding that information to almost every method on Ipv6Addr
would just be noise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me as written. I don't think every method needs to repeat it.
If this PR gets accepted I'll submit a followup PR to fill that gap. |
Since this is a stable API commitment I feel that we should FCP it, even though it's only changing docs. @rfcbot merge |
Team member @yaahc has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
Checking off sfackler's checkbox since he's left the libs team. |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. The RFC will be merged soon. |
…them This simplifies checking common properties in an address-family-agnostic way since since rust-lang#86335 commits to not checking IPv4 semantics of IPv4-mapped addresses in the `Ipv6Addr` property methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @CDirkx! This looks good to me.
@bors r+ |
📌 Commit 1f2480b has been approved by |
Add convenience method for handling ipv4-mapped addresses by canonicalizing them This simplifies checking common properties in an address-family-agnostic way since rust-lang#86335 commits to not checking IPv4 semantics of IPv4-mapped addresses in the `Ipv6Addr` property methods.
☀️ Test successful - checks-actions |
Add convenience method for handling ipv4-mapped addresses by canonicalizing them This simplifies checking common properties in an address-family-agnostic way since rust-lang#86335 commits to not checking IPv4 semantics of IPv4-mapped addresses in the `Ipv6Addr` property methods.
Add convenience method for handling ipv4-mapped addresses by canonicalizing them This simplifies checking common properties in an address-family-agnostic way since rust-lang#86335 commits to not checking IPv4 semantics of IPv4-mapped addresses in the `Ipv6Addr` property methods.
@rustbot label -to-announce |
This was very surprising for me. It would be great, if the documentation of If you bind a server to |
there's the unstable to_canonical which handles it, the example even covers localhost checking. |
Why not mention it in the comment about Something like
|
The issue isn't specific to Anyway, this is a closed PR. Only few people will read it. You should file an issue or open a PR with improved docs. |
Stabilization of the
ip
feature has for a long time been blocked on the question of whether Rust should support handling "IPv4-in-IPv6" addresses: should the variousIpv6Address
property methods take IPv4-mapped or IPv4-compatible addresses into account. See also the IPv4-in-IPv6 Address Support issue #85609 and #69772 which originally asked the question.Overview
In the recent PR #85655 I proposed changing
is_loopback
to take IPv4-mapped addresses into account, so::ffff:127.0.0.1
would be recognized as a looback address. However, due to the points that came up in that PR, I alternatively propose the following: Keeping the current behaviour and commit to not assigning any special meaning for IPv4-in-IPv6 addresses, other than what the standards prescribe. This would apply to the stable methodis_loopback
, but also to currently unstable methods likeis_global
andis_documentation
and any future methods. This is implemented in this PR as a change in documentation, specifically the following section:Discussion
In the discussion for or against supporting IPv4-in-IPv6 addresses the question what would be least surprising for users of other languages has come up several times. At first it seemed most big other languages supported IPv4-in-IPv6 addresses (or at least considered
::ffff:127.0.0.1
a loopback address). However after further investigation it appears that supporting IPv4-in-IPv6 addresses comes down to how a language represents addresses. .Net and Go do not have a separate type for IPv4 or IPv6 addresses, and do consider::ffff:127.0.0.1
a loopback address. Java and Python, which do have separate types, do not consider::ffff:127.0.0.1
a loopback address. Seeing as Rust has the separateIpv6Addr
type, it would make sense to also not support IPv4-in-IPv6 addresses. Note that this focuses on IPv4-mapped addresses, no other language handles IPv4-compatible addresses.Another issue that was raised is how useful supporting these IPv4-in-IPv6 addresses would be in practice. Again with the example of
::ffff:127.0.0.1
, considering it a loopback address isn't too useful as to use it with most of the socket APIs it has to be converted to an IPv4 address anyway. From that perspective it would be better to instead provide better ways for doing this conversion like stabilizingto_ipv4_mapped
or introducing ato_canonical
method.A point in favour of not supporting IPv4-in-IPv6 addresses is that that is the behaviour Rust has always had, and that supporting it would require changing already stable functions like
is_loopback
. This also keeps the documentation of these functions simpler, as we only have to refer to the relevant definitions in the IPv6 specification.Decision
To make progress on the
ip
feature, a decision needs to be made on whether or not to support IPv4-in-IPv6 addresses.There are several options:
IPv6Addr
methods (accept PR ChangeIpv6Addr::is_loopback
to include IPv4-mapped loopback addresses #85655).Ipv6Addr::is_loopback
to include IPv4-mapped loopback addresses #85655), this entire issue will however come up again in the stabilization of several methods under theip
feature.There are more options, like supporting IPv4-in-IPv6 addresses in
IpAddr
methods instead, but to my knowledge those haven't been seriously argued for by anyone.There is currently an FCP ongoing on PR #85655. I would ask the libs team for an alternative FCP on this PR as well, which if completed means the rejection of PR #85655, and the decision to commit to not supporting IPv4-in-IPv6 addresses.
If anyone feels there is not enough evidence yet to make the decision for or against supporting IPv4-in-IPv6 addresses, let me know and I'll do whatever I can to resolve it.