magicsock: mute noisy expected peer mtu related error (#10870)

This commit is contained in:
Claire Wang
2024-01-19 20:04:22 -05:00
committed by GitHub
parent 62b056d677
commit 213d696db0
3 changed files with 26 additions and 2 deletions

View File

@@ -5,7 +5,13 @@
package magicsock
import "tailscale.com/net/tstun"
import (
"errors"
"golang.org/x/sys/unix"
"tailscale.com/disco"
"tailscale.com/net/tstun"
)
// Peer path MTU routines shared by platforms that implement it.
@@ -110,3 +116,15 @@ func (c *Conn) UpdatePMTUD() {
c.peerMTUEnabled.Store(newStatus)
c.resetEndpointStates()
}
var errEMSGSIZE error = unix.EMSGSIZE
func pmtuShouldLogDiscoTxErr(m disco.Message, err error) bool {
// Large disco.Ping packets used to probe path MTU may result in
// an EMSGSIZE error fairly regularly which can pollute logs.
p, ok := m.(*disco.Ping)
if !ok || p.Padding == 0 || !errors.Is(err, errEMSGSIZE) || debugPMTUD() {
return true
}
return false
}