diff mbox series

[net,v3,2/2] selftests: add vlan hw filter tests

Message ID 20231216075219.2379123-3-liujian56@huawei.com (mailing list archive)
State Accepted
Commit 2258b666482d3326aec8b72ec3e009a2aad9582c
Delegated to: Netdev Maintainers
Headers show
Series check vlan filter feature in vlan_vids_add_by_dev() and vlan_vids_del_by_dev() | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net
netdev/ynl success SINGLE THREAD; Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers warning 2 maintainers not CCed: linux-kselftest@vger.kernel.org shuah@kernel.org
netdev/build_clang success Errors and warnings before: 8 this patch: 8
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: 8 this patch: 8
netdev/checkpatch warning WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? WARNING: line length of 87 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

liujian (CE) Dec. 16, 2023, 7:52 a.m. UTC
Add one basic vlan hw filter test.

Signed-off-by: Liu Jian <liujian56@huawei.com>
---
 tools/testing/selftests/net/Makefile          |  1 +
 tools/testing/selftests/net/vlan_hw_filter.sh | 29 +++++++++++++++++++
 2 files changed, 30 insertions(+)
 create mode 100755 tools/testing/selftests/net/vlan_hw_filter.sh

Comments

Hangbin Liu Dec. 18, 2023, 6:52 a.m. UTC | #1
On Sat, Dec 16, 2023 at 03:52:19PM +0800, Liu Jian wrote:
> Add one basic vlan hw filter test.
> 
> Signed-off-by: Liu Jian <liujian56@huawei.com>
> ---
>  tools/testing/selftests/net/Makefile          |  1 +
>  tools/testing/selftests/net/vlan_hw_filter.sh | 29 +++++++++++++++++++
>  2 files changed, 30 insertions(+)
>  create mode 100755 tools/testing/selftests/net/vlan_hw_filter.sh
> 
> diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
> index 5b2aca4c5f10..9e5bf59a20bf 100644
> --- a/tools/testing/selftests/net/Makefile
> +++ b/tools/testing/selftests/net/Makefile
> @@ -91,6 +91,7 @@ TEST_PROGS += test_bridge_neigh_suppress.sh
>  TEST_PROGS += test_vxlan_nolocalbypass.sh
>  TEST_PROGS += test_bridge_backup_port.sh
>  TEST_PROGS += fdb_flush.sh
> +TEST_PROGS += vlan_hw_filter.sh
>  
>  TEST_FILES := settings
>  
> diff --git a/tools/testing/selftests/net/vlan_hw_filter.sh b/tools/testing/selftests/net/vlan_hw_filter.sh
> new file mode 100755
> index 000000000000..7bc804ffaf7c
> --- /dev/null
> +++ b/tools/testing/selftests/net/vlan_hw_filter.sh
> @@ -0,0 +1,29 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +
> +readonly NETNS="ns-$(mktemp -u XXXXXX)"
> +
> +ret=0
> +
> +cleanup() {
> +	ip netns del $NETNS
> +}
> +
> +trap cleanup EXIT
> +
> +fail() {
> +    echo "ERROR: ${1:-unexpected return code} (ret: $_)" >&2
> +    ret=1
> +}
> +
> +ip netns add ${NETNS}
> +ip netns exec ${NETNS} ip link add bond0 type bond mode 0
> +ip netns exec ${NETNS} ip link add bond_slave_1 type veth peer veth2
> +ip netns exec ${NETNS} ip link set bond_slave_1 master bond0
> +ip netns exec ${NETNS} ethtool -K bond0 rx-vlan-filter off
> +ip netns exec ${NETNS} ip link add link bond_slave_1 name bond_slave_1.0 type vlan id 0
> +ip netns exec ${NETNS} ip link add link bond0 name bond0.0 type vlan id 0
> +ip netns exec ${NETNS} ip link set bond_slave_1 nomaster
> +ip netns exec ${NETNS} ip link del veth2 || fail "Please check vlan HW filter function"
> +
> +exit $ret
> -- 
> 2.34.1
> 

Reviewed-by: Hangbin Liu <liuhangbin@gmail.com>

Thanks
Hangbin
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 5b2aca4c5f10..9e5bf59a20bf 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -91,6 +91,7 @@  TEST_PROGS += test_bridge_neigh_suppress.sh
 TEST_PROGS += test_vxlan_nolocalbypass.sh
 TEST_PROGS += test_bridge_backup_port.sh
 TEST_PROGS += fdb_flush.sh
+TEST_PROGS += vlan_hw_filter.sh
 
 TEST_FILES := settings
 
diff --git a/tools/testing/selftests/net/vlan_hw_filter.sh b/tools/testing/selftests/net/vlan_hw_filter.sh
new file mode 100755
index 000000000000..7bc804ffaf7c
--- /dev/null
+++ b/tools/testing/selftests/net/vlan_hw_filter.sh
@@ -0,0 +1,29 @@ 
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+
+readonly NETNS="ns-$(mktemp -u XXXXXX)"
+
+ret=0
+
+cleanup() {
+	ip netns del $NETNS
+}
+
+trap cleanup EXIT
+
+fail() {
+    echo "ERROR: ${1:-unexpected return code} (ret: $_)" >&2
+    ret=1
+}
+
+ip netns add ${NETNS}
+ip netns exec ${NETNS} ip link add bond0 type bond mode 0
+ip netns exec ${NETNS} ip link add bond_slave_1 type veth peer veth2
+ip netns exec ${NETNS} ip link set bond_slave_1 master bond0
+ip netns exec ${NETNS} ethtool -K bond0 rx-vlan-filter off
+ip netns exec ${NETNS} ip link add link bond_slave_1 name bond_slave_1.0 type vlan id 0
+ip netns exec ${NETNS} ip link add link bond0 name bond0.0 type vlan id 0
+ip netns exec ${NETNS} ip link set bond_slave_1 nomaster
+ip netns exec ${NETNS} ip link del veth2 || fail "Please check vlan HW filter function"
+
+exit $ret