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

Recognise new IPv6 non-global range from IETF RFC 9602 #135745

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions library/core/src/net/ip_addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,8 @@ impl Ipv6Addr {
// IANA says N/A.
|| matches!(self.segments(), [0x2002, _, _, _, _, _, _, _])
|| self.is_documentation()
// Segment Routing (SRv6) SIDs (`5f00::/16`)
|| matches!(self.segments(), [0x5f00, ..])
|| self.is_unique_local()
|| self.is_unicast_link_local())
}
Expand Down Expand Up @@ -1773,6 +1775,8 @@ impl Ipv6Addr {
&& !self.is_unspecified()
&& !self.is_documentation()
&& !self.is_benchmarking()
// Segment Routing (SRv6) SIDs (`5f00::/16`)
&& !matches!(self.segments(), [0x5f00, ..])
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 haven't changed this to something potentially more comprehensive like self.is_unicast() && !self.global() since that would change behaviour for some other ranges, but it may be a good target for another PR.

Copy link
Member

Choose a reason for hiding this comment

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

See #85604 -- I think given those open questions, we should not change this at all right now.

(The last is_global update in #119006 also avoided this.)

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 will have a look and re-request review when this is ready.

@rustbot author

}

/// Returns the address's multicast scope if the address is multicast.
Expand Down
3 changes: 3 additions & 0 deletions library/core/tests/net/ip_addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ fn ipv6_properties() {
}
}

let none: u32 = 0;
let unspecified: u32 = 1 << 0;
let loopback: u32 = 1 << 1;
let unique_local: u32 = 1 << 2;
Expand Down Expand Up @@ -688,6 +689,8 @@ fn ipv6_properties() {

check!("2002::", &[0x20, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], unicast_global);

check!("5f00::", &[0x5f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], none);

check!("fc00::", &[0xfc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], unique_local);

check!(
Expand Down
Loading