From patchwork Wed May 2 16:11:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 10376083 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AFBAB6037D for ; Wed, 2 May 2018 16:12:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FC4A28F6B for ; Wed, 2 May 2018 16:12:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9438628F74; Wed, 2 May 2018 16:12:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, MAILING_LIST_MULTI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D722228F6A for ; Wed, 2 May 2018 16:12:00 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40bjvz1fBJzF2Td for ; Thu, 3 May 2018 02:11:59 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="M+gNt9qp"; dkim-atps=neutral X-Original-To: linux-mlxsw@lists.ozlabs.org Delivered-To: linux-mlxsw@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mellanox.com (client-ip=40.107.3.83; helo=eur03-am5-obe.outbound.protection.outlook.com; envelope-from=petrm@mellanox.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=mellanox.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=Mellanox.com header.i=@Mellanox.com header.b="M+gNt9qp"; dkim-atps=neutral Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30083.outbound.protection.outlook.com [40.107.3.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40bjvs3myMzF2TN for ; Thu, 3 May 2018 02:11:53 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=TQbOVlsw//P1Iro/zDm485rfpeNgwG6Yr36/VPkDhG4=; b=M+gNt9qpx9ggb92lePA6ddRg9wfT59L0elM/y08Q+AWxff6wrPQiDyOWQvfYyzG3AH/sXhrQQG1t+CB/dxi+MEIaOzI8kXdTcjGYDyyYFbo+TwsLjAxBngHop9pzGwMB/5Rd8xRvLKzXC0OYjXLHyrPFw7mdRjqXjeR0d4FpE3k= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=petrm@mellanox.com; Received: from t540p (78.45.160.211) by VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.715.20; Wed, 2 May 2018 16:11:47 +0000 From: Petr Machata To: Subject: [PATCH net-next mlxsw 1/2] selftests: forwarding: lib: Add sysctl_set(), sysctl_restore() In-Reply-To: References: Message-Id: Date: Wed, 02 May 2018 18:11:41 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 X-Originating-IP: [78.45.160.211] X-ClientProxiedBy: CWLP265CA0028.GBRP265.PROD.OUTLOOK.COM (2603:10a6:401:11::16) To VI1PR05MB4191.eurprd05.prod.outlook.com (2603:10a6:803:4e::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB4191; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 3:WfI63jaGy277pltwge8d60qOG+GH8WUbkkMXdRCdphpf098SlEP7FdsNCMnhJVYK//p32wff1LX/UD4Al5RDFIe4+vWLuIZqAJLG647BI/9JZZFsQim2bU+6DUT6FN3gXGeR58unRrKQuYPw+Lpr4fKt1PsZo7u6DtuJi5yfWKRWbP/u6AxoazKmqEhF3dmRHL9LtAfrZPebYFh6Phu3n27MpI2iVlNWGle/tJqn4hDO45BwcejYfU6g6NwTJ78a; 25:l3L2yyx7/VpTDK5lRj+o4Mkp65PEw8iMqQ72wqQN/px8saQlYWKaqLu8+l2mfDcOK0KBsHt/3bxrR8X9Z3H20PcbApBf2nHbNV5/6bQa3M80oXjyCB8zOX2EeoinTF1bbq5Mv9df8gADSDItT0hwzK/k3IGrXZg5cf2KAir3QO0anyLXe8j6GArqnoBtqMxFTiLsy/c4CLXv1lTvw6pd/cGGhJm32YgndfSK6OvIHZiYBrKZm2Btys2kkGuhwZWVuCoiWjbeX0vJCBI0kVxRLWRVyTp2/QKA0CGR5ZV5nrAhmjbqYoNtnmuNXQ/GsSQWA4JxQ6lsRajfQCPpm8NiGQ==; 31:54nDfsuQX0AN1HSDid5tLNSh3lNhzLO4MQxUxGb4TX0wSCDHBHHk5595Vpw0oiQ/I2e5OG+A3vVNmNV9DGiNuwgHYypI1lFtzt+VB2+7OAA/SEGEX66wTWjiAoyXvqwHT+qFD1aPIZJ5dL4A862NAjCny9UwZssjZt2WibSVVgSQZhfM9+Bz+VO6RGOYPiG1j030NWDP4CLJGfu96bRwxL+aKzI//MUwFvEQew3WhJg= X-MS-TrafficTypeDiagnostic: VI1PR05MB4191: X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 20:OzPta2kYweV1jkpRQoNWSt76VuV5AwQ4OiCQs/9k5cgwBJI0VZtEuOHh3X4GSQ3tLYqZGue2eoXe/Nn5CCXztMxzILgBAdw/k6s7tODtSTRNfy6BeQxBO6UJ7iu+ZESqoDfiPgijcHe6kQ/b21o0aNWK6EMiBU5HYJ9LYPTvi1hIe+VlQ3rH5VibyR3XdjdnHlG2Gi+OQqLASHh+Ot6FWf9+AirgPigiDdstKu1zgmIWG/12nT6azYpKWl4TRPYonnxcojTuLslRkbuQ+7PivAc2CZv7Wibk6r9uSpI751pn1pHoxMSKYytuMzfnGDH2rZSqw+zZskdG1skrsKMPcgIYHyv3MlkrYXTdYaAIzgnV+lFthLY8yCd99yzlLKZLZOm6OnM0hKF9pUO/9lmKnNTRs5891VoBX75XLnUZAv0VwXaRf9yT73t7EtnIPQBgZINONTiniH2Mgh32OnYE2V9SgfCUu2Z6qrOX3GRX7RccGO8mszAFUj1nb6MsG5Wf; 4:G4u1i36wLpSxtELMBZRNxtKYbljsxh9ilmekFE4tMJqXtOizwxu1opwB3E/3dJCn9jLQTapDwCm2YTskAdP8XorNNethe3Bpt+fEtJ20Nl9iwfOaikuSlsArbvUqsoJWiyUG327zRylMyMFRE/Ix2/jzbjY7JN59Ajplx8Bz8c5h3mxNAopTbf9DPebg9LBuVQO5dsDezagT7mQsDkmKscC8SHxtKwGdd5BTpVvWF2z/gBN1TyVGhpZhImvcFJXl7ryqT9dXm3pR7uCbRZRZAg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231254)(944501410)(52105095)(93006095)(93001095)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(6072148)(201708071742011); SRVR:VI1PR05MB4191; BCL:0; PCL:0; RULEID:; SRVR:VI1PR05MB4191; X-Forefront-PRVS: 06607E485E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(366004)(376002)(39860400002)(396003)(39380400002)(199004)(189003)(6496006)(11346002)(52116002)(5660300001)(76176011)(16586007)(58126008)(47776003)(59450400001)(386003)(446003)(2351001)(478600001)(68736007)(2616005)(476003)(66066001)(48376002)(50466002)(86362001)(36756003)(97736004)(8936002)(8676002)(956004)(26005)(6116002)(6666003)(6486002)(118296001)(53936002)(105586002)(107886003)(81156014)(81166006)(305945005)(16526019)(2906002)(51416003)(106356001)(316002)(486006)(6916009)(3846002)(25786009)(4326008)(7736002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB4191; H:t540p; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR05MB4191; 23:3z/YL5ebZKYTMqK/lb+OgK7i9D/kpJH0j9yAa4rRM?= =?us-ascii?Q?f6nUB2/1E3pAv/F0aGCPfFCZIoBMBPHiVEjteHU1iIBLMrbuzu+4/k0Minjd?= =?us-ascii?Q?u30P+213P/pLvVN2u9SU7p+re7nhjOj/zu5BsYj3NyCToFD/8V13mOnkfdBh?= =?us-ascii?Q?UdHo/tsE4daFlntCG5Wbj8PUCQEulhhLHU1Q/paJ+i1rq/Lyy6bXXQo1jGJk?= =?us-ascii?Q?GqSH5hOljuV6IK1iLjtMN62o3XoLk5jpP7/EXkAePd+6EIC1Df4tKoiHpNr+?= =?us-ascii?Q?RzsLFXn28MhKdfLfCcbG+nr7ZzXJVvzYXVG+Dws8QH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JCW50E4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB4191; 7:q40FveDMLCE1P9E6NXTr1Xom6D9mWegHdOuYJrWD9XQgLdx0IEI9BluMo9JQPu6auI6N/hOWaCvlHFQ59vD481IS1+PSqedTe0nPxsbqvonObcKD0/RSQfTDIN00C5m3iXcABOBUfVz8W8oJs2RdxjUVEVskp2Rs3IJl5aXou9dLG0aDTO8TB3IgfW4mLwZS1yFZziLE9WAi4ST+wutRIxHyHUaR/yhh2BB1I76cEdmm17DsbGStpaHPCNYD0aHl X-MS-Office365-Filtering-Correlation-Id: c0a8377f-148b-4d89-e381-08d5b04767dd X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 May 2018 16:11:47.1429 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c0a8377f-148b-4d89-e381-08d5b04767dd X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB4191 X-BeenThere: linux-mlxsw@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: mlxsw driver development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-internal@mellanox.com Errors-To: linux-mlxsw-bounces+patchwork-linux-mlxsw=patchwork.kernel.org@lists.ozlabs.org X-Virus-Scanned: ClamAV using ClamSMTP Add two helper functions: sysctl_set() to change the value of a given sysctl setting, and sysctl_restore() to change it back to what it was. Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel --- tools/testing/selftests/net/forwarding/lib.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 7fe6d27..426b294 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -401,6 +401,23 @@ bridge_ageing_time_get() echo $((ageing_time / 100)) } +declare -A SYSCTL_ORIG +sysctl_set() +{ + local key=$1; shift + local value=$1; shift + + SYSCTL_ORIG[$key]=$(sysctl -n $key) + sysctl -qw $key=$value +} + +sysctl_restore() +{ + local key=$1; shift + + sysctl -qw $key=${SYSCTL_ORIG["$key"]} +} + forwarding_enable() { ipv4_fwd=$(sysctl -n net.ipv4.conf.all.forwarding)