|
|
@ -361,10 +361,7 @@ func getGSOSizeFromControl(control []byte) (int, error) {
|
|
|
|
return 0, fmt.Errorf("error parsing socket control message: %w", err)
|
|
|
|
return 0, fmt.Errorf("error parsing socket control message: %w", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if hdr.Level == unix.SOL_UDP && hdr.Type == unix.UDP_GRO && len(data) >= 2 {
|
|
|
|
if hdr.Level == unix.SOL_UDP && hdr.Type == unix.UDP_GRO && len(data) >= 2 {
|
|
|
|
var gso uint16
|
|
|
|
return int(binary.NativeEndian.Uint16(data[:2])), nil
|
|
|
|
// TODO(jwhited): replace with encoding/binary.NativeEndian when it's available
|
|
|
|
|
|
|
|
copy(unsafe.Slice((*byte)(unsafe.Pointer(&gso)), 2), data[:2])
|
|
|
|
|
|
|
|
return int(gso), nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0, nil
|
|
|
|
return 0, nil
|
|
|
@ -385,8 +382,7 @@ func setGSOSizeInControl(control *[]byte, gsoSize uint16) {
|
|
|
|
hdr.Level = unix.SOL_UDP
|
|
|
|
hdr.Level = unix.SOL_UDP
|
|
|
|
hdr.Type = unix.UDP_SEGMENT
|
|
|
|
hdr.Type = unix.UDP_SEGMENT
|
|
|
|
hdr.SetLen(unix.CmsgLen(2))
|
|
|
|
hdr.SetLen(unix.CmsgLen(2))
|
|
|
|
// TODO(jwhited): replace with encoding/binary.NativeEndian when it's available
|
|
|
|
binary.NativeEndian.PutUint16((*control)[unix.SizeofCmsghdr:], gsoSize)
|
|
|
|
copy((*control)[unix.SizeofCmsghdr:], unsafe.Slice((*byte)(unsafe.Pointer(&gsoSize)), 2))
|
|
|
|
|
|
|
|
*control = (*control)[:unix.CmsgSpace(2)]
|
|
|
|
*control = (*control)[:unix.CmsgSpace(2)]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|