Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1// SPDX-License-Identifier: GPL-2.0
2// Test for blocking write.
3--tolerance_usecs=10000
4
5`./defaults.sh
6./set_sysctls.py /proc/sys/net/ipv4/tcp_min_tso_segs=10
7`
8
9// Establish a connection.
10 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
11 +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
12 +0 bind(3, ..., ...) = 0
13 +0 listen(3, 1) = 0
14
15 +.1 < S 0:0(0) win 50000 <mss 1000,nop,wscale 0>
16 +0 > S. 0:0(0) ack 1 <mss 1460,nop,wscale 8>
17 +.1 < . 1:1(0) ack 1 win 50000
18 +0 accept(3, ..., ...) = 4
19
20// Kernel doubles our value -> sk->sk_sndbuf is set to 42000
21 +0 setsockopt(4, SOL_SOCKET, SO_SNDBUF, [21000], 4) = 0
22 +0 getsockopt(4, SOL_SOCKET, SO_SNDBUF, [42000], [4]) = 0
23
24// A write of 60000 does not block.
25 +0...0.300 write(4, ..., 61000) = 61000 // this write() blocks
26
27 +.1 < . 1:1(0) ack 10001 win 50000
28
29 +.1 < . 1:1(0) ack 30001 win 50000
30
31// This ACK should wakeup the write(). An ACK of 35001 does not.
32 +.1 < . 1:1(0) ack 36001 win 50000
33
34// Reset to sysctls defaults.
35`/tmp/sysctl_restore_${PPID}.sh`