Re: [PATCH RFC nf-next 2/2] selftests: netfilter: nft_concat_range.sh: add check for double-create bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 12 Sep 2025 15:20:00 +0200
Florian Westphal <fw@xxxxxxxxx> wrote:

> Add a test case for bug resolved with:
> 'netfilter: nft_set_pipapo_avx2: fix skip of expired entries'.
> 
> It passes on nf.git (it uses the generic/C version for insertion
> duplicate check) but fails on unpatched nf-next if AVX2 is supported:
> 
>   cannot create same element twice      0s                        [FAIL]
> Could create element twice in same transaction
> table inet filter { # handle 8
> [..]
>   elements = { 1.2.3.4 . 1.2.4.1 counter packets 0 bytes 0,
>                1.2.4.1 . 1.2.3.4 counter packets 0 bytes 0,
>                1.2.3.4 . 1.2.4.1 counter packets 0 bytes 0,
>                1.2.4.1 . 1.2.3.4 counter packets 0 bytes 0 }
> 
> Cc: Stefano Brivio <sbrivio@xxxxxxxxxx>
> Signed-off-by: Florian Westphal <fw@xxxxxxxxx>
> ---
>  .../net/netfilter/nft_concat_range.sh         | 38 ++++++++++++++++++-
>  1 file changed, 37 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/net/netfilter/nft_concat_range.sh b/tools/testing/selftests/net/netfilter/nft_concat_range.sh
> index 20e76b395c85..4d4d5004684c 100755
> --- a/tools/testing/selftests/net/netfilter/nft_concat_range.sh
> +++ b/tools/testing/selftests/net/netfilter/nft_concat_range.sh
> @@ -29,7 +29,7 @@ TYPES="net_port port_net net6_port port_proto net6_port_mac net6_port_mac_proto
>         net6_port_net6_port net_port_mac_proto_net"
>  
>  # Reported bugs, also described by TYPE_ variables below
> -BUGS="flush_remove_add reload net_port_proto_match avx2_mismatch"
> +BUGS="flush_remove_add reload net_port_proto_match avx2_mismatch doublecreate"
>  
>  # List of possible paths to pktgen script from kernel tree for performance tests
>  PKTGEN_SCRIPT_PATHS="
> @@ -408,6 +408,18 @@ perf_duration	0
>  "
>  
>  
> +TYPE_doublecreate="
> +display		cannot create same element twice
> +type_spec	ipv4_addr . ipv4_addr
> +chain_spec	ip saddr . ip daddr
> +dst		addr4
> +proto		icmp
> +
> +race_repeat	0
> +
> +perf_duration	0
> +"
> +
>  # Set template for all tests, types and rules are filled in depending on test
>  set_template='
>  flush ruleset
> @@ -1900,6 +1912,30 @@ test_bug_avx2_mismatch()
>  	fi
>  }
>  
> +test_bug_doublecreate()
> +{
> +	local elements="1.2.3.4 . 1.2.4.1, 1.2.4.1 . 1.2.3.4"
> +	local ret=1
> +
> +	setup veth send_"${proto}" set || return ${ksft_skip}
> +
> +	nft add element inet filter test "{ $elements }"
> +nft -f - <<EOF 2>/dev/null
> +flush set inet filter test
> +create element inet filter test { $elements }
> +create element inet filter test { $elements }
> +EOF
> +	ret=$?
> +
> +	if [ $ret -eq 0 ];then

Nit: everywhere else in this file it's 'if [ ... ]; then', with a
whitespace before 'then' (same as all the examples from POSIX without a
newline). Either way,

Reviewed-by: Stefano Brivio <sbrivio@xxxxxxxxxx>

> +		err "Could create element twice in same transaction"
> +		err "$(nft -a list ruleset)"
> +		return 1
> +	fi
> +
> +	return 0
> +}
> +
>  test_reported_issues() {
>  	eval test_bug_"${subtest}"
>  }

-- 
Stefano





[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux