From patchwork Tue Nov 22 20:25:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Toppins X-Patchwork-Id: 24545 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2424445wrr; Tue, 22 Nov 2022 12:29:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf6uEMgM9lA1l2QJB7UkTSqqSSUvFNPne8apfSYpQ4ZEMfTUmYgTNmIpwK94JHgai3ZE5rcI X-Received: by 2002:a17:90a:2b8c:b0:212:f4f1:96ee with SMTP id u12-20020a17090a2b8c00b00212f4f196eemr34301006pjd.72.1669148941899; Tue, 22 Nov 2022 12:29:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669148941; cv=none; d=google.com; s=arc-20160816; b=xB/CY/7Lb1CU4FtzqycDS+iki2FJKsP4CRwR8YIwxH9+KPjm6fgGa5X4MWTHXBeYg7 SCkqDYpS0EKtxhYhgOzR7ZnzI19mcUUYSpfcf6O8FAfe2l9JS4aeBGxOaes1EYeKJLF8 rYyOQLgJSZA2Gai/m49ZANVZ2CeVUmgJ3HnpuYi5sHuNrrAHpTxlVvfFrUd0xCN0QFUB 3aJIGT4+q0ehzb5q1CNKDdTkuDOf5NLUapP+M5PZ7+cdUnBsX2ChIxwypXFh0QdC8Ptv fGqckgSo9IEW9+Wq+qcp3+k6OXVcA03/4Aiglav48dfAsMCcx+GW3N6ft40lhvM/7gPO y2Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=r3/2piB6GXyvdrxnNdT33GXkLuSFNYhdrcvdRhDy1+c=; b=zJtHKpGQ0WjZ+Hx3KdULpwXRNWxY/vdDwISAFsQ+bKW7IoVOA/2THf45GT7WIDxYb0 cNcb8kXAqmWPodXmWvXNqKShSJkluo5+4Z7H4srOpByDZ61YyYwJ+IIA+4B4mRL55Usv tZ2jIXqDRKiDJ+l/9aW7awa2yeE8vFlwqj+sltI79xObSGoSzMzQprWe/tRcW1v5BroN ujHcQ3YxMVuckJQok0iQ9FZbIg+QC7Qwdizs3nMIfoDC/Wj80/G7K4ezhpYMf6r+11z2 m691/xBap6BV8oivhsFNohJdSOzdHwL+9rVOe3yoffzd453C2oaeqcp2aakjZulEajZ/ cNgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="eESoclF/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bd9-20020a056a00278900b0056c0a9e09f0si1582746pfb.292.2022.11.22.12.28.48; Tue, 22 Nov 2022 12:29:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="eESoclF/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232341AbiKVU0V (ORCPT + 99 others); Tue, 22 Nov 2022 15:26:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234079AbiKVU0P (ORCPT ); Tue, 22 Nov 2022 15:26:15 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0751D65E4C for ; Tue, 22 Nov 2022 12:25:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669148715; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r3/2piB6GXyvdrxnNdT33GXkLuSFNYhdrcvdRhDy1+c=; b=eESoclF/6Fu0iaeYvain05abR3S3SDMNEJ+OOuvGqQlHBbOd9AFSOIaElsnmsSz4TSVdNz BTw5dP8Jrl97YM8njD/ua+tihzxFS1INswvEm5zkBsVAENbnsWcfae1UQvM3dkuBrSFDAi 8maEX8SCJ3+YCsAdAn4GGa0kFW3fV3Y= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-342-raX7gI8DNlSf5KwaXD7P4Q-1; Tue, 22 Nov 2022 15:25:13 -0500 X-MC-Unique: raX7gI8DNlSf5KwaXD7P4Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1957F800B23; Tue, 22 Nov 2022 20:25:13 +0000 (UTC) Received: from jtoppins.rdu.csb (unknown [10.22.32.190]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9942A40C6EC6; Tue, 22 Nov 2022 20:25:12 +0000 (UTC) From: Jonathan Toppins To: "netdev @ vger . kernel . org" , pabeni@redhat.com Cc: Jay Vosburgh , Liang Li , Veaceslav Falico , Andy Gospodarek , Shuah Khan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH net-next v2 1/2] selftests: bonding: up/down delay w/ slave link flapping Date: Tue, 22 Nov 2022 15:25:04 -0500 Message-Id: <58a5bf9b72f14eb9a770391359bae33da5e490f4.1669147951.git.jtoppins@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750229520830359842?= X-GMAIL-MSGID: =?utf-8?q?1750229520830359842?= 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 Signed-off-by: Jonathan Toppins --- Notes: v2: * reduced the number of icmp echos to two (-c 2) and removed the unneeded `return 0` from function `test_bond_recovery`. .../selftests/drivers/net/bonding/Makefile | 4 +- .../selftests/drivers/net/bonding/lag_lib.sh | 106 ++++++++++++++++++ .../net/bonding/mode-1-recovery-updelay.sh | 45 ++++++++ .../net/bonding/mode-2-recovery-updelay.sh | 45 ++++++++ .../selftests/drivers/net/bonding/settings | 2 +- 5 files changed, 200 insertions(+), 2 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh create mode 100755 tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.sh diff --git a/tools/testing/selftests/drivers/net/bonding/Makefile b/tools/testing/selftests/drivers/net/bonding/Makefile index 6b8d2e2f23c2..0f3921908b07 100644 --- a/tools/testing/selftests/drivers/net/bonding/Makefile +++ b/tools/testing/selftests/drivers/net/bonding/Makefile @@ -5,7 +5,9 @@ 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 \ + mode-1-recovery-updelay.sh \ + mode-2-recovery-updelay.sh TEST_FILES := \ lag_lib.sh \ diff --git a/tools/testing/selftests/drivers/net/bonding/lag_lib.sh b/tools/testing/selftests/drivers/net/bonding/lag_lib.sh index 16c7fb858ac1..2a268b17b61f 100644 --- a/tools/testing/selftests/drivers/net/bonding/lag_lib.sh +++ b/tools/testing/selftests/drivers/net/bonding/lag_lib.sh @@ -1,6 +1,8 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 +NAMESPACES="" + # Test that a link aggregation device (bonding, team) removes the hardware # addresses that it adds on its underlying devices. test_LAG_cleanup() @@ -59,3 +61,107 @@ test_LAG_cleanup() log_test "$driver cleanup mode $mode" } + +# Build a generic 2 node net namespace with 2 connections +# between the namespaces +# +# +-----------+ +-----------+ +# | node1 | | node2 | +# | | | | +# | | | | +# | eth0 +-------+ eth0 | +# | | | | +# | eth1 +-------+ eth1 | +# | | | | +# +-----------+ +-----------+ +lag_setup2x2() +{ + local state=${1:-down} + local namespaces="lag_node1 lag_node2" + + # create namespaces + for n in ${namespaces}; do + ip netns add ${n} + done + + # wire up namespaces + ip link add name lag1 type veth peer name lag1-end + ip link set dev lag1 netns lag_node1 $state name eth0 + ip link set dev lag1-end netns lag_node2 $state name eth0 + + ip link add name lag1 type veth peer name lag1-end + ip link set dev lag1 netns lag_node1 $state name eth1 + ip link set dev lag1-end netns lag_node2 $state name eth1 + + NAMESPACES="${namespaces}" +} + +# cleanup all lag related namespaces and remove the bonding module +lag_cleanup() +{ + for n in ${NAMESPACES}; do + ip netns delete ${n} >/dev/null 2>&1 || true + done + modprobe -r bonding +} + +SWITCH="lag_node1" +CLIENT="lag_node2" +CLIENTIP="172.20.2.1" +SWITCHIP="172.20.2.2" + +lag_setup_network() +{ + lag_setup2x2 "down" + + # create switch + ip netns exec ${SWITCH} ip link add br0 up type bridge + ip netns exec ${SWITCH} ip link set eth0 master br0 up + ip netns exec ${SWITCH} ip link set eth1 master br0 up + ip netns exec ${SWITCH} ip addr add ${SWITCHIP}/24 dev br0 +} + +lag_reset_network() +{ + ip netns exec ${CLIENT} ip link del bond0 + ip netns exec ${SWITCH} ip link set eth0 up + ip netns exec ${SWITCH} ip link set eth1 up +} + +create_bond() +{ + # create client + ip netns exec ${CLIENT} ip link set eth0 down + ip netns exec ${CLIENT} ip link set eth1 down + + ip netns exec ${CLIENT} ip link add bond0 type bond $@ + ip netns exec ${CLIENT} ip link set eth0 master bond0 + ip netns exec ${CLIENT} ip link set eth1 master bond0 + ip netns exec ${CLIENT} ip link set bond0 up + ip netns exec ${CLIENT} ip addr add ${CLIENTIP}/24 dev bond0 +} + +test_bond_recovery() +{ + RET=0 + + create_bond $@ + + # verify connectivity + ip netns exec ${CLIENT} ping ${SWITCHIP} -c 2 >/dev/null 2>&1 + check_err $? "No connectivity" + + # force the links of the bond down + ip netns exec ${SWITCH} ip link set eth0 down + sleep 2 + ip netns exec ${SWITCH} ip link set eth0 up + ip netns exec ${SWITCH} ip link set eth1 down + + # re-verify connectivity + ip netns exec ${CLIENT} ping ${SWITCHIP} -c 2 >/dev/null 2>&1 + + local rc=$? + check_err $rc "Bond failed to recover" + log_test "$1 ($2) bond recovery" + lag_reset_network +} diff --git a/tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh b/tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh new file mode 100755 index 000000000000..ad4c845a4ac7 --- /dev/null +++ b/tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh @@ -0,0 +1,45 @@ +#!/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 + + +REQUIRE_MZ=no +REQUIRE_JQ=no +NUM_NETIFS=0 +lib_dir=$(dirname "$0") +source "$lib_dir"/net_forwarding_lib.sh +source "$lib_dir"/lag_lib.sh + +cleanup() +{ + lag_cleanup +} + +trap cleanup 0 1 2 + +lag_setup_network +test_bond_recovery mode 1 miimon 100 updelay 0 +test_bond_recovery mode 1 miimon 100 updelay 200 +test_bond_recovery mode 1 miimon 100 updelay 500 +test_bond_recovery mode 1 miimon 100 updelay 1000 +test_bond_recovery mode 1 miimon 100 updelay 2000 +test_bond_recovery mode 1 miimon 100 updelay 5000 +test_bond_recovery mode 1 miimon 100 updelay 10000 + +exit "$EXIT_STATUS" diff --git a/tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.sh b/tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.sh new file mode 100755 index 000000000000..2330d37453f9 --- /dev/null +++ b/tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.sh @@ -0,0 +1,45 @@ +#!/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 + + +REQUIRE_MZ=no +REQUIRE_JQ=no +NUM_NETIFS=0 +lib_dir=$(dirname "$0") +source "$lib_dir"/net_forwarding_lib.sh +source "$lib_dir"/lag_lib.sh + +cleanup() +{ + lag_cleanup +} + +trap cleanup 0 1 2 + +lag_setup_network +test_bond_recovery mode 2 miimon 100 updelay 0 +test_bond_recovery mode 2 miimon 100 updelay 200 +test_bond_recovery mode 2 miimon 100 updelay 500 +test_bond_recovery mode 2 miimon 100 updelay 1000 +test_bond_recovery mode 2 miimon 100 updelay 2000 +test_bond_recovery mode 2 miimon 100 updelay 5000 +test_bond_recovery mode 2 miimon 100 updelay 10000 + +exit "$EXIT_STATUS" diff --git a/tools/testing/selftests/drivers/net/bonding/settings b/tools/testing/selftests/drivers/net/bonding/settings index 867e118223cd..6091b45d226b 100644 --- a/tools/testing/selftests/drivers/net/bonding/settings +++ b/tools/testing/selftests/drivers/net/bonding/settings @@ -1 +1 @@ -timeout=60 +timeout=120 From patchwork Tue Nov 22 21:24:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Toppins X-Patchwork-Id: 24589 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2448623wrr; Tue, 22 Nov 2022 13:32:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf4tOZt8zyyJVPTXlvCQ/WmZOmbEroaelozJKnYcpps6mDF8xSW1grYZywvOvZwSTR5jjoKb X-Received: by 2002:a17:906:470c:b0:78a:383a:e714 with SMTP id y12-20020a170906470c00b0078a383ae714mr21382293ejq.105.1669152761534; Tue, 22 Nov 2022 13:32:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669152761; cv=none; d=google.com; s=arc-20160816; b=POZin04Unqpf0OJySzTTqPK83rgDTwtD9zuC6ExzYAYN2JJyaRyCuEtbOunSnoTPKl vAa/XJ37J7LYW8ojRp3uLkB58vMcZe4dlK1AnwsExe3QGwxxsLWLtpdGqyHVNewqd876 LhNtWaWkXdqdA1ors6E8FpS9UASucGJVOGgyCHv1Fzp/1KCi53Sq9cYEfjUdsH18WSVO PSZnjcIwDqze9TQZ+pzWPKd7Al+gxZqVmOaUMGBxt8fBPbYc4LI5eiPcP6TDv1aaCRBU A9hqHGVaEkXsEaYWHGTwsrFqBpAL5ZEVOEuaoPgZ7CsrhHQzOzuZbNepVfXlHs3TfKws guAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HPuBaWQRr8cpwhtPqmiKsJrBi/GFZSasH/SPpO6YLxs=; b=skAn8X/3v1bHeCpe+Vcj4Md98sJbe6lLF7g+m2MPPiafLd5u2xobuE0fiMlRMdx4rT Pkm9FIpGE/KwndBvnHxCoRPQs37W6Pgy+TMlPo+zjdrvE2oRRyXdm/4JJ7o4Hil1WQs7 /tMx4NutBWQCU+xKGY/cg4SoFyYoQEOPaD1AGXUvCxdY8G7glcqmQnxqYbpPLtAaesv6 f8paVvHDBPHnEJNSOgrPQJBWt2XMbNf/ePrpbDcZMWHKl6lnFlNRJL13dYyUv9J2L08l a1oh3VmsDspHMHM9acLGRDJC0NSl/TuFCmtSarkAphdgY3fOlgtghzU754Zi6ShOebHo JpDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=En3C8TfJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e13-20020a17090658cd00b007ae43ee86aesi14014780ejs.69.2022.11.22.13.32.12; Tue, 22 Nov 2022 13:32:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=En3C8TfJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231773AbiKVVZl (ORCPT + 99 others); Tue, 22 Nov 2022 16:25:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235001AbiKVVZf (ORCPT ); Tue, 22 Nov 2022 16:25:35 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F39C8221F for ; Tue, 22 Nov 2022 13:24:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669152280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HPuBaWQRr8cpwhtPqmiKsJrBi/GFZSasH/SPpO6YLxs=; b=En3C8TfJB4axDyZqZhol9qeldmQ5fHapWMwr2nx48M5Wpin6oBcxnB9r0ZzeuFYxE4ztG7 Ym0iOXPSztCRzHD2QCoTGHJT2s21nHnOC1lIxKdN4HHKN8EKtlBGyVVv4qalzT+GLeSXfn +QlIh4nziBk+gCQ5G/aEpE/YQWMo3wk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-5-jh6kNTyaNHm9HmJfHgzvJg-1; Tue, 22 Nov 2022 16:24:36 -0500 X-MC-Unique: jh6kNTyaNHm9HmJfHgzvJg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A9FFC801585; Tue, 22 Nov 2022 21:24:35 +0000 (UTC) Received: from jtoppins.rdu.csb (unknown [10.22.32.190]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E8CC4B3FC6; Tue, 22 Nov 2022 21:24:35 +0000 (UTC) From: Jonathan Toppins To: "netdev @ vger . kernel . org" , pabeni@redhat.com Cc: Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S. Miller" , Eric Dumazet , Jakub Kicinski , linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 2/2] bonding: fix link recovery in mode 2 when updelay is nonzero Date: Tue, 22 Nov 2022 16:24:29 -0500 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750233526239845171?= X-GMAIL-MSGID: =?utf-8?q?1750233526239845171?= Before this change when a bond in mode 2 lost link, all of its slaves lost link, the bonding device would never recover even after the expiration of updelay. This change removes the updelay when the bond currently has no usable links. Conforming to bonding.txt section 13.1 paragraph 4. Fixes: 41f891004063 ("bonding: ignore updelay param when there is no active slave") Signed-off-by: Jonathan Toppins Acked-by: Jay Vosburgh --- Notes: v2: * added fixes tag and reposted to net tree drivers/net/bonding/bond_main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index f298b9b3eb77..f747bd60d399 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -2536,7 +2536,16 @@ static int bond_miimon_inspect(struct bonding *bond) struct slave *slave; bool ignore_updelay; - ignore_updelay = !rcu_dereference(bond->curr_active_slave); + if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) { + ignore_updelay = !rcu_dereference(bond->curr_active_slave); + } else { + struct bond_up_slave *usable_slaves; + + usable_slaves = rcu_dereference(bond->usable_slaves); + + if (usable_slaves && usable_slaves->count == 0) + ignore_updelay = true; + } bond_for_each_slave_rcu(bond, slave, iter) { bond_propose_link_state(slave, BOND_LINK_NOCHANGE);