summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/net/ip_defrag.sh
diff options
context:
space:
mode:
authorPeter Oskolkov <posk@google.com>2018-08-28 21:36:20 +0300
committerDavid S. Miller <davem@davemloft.net>2018-08-30 05:49:36 +0300
commit02c7f38b7ace9f1b2ddb7a88139127eef4cf8706 (patch)
treeee62cc038df2ba4bf482ad26ed73420e355dd4b6 /tools/testing/selftests/net/ip_defrag.sh
parent0ff89efb524631ac9901b81446b453c29711c376 (diff)
downloadlinux-02c7f38b7ace9f1b2ddb7a88139127eef4cf8706.tar.xz
selftests/net: add ip_defrag selftest
This test creates a raw IPv4 socket, fragments a largish UDP datagram and sends the fragments out of order. Then repeats in a loop with different message and fragment lengths. Then does the same with overlapping fragments (with overlapping fragments the expectation is that the recv times out). Tested: root@<host># time ./ip_defrag.sh ipv4 defrag PASS ipv4 defrag with overlaps PASS real 1m7.679s user 0m0.628s sys 0m2.242s A similar test for IPv6 is to follow. Signed-off-by: Peter Oskolkov <posk@google.com> Reviewed-by: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing/selftests/net/ip_defrag.sh')
-rwxr-xr-xtools/testing/selftests/net/ip_defrag.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/testing/selftests/net/ip_defrag.sh b/tools/testing/selftests/net/ip_defrag.sh
new file mode 100755
index 000000000000..78743adcca9e
--- /dev/null
+++ b/tools/testing/selftests/net/ip_defrag.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Run a couple of IP defragmentation tests.
+
+set +x
+set -e
+
+echo "ipv4 defrag"
+
+run_v4() {
+sysctl -w net.ipv4.ipfrag_high_thresh=9000000 &> /dev/null
+sysctl -w net.ipv4.ipfrag_low_thresh=7000000 &> /dev/null
+./ip_defrag -4
+}
+export -f run_v4
+
+./in_netns.sh "run_v4"
+
+echo "ipv4 defrag with overlaps"
+run_v4o() {
+sysctl -w net.ipv4.ipfrag_high_thresh=9000000 &> /dev/null
+sysctl -w net.ipv4.ipfrag_low_thresh=7000000 &> /dev/null
+./ip_defrag -4o
+}
+export -f run_v4o
+
+./in_netns.sh "run_v4o"