selftests: netfilter: add packetdrill based conntrack tests
authorFlorian Westphal <fw@strlen.de>
Tue, 7 May 2024 11:02:10 +0000 (13:02 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 10 May 2024 09:13:45 +0000 (11:13 +0200)
commita8a388c2aae490c08d59a6c15d15a968fea5089a
treed254ecac5f74bdaa8c62b95644099365554b69c4
parent532aec7e878b527fcee8877350ab5c5341789626
selftests: netfilter: add packetdrill based conntrack tests

Add a new test script that uses packetdrill tool to exercise conntrack
state machine.

Needs ip/ip6tables and conntrack tool (to check if we have an entry in
the expected state).

Test cases added here cover following scenarios:
1. already-acked (retransmitted) packets are not tagged as INVALID
2. RST packet coming when conntrack is already closing (FIN/CLOSE_WAIT)
  transitions conntrack to CLOSE even if the RST is not an exact match
3. RST packets with out-of-window sequence numbers are marked as INVALID
4. SYN+Challenge ACK: check that challenge ack is allowed to pass
5. Old SYN/ACK: check conntrack handles the case where SYN is answered
  with SYN/ACK for an old, previous connection attempt
6. Check SYN reception while in ESTABLISHED state generates a challenge
   ack, RST response clears 'outdated' state + next SYN retransmit gets
   us into 'SYN_RECV' conntrack state.

Tests get run twice, once with ipv4 and once with ipv6.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tools/testing/selftests/net/netfilter/Makefile
tools/testing/selftests/net/netfilter/config
tools/testing/selftests/net/netfilter/nf_conntrack_packetdrill.sh [new file with mode: 0755]
tools/testing/selftests/net/netfilter/packetdrill/common.sh [new file with mode: 0755]
tools/testing/selftests/net/netfilter/packetdrill/conntrack_ack_loss_stall.pkt [new file with mode: 0644]
tools/testing/selftests/net/netfilter/packetdrill/conntrack_inexact_rst.pkt [new file with mode: 0644]
tools/testing/selftests/net/netfilter/packetdrill/conntrack_rst_invalid.pkt [new file with mode: 0644]
tools/testing/selftests/net/netfilter/packetdrill/conntrack_syn_challenge_ack.pkt [new file with mode: 0644]
tools/testing/selftests/net/netfilter/packetdrill/conntrack_synack_old.pkt [new file with mode: 0644]
tools/testing/selftests/net/netfilter/packetdrill/conntrack_synack_reuse.pkt [new file with mode: 0644]