mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 21:27:31 +00:00
wgengine,net,ipn,disco: split up and define different types of MTU
Prepare for path MTU discovery by splitting up the concept of DefaultMTU() into the concepts of the Tailscale TUN MTU, MTUs of underlying network interfaces, minimum "safe" TUN MTU, user configured TUN MTU, probed path MTU to a peer, and maximum probed MTU. Add a set of likely MTUs to probe. Updates #311 Signed-off-by: Val <valerie@tailscale.com>
This commit is contained in:
@@ -150,10 +150,11 @@ type Impl struct {
|
||||
|
||||
const nicID = 1
|
||||
|
||||
// maxUDPPacketSize is the maximum size of a UDP packet we copy in startPacketCopy
|
||||
// when relaying UDP packets. We don't use the 'mtu' const in anticipation of
|
||||
// one day making the MTU more dynamic.
|
||||
const maxUDPPacketSize = 1500
|
||||
// maxUDPPacketSize is the maximum size of a UDP packet we copy in
|
||||
// startPacketCopy when relaying UDP packets. The user can configure
|
||||
// the tailscale MTU to anything up to this size so we can potentially
|
||||
// have a UDP packet as big as the MTU.
|
||||
const maxUDPPacketSize = tstun.MaxPacketSize
|
||||
|
||||
// Create creates and populates a new Impl.
|
||||
func Create(logf logger.Logf, tundev *tstun.Wrapper, e wgengine.Engine, mc *magicsock.Conn, dialer *tsdial.Dialer, dns *dns.Manager, pm *proxymap.Mapper) (*Impl, error) {
|
||||
@@ -184,7 +185,7 @@ func Create(logf logger.Logf, tundev *tstun.Wrapper, e wgengine.Engine, mc *magi
|
||||
if tcpipErr != nil {
|
||||
return nil, fmt.Errorf("could not enable TCP SACK: %v", tcpipErr)
|
||||
}
|
||||
linkEP := channel.New(512, tstun.DefaultMTU(), "")
|
||||
linkEP := channel.New(512, uint32(tstun.DefaultTUNMTU()), "")
|
||||
if tcpipProblem := ipstack.CreateNIC(nicID, linkEP); tcpipProblem != nil {
|
||||
return nil, fmt.Errorf("could not create netstack NIC: %v", tcpipProblem)
|
||||
}
|
||||
@@ -1059,7 +1060,9 @@ func (ns *Impl) acceptUDP(r *udp.ForwarderRequest) {
|
||||
go ns.forwardUDP(c, srcAddr, dstAddr)
|
||||
}
|
||||
|
||||
// Buffer pool for forwarding UDP packets.
|
||||
// Buffer pool for forwarding UDP packets. Implementations are advised not to
|
||||
// exceed 512 bytes per DNS request due to fragmenting but in reality can and do
|
||||
// send much larger packets, so use the maximum possible UDP packet size.
|
||||
var udpBufPool = &sync.Pool{
|
||||
New: func() any {
|
||||
b := make([]byte, maxUDPPacketSize)
|
||||
|
Reference in New Issue
Block a user