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.
()
| 1025 | // consideration for MTU and GSO support on ns.linkEP. They should be recycled |
| 1026 | // across subsequent inbound packet injection calls. |
| 1027 | func (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. |
no test coverage detected