1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4source lib.sh
5
6checktool "conntrack --version" "run test without conntrack"
7checktool "iptables --version" "run test without iptables"
8checktool "ip6tables --version" "run test without ip6tables"
9
10modprobe -q tun
11modprobe -q nf_conntrack
12# echo 1 > /proc/sys/net/netfilter/nf_log_all_netns
13
14PDRILL_TIMEOUT=10
15
16files="
17conntrack_ack_loss_stall.pkt
18conntrack_inexact_rst.pkt
19conntrack_syn_challenge_ack.pkt
20conntrack_synack_old.pkt
21conntrack_synack_reuse.pkt
22conntrack_rst_invalid.pkt
23"
24
25if ! packetdrill --dry_run --verbose "packetdrill/conntrack_ack_loss_stall.pkt";then
26	echo "SKIP: packetdrill not installed"
27	exit ${ksft_skip}
28fi
29
30ret=0
31
32run_packetdrill()
33{
34	filename="$1"
35	ipver="$2"
36	local mtu=1500
37
38	export NFCT_IP_VERSION="$ipver"
39
40	if [ "$ipver" = "ipv4" ];then
41		export xtables="iptables"
42	elif [ "$ipver" = "ipv6" ];then
43		export xtables="ip6tables"
44		mtu=1520
45	fi
46
47	timeout "$PDRILL_TIMEOUT" unshare -n packetdrill --ip_version="$ipver" --mtu=$mtu \
48		--tolerance_usecs=1000000 --non_fatal packet "$filename"
49}
50
51run_one_test_file()
52{
53	filename="$1"
54
55	for v in ipv4 ipv6;do
56		printf "%-50s(%s)%-20s" "$filename" "$v" ""
57		if run_packetdrill packetdrill/"$f" "$v";then
58			echo OK
59		else
60			echo FAIL
61			ret=1
62		fi
63	done
64}
65
66echo "Replaying packetdrill test cases:"
67for f in $files;do
68	run_one_test_file packetdrill/"$f"
69done
70
71exit $ret
72