introduce an ECNCapablePacketConn interface to determine ECN support #2788
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements solution 2 discussed in #2741 (comment).
TLDR: Currently we only enable ECN support if the user passes a naked
*net.UDPConn
intoDial
andListen
, respectively. With this PR, we'll also enable ECN if thenet.PacketConn
is a wrappednet.UDPConn
, as long as it exposes the required methodsSyscallConn
andReadMsgUDP
.Note that this might contain an element of surprise for the user: To read packets from the connection, we won't use
ReadFrom
any longer, butReadMsgUDP
, so any wrapping of theReadFrom
will be bypassed. I added comments at multiple places to make users aware of this.