lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250403085857.17868-4-liuhangbin@gmail.com>
Date: Thu,  3 Apr 2025 08:58:57 +0000
From: Hangbin Liu <liuhangbin@...il.com>
To: netdev@...r.kernel.org
Cc: Andrew Lunn <andrew+netdev@...n.ch>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>,
	Paolo Abeni <pabeni@...hat.com>,
	Simon Horman <horms@...nel.org>,
	Shuah Khan <shuah@...nel.org>,
	Xiao Liang <shaw.leon@...il.com>,
	Kuniyuki Iwashima <kuniyu@...zon.com>,
	Alexander Lobakin <aleksander.lobakin@...el.com>,
	Stanislav Fomichev <sdf@...ichev.me>,
	Venkat Venkatsubra <venkat.x.venkatsubra@...cle.com>,
	Etienne Champetier <champetier.etienne@...il.com>,
	Di Zhu <zhudi21@...wei.com>,
	Nikolay Aleksandrov <razor@...ckwall.org>,
	Travis Brown <travisb@...sta.com>,
	Suresh Krishnan <skrishnan@...sta.com>,
	linux-kselftest@...r.kernel.org,
	Hangbin Liu <liuhangbin@...il.com>
Subject: [PATCH net 3/3] selftests/rtnetlink.sh: add vlan/ipvlan/macvlan link state test

Add tests to create vlan/ipvlan/macvlan over a bond interface and move
them to a separate network namespace. Verify that the upper link state
correctly reflects the lower-layer link state.

 # ./rtnetlink.sh -t "kci_test_vlan kci_test_ipvlan kci_test_macvlan"
 PASS: vlan link state correct
 PASS: ipvlan link state correct
 PASS: macvlan link state correct

Signed-off-by: Hangbin Liu <liuhangbin@...il.com>
---
 tools/testing/selftests/net/rtnetlink.sh | 64 ++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh
index 2e8243a65b50..de2f5bed8777 100755
--- a/tools/testing/selftests/net/rtnetlink.sh
+++ b/tools/testing/selftests/net/rtnetlink.sh
@@ -30,6 +30,9 @@ ALL_TESTS="
 	kci_test_address_proto
 	kci_test_enslave_bonding
 	kci_test_mngtmpaddr
+	kci_test_vlan
+	kci_test_ipvlan
+	kci_test_macvlan
 "
 
 devdummy="test-dummy0"
@@ -1334,6 +1337,67 @@ kci_test_mngtmpaddr()
 	return $ret
 }
 
+kci_test_link_state()
+{
+	local test_link=$(mktemp -u test_link-XXX)
+	local bond=$(mktemp -u bond-XXX)
+	local link_param=$2
+	local link_type=$1
+	local ret=0
+
+	setup_ns testns
+	if [ $? -ne 0 ]; then
+		end_test "SKIP ${link_type} netns tests: cannot add net namespace $testns"
+		return $ksft_skip
+	fi
+
+	# 1. Test link state over bond
+	run_cmd ip link add dev $bond type bond mode active-backup miimon 10
+	run_cmd ip link set dev ${devdummy} down
+	run_cmd ip link set dev ${devdummy} master $bond
+	run_cmd ip link set dev ${bond} up
+	run_cmd ip link add link ${bond} name ${test_link} type ${link_type} ${link_param}
+	run_cmd ip link set ${test_link} up
+	run_cmd ip link set ${devdummy} down
+	run_cmd_grep_fail "LOWER_UP" ip link show dev ${test_link}
+	run_cmd ip link set ${devdummy} up
+	run_cmd_grep "LOWER_UP" ip link show dev ${test_link}
+
+	# 2. Test link state over bond in netns
+	run_cmd ip link set ${test_link} netns ${testns}
+	run_cmd ip -n ${testns} link set ${test_link} up
+	run_cmd ip link set ${devdummy} down
+	run_cmd_grep_fail "LOWER_UP" ip -n ${testns} link show dev ${test_link}
+	run_cmd ip link set ${devdummy} up
+	run_cmd_grep "LOWER_UP" ip -n ${testns} link show dev ${test_link}
+	ip -n ${testns} link del ${test_link}
+
+	if [ $ret -ne 0 ]; then
+		end_test "FAIL: ${link_type} link state incorrect"
+	else
+		end_test "PASS: ${link_type} link state correct"
+	fi
+
+	ip netns del "$testns"
+	ip link del dev ${bond}
+	return $ret
+}
+
+kci_test_vlan()
+{
+	kci_test_link_state "vlan" "id 2"
+}
+
+kci_test_ipvlan()
+{
+	kci_test_link_state "ipvlan" "mode l2"
+}
+
+kci_test_macvlan()
+{
+	kci_test_link_state "macvlan" "mode bridge"
+}
+
 kci_test_rtnl()
 {
 	local current_test
-- 
2.46.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ