From: Hangbin Liu <liuhangbin@gmail.com>
To: netdev@vger.kernel.org
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>,
Xiao Liang <shaw.leon@gmail.com>,
Kuniyuki Iwashima <kuniyu@amazon.com>,
Alexander Lobakin <aleksander.lobakin@intel.com>,
Stanislav Fomichev <sdf@fomichev.me>,
Venkat Venkatsubra <venkat.x.venkatsubra@oracle.com>,
Etienne Champetier <champetier.etienne@gmail.com>,
Di Zhu <zhudi21@huawei.com>,
Nikolay Aleksandrov <razor@blackwall.org>,
Travis Brown <travisb@arista.com>,
Suresh Krishnan <skrishnan@arista.com>,
linux-kselftest@vger.kernel.org,
Hangbin Liu <liuhangbin@gmail.com>
Subject: [PATCH net 3/3] selftests/rtnetlink.sh: add vlan/ipvlan/macvlan link state test
Date: Thu, 3 Apr 2025 08:58:57 +0000 [thread overview]
Message-ID: <20250403085857.17868-4-liuhangbin@gmail.com> (raw)
In-Reply-To: <20250403085857.17868-1-liuhangbin@gmail.com>
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@gmail.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
prev parent reply other threads:[~2025-04-03 8:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-03 8:58 [PATCH net 0/3] fix ipvlan/macvlan link event handing Hangbin Liu
2025-04-03 8:58 ` [PATCH net 1/3] ipvlan: fix NETDEV_UP/NETDEV_DOWN event handling Hangbin Liu
2025-04-03 10:28 ` Sabrina Dubroca
2025-04-03 13:09 ` Hangbin Liu
2025-04-03 15:00 ` Sabrina Dubroca
2025-04-14 7:02 ` Hangbin Liu
2025-04-03 8:58 ` [PATCH net 2/3] macvlan: " Hangbin Liu
2025-04-03 8:58 ` Hangbin Liu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250403085857.17868-4-liuhangbin@gmail.com \
--to=liuhangbin@gmail.com \
--cc=aleksander.lobakin@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=champetier.etienne@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=razor@blackwall.org \
--cc=sdf@fomichev.me \
--cc=shaw.leon@gmail.com \
--cc=shuah@kernel.org \
--cc=skrishnan@arista.com \
--cc=travisb@arista.com \
--cc=venkat.x.venkatsubra@oracle.com \
--cc=zhudi21@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).