diff mbox series

[net-next,v2,6/6] selftests: forwarding: tc_actions: test vlan flush

Message ID 20240814130618.2885431-7-boris.sukholitko@broadcom.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series tc: adjust network header after 2nd vlan push | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 7 this patch: 7
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 2 maintainers not CCed: shuah@kernel.org linux-kselftest@vger.kernel.org
netdev/build_clang success Errors and warnings before: 7 this patch: 7
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success net selftest script(s) already in Makefile
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch warning WARNING: line length of 88 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Boris Sukholitko Aug. 14, 2024, 1:06 p.m. UTC
Add new test checking the correctness of inner vlan flushing to the skb
data when outer vlan tag is added through act_vlan.

Signed-off-by: Boris Sukholitko <boris.sukholitko@broadcom.com>
---
 .../selftests/net/forwarding/tc_actions.sh    | 22 ++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

Comments

Ido Schimmel Aug. 14, 2024, 3:37 p.m. UTC | #1
On Wed, Aug 14, 2024 at 04:06:18PM +0300, Boris Sukholitko wrote:
> Add new test checking the correctness of inner vlan flushing to the skb
> data when outer vlan tag is added through act_vlan.
> 
> Signed-off-by: Boris Sukholitko <boris.sukholitko@broadcom.com>
> ---
>  .../selftests/net/forwarding/tc_actions.sh    | 22 ++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/net/forwarding/tc_actions.sh b/tools/testing/selftests/net/forwarding/tc_actions.sh
> index 589629636502..65ff80d66b17 100755
> --- a/tools/testing/selftests/net/forwarding/tc_actions.sh
> +++ b/tools/testing/selftests/net/forwarding/tc_actions.sh
> @@ -4,7 +4,7 @@
>  ALL_TESTS="gact_drop_and_ok_test mirred_egress_redirect_test \
>  	mirred_egress_mirror_test matchall_mirred_egress_mirror_test \
>  	gact_trap_test mirred_egress_to_ingress_test \
> -	mirred_egress_to_ingress_tcp_test"
> +	mirred_egress_to_ingress_tcp_test vlan_flush_test"
>  NUM_NETIFS=4
>  source tc_common.sh
>  source lib.sh
> @@ -244,6 +244,26 @@ mirred_egress_to_ingress_tcp_test()
>  	log_test "mirred_egress_to_ingress_tcp ($tcflags)"
>  }
>  
> +vlan_flush_test()
> +{
> +	ip link add x$h1 type veth peer x$h2
> +	ip link set x$h1 up
> +	ip link set x$h2 up

The test already creates the needed topology, there is no need to create
more interfaces. You can use $h1 and $swp1 which are either a veth pair
(default if you didn't configure anything) or two connected physical
ports.

> +
> +	tc qdisc add dev x$h1 clsact
> +	tc filter add dev x$h1 ingress pref 20 chain 0 handle 20 flower num_of_vlans 1 \

Please use $tcflags like other test cases.

> +		action vlan push id 100 protocol 0x8100 action goto chain 5
> +	tc filter add dev x$h1 ingress pref 30 chain 5 handle 30 flower num_of_vlans 2 \

The cover letter says that the bug also exists on egress so I suggest
checking that as well to avoid future regressions.

> +		cvlan_ethtype 0x800 action pass
> +
> +	$MZ x$h2 -t udp -Q 10 -q

For consistency, please invoke $MZ with similar parameters to other test
cases.

> +	tc_check_packets "dev x$h1 ingress" 30 1
> +	check_err $? "No double-vlan packets received"
> +
> +	ip link del x$h1
> +	log_test "vlan_flush_test ($tcflags)"
> +}
> +
>  setup_prepare()
>  {
>  	h1=${NETIFS[p1]}
> -- 
> 2.42.0
> 
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/forwarding/tc_actions.sh b/tools/testing/selftests/net/forwarding/tc_actions.sh
index 589629636502..65ff80d66b17 100755
--- a/tools/testing/selftests/net/forwarding/tc_actions.sh
+++ b/tools/testing/selftests/net/forwarding/tc_actions.sh
@@ -4,7 +4,7 @@ 
 ALL_TESTS="gact_drop_and_ok_test mirred_egress_redirect_test \
 	mirred_egress_mirror_test matchall_mirred_egress_mirror_test \
 	gact_trap_test mirred_egress_to_ingress_test \
-	mirred_egress_to_ingress_tcp_test"
+	mirred_egress_to_ingress_tcp_test vlan_flush_test"
 NUM_NETIFS=4
 source tc_common.sh
 source lib.sh
@@ -244,6 +244,26 @@  mirred_egress_to_ingress_tcp_test()
 	log_test "mirred_egress_to_ingress_tcp ($tcflags)"
 }
 
+vlan_flush_test()
+{
+	ip link add x$h1 type veth peer x$h2
+	ip link set x$h1 up
+	ip link set x$h2 up
+
+	tc qdisc add dev x$h1 clsact
+	tc filter add dev x$h1 ingress pref 20 chain 0 handle 20 flower num_of_vlans 1 \
+		action vlan push id 100 protocol 0x8100 action goto chain 5
+	tc filter add dev x$h1 ingress pref 30 chain 5 handle 30 flower num_of_vlans 2 \
+		cvlan_ethtype 0x800 action pass
+
+	$MZ x$h2 -t udp -Q 10 -q
+	tc_check_packets "dev x$h1 ingress" 30 1
+	check_err $? "No double-vlan packets received"
+
+	ip link del x$h1
+	log_test "vlan_flush_test ($tcflags)"
+}
+
 setup_prepare()
 {
 	h1=${NETIFS[p1]}