summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/net/packetdrill/tcp_zerocopy_maxfrags.pkt
blob: 672f817faca0d16b773af431f48134e05bbf39a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// SPDX-License-Identifier: GPL-2.0
// tcp_MAX_SKB_FRAGS test
//
// Verify that sending an iovec of tcp_MAX_SKB_FRAGS + 1 elements will
// 1) fit in a single packet without zerocopy
// 2) spill over into a second packet with zerocopy,
//    because each iovec element becomes a frag
// 3) the PSH bit is set on an skb when it runs out of fragments

`./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

   // Each pinned zerocopy page is fully accounted to skb->truesize.
   // This test generates a worst case packet with each frag storing
   // one byte, but increasing truesize with a page (64KB on PPC).
   +0 setsockopt(3, SOL_SOCKET, SO_SNDBUF, [2000000], 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 an iov of 18 elements: just becomes a linear skb
   +0 sendmsg(4, {msg_name(...)=...,
		  msg_iov(18)=[{..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}],
		  msg_flags=0}, 0) = 18

   +0 > P. 1:19(18) ack 1
   +0 < . 1:1(0) ack 19 win 257

   // send a zerocopy iov of 18 elements:
   +1 sendmsg(4, {msg_name(...)=...,
		  msg_iov(18)=[{..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}],
		  msg_flags=0}, MSG_ZEROCOPY) = 18

   // verify that it is split in one skb of 17 frags + 1 of 1 frag
   // verify that both have the PSH bit set
   +0 > P. 19:36(17) ack 1
   +0 < . 1:1(0) ack 36 win 257

   +0 > P. 36:37(1) ack 1
   +0 < . 1:1(0) ack 37 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 a zerocopy iov of 64 elements:
   +0 sendmsg(4, {msg_name(...)=...,
                  msg_iov(64)=[{..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1},
			       {..., 1}, {..., 1}, {..., 1}, {..., 1}],
                  msg_flags=0}, MSG_ZEROCOPY) = 64

   // verify that it is split in skbs with 17 frags
   +0 > P. 37:54(17) ack 1
   +0 < . 1:1(0) ack 54 win 257

   +0 > P. 54:71(17) ack 1
   +0 < . 1:1(0) ack 71 win 257

   +0 > P. 71:88(17) ack 1
   +0 < . 1:1(0) ack 88 win 257

   +0 > P. 88:101(13) ack 1
   +0 < . 1:1(0) ack 101 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