]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: fix race in flow dissector tests
authorPetar Penkov <ppenkov@google.com>
Mon, 12 Aug 2019 23:30:39 +0000 (16:30 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 13 Aug 2019 14:31:10 +0000 (16:31 +0200)
commitf5ac0214b40b1019292ff00e5f69df36899fae97
tree5b8fa71c24e314f5c38f7ab7bab4212e30f24ecf
parent86cded5d7e2f0a4e1e774c073b66f5a057b62359
selftests/bpf: fix race in flow dissector tests

Since the "last_dissection" map holds only the flow keys for the most
recent packet, there is a small race in the skb-less flow dissector
tests if a new packet comes between transmitting the test packet, and
reading its keys from the map. If this happens, the test packet keys
will be overwritten and the test will fail.

Changing the "last_dissection" map to a hash map, keyed on the
source/dest port pair resolves this issue. Additionally, let's clear the
last test results from the map between tests to prevent previous test
cases from interfering with the following test cases.

Fixes: 389fad8d32fc ("selftests/bpf: run flow dissector tests in skb-less mode")
Signed-off-by: Petar Penkov <ppenkov@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/testing/selftests/bpf/prog_tests/flow_dissector.c
tools/testing/selftests/bpf/progs/bpf_flow.c