envknob,net/tstun,wgengine: use TS_DEBUG_MTU consistently
Noted on #5915 TS_DEBUG_MTU was not used consistently everywhere. Extract the default into a function that can apply this centrally and use it everywhere. Added envknob.Lookup{Int,Uint}Sized to make it easier to keep CodeQL happy when using converted values. Updates #5915 Signed-off-by: James Tucker <james@tailscale.com>
This commit is contained in:

committed by
James Tucker

parent
8ed4fd1dbc
commit
40fa2a420c
@ -146,7 +146,6 @@ type Impl struct {
|
||||
}
|
||||
|
||||
const nicID = 1
|
||||
const mtu = tstun.DefaultMTU
|
||||
|
||||
// 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
|
||||
@ -179,7 +178,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, mtu, "")
|
||||
linkEP := channel.New(512, tstun.DefaultMTU(), "")
|
||||
if tcpipProblem := ipstack.CreateNIC(nicID, linkEP); tcpipProblem != nil {
|
||||
return nil, fmt.Errorf("could not create netstack NIC: %v", tcpipProblem)
|
||||
}
|
||||
@ -1078,7 +1077,7 @@ func (ns *Impl) acceptUDP(r *udp.ForwarderRequest) {
|
||||
func (ns *Impl) handleMagicDNSUDP(srcAddr netip.AddrPort, c *gonet.UDPConn) {
|
||||
// In practice, implementations are advised not to exceed 512 bytes
|
||||
// due to fragmenting. Just to be sure, we bump all the way to the MTU.
|
||||
const maxUDPReqSize = mtu
|
||||
var maxUDPReqSize = tstun.DefaultMTU()
|
||||
// Packets are being generated by the local host, so there should be
|
||||
// very, very little latency. 150ms was chosen as something of an upper
|
||||
// bound on resource usage, while hopefully still being long enough for
|
||||
|
Reference in New Issue
Block a user