Skip to content

Commit

Permalink
🗝️ conn: make MaxUDPGSOSegments useful
Browse files Browse the repository at this point in the history
  • Loading branch information
database64128 committed Oct 12, 2024
1 parent 4382a2f commit f0c30eb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion conn/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type SocketInfo struct {
// If UDP GSO is not enabled on the socket, or the system does not support UDP GSO, the value is 1.
//
// The value is 0 if the socket is not a UDP socket.
MaxUDPGSOSegments int
MaxUDPGSOSegments uint32

// UDPGenericReceiveOffload indicates whether UDP GRO is enabled on the socket.
UDPGenericReceiveOffload bool
Expand Down Expand Up @@ -80,6 +80,7 @@ func (lc *ListenConfig) ListenTCP(ctx context.Context, network, address string)

// ListenUDP wraps [net.ListenConfig.ListenPacket] and returns a [*net.UDPConn] directly.
func (lc *ListenConfig) ListenUDP(ctx context.Context, network, address string) (uc *net.UDPConn, info SocketInfo, err error) {
info.MaxUDPGSOSegments = 1
nlc := lc.tlc.ListenConfig
nlc.Control = lc.fns.controlFunc(&info)
pc, err := nlc.ListenPacket(ctx, network, address)
Expand Down
1 change: 1 addition & 0 deletions conn/conn_mmsg.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

// ListenUDPRawConn is like [ListenUDP] but wraps the [*net.UDPConn] in a [rawUDPConn] for batch I/O.
func (lc *ListenConfig) ListenUDPRawConn(ctx context.Context, network, address string) (c rawUDPConn, info SocketInfo, err error) {
info.MaxUDPGSOSegments = 1
nlc := lc.tlc.ListenConfig
nlc.Control = lc.fns.controlFunc(&info)
pc, err := nlc.ListenPacket(ctx, network, address)
Expand Down

0 comments on commit f0c30eb

Please sign in to comment.