xref: /linux/tools/testing/selftests/net/packetdrill/tcp_zerocopy_epoll_edge.pkt (revision d30c1683aaecb93d2ab95685dc4300a33d3cea7a)
1// SPDX-License-Identifier: GPL-2.0
2// epoll zerocopy test:
3//
4// EPOLLERR is known to be not edge-triggered unlike EPOLLIN and EPOLLOUT but
5// it is not level-triggered either.
6//
7// fire two sends with MSG_ZEROCOPY and receive the acks. confirm that EPOLLERR
8// is correctly fired only once, when EPOLLET is set. send another packet with
9// MSG_ZEROCOPY. confirm that EPOLLERR is correctly fired again only once.
10
11--send_omit_free	// do not reuse send buffers with zerocopy
12
13`./defaults.sh`
14
15    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
16   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
17   +0 setsockopt(3, SOL_SOCKET, SO_ZEROCOPY, [1], 4) = 0
18   +0 bind(3, ..., ...) = 0
19   +0 listen(3, 1) = 0
20
21   +0 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
22   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
23   +0 < . 1:1(0) ack 1 win 257
24
25   +0 accept(3, ..., ...) = 4
26
27   +0 fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK) = 0
28   +0 epoll_create(1) = 5
29   +0 epoll_ctl(5, EPOLL_CTL_ADD, 4, {events=EPOLLOUT|EPOLLET, fd=4}) = 0
30   +0 epoll_wait(5, {events=EPOLLOUT, fd=4}, 1, 0) = 1
31
32   +0 send(4, ..., 4000, MSG_ZEROCOPY) = 4000
33   +0 > P. 1:4001(4000) ack 1
34   +0 < . 1:1(0) ack 4001 win 257
35
36   +0 send(4, ..., 4000, MSG_ZEROCOPY) = 4000
37   +0 > P. 4001:8001(4000) ack 1
38   +0 < . 1:1(0) ack 8001 win 257
39
40// receive only one EPOLLERR for the two sends above.
41   +0 epoll_wait(5, {events=EPOLLERR|EPOLLOUT, fd=4}, 1, 0) = 1
42   +0 epoll_wait(5, {events=0, ptr=0}, 1, 0) = 0
43
44   +0 send(4, ..., 4000, MSG_ZEROCOPY) = 4000
45   +0 > P. 8001:12001(4000) ack 1
46   +0 < . 1:1(0) ack 12001 win 257
47
48// receive only one EPOLLERR for the third send above.
49   +0 epoll_wait(5, {events=EPOLLERR|EPOLLOUT, fd=4}, 1, 0) = 1
50   +0 epoll_wait(5, {events=0, ptr=0}, 1, 0) = 0
51
52   +0 recvmsg(4, {msg_name(...)=...,
53                  msg_iov(1)=[{...,0}],
54                  msg_flags=MSG_ERRQUEUE,
55                  msg_control=[
56                        {cmsg_level=CMSG_LEVEL_IP,
57                         cmsg_type=CMSG_TYPE_RECVERR,
58                         cmsg_data={ee_errno=0,
59                                    ee_origin=SO_EE_ORIGIN_ZEROCOPY,
60                                    ee_type=0,
61                                    ee_code=SO_EE_CODE_ZEROCOPY_COPIED,
62                                    ee_info=0,
63                                    ee_data=2}}
64                   ]}, MSG_ERRQUEUE) = 0
65