Testsuite: use more reliable IP for TFO testcases
[exim.git] / test / scripts / 1090-TCP-Fast-Open / 1090
1 # TCP Fast Open
2 #
3 # Linux:
4 # Both server and client-side TFO support must be enabled in the
5 # kernel, 'sudo sh -c "echo 3 > /proc/sys/net/ipv4/tcp_fastopen"'.
6 #
7 # A packet capture on the loopback interface will show the TFO
8 # option on the SYN, but the fast-output SMTP banner will not
9 # be seen unless you also deliberately emulate a long path:
10 # 'sudo tc qdisc add dev lo root netem delay 50ms'
11 # You'll need iproute-tc installed, for the tc command.
12 # You'll need kernel-modules-extra installed, or you get
13 # an unhelpful error from RTNETLINK.
14 # To tidy up:  'sudo tc qdisc delete dev lo root'
15 #
16 # MacOS:
17 # The kernel seems to have TFO enabled both ways as default.
18 # There is a net.inet.tcp.clear_tfocache parameter
19 ## sysctl -w foo-val
20 #
21 # For network delays there is something called 'Network Link Conditioner'
22 # which might do the job.  But how to manipulate it?
23 #
24 #
25 # FreeBSD: it looks like you have to compile a custom kernel, with
26 # 'options TCP_RFC7413' in the config.  Also set
27 # 'net.inet.tcp.fastopen.server_enable=1' in /etc/sysctl.conf
28 # Seems to always claim TFO used by transport, if tried.
29 #
30 # FreeBSD: tried this setup, but we only get the banner captured 100ms after 3rd-ack:
31 # #kenv net.inet.ip.fw.default_to_accept=1
32 # #kldload ipfw dummynet
33 # #ipfw add 00097 pipe 1 ip from HOSTIPV4 to HOSTIPV4
34 # #ipfw pipe 1 config delay 50ms
35 # Also, the VM managed to lose the ipv4 & 6 addrs on its main interface
36 # after a while - so not usable in production
37 #
38 sudo perl
39 system ("tc qdisc add dev lo root netem delay 50ms");
40 ****
41 #
42 #
43 # Disable the TFO blackhole detection, as we seem to be running foul of it.
44 # If bitten, we see the expected EINPROGRESS for sendto, yet no TFO cookie
45 # option on the SYN.
46 #
47 sudo perl
48 system ("[ -e /proc/sys/net/ipv4/tcp_fastopen_blackhole_timeout_sec ] && echo 0 > /proc/sys/net/ipv4/tcp_fastopen_blackhole_timeout_sec");
49 ****
50 #
51 # First time runs will see a TFO request option only; subsequent
52 # ones should see the TFO cookie and fast-output SMTP banner
53 # (currently on a separate packet after the server SYN,ACK but before
54 # the client ACK).
55 #
56 # The client log => line  should have a "TFO" element.
57 # The server log <= line for no_cookie@test.ex  should not.
58 #
59 # First clear any previously-obtained cookie:
60 sudo perl
61 open(INFO, "-|", "/usr/bin/uname -s");
62 $_ = <INFO>;
63 if (/^FreeBSD/) {
64 system("sysctl net.inet.tcp.fastopen.client_enable=0"); system("sysctl net.inet.tcp.fastopen.client_enable=1");
65 } else {
66 system ("ip tcp_metrics delete HOSTIPV4");
67 }
68
69 ****
70 #
71 #
72 #
73 exim -DSERVER=server -bd -oX PORT_D
74 ****
75 #
76 exim no_cookie@test.ex
77 Testing
78 ****
79 sleep 3
80 #
81 # The server log <= line for with_cookie@test.ex  should have a "TFO" element, but
82 # this will only be obtained when the above delay is inserted into the
83 # loopback net path.
84 #
85 exim with_cookie@test.ex
86 Testing
87 ****
88 sleep 3
89 #
90 #
91 sudo perl
92 system ("tc qdisc delete dev lo root");
93 system ("[ -e /proc/sys/net/ipv4/tcp_fastopen_blackhole_timeout_sec ] && echo 3600 > /proc/sys/net/ipv4/tcp_fastopen_blackhole_timeout_sec");
94 ****
95 #
96 killdaemon
97 no_msglog_check