From efc252ff56c22d978a4fd1c635b7064200d2ea77 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Mon, 26 Jun 2023 14:57:50 +0200 Subject: [PATCH] use the UDP_SEGMENT constant defined in the unix package (for GSO) (#3917) --- sys_conn_df_linux.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sys_conn_df_linux.go b/sys_conn_df_linux.go index f027b47ab..58f6f80ab 100644 --- a/sys_conn_df_linux.go +++ b/sys_conn_df_linux.go @@ -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.