diff --git a/library/core/src/net/ip_addr.rs b/library/core/src/net/ip_addr.rs index 7dd5c21401264..e9dca076e3bb2 100644 --- a/library/core/src/net/ip_addr.rs +++ b/library/core/src/net/ip_addr.rs @@ -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()) } @@ -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, ..]) } /// Returns the address's multicast scope if the address is multicast. diff --git a/library/core/tests/net/ip_addr.rs b/library/core/tests/net/ip_addr.rs index 707f9a160e127..1acdbdeadee35 100644 --- a/library/core/tests/net/ip_addr.rs +++ b/library/core/tests/net/ip_addr.rs @@ -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; @@ -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!(