mirror of
https://github.com/qdm12/gluetun.git
synced 2026-05-09 20:29:23 +02:00
chore(pmtud/tcp): silently discard IPv6 network unreachable errors
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
package ip
|
package ip
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/netip"
|
"net/netip"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/jsimonetti/rtnetlink"
|
"github.com/jsimonetti/rtnetlink"
|
||||||
"github.com/qdm12/gluetun/internal/pmtud/constants"
|
"github.com/qdm12/gluetun/internal/pmtud/constants"
|
||||||
@@ -26,7 +28,10 @@ func SrcAddr(dst netip.AddrPort, proto int) (src netip.AddrPort, cleanup func(),
|
|||||||
return netip.AddrPortFrom(srcAddr, srcPort), cleanup, nil
|
return netip.AddrPortFrom(srcAddr, srcPort), cleanup, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var errNoRoute = fmt.Errorf("no route to destination")
|
var (
|
||||||
|
errNoRoute = fmt.Errorf("no route to destination")
|
||||||
|
ErrNetworkUnreachable = errors.New("network unreachable")
|
||||||
|
)
|
||||||
|
|
||||||
func srcIP(dst netip.Addr) (netip.Addr, error) {
|
func srcIP(dst netip.Addr) (netip.Addr, error) {
|
||||||
conn, err := rtnetlink.Dial(nil)
|
conn, err := rtnetlink.Dial(nil)
|
||||||
@@ -49,6 +54,10 @@ func srcIP(dst netip.Addr) (netip.Addr, error) {
|
|||||||
}
|
}
|
||||||
messages, err := conn.Route.Get(requestMessage)
|
messages, err := conn.Route.Get(requestMessage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
var sysErr syscall.Errno
|
||||||
|
if errors.As(err, &sysErr) && sysErr == syscall.ENETUNREACH {
|
||||||
|
err = ErrNetworkUnreachable
|
||||||
|
}
|
||||||
return netip.Addr{}, fmt.Errorf("getting routes to %s: %w", dst, err)
|
return netip.Addr{}, fmt.Errorf("getting routes to %s: %w", dst, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ func findHighestMSSDestination(ctx context.Context, familyToFD map[int]fileDescr
|
|||||||
case err != nil: // error already occurred for another findMSS goroutine
|
case err != nil: // error already occurred for another findMSS goroutine
|
||||||
case errors.Is(result.err, firewall.ErrMarkMatchModuleMissing):
|
case errors.Is(result.err, firewall.ErrMarkMatchModuleMissing):
|
||||||
err = fmt.Errorf("finding MSS for %s: %w", result.dst, result.err)
|
err = fmt.Errorf("finding MSS for %s: %w", result.dst, result.err)
|
||||||
|
case dst.Addr().Is6() && errors.Is(result.err, ip.ErrNetworkUnreachable):
|
||||||
|
// silently discard IPv6 network unreachable errors since they are common
|
||||||
|
// and expected when the host doesn't have IPv6 connectivity
|
||||||
default: // another error not due to the match module missing
|
default: // another error not due to the match module missing
|
||||||
logger.Debugf("finding MSS for %s failed: %s", result.dst, result.err)
|
logger.Debugf("finding MSS for %s failed: %s", result.dst, result.err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user