aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKristof Provost <kp@FreeBSD.org>2018-08-17 15:02:58 +0000
committerKristof Provost <kp@FreeBSD.org>2018-08-17 15:02:58 +0000
commit2848a0e2da030de96b64f8b138855f1596afa8db (patch)
tree61717dbe8197030296cbe905d83d3a38170a1a3a /tests
parenta8e93e3cd70d65212d59ee3a9bfcbb0916b04464 (diff)
downloadsrc-2848a0e2da030de96b64f8b138855f1596afa8db.tar.gz
src-2848a0e2da030de96b64f8b138855f1596afa8db.zip
pf tests: Verify that pf limits the number of fragments per packet
Test the limitation on number of frames per packet introduced in pf in r337969. Sponsored by: Klara Systems
Notes
Notes: svn path=/head/; revision=337971
Diffstat (limited to 'tests')
-rwxr-xr-xtests/sys/netpfil/pf/fragmentation.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/sys/netpfil/pf/fragmentation.sh b/tests/sys/netpfil/pf/fragmentation.sh
index 3ef939582411..2a9811d748a1 100755
--- a/tests/sys/netpfil/pf/fragmentation.sh
+++ b/tests/sys/netpfil/pf/fragmentation.sh
@@ -2,6 +2,49 @@
. $(atf_get_srcdir)/utils.subr
+atf_test_case "too_many_fragments" "cleanup"
+
+too_many_fragments_head()
+{
+ atf_set descr 'IPv4 fragment limitation test'
+ atf_set require.user root
+}
+
+too_many_fragments_body()
+{
+ pft_init
+
+ epair=$(pft_mkepair)
+ pft_mkjail alcatraz ${epair}a
+
+ ifconfig ${epair}b inet 192.0.2.1/24 up
+ jexec alcatraz ifconfig ${epair}a 192.0.2.2/24 up
+
+ ifconfig ${epair}b mtu 200
+ jexec alcatraz ifconfig ${epair}a mtu 200
+
+ jexec alcatraz pfctl -e
+ pft_set_rules alcatraz \
+ "scrub all fragment reassemble"
+
+ # So we know pf is limiting things
+ jexec alcatraz sysctl net.inet.ip.maxfragsperpacket=1024
+
+ # Sanity check
+ atf_check -s exit:0 -o ignore ping -c 1 192.0.2.2
+
+ # We can ping with < 64 fragments
+ atf_check -s exit:0 -o ignore ping -c 1 -s 800 192.0.2.2
+
+ # Too many fragments should fail
+ atf_check -s exit:2 -o ignore ping -c 1 -s 20000 192.0.2.2
+}
+
+too_many_fragments_cleanup()
+{
+ pft_cleanup
+}
+
atf_test_case "v6" "cleanup"
v6_head()
{
@@ -70,5 +113,6 @@ v6_cleanup()
atf_init_test_cases()
{
+ atf_add_test_case "too_many_fragments"
atf_add_test_case "v6"
}