From patchwork Fri Aug 11 09:36:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 134408 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp999853vqi; Fri, 11 Aug 2023 03:59:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQSno4NsykxxZopS4Yb03jV2eZ29vHwVMoIaixfrjwTBdS3uJ0Z1c1BjzMrNl9vFyNO/m3 X-Received: by 2002:a05:6402:88e:b0:523:102f:3ce1 with SMTP id e14-20020a056402088e00b00523102f3ce1mr1341442edy.10.1691751545582; Fri, 11 Aug 2023 03:59:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691751545; cv=none; d=google.com; s=arc-20160816; b=CgypqRILIs+YbVcUXg2xq68gIbZYDwloQXyQuE5iRHHmkwUtviplkPSBo9DIjoQT1E PzkIUC64qqOFlXe9ChkqR3Hcb04AUjqpEhd+ypHLBfbTq4gGNeZBJqwF3AgQfmlAUuuH bkECybRvgtutY21H87VB5247ELrLyg8LPC+oSXQvsMCo2SIKogqvYLb838SmuV2cp+US YABywTWSviUbGZm5V6OXmpNbYQ9qjIwTmH3QF66aFRfG7iMbm87v/a715VNOnYBiAt99 PEspHarLCOkgSlM27DqYg9RCUAkjxkjtUkhF5IzQBMdnqazlmiZWfFhOtmWpIupT7Vo2 lqag== 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:dkim-signature; bh=ONB0rT+VRdNbFZzplDFSYd3J2+VwEauFZ4m3EdIIa7w=; fh=bV6KfuSN3hKC74ZszsAG29NNR6004wMeMm9n9bF0ols=; b=DWyoto59yZQmdoXzOMybRlA793vyW7DxJMokRxs9ZpRC9QdZeWrNyhKTyN1Ry5J5JH jMUEWUx+No1cExykms3Z/vJaQbDWKvOZ1hxY5eLKYBC8uDWIMBiFXTJylVQ6v2WYISWt D5L0gywDycHQpKfXrfiY/ht5E/VPkfZEnWavoS2PSSsDgmU+mG/kz2F7WfbSF1++wYGE 3YBE3NovlqyduT7nDLBkAqr0MDU5GYVa7G/Yt76y00fsnxcWv+q14MTAIHAYVYu51M5G PvAvvZOL9D9YvoeVnHfms6n/MrCQmPBY3i6XOxYkuclxIJ5ukcq4HeWrTtOLY+8Mqfen 2ibQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=vXPAhoae; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=FX7SI2W9; 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=suse.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d8-20020a056402078800b005234d2cd73dsi3226386edy.149.2023.08.11.03.58.41; Fri, 11 Aug 2023 03:59:05 -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=@suse.de header.s=susede2_rsa header.b=vXPAhoae; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=FX7SI2W9; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235371AbjHKJh0 (ORCPT + 99 others); Fri, 11 Aug 2023 05:37:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235163AbjHKJgp (ORCPT ); Fri, 11 Aug 2023 05:36:45 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC968359D; Fri, 11 Aug 2023 02:36:37 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 90DE121881; Fri, 11 Aug 2023 09:36:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1691746596; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ONB0rT+VRdNbFZzplDFSYd3J2+VwEauFZ4m3EdIIa7w=; b=vXPAhoaecUfc3nRG2DWFLi6cthWO/0rZvkaAWjUqkyhtY6vhKDxO5hpoh0JGHkzkBA/Vdu rBoQmwc8waBX440zY76tVffz29ARY+U9+IrSM+AMI5kJ1zf26t70NWrwDcXeIklh8KX9UA +It47EeQrmAIwD+oswf8Y+wwCQ0pnI0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1691746596; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ONB0rT+VRdNbFZzplDFSYd3J2+VwEauFZ4m3EdIIa7w=; b=FX7SI2W90x7QzkTw3STpDrjYVPdrJpArtwtc/Jb7dQ8DqvvxRIchakm1+ZU00Tj6P0Dsxn +rUkEpfu/WYRFKBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7DE83138E2; Fri, 11 Aug 2023 09:36:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8ErKHSQB1mTPHwAAMHmgww (envelope-from ); Fri, 11 Aug 2023 09:36:36 +0000 From: Daniel Wagner To: linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Chaitanya Kulkarni , Shin'ichiro Kawasaki , Max Gurtovoy , Hannes Reinecke , Sagi Grimberg , James Smart , Bart Van Assche , Daniel Wagner Subject: [PATCH blktests v3 11/13] nvme/rc: Add helper for adding/removing to allow list Date: Fri, 11 Aug 2023 11:36:12 +0200 Message-ID: <20230811093614.28005-12-dwagner@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230811093614.28005-1-dwagner@suse.de> References: <20230811093614.28005-1-dwagner@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773930068814109503 X-GMAIL-MSGID: 1773930068814109503 Add two helpers to add or remove the host from the allow list of the subsystem. Signed-off-by: Daniel Wagner --- tests/nvme/rc | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/nvme/rc b/tests/nvme/rc index 7f5829a2e58d..61cc2e6d2c2c 100644 --- a/tests/nvme/rc +++ b/tests/nvme/rc @@ -612,17 +612,32 @@ _create_nvmet_subsystem() { _create_nvmet_ns "${nvmet_subsystem}" "1" "${blkdev}" "${uuid}" } +_add_nvmet_allow_hosts() { + local nvmet_subsystem="$1" + local nvmet_hostnqn="$2" + local cfs_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}" + local host_path="${NVMET_CFS}/hosts/${nvmet_hostnqn}" + + ln -s "${host_path}" "${cfs_path}/allowed_hosts/${nvmet_hostnqn}" +} + +_remove_nvmet_allow_hosts() { + local nvmet_subsystem="$1" + local nvmet_hostnqn="$2" + local cfs_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}" + + rm "${cfs_path}/allowed_hosts/${nvmet_hostnqn}" +} + _create_nvmet_host() { local nvmet_subsystem="$1" local nvmet_hostnqn="$2" local nvmet_hostkey="$3" local nvmet_ctrlkey="$4" - local cfs_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}" local host_path="${NVMET_CFS}/hosts/${nvmet_hostnqn}" mkdir "${host_path}" - echo 0 > "${cfs_path}/attr_allow_any_host" - ln -s "${host_path}" "${cfs_path}/allowed_hosts/${nvmet_hostnqn}" + _add_nvmet_allow_hosts "${nvmet_subsystem}" "${nvmet_hostnqn}" if [[ "${nvmet_hostkey}" ]] ; then echo "${nvmet_hostkey}" > "${host_path}/dhchap_key" fi