Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5703398rwb; Tue, 22 Nov 2022 03:57:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Ir9x6X3vMBRaKdSuQj/HU+zfskD7CyCi5eHO9p0wXLPpu0AHp6brS7HuUdRByyIGy9nwU X-Received: by 2002:a05:6402:2053:b0:468:f837:9a16 with SMTP id bc19-20020a056402205300b00468f8379a16mr18635842edb.324.1669118260877; Tue, 22 Nov 2022 03:57:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669118260; cv=none; d=google.com; s=arc-20160816; b=LiGkh5mA0VtF3+/0IocfupqHhjxTWr5NZ+02ky7kSLH6G6NpjgobWh95ZS+2IsuYbQ r3vt5KWrxBnmpCsUy+G7O0M0s2ShUVdSn4FwF8eHgZ/RGv90HrAuBvJpTeRPa9SnPplJ DKQ6l2fLnQRdaehtg7AivmQhcT9Y9E8M27qzeV/i9j8fuaaSB0ofXtRnnkdQiLJu73kg K2QorIwYXPRMrHIcjOj+zi7nqe33/02FBmSJKkuv18vh9pPq2K59CGGtVkBKzriK1D0Y S5kNB/uNLkTv3x0AzpSycMgFao8qov1gYl11vOgYZ2n7h1530DSS9La6Sk62kFZVnGkZ tV+w== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=FhojcgZQjkVkxO1IPtc27+RD5uOCkquMJUyVv8stBrg=; b=AET6kgGSb/oQZ9upGpqg4ypYP9hR4FIt9Ie4SG7g5X1zWD7S7H10i5kdV+TpPLpFpo syX19nmRVHPE4hHxeXpiPyrz035VSzzL+B5yRVKn6UsAiTCbsAqs/CxaHiyHbURKQKtK 18C/xNIqAlgwWzPZaNJwtQHo9hIjKkncHYPSMS3AL8Dr1CaV0rbMVvAPiyhJd8CnXD1y wXpA9Q6oEVIPDeZFpitiDEVBCXr8YAuub+HxIr9Ks28Xp0NYYL1dxhdWTvfUvZO3fZSK sWmz9uzy49u66Qy6bGQMuVAE0jZhZezJ6x3US/BL7DtC6OY/wd2wapa3Bdf8tP5Uz8W/ THUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="N/f1e/M+"; 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 i2-20020a05640242c200b0046453c385e4si13248655edc.365.2022.11.22.03.57.19; Tue, 22 Nov 2022 03:57:40 -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="N/f1e/M+"; 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 S230284AbiKVKyn (ORCPT + 90 others); Tue, 22 Nov 2022 05:54:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232580AbiKVKyk (ORCPT ); Tue, 22 Nov 2022 05:54:40 -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 C031D2AC75 for ; Tue, 22 Nov 2022 02:53:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669114423; 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=FhojcgZQjkVkxO1IPtc27+RD5uOCkquMJUyVv8stBrg=; b=N/f1e/M+U/kRBiRtetDVUU/TAyM/3XBuJpIjebFa4n4R9HGAsfG2acnaoskgurfebFLke8 fAoM1RwrCLK3aMnb71bR/2koQRRaq6WpP5AQtZm5Ani5CEz4U0tIJZAPfW/8R9viH/GwKe yKoeoorP7/TZEhsYNY0GiE418DSaGSI= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-611-dbiCREZtPAmZBqMxFDoyBw-1; Tue, 22 Nov 2022 05:53:40 -0500 X-MC-Unique: dbiCREZtPAmZBqMxFDoyBw-1 Received: by mail-qt1-f199.google.com with SMTP id i4-20020ac813c4000000b003a5044a818cso14353317qtj.11 for ; Tue, 22 Nov 2022 02:53:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=FhojcgZQjkVkxO1IPtc27+RD5uOCkquMJUyVv8stBrg=; b=4WHE2HB05LFBnJPpiC7wWqjZoLIdWjGf2qhrKMag9E2JxzBPNE3fUXWO6r4HGyjGtu C1+lwbMnMtjNgmzj5+Z6puBuFq05rrPrZFOgZQDBY6ZcQDnhCKJ5kch00q+LG3DE0UMp Q0Y/EZKYDouMXmCk2vHH1l+8s6CctQzR48t+KHuWElNFPyCs6njTwaAPWCHPJoww6CPr gO3jTHT6SWsoqjFUYGWdQeq8L4/+dXXyXmgLmj2IQD70dmd17OGEBV/jynbFIBHhrPjy UxVVFWwGhoL2kslP0HGk1ztk8w3CJu3ohJhynK4JVvlfy+mcn7KG2y0BtaF8yNncWsnD jAKA== X-Gm-Message-State: ANoB5plR7E9njiGlpAmTdrouaevlRwfaIRn0QDkTARQ1bPhukR4TiUrK mYUe6RHzhI1DVggQP8zdfDm44NI5k+0/Ucf2d7gTpBjFZhWtfOhJMZcUSwaSnz6rnTKPAiJxBGj rFwaI0FKsPzKkV5aOfOfCtjCD X-Received: by 2002:a05:620a:c95:b0:6fa:91f9:c84d with SMTP id q21-20020a05620a0c9500b006fa91f9c84dmr19769348qki.724.1669114419836; Tue, 22 Nov 2022 02:53:39 -0800 (PST) X-Received: by 2002:a05:620a:c95:b0:6fa:91f9:c84d with SMTP id q21-20020a05620a0c9500b006fa91f9c84dmr19769340qki.724.1669114419549; Tue, 22 Nov 2022 02:53:39 -0800 (PST) Received: from gerbillo.redhat.com (146-241-120-203.dyn.eolo.it. [146.241.120.203]) by smtp.gmail.com with ESMTPSA id u36-20020a05622a19a400b0039a55f78792sm8163824qtc.89.2022.11.22.02.53.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 02:53:39 -0800 (PST) Message-ID: Subject: Re: [PATCH net-next 1/2] selftests: bonding: up/down delay w/ slave link flapping From: Paolo Abeni To: Jonathan Toppins , netdev@vger.kernel.org, Jay Vosburgh Cc: Liang Li , Veaceslav Falico , Andy Gospodarek , Shuah Khan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Date: Tue, 22 Nov 2022 11:53:34 +0100 In-Reply-To: <314990ea9ee4e475cb200cf32efdf9fc37f4a02a.1668800711.git.jtoppins@redhat.com> References: <314990ea9ee4e475cb200cf32efdf9fc37f4a02a.1668800711.git.jtoppins@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 On Fri, 2022-11-18 at 15:30 -0500, Jonathan Toppins wrote: > 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 > --- > .../selftests/drivers/net/bonding/Makefile | 4 +- > .../selftests/drivers/net/bonding/lag_lib.sh | 107 ++++++++++++++++++ > .../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, 201 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..6dc9af1f2428 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,108 @@ 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 5 >/dev/null 2>&1 Minor nit: here and below you reduce the count number, to shorten significantly the tests runtime. > + 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 5 >/dev/null 2>&1 > + > + local rc=$? > + check_err $rc "Bond failed to recover" > + log_test "$1 ($2) bond recovery" > + lag_reset_network > + return 0 Minor nit: the return statement is not needed here. Cheers, Paolo