Skip to content
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

net/netip: Need to unmap the Addr in AddrFromSlice due to that there may be an IPv4-mapped IPv6 address #56406

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

zhlsunshine
Copy link

@zhlsunshine zhlsunshine commented Oct 25, 2022

Generally, the code should not assert an IP address is IPv4 or IPv6 via the slice length due to there may be an IPv4-mapped IPv6 address, so need to unmap the Addr in AddrFromSlice in net/netip package.

This can be reproduced by calling net.DefaultResolver.LookupNetIP in net package to obtain all interfaces and then each interface address may be in an IPv4-mapped IPv6 address, and this will cause the problem when checking an address's IP family.

@gopherbot
Copy link

This PR (HEAD: 6186106) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/445275 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link

Message from Zeke Lu:

Patch Set 2:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/445275.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

This PR (HEAD: e86a494) has been imported to Gerrit for code review.

Please visit https://go-review.googlesource.com/c/go/+/445275 to see it.

Tip: You can toggle comments from me using the comments slash command (e.g. /comments off)
See the Wiki page for more info

@gopherbot
Copy link

Message from Huailong Zhang:

Patch Set 2:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/445275.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Zeke Lu:

Patch Set 3:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/445275.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Damien Neil:

Patch Set 3:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/445275.
After addressing review feedback, remember to publish your drafts!

@ZekeLu
Copy link
Contributor

ZekeLu commented Nov 3, 2022

Hi @zhlsunshine, now that https://go.dev/cl/415580 is merged and net.DefaultResolver.LookupNetIP won't return IPv4-mapped IPv6 address. Can you verify whether it addresses your issue? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants