linux/tools/testing/selftests/net/packetdrill/defaults.sh
Willem de Bruijn 8a405552fd selftests/net: integrate packetdrill with ksft
Lay the groundwork to import into kselftests the over 150 packetdrill
TCP/IP conformance tests on github.com/google/packetdrill.

Florian recently added support for packetdrill tests in nf_conntrack,
in commit a8a388c2aa ("selftests: netfilter: add packetdrill based
conntrack tests").

This patch takes a slightly different approach. It relies on
ksft_runner.sh to run every *.pkt file in the directory.

Any future imports of packetdrill tests should require no additional
coding. Just add the *.pkt files.

Initially import only two features/directories from github. One with a
single script, and one with two. This was the only reason to pick
tcp/inq and tcp/md5.

The path replaces the directory hierarchy in github with a flat space
of files: $(subst /,_,$(wildcard tcp/**/*.pkt)). This is the most
straightforward option to integrate with kselftests. The Linked thread
reviewed two ways to maintain the hierarchy: TEST_PROGS_RECURSE and
PRESERVE_TEST_DIRS. But both introduce significant changes to
kselftest infra and with that risk to existing tests.

Implementation notes:
- restore alphabetical order when adding the new directory to
  tools/testing/selftests/Makefile
- imported *.pkt files and support verbatim from the github project,
  except for
    - update `source ./defaults.sh` path (to adjust for flat dir)
    - add SPDX headers
    - remove one author statement
    - Acknowledgment: drop an e (checkpatch)

Tested:
	make -C tools/testing/selftests \
	  TARGETS=net/packetdrill \
	  run_tests

	make -C tools/testing/selftests \
	  TARGETS=net/packetdrill \
	  install INSTALL_PATH=$KSFT_INSTALL_PATH

	# in virtme-ng
	./run_kselftest.sh -c net/packetdrill
	./run_kselftest.sh -t net/packetdrill:tcp_inq_client.pkt

Link: https://lore.kernel.org/netdev/20240827193417.2792223-1-willemdebruijn.kernel@gmail.com/
Signed-off-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20240905231653.2427327-3-willemdebruijn.kernel@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-09-09 17:38:02 -07:00

64 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Set standard production config values that relate to TCP behavior.
# Flush old cached data (fastopen cookies).
ip tcp_metrics flush all > /dev/null 2>&1
# TCP min, default, and max receive and send buffer sizes.
sysctl -q net.ipv4.tcp_rmem="4096 540000 $((15*1024*1024))"
sysctl -q net.ipv4.tcp_wmem="4096 $((256*1024)) 4194304"
# TCP timestamps.
sysctl -q net.ipv4.tcp_timestamps=1
# TCP SYN(ACK) retry thresholds
sysctl -q net.ipv4.tcp_syn_retries=5
sysctl -q net.ipv4.tcp_synack_retries=5
# TCP Forward RTO-Recovery, RFC 5682.
sysctl -q net.ipv4.tcp_frto=2
# TCP Selective Acknowledgements (SACK)
sysctl -q net.ipv4.tcp_sack=1
# TCP Duplicate Selective Acknowledgements (DSACK)
sysctl -q net.ipv4.tcp_dsack=1
# TCP FACK (Forward Acknowldgement)
sysctl -q net.ipv4.tcp_fack=0
# TCP reordering degree ("dupthresh" threshold for entering Fast Recovery).
sysctl -q net.ipv4.tcp_reordering=3
# TCP congestion control.
sysctl -q net.ipv4.tcp_congestion_control=cubic
# TCP slow start after idle.
sysctl -q net.ipv4.tcp_slow_start_after_idle=0
# TCP RACK and TLP.
sysctl -q net.ipv4.tcp_early_retrans=4 net.ipv4.tcp_recovery=1
# TCP method for deciding when to defer sending to accumulate big TSO packets.
sysctl -q net.ipv4.tcp_tso_win_divisor=3
# TCP Explicit Congestion Notification (ECN)
sysctl -q net.ipv4.tcp_ecn=0
sysctl -q net.ipv4.tcp_pacing_ss_ratio=200
sysctl -q net.ipv4.tcp_pacing_ca_ratio=120
sysctl -q net.ipv4.tcp_notsent_lowat=4294967295 > /dev/null 2>&1
sysctl -q net.ipv4.tcp_fastopen=0x70403
sysctl -q net.ipv4.tcp_fastopen_key=a1a1a1a1-b2b2b2b2-c3c3c3c3-d4d4d4d4
sysctl -q net.ipv4.tcp_syncookies=1
# Override the default qdisc on the tun device.
# Many tests fail with timing errors if the default
# is FQ and that paces their flows.
tc qdisc add dev tun0 root pfifo