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

Add Ipv6Addr::is_benchmarking #86434

Merged
merged 2 commits into from
Oct 4, 2021
Merged

Conversation

CDirkx
Copy link
Contributor

@CDirkx CDirkx commented Jun 18, 2021

This PR adds the unstable method Ipv6Addr::is_benchmarking. This method is added for parity with Ipv4Addr::is_benchmarking, and I intend to use it in a future rework of Ipv6Addr::is_global (edit: #86634) to more accurately follow the IANA Special Address Registry (like is done in Ipv4Addr::is_global).

With Ipv6Addr::is_benchmarking and Ipv4Addr::is_benchmarking now both existing, IpAddr::is_benchmarking is also added.

@rustbot rustbot added A-io Area: `std::io`, `std::fs`, `std::net` and `std::path` T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 18, 2021
@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(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 Jun 18, 2021
Comment on lines -478 to +502
let unspecified: u16 = 1 << 0;
let loopback: u16 = 1 << 1;
let unique_local: u16 = 1 << 2;
let global: u16 = 1 << 3;
let unicast_link_local: u16 = 1 << 4;
let unicast_global: u16 = 1 << 7;
let documentation: u16 = 1 << 8;
let multicast_interface_local: u16 = 1 << 9;
let multicast_link_local: u16 = 1 << 10;
let multicast_realm_local: u16 = 1 << 11;
let multicast_admin_local: u16 = 1 << 12;
let multicast_site_local: u16 = 1 << 13;
let multicast_organization_local: u16 = 1 << 14;
let multicast_global: u16 = 1 << 15;
let multicast: u16 = multicast_interface_local
let unspecified: u32 = 1 << 0;
let loopback: u32 = 1 << 1;
let unique_local: u32 = 1 << 2;
let global: u32 = 1 << 3;
let unicast_link_local: u32 = 1 << 4;
let unicast_global: u32 = 1 << 7;
let documentation: u32 = 1 << 8;
let benchmarking: u32 = 1 << 16;
let multicast_interface_local: u32 = 1 << 9;
let multicast_link_local: u32 = 1 << 10;
let multicast_realm_local: u32 = 1 << 11;
let multicast_admin_local: u32 = 1 << 12;
let multicast_site_local: u32 = 1 << 13;
let multicast_organization_local: u32 = 1 << 14;
let multicast_global: u32 = 1 << 15;
let multicast: u32 = multicast_interface_local
Copy link
Contributor Author

@CDirkx CDirkx Jun 18, 2021

Choose a reason for hiding this comment

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

More than 16 properties are now being checked, so the tag type is changed from u16 to u32. Also benchmarking is assigned value i << 16, the order doesn't really matter, only that the value is distinct from the other tags.

@@ -313,6 +321,7 @@ fn ip_properties() {
check!("ff08::", multicast);
check!("ff0e::", global | multicast);
check!("2001:db8:85a3::8a2e:370:7334", doc);
check!("2001:2::ac32:23ff:21", global | benchmarking);
Copy link
Contributor Author

@CDirkx CDirkx Jun 18, 2021

Choose a reason for hiding this comment

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

According to the IANA IPv6 Special Address Registry benchmarking addresses are not globally reachable. However due to the current simplistic implementation of Ipv6Addr::is_global compared to Ipv4Addr::is_global, Rust currently considers benchmarking addresses global. I plan to address this in a future PR reworking is_global.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The rework of Ipv6Addr::is_global has been submitted (#86634).

check!(
"2001:2::ac32:23ff:21",
&[0x20, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0xac, 0x32, 0x23, 0xff, 0, 0x21],
global | unicast_global | benchmarking
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above, benchmarking addresses should not actually be globally reachable. They do however have global unicast scope.

@CDirkx

This comment has been minimized.

@rustbot rustbot added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 23, 2021
@Mark-Simulacrum
Copy link
Member

r? @joshtriplett for T-libs-api review

@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 18, 2021
@JohnCSimon JohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 9, 2021
@camelid

This comment has been minimized.

1 similar comment
@camelid

This comment has been minimized.

@camelid

This comment has been minimized.

@camelid camelid added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 29, 2021
@joelpalmer joelpalmer added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 14, 2021
@JohnCSimon JohnCSimon removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 3, 2021
@JohnCSimon JohnCSimon added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 3, 2021
@joshtriplett
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Oct 4, 2021

📌 Commit cbaccc1 has been approved by joshtriplett

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 4, 2021
Manishearth added a commit to Manishearth/rust that referenced this pull request Oct 4, 2021
…plett

Add `Ipv6Addr::is_benchmarking`

This PR adds the unstable method `Ipv6Addr::is_benchmarking`. This method is added for parity with `Ipv4Addr::is_benchmarking`, and I intend to use it in a future rework of `Ipv6Addr::is_global` (edit: rust-lang#86634) to more accurately follow the [IANA Special Address Registry](https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml) (like is done in `Ipv4Addr::is_global`).

With `Ipv6Addr::is_benchmarking` and `Ipv4Addr::is_benchmarking` now both existing, `IpAddr::is_benchmarking` is also added.
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 4, 2021
…arth

Rollup of 14 pull requests

Successful merges:

 - rust-lang#86434 (Add `Ipv6Addr::is_benchmarking`)
 - rust-lang#86828 (const fn for option copied, take & replace)
 - rust-lang#87679 (BTree: refine some comments)
 - rust-lang#87910 (Mark unsafe methods NonZero*::unchecked_(add|mul) as const.)
 - rust-lang#88286 (Remove unnecessary unsafe block in `process_unix`)
 - rust-lang#88305 (Manual Debug for Unix ExitCode ExitStatus ExitStatusError)
 - rust-lang#88353 (Partially stabilize `array_methods`)
 - rust-lang#88370 (Add missing `# Panics` section to `Vec` method)
 - rust-lang#88481 (Remove some feature gates)
 - rust-lang#89138 (Fix link in Ipv6Addr::to_ipv4 docs)
 - rust-lang#89401 (Add truncate note to Vec::resize)
 - rust-lang#89467 (Fix typos in rustdoc/lints)
 - rust-lang#89472 (Only register `WSACleanup` if `WSAStartup` is actually ever called)
 - rust-lang#89505 (Add regression test for spurious const error with NLL)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 22714ed into rust-lang:master Oct 4, 2021
@rustbot rustbot added this to the 1.57.0 milestone Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-io Area: `std::io`, `std::fs`, `std::net` and `std::path` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants