MCPcopy Index your code
hub / github.com/tailscale/tailscale / getInjectInboundBuffsSizes

Method getInjectInboundBuffsSizes

wgengine/netstack/netstack.go:1027–1043  ·  view source on GitHub ↗

getInjectInboundBuffsSizes returns packet memory and a sizes slice for usage when calling tstun.Wrapper.InjectInboundPacketBuffer(). These are sized with consideration for MTU and GSO support on ns.linkEP. They should be recycled across subsequent inbound packet injection calls.

()

Source from the content-addressed store, hash-verified

1025// consideration for MTU and GSO support on ns.linkEP. They should be recycled
1026// across subsequent inbound packet injection calls.
1027func (ns *Impl) getInjectInboundBuffsSizes() (buffs [][]byte, sizes []int) {
1028 batchSize := 1
1029 gsoEnabled := ns.linkEP.SupportedGSO() == stack.HostGSOSupported
1030 if gsoEnabled {
1031 batchSize = conn.IdealBatchSize
1032 }
1033 buffs = make([][]byte, batchSize)
1034 sizes = make([]int, batchSize)
1035 for i := 0; i < batchSize; i++ {
1036 if i == 0 && gsoEnabled {
1037 buffs[i] = make([]byte, tstun.PacketStartOffset+ns.linkEP.GSOMaxSize())
1038 } else {
1039 buffs[i] = make([]byte, tstun.PacketStartOffset+tstun.DefaultTUNMTU())
1040 }
1041 }
1042 return buffs, sizes
1043}
1044
1045// The inject goroutine reads in packets that netstack generated, and delivers
1046// them to the correct path.

Callers 1

injectMethod · 0.95

Calls 3

DefaultTUNMTUFunction · 0.92
SupportedGSOMethod · 0.80
GSOMaxSizeMethod · 0.80

Tested by

no test coverage detected