Skip to content
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

stabilize the "ip" feature #66584

Closed
wants to merge 2 commits into from
Closed

Conversation

little-dude
Copy link
Contributor

@little-dude little-dude commented Nov 20, 2019

This my first time doing that, so I hope I didn't mess this up.


Stabilize the "ip" feature (fixes #27709), and add a disclaimer about the IP helpers stability (fixes #60239)

Stabilize the following methods:

  • IpAddr::is_global
  • IpAddr::is_documentation
  • Ipv4Addr::is_global
  • Ipv4addr::is_shared
  • Ipv4Addr::is_ietf_protocol_assignment
  • Ipv4addr::is_benchmarking
  • Ipv4Addr::is_reserved
  • Ipv6Addr::is_global
  • Ipv6Addr::is_unique_local
  • Ipv6Addr::is_unicast_link_local_strict
  • Ipv6Addr::is_unicast_link_local
  • Ipv6Addr::is_unicast_site_local
  • Ipv6Addr::is_documentation
  • Ipv6Addr::is_unicast_global
  • Ipv6Addr::multicast_scope

Stabilize the following enum: Ipv6MulticastScope

@rust-highfive
Copy link
Collaborator

r? @Kimundi

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 20, 2019
@jonas-schievink jonas-schievink added relnotes Marks issues that should be documented in the release notes of the next release. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Nov 20, 2019
@jonas-schievink jonas-schievink added this to the 1.41 milestone Nov 20, 2019
@jonas-schievink jonas-schievink added the needs-fcp This change is insta-stable, so needs a completed FCP to proceed. label Nov 20, 2019
@little-dude
Copy link
Contributor Author

@the8472, what do you think of the "stability guarantees" disclaimer?

src/libstd/net/mod.rs Outdated Show resolved Hide resolved
src/libstd/net/mod.rs Outdated Show resolved Hide resolved
src/libstd/net/mod.rs Outdated Show resolved Hide resolved
@Dylan-DPC-zz
Copy link

r? @kennytm

@rust-highfive rust-highfive assigned kennytm and unassigned Kimundi Dec 8, 2019
src/libstd/net/ip.rs Show resolved Hide resolved
src/libstd/net/mod.rs Show resolved Hide resolved
src/libstd/net/mod.rs Show resolved Hide resolved
@kennytm
Copy link
Member

kennytm commented Dec 8, 2019

@Dylan-DPC This stabilization PR requires FCP from the libs team. Could you r? a libs team member instead? Thanks.

@Dylan-DPC-zz
Copy link

Thanks for reviewing.

r? @KodrAus

@little-dude
Copy link
Contributor Author

Hi, is there anything I can do to push this forward?

@Dylan-DPC-zz
Copy link

@little-dude nothing. we will do a team consensus voting after the holiday break.

@Centril Centril modified the milestones: 1.41, 1.42 Dec 20, 2019
@bors
Copy link
Contributor

bors commented Dec 23, 2019

☔ The latest upstream changes (presumably #67540) made this pull request unmergeable. Please resolve the merge conflicts.

@little-dude
Copy link
Contributor Author

@Dylan-DPC @KodrAus can we start an FCP? I seems that it did not make it to 1.41 so I'd like to make sure it's not forgotten for 1.42.

Copy link
Contributor

@KodrAus KodrAus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your patience @little-dude!

I’ve just left a few comments around docs, but I don’t think that needs to hold up the FCP.

@rfcbot fcp merge

@@ -124,13 +116,21 @@ pub struct Ipv6Addr {

#[allow(missing_docs)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s make sure we have proper docs for this before stabilizing, which I think would include linking to the appropriate section of the RFC.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that the Reserved and Unassigned variants are part of the table but are missing from the enum. Instead, Ipv6Address::multicast_scope() returns None for such scopes. I don't think this is a problem but I think it's worth mentioning. Maybe @therealbstern or @the8472 have an opinion on that API?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I think Reserved and Unassigned are good things to put in the enum, but my concern is that there's a non-zero chance the Reserved/Unassigned space will get assigned to something in the future.

On the other hand, None is just as wrong as Reserved or Unassigned if the IETF assigns them in the future. In addition, IPv6 is so big that who knows when/if they'll get assigned.

My measured opinion is that we should add Reserved and Unassigned right now, since it's correct right now and might remain correct indefinitely.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it’s something to consider now before stabilization.

Let’s at least drop a #[non_exhaustive] attribute on the enum so we can add those variants later if need be.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, nonexhaustive should cover future RFC changes nicely.

Copy link
Contributor Author

@little-dude little-dude Jan 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, I'll make the changes.
edit: pushed a commit with the changes.

src/libstd/net/mod.rs Outdated Show resolved Hide resolved
src/libstd/net/mod.rs Outdated Show resolved Hide resolved
@folex
Copy link
Contributor

folex commented Mar 2, 2020

Thanks for your work, @little-dude! Would be awesome to see this merged.

@the8472
Copy link
Member

the8472 commented Mar 8, 2020

#69772 raises the question how these helper methods should behave if the ipv6 address is actually an ipv4-compatible or ipv4-mapped address. Maybe that should be discussed before stabilization.

@Centril Centril modified the milestones: 1.43, 1.44 Mar 10, 2020
@KodrAus
Copy link
Contributor

KodrAus commented Mar 11, 2020

@rfcbot concern ipv4 in ipv6

Not identifying ::ffff:127.0.0.1 (the ipv4 loopback address mapped to ipv6) as loopback is an example of where we're not currently considering ipv4 mapped to ipv6 addresses in the helpers. We should try build a list of other helpers that should consider ipv4 in ipv6.

@TyPR124
Copy link
Contributor

TyPR124 commented Mar 17, 2020

Re Ipv6Addr::is_unicast_link_local vs Ipv6Addr::is_unicast_link_local_strict, I personally don't see the value in the strict version, for a few reasons.

  1. Both RFC4291 and RFC5156 specify the entirety of fe80/10 as link-local

  2. In RFC4291, section 2.5 specifies about unicast addresses that "Additional address types or subtypes can be defined in the future" so what is "strict" may change in the future

  3. In the same section, it specifies that "Except for the knowledge of the subnet boundary discussed in the previous paragraphs [referring to fe80/10], nodes should not make any assumptions about the structure of an IPv6 address." This implementation of strict makes the assumption that all fe80/10 addresses must adhere to the structure shown in RFC4291, however the same RFC specifies that nodes should not make this assumption.

Given point 3, I don't see any situation where I would want to check anything but the /10 prefix.

@dillona
Copy link
Contributor

dillona commented Apr 1, 2020

@little-dude do you have a plan for resolving the existing concerns? Could you use a hand?

@Dylan-DPC-zz Dylan-DPC-zz modified the milestones: 1.44, 1.45 Apr 21, 2020
@crlf0710
Copy link
Member

crlf0710 commented May 2, 2020

@little-dude Ping from triage, any updates here?

@crlf0710
Copy link
Member

@little-dude Closing due to inactivity. Free free to reopen or create another PR to address the mentioned concerns above. You might also create a topic on Zulip for discussions. Thanks!

@crlf0710 crlf0710 closed this May 15, 2020
@rfcbot rfcbot removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels May 15, 2020
@crlf0710 crlf0710 added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. relnotes Marks issues that should be documented in the release notes of the next release. labels Jul 8, 2020
@crlf0710 crlf0710 removed this from the 1.45 milestone Jul 8, 2020
@caass
Copy link
Contributor

caass commented Aug 29, 2020

Hello! I'd really love to use is_global. I'd be willing to pick up the reigns for this if @little-dude is unavailable. If I understand correctly, the blockers currently are:

  1. There should be some checking for IPv4 addresses mapped it IPv6 space (comment)

From the RFC:

Two types of IPv6 addresses are defined that carry an IPv4 address in the low-order 32 bits of the address. These are the "IPv4-Compatible IPv6 address" and the "IPv4-mapped IPv6 address".

[...]

The "IPv4-Compatible IPv6 address" was defined to assist in the IPv6 transition. The format of the "IPv4-Compatible IPv6 address" is as follows:

80 bits 16 bits 32 bits
0000..............................0000 0000 IPv4 address

[...]

A second type of IPv6 address that holds an embedded IPv4 address is defined. This address type is used to represent the addresses of IPv4 nodes as IPv6 addresses. The format of the "IPv4-mapped IPv6 address" is as follows:

80 bits 16 bits 32 bits
0000..............................0000 FFFF IPv4 address

If we already have capability to check IPv4 addresses, I feel like it's almost trivial to implement these rules for IPv6 as well if we just need to pad it with some extra bytes? Famous last words, I know...

  1. There's some concern over the need for both is_unicast_link_local_strict and is_unicast_link_local (comment)

From the commit that introduced the change:

RFC 4291 is a little unclear about what is a unicast link local address.
According to section 2.4, the entire fe80::/10 range is reserved for
these addresses, but section 2.5.3 defines a stricter format for such
addresses.

After a discussion is has been decided to add a different method for
each definition, so this commit:

  • renames is_unicast_link_local() into is_unicast_link_local_strict()
  • relaxed the check in is_unicast_link_local()

From section 2.4:

Address type Binary prefix IPv6 notation Section
Unspecified 00...0 (128 bits) ::/128 2.5.2
Loopback 00...1 (128 bits) ::1/128 2.5.3
Multicast 11111111 FF00::/8 2.7
Link-Local unicast 1111111010 FE80::/10 2.5.6
Global Unicast (everything else)

Section section 2.5.3 seems...unrelated? It has to do with the loopback address. Section 2.5.6 however, is where the problem lies:

Link-Local addresses are for use on a single link. Link-Local addresses have the following format:

10 bits 16 bits 64 bits
1111111010 0 interface ID

So the difference in the spec is this:

Spec CIDR Start End Available
2.4 FE80::/10 fe80:0:0:0:0:0:0:0 febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff 2^118
2.5.6 FE80::/64 fe80:0:0:0:0:0:0:0 fe80:0:0:0:ffff:ffff:ffff:ffff 2^64

This does seem like an issue, so I did some more digging to figure out what's going on. I found this draft, which appears to have died. It does however point us in the right direction:

The RFC "IPv6 Address Archi" illustrates the format of the link-local addresses. From the illustration it MAY be understood that the length of the link-local prefix is 10 bits of value 1111111010 and 54 0 bits.

IANA lists the "IPv6 prefix", and "Address Block", to be "fe80::/10" on its website. It is possible that in the future the IETF could decide to use the bits 11-53.

The RFC 2464 "IPv6-over-Ethernet" states that the prefix for link-local addresses is "fe80::/64".

RFC 6874, "Representing IPv6 Zone Identifiers in Address Literals and Uniform Resource Identifiers" specifies the link-local addresses to be under prefix "fe80::/10".

I'm not an expert in reading IETF material -- far from it -- but I am vaguely aware of the passage of time. Every document that has been linked here that specifies /64 is more recent than those specifying /10, unless I've missed one. Additionally, there are countless secondhand sources (blogs, stackoverflow, etc) online all talking about how /64 is the spec.

Again, not an expert. I posted all this info here so someone more versed than me can evaluate and decide what the best course of action is. Without further input, I'd personally go ahead with just the one is_unicast_link_local that validates against /64.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 15, 2023
Stabilize `{IpAddr, Ipv6Addr}::to_canonical`

Make `IpAddr::to_canonical` and `IpV6Addr::to_canonical` stable (+const), as well as const stabilize `Ipv6Addr::to_ipv4_mapped`.

Newly stable API:

```rust
impl IpAddr {
    // Newly stable under `ip_to_canonical`
    const fn to_canonical(&self) -> IpAddr;
}

impl Ipv6Addr {
    // Newly stable under `ip_to_canonical`
    const fn to_canonical(&self) -> IpAddr;

    // Already stable, this makes it const stable under
    // `const_ipv6_to_ipv4_mapped`
    const fn to_ipv4_mapped(&self) -> Option<Ipv4Addr>
}
```

These stabilize a subset of the following tracking issues:

- rust-lang#27709
- rust-lang#76205

Stabilization of all methods under the `ip` gate was attempted once at rust-lang#66584 then again at rust-lang#76098. These were not successful because there are still unknowns about `is_documentation` `is_benchmarking` and similar; `to_canonical` is much more straightforward.

I have looked and could not find any known issues with `to_canonical`. These were added in 2021 in rust-lang#87708

cc implementor `@the8472`

r? libs-api
`@rustbot` label +T-libs-api +needs-fcp
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 16, 2023
Stabilize `{IpAddr, Ipv6Addr}::to_canonical`

Make `IpAddr::to_canonical` and `IpV6Addr::to_canonical` stable (+const), as well as const stabilize `Ipv6Addr::to_ipv4_mapped`.

Newly stable API:

```rust
impl IpAddr {
    // Newly stable under `ip_to_canonical`
    const fn to_canonical(&self) -> IpAddr;
}

impl Ipv6Addr {
    // Newly stable under `ip_to_canonical`
    const fn to_canonical(&self) -> IpAddr;

    // Already stable, this makes it const stable under
    // `const_ipv6_to_ipv4_mapped`
    const fn to_ipv4_mapped(&self) -> Option<Ipv4Addr>
}
```

These stabilize a subset of the following tracking issues:

- rust-lang#27709
- rust-lang#76205

Stabilization of all methods under the `ip` gate was attempted once at rust-lang#66584 then again at rust-lang#76098. These were not successful because there are still unknowns about `is_documentation` `is_benchmarking` and similar; `to_canonical` is much more straightforward.

I have looked and could not find any known issues with `to_canonical`. These were added in 2021 in rust-lang#87708

cc implementor ``@the8472``

r? libs-api
``@rustbot`` label +T-libs-api +needs-fcp
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Oct 16, 2023
Rollup merge of rust-lang#115955 - tgross35:ip-to-canonical, r=dtolnay

Stabilize `{IpAddr, Ipv6Addr}::to_canonical`

Make `IpAddr::to_canonical` and `IpV6Addr::to_canonical` stable (+const), as well as const stabilize `Ipv6Addr::to_ipv4_mapped`.

Newly stable API:

```rust
impl IpAddr {
    // Newly stable under `ip_to_canonical`
    const fn to_canonical(&self) -> IpAddr;
}

impl Ipv6Addr {
    // Newly stable under `ip_to_canonical`
    const fn to_canonical(&self) -> IpAddr;

    // Already stable, this makes it const stable under
    // `const_ipv6_to_ipv4_mapped`
    const fn to_ipv4_mapped(&self) -> Option<Ipv4Addr>
}
```

These stabilize a subset of the following tracking issues:

- rust-lang#27709
- rust-lang#76205

Stabilization of all methods under the `ip` gate was attempted once at rust-lang#66584 then again at rust-lang#76098. These were not successful because there are still unknowns about `is_documentation` `is_benchmarking` and similar; `to_canonical` is much more straightforward.

I have looked and could not find any known issues with `to_canonical`. These were added in 2021 in rust-lang#87708

cc implementor ``@the8472``

r? libs-api
``@rustbot`` label +T-libs-api +needs-fcp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-fcp This change is insta-stable, so needs a completed FCP to proceed. S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet