diff options
author | Yoshiki Komachi <komachi.yoshiki@gmail.com> | 2020-01-17 10:05:33 +0300 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2020-01-27 13:25:07 +0300 |
commit | 265bb359061db6ef825dec3912f341a604966371 (patch) | |
tree | d8a90788a7a29307fd509bbf2761f024b4a902f8 /tools | |
parent | 59fb9b62fb6c929a756563152a89f39b07cf8893 (diff) | |
download | linux-265bb359061db6ef825dec3912f341a604966371.tar.xz |
selftests/bpf: Add test based on port range for BPF flow dissector
Add a simple test to make sure that a filter based on specified port
range classifies packets correctly.
Signed-off-by: Yoshiki Komachi <komachi.yoshiki@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Petar Penkov <ppenkov@google.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20200117070533.402240-3-komachi.yoshiki@gmail.com
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/testing/selftests/bpf/test_flow_dissector.sh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/test_flow_dissector.sh b/tools/testing/selftests/bpf/test_flow_dissector.sh index a8485ae103d1..174b72a64a4c 100755 --- a/tools/testing/selftests/bpf/test_flow_dissector.sh +++ b/tools/testing/selftests/bpf/test_flow_dissector.sh @@ -139,6 +139,20 @@ echo "Testing IPv4 + GRE..." tc filter del dev lo ingress pref 1337 +echo "Testing port range..." +# Drops all IP/UDP packets coming from port 8-10 +tc filter add dev lo parent ffff: protocol ip pref 1337 flower ip_proto \ + udp src_port 8-10 action drop + +# Send 10 IPv4/UDP packets from port 7. Filter should not drop any. +./test_flow_dissector -i 4 -f 7 +# Send 10 IPv4/UDP packets from port 9. Filter should drop all. +./test_flow_dissector -i 4 -f 9 -F +# Send 10 IPv4/UDP packets from port 11. Filter should not drop any. +./test_flow_dissector -i 4 -f 11 + +tc filter del dev lo ingress pref 1337 + echo "Testing IPv6..." # Drops all IPv6/UDP packets coming from port 9 tc filter add dev lo parent ffff: protocol ipv6 pref 1337 flower ip_proto \ |