only run DPLPMTUD if the connection can send packets with the DF bit set (#3879)

This commit is contained in:
Marten Seemann 2023-06-02 16:54:34 +03:00 committed by GitHub
parent 0438eada95
commit 614fdb3271
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 67 additions and 26 deletions

View file

@ -11,7 +11,7 @@ import (
"github.com/quic-go/quic-go/internal/utils"
)
func setDF(rawConn syscall.RawConn) error {
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
var errDFIPv4, errDFIPv6 error
@ -19,7 +19,7 @@ func setDF(rawConn syscall.RawConn) error {
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
return false, err
}
switch {
case errDFIPv4 == nil && errDFIPv6 == nil:
@ -29,9 +29,9 @@ func setDF(rawConn syscall.RawConn) error {
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 false, errors.New("setting DF failed for both IPv4 and IPv6")
}
return nil
return true, nil
}
func isMsgSizeErr(err error) bool {