mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
rename files dealing with low level conns to sys_conn
This commit is contained in:
parent
f68b38635a
commit
3126062aa7
14 changed files with 9 additions and 2 deletions
40
sys_conn_df_linux.go
Normal file
40
sys_conn_df_linux.go
Normal file
|
@ -0,0 +1,40 @@
|
|||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
package quic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"syscall"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/internal/utils"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func setDF(rawConn syscall.RawConn) error {
|
||||
// Enabling IP_MTU_DISCOVER will force the kernel to return "sendto: message too long"
|
||||
// and the datagram will not be fragmented
|
||||
var errDFIPv4, errDFIPv6 error
|
||||
if err := rawConn.Control(func(fd uintptr) {
|
||||
errDFIPv4 = unix.SetsockoptInt(int(fd), unix.IPPROTO_IP, unix.IP_MTU_DISCOVER, unix.IP_PMTUDISC_DO)
|
||||
errDFIPv6 = unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_MTU_DISCOVER, unix.IPV6_PMTUDISC_DO)
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
switch {
|
||||
case errDFIPv4 == nil && errDFIPv6 == nil:
|
||||
utils.DefaultLogger.Debugf("Setting DF for IPv4 and IPv6.")
|
||||
case errDFIPv4 == nil && errDFIPv6 != nil:
|
||||
utils.DefaultLogger.Debugf("Setting DF for IPv4.")
|
||||
case errDFIPv4 != nil && errDFIPv6 == nil:
|
||||
utils.DefaultLogger.Debugf("Setting DF for IPv6.")
|
||||
case errDFIPv4 != nil && errDFIPv6 != nil:
|
||||
return errors.New("setting DF failed for both IPv4 and IPv6")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func isMsgSizeErr(err error) bool {
|
||||
// https://man7.org/linux/man-pages/man7/udp.7.html
|
||||
return errors.Is(err, unix.EMSGSIZE)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue