1// SPDX-License-Identifier: GPL-2.0 2// tcp_MAX_SKB_FRAGS test 3// 4// Verify that sending an iovec of tcp_MAX_SKB_FRAGS + 1 elements will 5// 1) fit in a single packet without zerocopy 6// 2) spill over into a second packet with zerocopy, 7// because each iovec element becomes a frag 8// 3) the PSH bit is set on an skb when it runs out of fragments 9 10--send_omit_free // do not reuse send buffers with zerocopy 11 12`./defaults.sh` 13 14 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 15 +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 16 +0 setsockopt(3, SOL_SOCKET, SO_ZEROCOPY, [1], 4) = 0 17 18 // Each pinned zerocopy page is fully accounted to skb->truesize. 19 // This test generates a worst case packet with each frag storing 20 // one byte, but increasing truesize with a page (64KB on PPC). 21 +0 setsockopt(3, SOL_SOCKET, SO_SNDBUF, [2000000], 4) = 0 22 23 +0 bind(3, ..., ...) = 0 24 +0 listen(3, 1) = 0 25 26 +0 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7> 27 +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8> 28 +0 < . 1:1(0) ack 1 win 257 29 30 +0 accept(3, ..., ...) = 4 31 32 // send an iov of 18 elements: just becomes a linear skb 33 +0 sendmsg(4, {msg_name(...)=..., 34 msg_iov(18)=[{..., 1}, {..., 1}, {..., 1}, {..., 1}, 35 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 36 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 37 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 38 {..., 1}, {..., 1}], 39 msg_flags=0}, 0) = 18 40 41 +0 > P. 1:19(18) ack 1 42 +0 < . 1:1(0) ack 19 win 257 43 44 // send a zerocopy iov of 18 elements: 45 +1 sendmsg(4, {msg_name(...)=..., 46 msg_iov(18)=[{..., 1}, {..., 1}, {..., 1}, {..., 1}, 47 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 48 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 49 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 50 {..., 1}, {..., 1}], 51 msg_flags=0}, MSG_ZEROCOPY) = 18 52 53 // verify that it is split in one skb of 17 frags + 1 of 1 frag 54 // verify that both have the PSH bit set 55 +0 > P. 19:36(17) ack 1 56 +0 < . 1:1(0) ack 36 win 257 57 58 +0 > P. 36:37(1) ack 1 59 +0 < . 1:1(0) ack 37 win 257 60 61 +1 recvmsg(4, {msg_name(...)=..., 62 msg_iov(1)=[{...,0}], 63 msg_flags=MSG_ERRQUEUE, 64 msg_control=[ 65 {cmsg_level=CMSG_LEVEL_IP, 66 cmsg_type=CMSG_TYPE_RECVERR, 67 cmsg_data={ee_errno=0, 68 ee_origin=SO_EE_ORIGIN_ZEROCOPY, 69 ee_type=0, 70 ee_code=SO_EE_CODE_ZEROCOPY_COPIED, 71 ee_info=0, 72 ee_data=0}} 73 ]}, MSG_ERRQUEUE) = 0 74 75 // send a zerocopy iov of 64 elements: 76 +0 sendmsg(4, {msg_name(...)=..., 77 msg_iov(64)=[{..., 1}, {..., 1}, {..., 1}, {..., 1}, 78 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 79 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 80 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 81 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 82 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 83 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 84 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 85 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 86 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 87 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 88 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 89 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 90 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 91 {..., 1}, {..., 1}, {..., 1}, {..., 1}, 92 {..., 1}, {..., 1}, {..., 1}, {..., 1}], 93 msg_flags=0}, MSG_ZEROCOPY) = 64 94 95 // verify that it is split in skbs with 17 frags 96 +0 > P. 37:54(17) ack 1 97 +0 < . 1:1(0) ack 54 win 257 98 99 +0 > P. 54:71(17) ack 1 100 +0 < . 1:1(0) ack 71 win 257 101 102 +0 > P. 71:88(17) ack 1 103 +0 < . 1:1(0) ack 88 win 257 104 105 +0 > P. 88:101(13) ack 1 106 +0 < . 1:1(0) ack 101 win 257 107 108 +1 recvmsg(4, {msg_name(...)=..., 109 msg_iov(1)=[{...,0}], 110 msg_flags=MSG_ERRQUEUE, 111 msg_control=[ 112 {cmsg_level=CMSG_LEVEL_IP, 113 cmsg_type=CMSG_TYPE_RECVERR, 114 cmsg_data={ee_errno=0, 115 ee_origin=SO_EE_ORIGIN_ZEROCOPY, 116 ee_type=0, 117 ee_code=SO_EE_CODE_ZEROCOPY_COPIED, 118 ee_info=1, 119 ee_data=1}} 120 ]}, MSG_ERRQUEUE) = 0 121