Skip to content

net: WriteMsgUDPAddrPort should accept IPv4-mapped IPv6 destination addresses on IPv4 UDP sockets #74737

@database64128

Description

@database64128

Go version

all versions since go1.18

Output of go env in your module/workspace:

see above

What did you do?

Create an IPv4 UDP socket listening on 0.0.0.0. Call WriteMsgUDPAddrPort with an IPv4-mapped IPv6 destination address.

What did you see happen?

write udp4 0.0.0.0:48509->[::ffff:192.168.0.162]:20221: address ::ffff:192.168.0.162: non-IPv4 address

What did you expect to see?

The write succeeds, just like WriteMsgUDP.

Back when Go 1.18 was just out, I opened #52264 for sending to IPv4 addresses on IPv6 sockets.

This issue is about the other way around: sending to IPv4-mapped IPv6 addresses on IPv4 sockets. It's less common, as IPv4 UDP sockets are less used compared to dual-stack IPv6 sockets. But it's just as painful, as APIs like net.DefaultResolver.LookupNetIP happily return IPv4-mapped IPv6 addresses.

I'm sending a CL to address it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.NeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions