Skip to content

Commit 2352fcf

Browse files
committed
Recognise new IPv6 non-global range from RFC9602
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.
1 parent 39dc268 commit 2352fcf

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

library/core/src/net/ip_addr.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1581,6 +1581,8 @@ impl Ipv6Addr {
15811581
// IANA says N/A.
15821582
|| matches!(self.segments(), [0x2002, _, _, _, _, _, _, _])
15831583
|| self.is_documentation()
1584+
// Segment Routing (SRv6) SIDs (`5f00::/16`)
1585+
|| matches!(self.segments(), [0x5f00, ..])
15841586
|| self.is_unique_local()
15851587
|| self.is_unicast_link_local())
15861588
}
@@ -1773,6 +1775,8 @@ impl Ipv6Addr {
17731775
&& !self.is_unspecified()
17741776
&& !self.is_documentation()
17751777
&& !self.is_benchmarking()
1778+
// Segment Routing (SRv6) SIDs (`5f00::/16`)
1779+
&& !matches!(self.segments(), [0x5f00, ..])
17761780
}
17771781

17781782
/// Returns the address's multicast scope if the address is multicast.

library/core/tests/net/ip_addr.rs

+3
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ fn ipv6_properties() {
603603
}
604604
}
605605

606+
let none: u32 = 0;
606607
let unspecified: u32 = 1 << 0;
607608
let loopback: u32 = 1 << 1;
608609
let unique_local: u32 = 1 << 2;
@@ -688,6 +689,8 @@ fn ipv6_properties() {
688689

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

692+
check!("5f00::", &[0x5f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], none);
693+
691694
check!("fc00::", &[0xfc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], unique_local);
692695

693696
check!(

0 commit comments

Comments
 (0)