From patchwork Tue Jul 21 14:52:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Pisati X-Patchwork-Id: 11675833 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7B95513B4 for ; Tue, 21 Jul 2020 14:52:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 63C2B20717 for ; Tue, 21 Jul 2020 14:52:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728342AbgGUOwy (ORCPT ); Tue, 21 Jul 2020 10:52:54 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:55431 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728156AbgGUOwx (ORCPT ); Tue, 21 Jul 2020 10:52:53 -0400 Received: from 1.general.ppisati.uk.vpn ([10.172.193.134] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jxtdR-0002Sv-Ig; Tue, 21 Jul 2020 14:52:49 +0000 From: Paolo Pisati To: "David S . Miller" , Jakub Kicinski , Shuah Khan , Willem de Bruijn , Jian Yang Cc: netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] selftests: txtimestamp: tear down setup() 'tc' and 'ip' env on EXIT Date: Tue, 21 Jul 2020 16:52:49 +0200 Message-Id: <20200721145249.72153-1-paolo.pisati@canonical.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Add a cleanup() path upon exit, making it possible to run the test twice in a row: $ sudo bash -x ./txtimestamp.sh + set -e ++ ip netns identify + [[ '' == \r\o\o\t ]] + main + [[ 0 -eq 0 ]] + run_test_all + setup + tc qdisc add dev lo root netem delay 1ms Error: Exclusivity flag on, cannot modify. Signed-off-by: Paolo Pisati --- tools/testing/selftests/net/txtimestamp.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/testing/selftests/net/txtimestamp.sh b/tools/testing/selftests/net/txtimestamp.sh index eea6f5193693..77f29cabff87 100755 --- a/tools/testing/selftests/net/txtimestamp.sh +++ b/tools/testing/selftests/net/txtimestamp.sh @@ -23,6 +23,14 @@ setup() { action mirred egress redirect dev ifb_netem0 } +cleanup() { + tc filter del dev lo parent ffff: + tc qdisc del dev lo handle ffff: ingress + tc qdisc del dev ifb_netem0 root + ip link del ifb_netem0 + tc qdisc del dev lo root +} + run_test_v4v6() { # SND will be delayed 1000us # ACK will be delayed 6000us: 1 + 2 ms round-trip @@ -75,6 +83,8 @@ main() { fi } +trap cleanup EXIT + if [[ "$(ip netns identify)" == "root" ]]; then ./in_netns.sh $0 $@ else