ndp
ndp copied to clipboard
The default ControlMessage set on WriteTo causes failures when the connection is bound to link-local on macOS
I've come across an issue that seems to be specific to macOS when binding an ndp connection to the LinkLocal address of an interface. Subsequent Writes using WriteTo will fail with a sendmsg: no route to host
error. This problem does not occur when binding the connection to either the Global scoped address or Unspecified.
After some digging and reconstructing the process manually I managed to narrow the issue down to the WriteTo providing a default ControlMessage to the ipv6.PacketConn when nil is passed to the WriteTo method. Specifically it seems that explicitly setting the Src field of the ControlMessage is what causes this to fail. Passing nil or using a ControlMessage without the Src field set avoids the problem
None of this is reproducible on Linux where all versions worked as expected.