• Petar Penkov's avatar
    selftests/bpf: fix race in flow dissector tests · 9840a4ff
    Petar Penkov authored
    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: 0905beec ("selftests/bpf: run flow dissector tests in skb-less mode")
    Signed-off-by: default avatarPetar Penkov <ppenkov@google.com>
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    9840a4ff
flow_dissector.c 12.8 KB