File Index
Files and directories
Sign in
FILE

tcp_zerocopy_epoll_oneshot.pkt

File preview with syntax highlighting.

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