@@ -168,6 +168,7 @@ type endpoint struct {
168168 mtu uint32
169169
170170 batchSize int
171+ writeMsgX bool
171172}
172173
173174// Options specify the details about the fd-based endpoint to be created.
@@ -223,6 +224,9 @@ type Options struct {
223224 // ProcessorsPerChannel is the number of goroutines used to handle packets
224225 // from each FD.
225226 ProcessorsPerChannel int
227+
228+ MultiPendingPackets bool
229+ WriteMsgX bool
226230}
227231
228232// New creates a new fd-based endpoint.
@@ -261,6 +265,12 @@ func New(opts *Options) (stack.LinkEndpoint, error) {
261265 if opts .MaxSyscallHeaderBytes < 0 {
262266 return nil , fmt .Errorf ("opts.MaxSyscallHeaderBytes is negative" )
263267 }
268+ var batchSize int
269+ if opts .MultiPendingPackets {
270+ batchSize = int ((512 * 1024 )/ (opts .MTU )) + 1
271+ } else {
272+ batchSize = 1
273+ }
264274
265275 e := & endpoint {
266276 mtu : opts .MTU ,
@@ -271,7 +281,8 @@ func New(opts *Options) (stack.LinkEndpoint, error) {
271281 packetDispatchMode : opts .PacketDispatchMode ,
272282 maxSyscallHeaderBytes : uintptr (opts .MaxSyscallHeaderBytes ),
273283 writevMaxIovs : rawfile .MaxIovs ,
274- batchSize : int ((512 * 1024 )/ (opts .MTU )) + 1 ,
284+ batchSize : batchSize ,
285+ writeMsgX : opts .WriteMsgX ,
275286 }
276287 if e .maxSyscallHeaderBytes != 0 {
277288 if max := int (e .maxSyscallHeaderBytes / rawfile .SizeofIovec ); max < e .writevMaxIovs {
@@ -478,7 +489,7 @@ func (e *endpoint) writePacket(pkt *stack.PacketBuffer) tcpip.Error {
478489
479490func (e * endpoint ) sendBatch (batchFDInfo fdInfo , pkts []* stack.PacketBuffer ) (int , tcpip.Error ) {
480491 // Degrade to writePacket if underlying fd is not a socket.
481- if ! batchFDInfo .isSocket {
492+ if ! batchFDInfo .isSocket || ! e . writeMsgX {
482493 var written int
483494 var err tcpip.Error
484495 for written < len (pkts ) {
0 commit comments