Skip to content

Commit

Permalink
Recognise new IPv6 non-global range from RFC9602
Browse files Browse the repository at this point in the history
This commit adds the 5f00::/16 range defined by RFC9602 to those ranges which Ipv6Addr::is_global recognises as a non-global IP. This range is used for Segment Routing (SRv6) SIDs.
  • Loading branch information
bardiharborow committed Jan 19, 2025
1 parent 39dc268 commit 3807f52
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 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
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

0 comments on commit 3807f52

Please sign in to comment.