forked from quic-go/quic-go
use the UDP_SEGMENT constant defined in the unix package (for GSO) (#3917)
This commit is contained in:
@@ -15,11 +15,6 @@ import (
|
||||
"github.com/quic-go/quic-go/internal/utils"
|
||||
)
|
||||
|
||||
// UDP_SEGMENT controls GSO (Generic Segmentation Offload)
|
||||
//
|
||||
//nolint:stylecheck
|
||||
const UDP_SEGMENT = 103
|
||||
|
||||
func setDF(rawConn syscall.RawConn) (bool, error) {
|
||||
// Enabling IP_MTU_DISCOVER will force the kernel to return "sendto: message too long"
|
||||
// and the datagram will not be fragmented
|
||||
@@ -51,7 +46,7 @@ func maybeSetGSO(rawConn syscall.RawConn) bool {
|
||||
|
||||
var setErr error
|
||||
if err := rawConn.Control(func(fd uintptr) {
|
||||
setErr = unix.SetsockoptInt(int(fd), syscall.IPPROTO_UDP, UDP_SEGMENT, 1)
|
||||
setErr = unix.SetsockoptInt(int(fd), syscall.IPPROTO_UDP, unix.UDP_SEGMENT, 1)
|
||||
}); err != nil {
|
||||
setErr = err
|
||||
}
|
||||
@@ -73,7 +68,7 @@ func appendUDPSegmentSizeMsg(b []byte, size uint16) []byte {
|
||||
b = append(b, make([]byte, unix.CmsgSpace(dataLen))...)
|
||||
h := (*unix.Cmsghdr)(unsafe.Pointer(&b[startLen]))
|
||||
h.Level = syscall.IPPROTO_UDP
|
||||
h.Type = UDP_SEGMENT
|
||||
h.Type = unix.UDP_SEGMENT
|
||||
h.SetLen(unix.CmsgLen(dataLen))
|
||||
|
||||
// UnixRights uses the private `data` method, but I *think* this achieves the same goal.
|
||||
|
||||
Reference in New Issue
Block a user