linux/tools/testing/selftests/net/packetdrill/tcp_zerocopy_small.pkt

// SPDX-License-Identifier: GPL-2.0
// small packet zerocopy test:
//
// verify that SO_EE_CODE_ZEROCOPY_COPIED is set on zerocopy
// packets of all sizes, including the smallest payload, 1B.

`./defaults.sh`

    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
   +0 setsockopt(3, SOL_SOCKET, SO_ZEROCOPY, [1], 4) = 0
   +0 bind(3, ..., ...) = 0
   +0 listen(3, 1) = 0

   +0 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
   +0 < . 1:1(0) ack 1 win 257

   +0 accept(3, ..., ...) = 4

   // send 1B
   +0 send(4, ..., 1, MSG_ZEROCOPY) = 1
   +0 > P. 1:2(1) ack 1
   +0 < . 1:1(0) ack 2 win 257

   +1 recvmsg(4, {msg_name(...)=...,
                  msg_iov(1)=[{...,0}],
                  msg_flags=MSG_ERRQUEUE,
                  msg_control=[
                        {cmsg_level=CMSG_LEVEL_IP,
                         cmsg_type=CMSG_TYPE_RECVERR,
                         cmsg_data={ee_errno=0,
                                    ee_origin=SO_EE_ORIGIN_ZEROCOPY,
                                    ee_type=0,
                                    ee_code=SO_EE_CODE_ZEROCOPY_COPIED,
                                    ee_info=0,
                                    ee_data=0}}
                   ]}, MSG_ERRQUEUE) = 0

   // send 1B again
   +0 send(4, ..., 1, MSG_ZEROCOPY) = 1
   +0 > P. 2:3(1) ack 1
   +0 < . 1:1(0) ack 3 win 257

   +1 recvmsg(4, {msg_name(...)=...,
                  msg_iov(1)=[{...,0}],
                  msg_flags=MSG_ERRQUEUE,
                  msg_control=[
                        {cmsg_level=CMSG_LEVEL_IP,
                         cmsg_type=CMSG_TYPE_RECVERR,
                         cmsg_data={ee_errno=0,
                                    ee_origin=SO_EE_ORIGIN_ZEROCOPY,
                                    ee_type=0,
                                    ee_code=SO_EE_CODE_ZEROCOPY_COPIED,
                                    ee_info=1,
                                    ee_data=1}}
                   ]}, MSG_ERRQUEUE) = 0