-
Notifications
You must be signed in to change notification settings - Fork 18k
net/netip: Is4In6 should return true for well-known prefixes used in IPv4/IPv6 translation #65635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@ianlancetaylor @neild if you could give this a look. |
My 2 cents: I like this proposal to improve the output, but I hope we can keep the current behavior of |
I do not have any strong opinion on that, I guess we can create a new function and mark Is4In6() as deprecated. |
I believe that the current This distinction is crucial when compared to other protocols, which aim to send genuine IPv6 packets with an embedded address. The need for a different prefix (e.g., Well-Known Prefix) in these cases arises from this fundamental difference. For example, IPv4-embedded IPv6 addresses are designed to be used in AAAA records, because genuine IPv6 packets will be sent, while IPv4-mapped ones should never appear in them, because only IPv4 packets will be sent. Therefore we should avoid conflating IPv4-mapped IPv6 addresses with other IPv4-translatable or IPv4-embedded IPv6 addresses. Personally I'm fine if we wish to modify PS: I know the SIIT protocol messed up the situation a little bit, but my main point stands. |
Change https://go.dev/cl/617835 mentions this issue: |
netip.Addr.Is4In6 is documented as reporting whether an address is "an IPv4-mapped IPv6 address". RFC 4291, section 2.5.5.2 defines an IPv4-mapped IPv6 address as in the subnet ::ffff:0:0/96. RFC 5156, section 2.2 has a more concise definition. Since "IPv4-mapped IPv6 address" is a term of art with a specific definition, Is4In6's current behavior is correct and should not change. https://go.dev/cl/617835 makes the Is4In6 documentation more explicit. A separate question is whether we should use mixed notation when formatting RFC6052 and RFC8215 addresses. That seems like it would be reasonable, but I haven't thought about it in detail. |
For #65635 Change-Id: I4e4b0309d9139f970d6fd6b41303dfd2e0ec6236 Reviewed-on: https://go-review.googlesource.com/c/go/+/617835 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
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: