net/netip: Prefix, the range of bits for 4in6 addresses must be restricted to [96,128] #53153
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes, I use the latst stable release
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://go.dev/play/p/2KQHE36RXEa
The type changes after applying Prefix.Masked() from 4in6 to 6, but Masked() should only mask the hostbits and not producing nonsense.
What did you expect to see?
You should change the limitations for type netip.Prefix to:
// Prefix is an IP address prefix (CIDR) representing an IP network.
//
// The first Bits() of Addr() are specified. The remaining bits match any address.
// The range of Bits() is [0,32] for IPv4 or [0,128] for IPv6.
to
// Prefix is an IP address prefix (CIDR) representing an IP network.
//
// The first Bits() of Addr() are specified. The remaining bits match any address.
// The range of Bits() is [0,32] for IPv4 or [0,128] for IPv6 and [96,128] for IP4In6
and netip.ParsePrefix should return an error
What did you see instead?
after applying netip.Prefix.Masked() the type of the IP address changed from IP4In6 to IP6 and the result is nonsense, because more than the hostbits are masked.
prefix: ::ffff:10.5.6.7/88, addr: ::ffff:10.5.6.7, is4in6: true
masked: ::ff00:0:0/88, addr: ::ff00:0:0, is4in6: false
The text was updated successfully, but these errors were encountered: