mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Toppins <jtoppins@redhat.com>
To: "netdev @ vger . kernel . org" <netdev@vger.kernel.org>
Cc: Jay Vosburgh <j.vosburgh@gmail.com>, Liang Li <liali@redhat.com>,
	Veaceslav Falico <vfalico@gmail.com>,
	Andy Gospodarek <andy@greyhouse.net>,
	Shuah Khan <shuah@kernel.org>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: [net RFC] selftests: bonding: up/down delay w/ slave link flapping
Date: Wed, 12 Oct 2022 10:32:29 -0400	[thread overview]
Message-ID: <016a7258b6150e97ddca69d993f8223aa0761d14.1665585149.git.jtoppins@redhat.com> (raw)

Verify when a bond is configured with {up,down}delay and the link state
of slave members flaps if there are no remaining members up the bond
should immediately select a member to bring up. (from bonding.txt
section 13.1 paragraph 4)

Suggested-by: Liang Li <liali@redhat.com>
Signed-off-by: Jonathan Toppins <jtoppins@redhat.com>
---

Notes:
    Bug: Currently the bond never comes back up.

 .../selftests/drivers/net/bonding/Makefile    |  3 +-
 .../net/bonding/slave-link-flapping.sh        | 85 +++++++++++++++++++
 2 files changed, 87 insertions(+), 1 deletion(-)
 create mode 100755 tools/testing/selftests/drivers/net/bonding/slave-link-flapping.sh

diff --git a/tools/testing/selftests/drivers/net/bonding/Makefile b/tools/testing/selftests/drivers/net/bonding/Makefile
index e9dab5f9d773..cb40ef91c152 100644
--- a/tools/testing/selftests/drivers/net/bonding/Makefile
+++ b/tools/testing/selftests/drivers/net/bonding/Makefile
@@ -5,7 +5,8 @@ TEST_PROGS := \
 	bond-arp-interval-causes-panic.sh \
 	bond-break-lacpdu-tx.sh \
 	bond-lladdr-target.sh \
-	dev_addr_lists.sh
+	dev_addr_lists.sh \
+	slave-link-flapping.sh
 
 TEST_FILES := lag_lib.sh
 
diff --git a/tools/testing/selftests/drivers/net/bonding/slave-link-flapping.sh b/tools/testing/selftests/drivers/net/bonding/slave-link-flapping.sh
new file mode 100755
index 000000000000..a1499933fd39
--- /dev/null
+++ b/tools/testing/selftests/drivers/net/bonding/slave-link-flapping.sh
@@ -0,0 +1,85 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+
+# Regression Test:
+#  When the bond is configured with down/updelay and the link state of
+#  slave members flaps if there are no remaining members up the bond
+#  should immediately select a member to bring up. (from bonding.txt
+#  section 13.1 paragraph 4)
+#
+#  +-------------+       +-----------+
+#  | client      |       | switch    |
+#  |             |       |           |
+#  |    +--------| link1 |-----+     |
+#  |    |        +-------+     |     |
+#  |    |        |       |     |     |
+#  |    |        +-------+     |     |
+#  |    | bond   | link2 | Br0 |     |
+#  +-------------+       +-----------+
+#     172.20.2.1           172.20.2.2
+
+set -e
+
+BOND="bond0"
+LINK1="veth1"
+LINK2="veth2"
+CLIENTIP="172.20.2.1"
+SWITCHIP="172.20.2.2"
+NAMESPACES="switch client"
+
+cleanup()
+{
+	for n in ${NAMESPACES}; do
+		ip netns delete ${n} >/dev/null 2>&1 || true
+	done
+	modprobe -r bonding
+}
+
+setup_network()
+{
+	# create namespaces
+	for n in ${NAMESPACES}; do
+		ip netns add ${n}
+	done
+
+	# create veths
+	ip link add name ${LINK1}-bond type veth peer name ${LINK1}-end
+	ip link add name ${LINK2}-bond type veth peer name ${LINK2}-end
+
+	# create switch
+	ip netns exec switch ip link add br0 up type bridge
+	ip link set ${LINK1}-end netns switch up
+	ip link set ${LINK2}-end netns switch up
+	ip netns exec switch ip link set ${LINK1}-end master br0
+	ip netns exec switch ip link set ${LINK2}-end master br0
+	ip netns exec switch ip addr add ${SWITCHIP}/24 dev br0
+
+	# create client
+	ip link set ${LINK1}-bond netns client
+	ip link set ${LINK2}-bond netns client
+	ip netns exec client ip link add ${BOND} type bond \
+		mode 2 miimon 100 updelay 10000
+	ip netns exec client ip link set ${LINK1}-bond master ${BOND}
+	ip netns exec client ip link set ${LINK2}-bond master ${BOND}
+	ip netns exec client ip link set ${BOND} up
+	ip netns exec client ip addr add ${CLIENTIP}/24 dev ${BOND}
+}
+
+trap cleanup 0 1 2
+cleanup
+sleep 1
+
+dmesg --clear
+setup_network
+
+# verify connectivity
+ip netns exec client ping ${SWITCHIP} -c 5 >/dev/null 2>&1
+
+# force the links of the bond down
+ip netns exec switch ip link set ${LINK1}-end down
+sleep 2
+ip netns exec switch ip link set ${LINK1}-end up
+ip netns exec switch ip link set ${LINK2}-end down
+
+# re-verify connectivity
+ip netns exec client ping ${SWITCHIP} -c 5 >/dev/null 2>&1
-- 
2.31.1


                 reply	other threads:[~2022-10-12 14:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=016a7258b6150e97ddca69d993f8223aa0761d14.1665585149.git.jtoppins@redhat.com \
    --to=jtoppins@redhat.com \
    --cc=andy@greyhouse.net \
    --cc=j.vosburgh@gmail.com \
    --cc=liali@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=vfalico@gmail.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

all inboxes | Powered by JetHome®