diff mbox series

[nf,2/2] selftests: netfilter: Add correctness test for mac,net set type

Message ID 142425004cc8d6bc6777fef933d3f290491f87c4.1637976889.git.sbrivio@redhat.com
State Accepted
Delegated to: Pablo Neira
Headers show
Series nft_set_pipapo: Fix AVX2 MAC address match, add test | expand

Commit Message

Stefano Brivio Nov. 27, 2021, 10:33 a.m. UTC
The existing net,mac test didn't cover the issue recently reported
by Nikita Yushchenko, where MAC addresses wouldn't match if given
as first field of a concatenated set with AVX2 and 8-bit groups,
because there's a different code path covering the lookup of six
8-bit groups (MAC addresses) if that's the first field.

Add a similar mac,net test, with MAC address and IPv4 address
swapped in the set specification.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
---
 .../selftests/netfilter/nft_concat_range.sh   | 24 ++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

Comments

Greg Kroah-Hartman Nov. 27, 2021, 11:22 a.m. UTC | #1
On Sat, Nov 27, 2021 at 11:33:38AM +0100, Stefano Brivio wrote:
> The existing net,mac test didn't cover the issue recently reported
> by Nikita Yushchenko, where MAC addresses wouldn't match if given
> as first field of a concatenated set with AVX2 and 8-bit groups,
> because there's a different code path covering the lookup of six
> 8-bit groups (MAC addresses) if that's the first field.
> 
> Add a similar mac,net test, with MAC address and IPv4 address
> swapped in the set specification.
> 
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
> ---
>  .../selftests/netfilter/nft_concat_range.sh   | 24 ++++++++++++++++---
>  1 file changed, 21 insertions(+), 3 deletions(-)

<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>
Stefano Brivio Nov. 27, 2021, 12:42 p.m. UTC | #2
Hi Greg,

On Sat, 27 Nov 2021 12:22:39 +0100
Greg KH <gregkh@linuxfoundation.org> wrote:

> On Sat, Nov 27, 2021 at 11:33:38AM +0100, Stefano Brivio wrote:
> > The existing net,mac test didn't cover the issue recently reported
> > by Nikita Yushchenko, where MAC addresses wouldn't match if given
> > as first field of a concatenated set with AVX2 and 8-bit groups,
> > because there's a different code path covering the lookup of six
> > 8-bit groups (MAC addresses) if that's the first field.
> > 
> > Add a similar mac,net test, with MAC address and IPv4 address
> > swapped in the set specification.
> > 
> > Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
> > ---
> >  .../selftests/netfilter/nft_concat_range.sh   | 24 ++++++++++++++++---
> >  1 file changed, 21 insertions(+), 3 deletions(-)  
> 
> <formletter>
> 
> This is not the correct way to submit patches for inclusion in the
> stable kernel tree.  Please read:
>     https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
> for how to do this properly.
> 
> </formletter>

This patch (2/2) is not intended for the stable kernel tree, only patch
1/2 is. I Cc'ed stable@kernel.org on the whole series for context.
diff mbox series

Patch

diff --git a/tools/testing/selftests/netfilter/nft_concat_range.sh b/tools/testing/selftests/netfilter/nft_concat_range.sh
index 5a4938d6dcf2..ed61f6cab60f 100755
--- a/tools/testing/selftests/netfilter/nft_concat_range.sh
+++ b/tools/testing/selftests/netfilter/nft_concat_range.sh
@@ -23,8 +23,8 @@  TESTS="reported_issues correctness concurrency timeout"
 
 # Set types, defined by TYPE_ variables below
 TYPES="net_port port_net net6_port port_proto net6_port_mac net6_port_mac_proto
-       net_port_net net_mac net_mac_icmp net6_mac_icmp net6_port_net6_port
-       net_port_mac_proto_net"
+       net_port_net net_mac mac_net net_mac_icmp net6_mac_icmp
+       net6_port_net6_port net_port_mac_proto_net"
 
 # Reported bugs, also described by TYPE_ variables below
 BUGS="flush_remove_add"
@@ -277,6 +277,23 @@  perf_entries	1000
 perf_proto	ipv4
 "
 
+TYPE_mac_net="
+display		mac,net
+type_spec	ether_addr . ipv4_addr
+chain_spec	ether saddr . ip saddr
+dst		 
+src		mac addr4
+start		1
+count		5
+src_delta	2000
+tools		sendip nc bash
+proto		udp
+
+race_repeat	0
+
+perf_duration	0
+"
+
 TYPE_net_mac_icmp="
 display		net,mac - ICMP
 type_spec	ipv4_addr . ether_addr
@@ -984,7 +1001,8 @@  format() {
 		fi
 	done
 	for f in ${src}; do
-		__expr="${__expr} . "
+		[ "${__expr}" != "{ " ] && __expr="${__expr} . "
+
 		__start="$(eval format_"${f}" "${srcstart}")"
 		__end="$(eval format_"${f}" "${srcend}")"