Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3914342rwi; Wed, 12 Oct 2022 08:17:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Q7RuKiZwuThHBiQZQ80neMvIV5a3Rh1+OHyEQj5VtO3Q3TeoCrxyxXa+81pAI0n7nFzhJ X-Received: by 2002:a05:6402:358e:b0:45c:aa8b:f7e9 with SMTP id y14-20020a056402358e00b0045caa8bf7e9mr3591735edc.33.1665587856327; Wed, 12 Oct 2022 08:17:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665587856; cv=none; d=google.com; s=arc-20160816; b=NNs//UZsc5THYMRJvqpeJhUZ5rSvbFE7QVU/4k9HCEyB05EXNANEMWTP1CYQu0hlQy Gf9W0f1BK5kO/ngyLNhNw4AAB656nuTQI3FDdf4UNDA+8hiltO/CikTDkLxII8IZsQ0o fZdkLvleDCchLkmt3ekFvQ3kjGkv9bCNuGd0PQuL2mvyiIotoFA1Ynbqw6RuEVyzHLm6 bjcrBHGAvF7fUgewXJRqIAVpddE6qMketp035oQOXWWZb3H+66kJdpalTG48JkZh2FpY KjPHRjLD+8AihS0zWGQdvSNRXP4vsxOxCPbLZx6g192vAcg3SlBzdnZ6QpNmtwU6O+8y 4Rdg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=59ODeYb/zj0xWpehY5IjWapAt6RkzLSO55I3d59wWk8=; b=NmaUvy6KGYUnIJyX4cqwAOI/u+PBGIhOggMM2W2psywDGr5cdvPWZ9WNAwMHk36eyU WHXH+IU7DJVq3Wr/1KRh8/RbRAg4kIZWQmDFKYhXMr8TptU+ud3MbevDCOlhnx5UO5wf 2uRN8JPpeFKS4kXKsW0WxmNBk4gsuM7/GRtVzRSLScMapVEtCos76T14ygmi3f8/fD1w S7EmlT654mMhIRxL9lY0ceDdzPUcDtTugmcMfAabvcAcja9LLfPwk9YxH3B38ihcaylf N3g+hxLgHMeFgv3n3e1azg+vurDBuaZNvDnOwFC7Ll4VNzXxCyCmAlVTkZKkXHrGzZNj uhDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PxIP9btN; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ca22-20020aa7cd76000000b00458bf560cbasi14678948edb.90.2022.10.12.08.17.09; Wed, 12 Oct 2022 08:17:36 -0700 (PDT) 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=PxIP9btN; 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 S229747AbiJLOcq (ORCPT + 99 others); Wed, 12 Oct 2022 10:32:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229607AbiJLOcm (ORCPT ); Wed, 12 Oct 2022 10:32:42 -0400 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 ED316CF1A9 for ; Wed, 12 Oct 2022 07:32:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665585158; 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; bh=59ODeYb/zj0xWpehY5IjWapAt6RkzLSO55I3d59wWk8=; b=PxIP9btN6aYa4XXZTVMZp9o6t9Qaeixao9FC3KfwwKLkGnJteze0WF03pNTc9AO7OlWfWp 2qOLhDsCtd7PCfncxnkjLGsnb9M7a/pF6AvzEfyC2n1tx5dsrMgeGE1jE7s6cVWyrhOxd6 2Xb1i7pNj+dmGemzYNwrKDfKuiJUkEY= 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-389-vMwQdboiM6uXOlQ93jUmFA-1; Wed, 12 Oct 2022 10:32:35 -0400 X-MC-Unique: vMwQdboiM6uXOlQ93jUmFA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A52AA811E81; Wed, 12 Oct 2022 14:32:34 +0000 (UTC) Received: from jtoppins.rdu.csb (unknown [10.22.34.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F82A492B05; Wed, 12 Oct 2022 14:32:34 +0000 (UTC) From: Jonathan Toppins To: "netdev @ vger . kernel . org" Cc: Jay Vosburgh , Liang Li , Veaceslav Falico , Andy Gospodarek , Shuah Khan , 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 Message-Id: <016a7258b6150e97ddca69d993f8223aa0761d14.1665585149.git.jtoppins@redhat.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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, 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 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: 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