From: Nikolay Aleksandrov <razor@blackwall.org>
To: netdev@vger.kernel.org
Cc: syoshida@redhat.com, j.vosburgh@gmail.com, andy@greyhouse.net,
kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com,
edumazet@google.com,
syzbot+9dfc3f3348729cc82277@syzkaller.appspotmail.com,
Nikolay Aleksandrov <razor@blackwall.org>
Subject: [PATCH net 2/2] selftests: rtnetlink: add a bond test trying to enslave non-eth dev
Date: Mon, 13 Mar 2023 15:28:34 +0200 [thread overview]
Message-ID: <20230313132834.946360-3-razor@blackwall.org> (raw)
In-Reply-To: <20230313132834.946360-1-razor@blackwall.org>
Add a new selftest for the recent bonding bug hit by syzbot[1] which
causes a warning and results in wrong device flags (IFF_SLAVE missing).
The test adds two bond devices and a nlmon device, enslaves one of the
bond devices to the other and then tries to enslave the nlmon device to
the enslaved bond testing the bond_enslave() error path when trying to
enslave a non-eth device. It checks that both MASTER and SLAVE flags are
properly restored.
If the flags are properly restored we get:
PASS: enslaved bond device has flags restored properly
[1] https://syzkaller.appspot.com/bug?id=391c7b1f6522182899efba27d891f1743e8eb3ef
Cc: Shigeru Yoshida <syoshida@redhat.com>
Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org>
---
tools/testing/selftests/net/rtnetlink.sh | 36 ++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh
index 275491be3da2..02964b2afd8d 100755
--- a/tools/testing/selftests/net/rtnetlink.sh
+++ b/tools/testing/selftests/net/rtnetlink.sh
@@ -1225,6 +1225,40 @@ kci_test_bridge_parent_id()
echo "PASS: bridge_parent_id"
}
+kci_test_enslaved_bond_non_eth()
+{
+ local ret=0
+
+ ip link add name test-nlmon0 type nlmon
+ ip link add name test-bond0 type bond
+ ip link add name test-bond1 type bond
+ ip link set dev test-bond0 master test-bond1
+ ip link set dev test-nlmon0 master test-bond0 1>/dev/null 2>/dev/null
+
+ ip -d l sh dev test-bond0 | grep -q "SLAVE"
+ if [ $? -ne 0 ]; then
+ echo "FAIL: IFF_SLAVE flag is missing from the bond device"
+ check_err 1
+ fi
+ ip -d l sh dev test-bond0 | grep -q "MASTER"
+ if [ $? -ne 0 ]; then
+ echo "FAIL: IFF_MASTER flag is missing from the bond device"
+ check_err 1
+ fi
+
+ # on error we return before cleaning up as that may hang the system
+ if [ $ret -ne 0 ]; then
+ return 1
+ fi
+
+ # clean up any leftovers
+ ip link del dev test-bond0
+ ip link del dev test-bond1
+ ip link del dev test-nlmon0
+
+ echo "PASS: enslaved bond device has flags restored properly"
+}
+
kci_test_rtnl()
{
local ret=0
@@ -1276,6 +1310,8 @@ kci_test_rtnl()
check_err $?
kci_test_bridge_parent_id
check_err $?
+ kci_test_enslaved_bond_non_eth
+ check_err $?
kci_del_dummy
return $ret
--
2.39.2
next prev parent reply other threads:[~2023-03-13 13:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-13 13:28 [PATCH net 0/2] bonding: properly restore flags when non-eth dev enslave fails Nikolay Aleksandrov
2023-03-13 13:28 ` [PATCH net 1/2] bonding: restore bond's IFF_SLAVE flag if a " Nikolay Aleksandrov
2023-03-13 13:28 ` Nikolay Aleksandrov [this message]
2023-03-13 13:32 ` [PATCH net 2/2] selftests: rtnetlink: add a bond test trying to enslave non-eth dev Nikolay Aleksandrov
2023-03-13 13:34 ` Nikolay Aleksandrov
2023-03-13 13:42 ` [PATCH net 0/2] bonding: properly restore flags when non-eth dev enslave fails Nikolay Aleksandrov
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=20230313132834.946360-3-razor@blackwall.org \
--to=razor@blackwall.org \
--cc=andy@greyhouse.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=j.vosburgh@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=syoshida@redhat.com \
--cc=syzbot+9dfc3f3348729cc82277@syzkaller.appspotmail.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