x/sys/unix: missing function to marshal a Cmsghdr #59653
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
FeatureRequest
help wanted
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I'm implementing UDP GSO for quic-go (tracking issue). Since quic-go does DPLPMTUD, a server will send packets with different sizes to different clients. Therefore, we can't just set a single packet size per UDP socket. Instead, we have to pass the desired packet size to the kernel with every
sendmsg
call.In Go, this is done using the
WriteMsgUDP
function on thenet.UDPConn
. The size is encoded as a control message, which is passed in theoob []byte
parameter to that function:Proof of concept here: https://gist.github.com/marten-seemann/a549773b53f30960b966a9f4068b6e48#file-gso-go-L45-L50
What did you expect to see?
The proof of concept works, as can be confirmed by running
tcpdump
(e.g.tcpdump host 8.8.8.8 -n -v -i eth0
).What did you see instead?
Serializing the control message has to be done by hand (see the
getCmsg
function in my PoC). The precise format of the control message is highly dependent on the architecture, and my PoC will only work on amd64 (see definition). Other architectures serialize this message slightly different, there are 41 (!) architecture-dependent ztypes_ files in the unix package that define theCmsghdr
.x/sys/unix already provides a deserialization function (via
ParseOneSocketControlMessage
/ParseSocketControlMessage
). It would it would provide some kind of serialization function that works on all architectures as well.The text was updated successfully, but these errors were encountered: