net/netip: Is4In6 should return true for well-known prefixes used in IPv4/IPv6 translation #65635
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Go version
go1.22-20240109-RC01 linux/amd64
Output of
go env
in your module/workspace:What did you do?
https://go.dev/play/p/FwpGyqH1hio
package main
import (
"fmt"
"net/netip"
)
func main() {
}
What did you see happen?
The output:
IPv4-mapped address: ::ffff:192.0.2.1
NAT64 address: 64:ff9b::c000:201
RFC8215 address: 64:ff9b:1::c000:201
Only the first address is printed in mixed notation (https://datatracker.ietf.org/doc/html/rfc5952#section-5). That indicates that Is4In6() only recognizes ::ffff:0:0/96 as a well-known prefix, used for embedding IPv4 addresses into IPv6 ones.
Both 64:ff9b::/96 (RFC6052) and 64:ff9b:1::/48 (RFC8215) prefixes are not recognized as used for having IPv4 addresses embedded in the lower 32 bits.
As both prefixes are well-known and reserved by IANA (https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml), I believe Is4In6() shall be updated (happy to write that code, indeed).
P.S. I'd also argue that for backwards compatibility it would be beneficial to recognize ::/96 as a Well-Known Prefix, despite its deprecation, as there are still systems around which might be using it.
What did you expect to see?
All 3 addresses shall be represented using mixed notation, as per https://datatracker.ietf.org/doc/html/rfc5952#section-5
"mixed notation is RECOMMENDED if the following condition is met: the address can be distinguished as having IPv4 addresses embedded in the lower 32 bits solely from the address field through the use of a well-known prefix.
Such prefixes are defined in [RFC4291] and [RFC2765] at the time of this writing."
The text was updated successfully, but these errors were encountered: