From patchwork Wed Apr 2 07:08:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 14035590 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B531B236421 for ; Wed, 2 Apr 2025 07:09:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577754; cv=none; b=qIbFySw4MBRhnXLgj/ScN8plRIAnxMEHW1FrIGzfNK5hzJF7gTVxHm7APWI4HSxdu+K0+MEcXDLBMuRcV5bxKv/Am6rRMdrQglbEAta5SZhkweCdkO+a8HNemCYE+dtp6YEt90r6BY2h3Ucya4iCNcNZuT2T5mGoC8WVQMmESgs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577754; c=relaxed/simple; bh=+YXy23ytnJLV0YbuAGgRiT2EsTOOJ5DnpJeZbJUGvdE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YIYEYUyjlVtUGvVrbFr//ZpqxxeAKreD9a7TjACwPUHbGJXTCcD9lLNXc2l8eiTs0Pj5ubpMi6nFGXqR8KxBE8i6Lh4dWUGlLExEJkmv4LFQbuPWYfnxHZ9+BvkB0ADUY5J6AWAkqu+5EPcRRDrBo/mJFC6O7sf8RG+EGgDyROc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=obMbrSSc; arc=none smtp.client-ip=216.71.154.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="obMbrSSc" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1743577751; x=1775113751; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+YXy23ytnJLV0YbuAGgRiT2EsTOOJ5DnpJeZbJUGvdE=; b=obMbrSScrSx2X15Z3HbtcD5I6M+XDaeHNouXvALKijarebUZcYov3QY9 Y2d2MlZei5imr1cOWjUtUSMJ6YkbitwMuUAS/M+dcp0TTYZVGQ28Z5iaZ Nmu1by17MZEjfwiahPNzCezDfg6NFd5r88g4FO1go/I0EcbNPS3zGXpZE h5Oh5Wv9lv6jiDA0NvsCB4JSXwGOhePcu2jZ66k7A5Fd72Iph0uTBCpeT OoY9BTVdnb3FZ9Pn6z/6FbSt6YjKem70CldWEOabbbLY8UABhDW030oaM M6z+RwJQGIWIm56/1MzaJOklMURea5i+ZKqINgiB55CaHs7AsKNw4KxON Q==; X-CSE-ConnectionGUID: cqm9Q9lfR1Wquy+X83NLrw== X-CSE-MsgGUID: 2XQRTor9QHq60eJYb6L8FA== X-IronPort-AV: E=Sophos;i="6.14,295,1736784000"; d="scan'208";a="71367519" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Apr 2025 15:09:09 +0800 IronPort-SDR: 67ecd49e_695biO7rC922p9IgbB0FcNcYDvGPp9uHTty1riOpK4OtO3E Cnc1nYgwS2i5Z2uBp7sZsjyGEnMYnJHFr2A0xmw== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 01 Apr 2025 23:09:34 -0700 WDCIronportException: Internal Received: from 5cg2075fn7.ad.shared (HELO shinmob.wdc.com) ([10.224.102.114]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Apr 2025 00:09:09 -0700 From: Shin'ichiro Kawasaki To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Hannes Reinecke , Shin'ichiro Kawasaki Subject: [PATCH blktests 01/10] common/rc: introduce _have_systemctl_unit() Date: Wed, 2 Apr 2025 16:08:57 +0900 Message-ID: <20250402070906.393160-2-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> References: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Hannes Reinecke To check that the test system has a specific systemctl unit, introduce the new helper function _have_systemctl_unit. Signed-off-by: Hannes Reinecke Signed-off-by: Shin'ichiro Kawasaki --- common/rc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/rc b/common/rc index bc6c2e4..ce7f975 100644 --- a/common/rc +++ b/common/rc @@ -500,6 +500,17 @@ _have_writeable_kmsg() { return 0 } +_have_systemctl_unit() { + local unit="$1" + + _have_program systemctl || return 1 + if ! grep -qe "$unit" < <(systemctl list-unit-files); then + SKIP_REASONS+=("systemctl unit '${unit}' is missing") + return 1 + fi + return 0 +} + # Run the given command as NORMAL_USER _run_user() { su "$NORMAL_USER" -c "$1" From patchwork Wed Apr 2 07:08:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 14035591 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7DAB23315D for ; Wed, 2 Apr 2025 07:09:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577755; cv=none; b=t5Pwpfm+G7gMdeXXOMT6Nn4CzFIXGmAo5us5Tix9Gq6sX4b/9SgiHdzaniXOs1ER/VZXGjYLsHwWFJvVPeDSOBgNHV/LeODClVPLrTX2JTLuc7ZQt2WtCoFgE/z6jvlOH6u2UvbE0U6Kn2ALBG4SkZAK2lFOQRv8qLQXB7JfTXU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577755; c=relaxed/simple; bh=//8Nb3BSwEDLv+lBYEejrYD/CHrsy84oq7ePiX7R4oY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hayj7jelXtRuXXdKQ7yQ7Rabf+1jZHJ8h5q8OHpxLR6KlRKafOA61rO4S1LhJISAsUfTTnZNuP0ehFzRCKXLl4z9sARCvv0f4cHEF8Dk+U9upPw4KSzN9PpwF9gdsrst5XRvHzsF5f+g49Ra2hrVRyssJLEmyP9av+/amsp5RjU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=AqXcyFhu; arc=none smtp.client-ip=216.71.154.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="AqXcyFhu" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1743577752; x=1775113752; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=//8Nb3BSwEDLv+lBYEejrYD/CHrsy84oq7ePiX7R4oY=; b=AqXcyFhuTX+tM+w5bpGAWv/PFzwt/wgsU3f9Z7nEr0HEZrUBIcnx0Ksp fZfVsScc3/JXvz0cbI7zLUmkXBeT4LySomNLawoReGE4AXcDCNf6b6ZrH W6BlyQ53Kj5VyvR3VEsPCbYZOrtXV8N15vqokCee2AzkXLm0gHudWUwLP 8OxMzaD6lc4mI9B2v5R4Usg+IX8LdIyAtfIr5Xx8pBSupsEsmB78mxQnw WUdURsihhB0rtyOJW4mk3zEXAl/qRCD7RLP2XG4EO+J5bHM7Cwcv5fcx1 dGwvxZph7bideUYAvrNBk/dc+0I/p3jX26Vp+6MQ3srNMyuKQfhx5uydE w==; X-CSE-ConnectionGUID: XGoQlHZ+QF+uOM/UmweYxQ== X-CSE-MsgGUID: LlvT/QRnRoOyaKN/FeslTw== X-IronPort-AV: E=Sophos;i="6.14,295,1736784000"; d="scan'208";a="71367544" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Apr 2025 15:09:10 +0800 IronPort-SDR: 67ecd49f_izzwpiE5lHRiuKNPc9S4wKlCTvon70LJdgWa/pi4TWgOO4j CFRhHshQvrOi8jEognqm5+4JHo7qGkvViHurcAA== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 01 Apr 2025 23:09:35 -0700 WDCIronportException: Internal Received: from 5cg2075fn7.ad.shared (HELO shinmob.wdc.com) ([10.224.102.114]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Apr 2025 00:09:10 -0700 From: Shin'ichiro Kawasaki To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Hannes Reinecke , Shin'ichiro Kawasaki Subject: [PATCH blktests 02/10] common/rc: introduce _systemctl_start() and _systemctl_stop() Date: Wed, 2 Apr 2025 16:08:58 +0900 Message-ID: <20250402070906.393160-3-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> References: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When test cases depend on specific systemctl services, the test cases need to start the service. After the test case completion, it is better to stop the service. However, if the service was already started and active before executing the test cases, stopping the service will affect test systems. To avoid such affect on the test systems, introduce _systemctl_start() and _systemctl_stop(). When _systemctl_start() check if the specified service has already started or not. If the service has not yet started, start it and record it in the global array SYSTEMCTL_UNITS_TO_STOP. When _systemctl_stop() is called, stop the service recorded in the array SYSTEMCTL_UNITS_TO_STOP. Signed-off-by: Shin'ichiro Kawasaki --- common/rc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/common/rc b/common/rc index ce7f975..068a676 100644 --- a/common/rc +++ b/common/rc @@ -13,6 +13,7 @@ shopt -s extglob . common/dm declare IO_URING_DISABLED +declare -a SYSTEMCTL_UNITS_TO_STOP # If a test runs multiple "subtests", then each subtest should typically run # for TIMEOUT / number of subtests. @@ -511,6 +512,26 @@ _have_systemctl_unit() { return 0 } +_systemctl_start() { + local unit="$1" + + if systemctl is-active --quiet "$unit"; then + return + fi + + if systemctl start "$unit"; then + SYSTEMCTL_UNITS_TO_STOP+=("$unit") + fi +} + +_systemctl_stop() { + local unit + + for unit in "${SYSTEMCTL_UNITS_TO_STOP[@]}"; do + systemctl stop "$unit" + done +} + # Run the given command as NORMAL_USER _run_user() { su "$NORMAL_USER" -c "$1" From patchwork Wed Apr 2 07:08:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 14035592 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AF06236431 for ; Wed, 2 Apr 2025 07:09:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577755; cv=none; b=VCVVuHqrRtbxqu/716lTb985efq6VoFE6bYiqQ4O4CfJRbp0nYzE4XRZzrLVV2J5WVD43Z0ZtLy7SUricjkgPV5eELjGx0jtGUx63mvgq5F+c5yivEDbEXW/QlDMii5+OColyb6YF7S1itcdK0wc6J/2273QvnaqzXqpVEDOIag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577755; c=relaxed/simple; bh=VrB4fyxXXV8fR9OLATgUooSVYgD6QeH7LZfh/6lSCFQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R3LVJfCf5+BWfk9/dhDm+yZkgDPtQK4P4vXR4jCs/UiOFN50FAYpvoEweL4gxB1vuenDxe0QqF7R06fFrbtWEc/OILCPfmwoYzgZY9qwDrnHbX006XvklxcL08vq1jA0d+91w4ESqIrmWYMgFl3JeBW+gRzvh2+3MdEZHELnHMY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=iAA7cSSB; arc=none smtp.client-ip=216.71.154.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="iAA7cSSB" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1743577753; x=1775113753; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VrB4fyxXXV8fR9OLATgUooSVYgD6QeH7LZfh/6lSCFQ=; b=iAA7cSSBMc2HL5LHUAWqAouG9n5uX2P32F8Gbi7XQQzauN1dKuiBCUEq vzx+P+g+RCiN3Au8GWFyAWGQv1ppd1EPrtzr046o9br0yW1LJSawKlAjG JWuSCz5ZXDL9BB+dTpvd1FNK39/dtDhraTBg2td/DOF8uwSpRTHUkEWv3 v4uhlTNp2VCd9aGjvykRbDdgkWFgSdLTWc9k+dV+ovl00xQZ+PqWUT6fh r+c9AlA6WO0A4DNVcDrN+xmA1WI4QdNxcvDMEMqsygTqz6/3OXs1xpM5q kzNJ7wq1o2tJk9RSLTpk7B5VJHzOoxt5IsJIOixBA+r4YRH8OwY0OT7wS A==; X-CSE-ConnectionGUID: ax/Qu9OVQQeOKVbR51rNfA== X-CSE-MsgGUID: 1Ad7VO9LRCC1m/b+wHujQQ== X-IronPort-AV: E=Sophos;i="6.14,295,1736784000"; d="scan'208";a="71367593" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Apr 2025 15:09:11 +0800 IronPort-SDR: 67ecd4a0_W1Ciycq0G/AscWahbFiAXedhK20kdMZQaYl2RMj45U+h7b2 dE010LoQDqnXQGmcccgWq58d/6OSROFg+CQAARw== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 01 Apr 2025 23:09:37 -0700 WDCIronportException: Internal Received: from 5cg2075fn7.ad.shared (HELO shinmob.wdc.com) ([10.224.102.114]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Apr 2025 00:09:12 -0700 From: Shin'ichiro Kawasaki To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Hannes Reinecke , Shin'ichiro Kawasaki Subject: [PATCH blktests 03/10] common/rc,fio: factor out _compare_three_version_numbers() Date: Wed, 2 Apr 2025 16:08:59 +0900 Message-ID: <20250402070906.393160-4-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> References: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The helper functions _have_kver() and _have_fio_ver() have the common logic that compares three numbers with the version string in the format "a.b.c". Factor out the common logic to the new helper function _compare_three_version_numbers(). This prepares for to introduce more functions for version checks. Signed-off-by: Shin'ichiro Kawasaki --- common/fio | 9 +++------ common/rc | 25 +++++++++++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/common/fio b/common/fio index 046791f..7c88460 100644 --- a/common/fio +++ b/common/fio @@ -28,14 +28,11 @@ _have_fio_zbd_zonemode() { # Check whether the version of the fio is greater than or equal to $1.$2.$3 _have_fio_ver() { - local d=$1 e=$2 f=$3 - _have_fio || return $? - IFS='.' read -r a b c < <(fio --version | cut -c 5- | sed 's/-.*//') - if [ $((a * 65536 + b * 256 + c)) -lt $((d * 65536 + e * 256 + f)) ]; - then - SKIP_REASONS+=("fio version too old") + if _compare_three_version_numbers \ + "$(fio --version | cut -c 5- | sed 's/-.*//')" "$1" "$2" "$3"; then + SKIP_REASONS+=("fio version is older than ${1}.${2}.${3:-0}") return 1 fi return 0 diff --git a/common/rc b/common/rc index 068a676..ff3f0a3 100644 --- a/common/rc +++ b/common/rc @@ -226,15 +226,28 @@ _have_kernel_option() { return 0 } +# Compare the version string in $1 in "a.b.c" format with "$2.$3.$4". +# If "a.b.c" is smaller than "$2.$3.$4", return true. Otherwise, return +# false. +_compare_three_version_numbers() { + local -i a b c d e f + + IFS='.' read -r a b c <<< "$1" + d=${2:0} + e=${3:0} + f=${4:0} + if ((a * 65536 + b * 256 + c < d * 65536 + e * 256 + f)); then + return 0 + fi + return 1 +} + # Check whether the version of the running kernel is greater than or equal to # $1.$2.$3 _have_kver() { - local d=$1 e=$2 f=$3 - - IFS='.' read -r a b c < <(uname -r | sed 's/-.*//;s/[^.0-9]//') - if [ $((a * 65536 + b * 256 + c)) -lt $((d * 65536 + e * 256 + f)) ]; - then - SKIP_REASONS+=("Kernel version too old") + if _compare_three_version_numbers \ + "$(uname -r | sed 's/-.*//;s/[^.0-9]//')" "$1" "$2" "$3"; then + SKIP_REASONS+=("Kernel version is older than ${1}.${2}.${3}") return 1 fi } From patchwork Wed Apr 2 07:09:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 14035593 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9957C232364 for ; Wed, 2 Apr 2025 07:09:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577756; cv=none; b=FUALG6Hkfa45mi43Dm5btI1mT7U8vGTERqaOseJO9RfrR2ci7hT430d7qIjnlqISRKWim79WIToxqRCfDErYgo6X2EkxIoe8lR3ms2XCXRxBp8Yk3pnpjKSzRUrDY6oRozWdS1XreOQsvlRqcGMhCphyS6bvCZIopl7PivHVvcE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577756; c=relaxed/simple; bh=QYoXh2T33Um9vyJzMNSajt2mhPw/PFqAatUozcTWlZA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F8QKj+Rrbup3M777JgP6nBPJ2waZpUeLGiSCFx66XJvQ55rk338jRwqfolXaTEvcVOtuEuztykKTve/yecgLuvuuJEuI/HVSZZGxgMfigksKzYLKPIxkKzYA3fMeoNWNAn9dkYsouFLqqrDnnC371Hhd+PeJ1txEieUAirOkJ90= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=OKIbD681; arc=none smtp.client-ip=216.71.154.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="OKIbD681" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1743577754; x=1775113754; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QYoXh2T33Um9vyJzMNSajt2mhPw/PFqAatUozcTWlZA=; b=OKIbD681UfcXaOCswbKiWhN2mrI7c9oGGSTePoJgSlayVfW9U2DxRZfx BNYJijBLvz+QkuWiqMD2G57O7Q2wpMs/M+Q+7+jFg7VTWfZFoLAED3Gzj OsgaWiV5xLaUEbOtvzSCWjIb/mszfIu71ojHMgT6dNHwmtlyAXunwhTb3 lJYwdWXdP11g3zun3sOu2wvCzgzsgTgyRscHQi6oRYldAd3ECOYc8uK7P V1InKPzlWro8ttI3IlX4as7bOaSBtEztLScC9xp32GPjzu6Duo6uCV1J7 InYwYCCTny5jQC3CT8WI0zXbbr2ScTeBimcAhzCBGc557s1G/6IN4iXsm g==; X-CSE-ConnectionGUID: /fpT4UqnTiu2xHUJSnS7Hg== X-CSE-MsgGUID: +P2lmsQ/RwKjDoXsvbN1Dw== X-IronPort-AV: E=Sophos;i="6.14,295,1736784000"; d="scan'208";a="71367629" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Apr 2025 15:09:12 +0800 IronPort-SDR: 67ecd4a1_1vLfSGxNPa9W37Yrk7XlAbRAXofwefMzSyB6u58tb+JhEgS J/JN5M8F1NIfXwBZKXKHLs/dcYMGcbNlCqEEnUQ== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 01 Apr 2025 23:09:38 -0700 WDCIronportException: Internal Received: from 5cg2075fn7.ad.shared (HELO shinmob.wdc.com) ([10.224.102.114]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Apr 2025 00:09:13 -0700 From: Shin'ichiro Kawasaki To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Hannes Reinecke , Shin'ichiro Kawasaki Subject: [PATCH blktests 04/10] nvme/rc: introduce _have_tlshd_ver() and _have_systemd_tlshd_service() Date: Wed, 2 Apr 2025 16:09:00 +0900 Message-ID: <20250402070906.393160-5-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> References: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To run the newly introduced test cases for nvme-tcp TLS support, the userland daemon tlshd and its systemctl service unit are required. Confirm availability of tlshd and the systemctl service. Also check that the tlshd version is larger than or equal to 1.0.0, which allows to authenticate TLS sessions for nvme subsystem with the default configurations. Signed-off-by: Shin'ichiro Kawasaki --- tests/nvme/rc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/nvme/rc b/tests/nvme/rc index de68b31..9584610 100644 --- a/tests/nvme/rc +++ b/tests/nvme/rc @@ -597,3 +597,23 @@ _nvme_reset_ctrl() { _nvme_delete_ctrl() { echo 1 > /sys/class/nvme/"$1"/delete_controller } + +# Check whether the version of the fio is greater than or equal to $1.$2.$3 +_have_tlshd_ver() { + _have_program tlshd || return $? + + if _compare_three_version_numbers \ + "$(tlshd --version |& sed 's/.*utils \([0-9^.]*\).*/\1/')" \ + "$1" "$2" "$3"; then + SKIP_REASONS+=("tlshd version is older than ${1}.${2}.${3}") + return 1 + fi + return 0 +} + +_have_systemd_tlshd_service() { + _have_tlshd_ver 1 0 0 + if ! _have_systemctl_unit tlshd; then + SKIP_REASONS+=("Install ktls-utils for tlshd") + fi +} From patchwork Wed Apr 2 07:09:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 14035594 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91E07236421 for ; Wed, 2 Apr 2025 07:09:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577757; cv=none; b=qg01groBnQM8EdGEd8/A0UjJF6/gAPuAdRAPc6s9aYuwdKYIXWpoWTJ13XOabK08NmH6EQ8i9uEjYNNsbUgdYjMVKAUXRqhTIQ7+yLO4tH5k4TMPfCwz2VzviAUdHDeAIbc+T3mh82ZkSLJiA70GOrgf60cJIdH/ZUrIJrK4nG0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577757; c=relaxed/simple; bh=J6/Hu2MKW11tsgpsq1VkvyADxkqS13Ky70HS3L0WoQs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bq/uc2D83jQaE5ulAr38CtP2eRLEfw+E9npZ2Zosc4hGB+BMcBat2ikO/f9YK9g9iBz+WlBGfSfzLWfCnau7wUFTsfJZvgMA9wUNOsJOYY5CuTOIl/CKqbkLdLWh5U35kGxJ/XKoh6upXrkjjbpQ7nUFuhkJ+p+wO7uZ+8pbIFw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=JZVhytfU; arc=none smtp.client-ip=216.71.154.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="JZVhytfU" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1743577755; x=1775113755; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=J6/Hu2MKW11tsgpsq1VkvyADxkqS13Ky70HS3L0WoQs=; b=JZVhytfUQhtbd3TpRI2meb0ToBwR6ey9xSBSX9x9gVaJsD7pzy8qBt+F 01E4iglExIGnxa+2OEerBefs1/Zv5ESnhW57bM8shRdIQ4rrnik27JnsT O7nnVT9eN2AhgAqa0LZYCJOoeDp9IC/G4EFxHbEJMSdvEmTHG9K1hSo+u c8J5loRYkDWCJXOyeAnlFsea54mRqHqUmBzAPl6AiDPJLbqft9GmWZxeq IjCHRPye0olmkH9jltZ0YKUk4a0nlN07px+iN9SCP4sG1ZYH8PAuFRheI u18o0Y3upohFfuHRTA0HwXaccVXheTmBFxmvqxi3CU/FKXp1shHeXOQoJ g==; X-CSE-ConnectionGUID: tswvNtugTGaJm4vKN0/hMA== X-CSE-MsgGUID: GmJPiOmCTvWSN2JZrZlAZg== X-IronPort-AV: E=Sophos;i="6.14,295,1736784000"; d="scan'208";a="71367663" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Apr 2025 15:09:14 +0800 IronPort-SDR: 67ecd4a3_F6YkTHF8tnDaV6kSoNMWMU7EO5ibBdad8OwgwfadRnq7l8U RMBE403Fng4glQB+3q3qze1l/NNShssQ/xVR4oQ== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 01 Apr 2025 23:09:39 -0700 WDCIronportException: Internal Received: from 5cg2075fn7.ad.shared (HELO shinmob.wdc.com) ([10.224.102.114]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Apr 2025 00:09:14 -0700 From: Shin'ichiro Kawasaki To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Hannes Reinecke , Shin'ichiro Kawasaki Subject: [PATCH blktests 05/10] nvme/rc: introduce _have_libnvme_ver() Date: Wed, 2 Apr 2025 16:09:01 +0900 Message-ID: <20250402070906.393160-6-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> References: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 A following patch is going to add a test case which depends on the version of libnvme linked to nvme-cli. Introduce the helper function _have_libnvme_ver() to check the version dependency. Signed-off-by: Shin'ichiro Kawasaki --- tests/nvme/rc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/nvme/rc b/tests/nvme/rc index 9584610..e52437f 100644 --- a/tests/nvme/rc +++ b/tests/nvme/rc @@ -617,3 +617,16 @@ _have_systemd_tlshd_service() { SKIP_REASONS+=("Install ktls-utils for tlshd") fi } + +_have_libnvme_ver() { + local ver + + _have_program nvme || return $? + ver="$(nvme --version | grep libnvme | cut --delimiter ' ' --fields 3 | sed 's/-.*//')" + + if _compare_three_version_numbers "$ver" "$1" "$2" "$3"; then + SKIP_REASONS+=("libnvme version is older than ${1}.${2}.${3:-0}") + return 1 + fi + return 0 +} From patchwork Wed Apr 2 07:09:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 14035595 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCA73236453 for ; Wed, 2 Apr 2025 07:09:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577757; cv=none; b=SN8LlSp7sqkOiVBMEVzsk2UvBehuZSULg+TgQ4VmCUvf7Z9Qkdihotf9Rzl74x6U5fj1Jo+TRk5nuzKHNsHQnQ+qLRn7A28xrQRdg2F9l01e2RcUx64L3FzSMf6eIYOzouaGl3wtxojA2aYSuDJeDdem3VmD7omDlI1Xw+Men4I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577757; c=relaxed/simple; bh=tftTrXPbJbZQ11TozRGfTpfYSu/Q0A0MVEOzzzAL7/E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CSvqUatdoEXSaqrBZn7wXWSwhnvo+G6lJvCadUlsklns0UGWkJi46Nv1IRL/HOzJNXda4gi2f2i+fCAWsFkRZyK/nbkWmJlNmiIFaiAWBCOfmILlIXllxKFEOTTtavjLGM0L8M6GpTXLsZcoTJwQMUfmKhCnipqJsiJVEaam89c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=leiXIYHn; arc=none smtp.client-ip=216.71.154.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="leiXIYHn" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1743577755; x=1775113755; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tftTrXPbJbZQ11TozRGfTpfYSu/Q0A0MVEOzzzAL7/E=; b=leiXIYHnBSpxzdUkF++aH3A1fBWD89uqtwg112HNsrmlAmOMiRtAxIIe 7Lpv1+4+25CSvo61R7wcQ/TMLbkELfeQZEb6vcXsuypSZH9kYHlJMkOIJ U33h5fm3svMyBR8fgzS6gGBUS3VLo+nLU7D9a1n++jBc8w6pxsRaEVadY iIAemsC+PVrqYkMDk/loK+DDbfgQmj0SVCDwBpZFbot13u9m48EhedxY/ S4944q1ArAxgCA7yqc7tiKZFOfmFMYoEN3OQRCBxCpla+HBZiHwgzit+m o7B66iQ6FZaaK4EGNPw/7JqnHOaAgFOokHI3XYVYzWtRCttLiHdrXlNRV w==; X-CSE-ConnectionGUID: /oitlINYQP+Rln4lV4yXPw== X-CSE-MsgGUID: eDK68Kc5Rd6MZDqFY6uSzw== X-IronPort-AV: E=Sophos;i="6.14,295,1736784000"; d="scan'208";a="71367698" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Apr 2025 15:09:15 +0800 IronPort-SDR: 67ecd4a4_9VZTIf5hSx/o4mO1Ppvy0Y+gc0FAVT73ODCxsk2hqVzmk9U WO265ICGq7oH5cZ31jELNWBwFgaY/WicTd4WX3g== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 01 Apr 2025 23:09:40 -0700 WDCIronportException: Internal Received: from 5cg2075fn7.ad.shared (HELO shinmob.wdc.com) ([10.224.102.114]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Apr 2025 00:09:15 -0700 From: Shin'ichiro Kawasaki To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Hannes Reinecke , Shin'ichiro Kawasaki Subject: [PATCH blktests 06/10] common/nvme: add '--tls' argument to _nvme_connect_subsys() Date: Wed, 2 Apr 2025 16:09:02 +0900 Message-ID: <20250402070906.393160-7-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> References: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Hannes Reinecke To start TLS-encrypted connections. Signed-off-by: Hannes Reinecke Signed-off-by: Shin'ichiro Kawasaki --- common/nvme | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/nvme b/common/nvme index 3761329..9327dff 100644 --- a/common/nvme +++ b/common/nvme @@ -274,6 +274,7 @@ _nvme_connect_subsys() { local no_wait=false local hdr_digest=false local data_digest=false + local tls=false local port local i local -a ARGS @@ -340,6 +341,10 @@ _nvme_connect_subsys() { data_digest=true shift 1 ;; + --tls) + tls=true + shift 1 + ;; *) echo "WARNING: unknown argument: $1" shift @@ -397,6 +402,9 @@ _nvme_connect_subsys() { if [[ ${data_digest} = true ]]; then ARGS+=(--data-digest) fi + if [[ ${tls} = true ]]; then + ARGS+=(--tls) + fi ARGS+=(-o json) connect=$(nvme connect "${ARGS[@]}" 2> /dev/null) From patchwork Wed Apr 2 07:09:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 14035596 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D360223645F for ; Wed, 2 Apr 2025 07:09:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577758; cv=none; b=aIPyJI6tA8gdBObHxRTJ7C7g3RijiqefqLyMMRYi6GZyOBI2WsEkoHqvCkVfhihIkfEtdLSEdL+0SuttL0q14frK042kZ7Nu2eiQLbqdXNgZvkLmhnYO6I9LqxQIwOL9EFvJwczgaFymm/v6hUYp7glJgWCrrrL7LdtiJl434wk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577758; c=relaxed/simple; bh=TINAFm3X74n/MGQFIZO+LLmFc58R1cN4e58MBJh5UUA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k8Kv90ttuGD2l8k2CNReQWy7EDITUNtIBlkLeZMhiceoEKR1nyf99FNW8r5WdbTWbSbl0LFpJnEdeGMy+BaBUkjfdoz+Ztci7gh9OvcO3gkI5daxGYePetQWlOhwsgQhVe28+axFVmPlSLYASCzRkNtB3tPK0B698FfyjQWPauk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=hFrraZd3; arc=none smtp.client-ip=216.71.154.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="hFrraZd3" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1743577756; x=1775113756; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TINAFm3X74n/MGQFIZO+LLmFc58R1cN4e58MBJh5UUA=; b=hFrraZd3vGoKT4+tF5OPTjGQ+QJFRD63VoEKSnLY/tJhDRwX1P0kijGb Dr2ujk5qva3eovNE8sVHR7+9oMlRvIxIIiNmFMW0vjcCaCmaqdRoMdAs2 ssDn61y16p2lUf1OFn0bhWgxmgq7kkP/VwvXFWQZpaZE1YLCPXQ29pOJ2 5gx09ML8jBDhhKaWV3jWCxRTOAAWaV8TFwNz2yGmjEhJingsN7Sn0sgsi 6vOpx/kRdsXioN5Vs1J4hxZJ2xl0oYyL05zaZjBRgc6Fcn8eKD32zAXhR XanTUjUlLM9ZVXA3V+JxknL4VuMbrgIg2H2Z4CUdEAyvhCujzeF4+12S7 g==; X-CSE-ConnectionGUID: ZZulwOWeS4i1XALdhi7Uxg== X-CSE-MsgGUID: xRrIWvQuRvuT+QZz4xRCRw== X-IronPort-AV: E=Sophos;i="6.14,295,1736784000"; d="scan'208";a="71367724" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Apr 2025 15:09:16 +0800 IronPort-SDR: 67ecd4a5_t93MXZFKER6HQSjMHfT4Z3FBI8FYzkFCYm7VY35+o8huhbw NjAIBdZH9+XrKR4UwP67itHp8fhIm7Tz0d56ZVA== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 01 Apr 2025 23:09:41 -0700 WDCIronportException: Internal Received: from 5cg2075fn7.ad.shared (HELO shinmob.wdc.com) ([10.224.102.114]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Apr 2025 00:09:16 -0700 From: Shin'ichiro Kawasaki To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Hannes Reinecke , Shin'ichiro Kawasaki Subject: [PATCH blktests 07/10] common/nvme: TLS target support Date: Wed, 2 Apr 2025 16:09:03 +0900 Message-ID: <20250402070906.393160-8-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> References: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Hannes Reinecke Add --tls option to _create_nvmet_subsystem and allow to specify the tls requirements in _create_nvmet_port. Signed-off-by: Hannes Reinecke Signed-off-by: Shin'ichiro Kawasaki --- common/nvme | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/common/nvme b/common/nvme index 9327dff..47bcdc9 100644 --- a/common/nvme +++ b/common/nvme @@ -477,6 +477,7 @@ _fc_host_traddr() { } _create_nvmet_port() { + local tls="${1:-none}" local trtype="${nvme_trtype}" local traddr="${def_traddr}" local adrfam="${def_adrfam}" @@ -513,7 +514,13 @@ _create_nvmet_port() { [[ "${adrfam}" != "loop" ]] ; then echo "${trsvcid}" > "${portcfs}/addr_trsvcid" fi - + if [[ "${trtype}" == "tcp" ]] && \ + [[ "${tls}" != "none" ]]; then + echo "tls1.3" > "${portcfs}/addr_tsas" + if [[ "${tls}" != "required" ]]; then + echo "not required" > "${portcfs}/addr_treq" + fi + fi echo "${port}" } @@ -878,6 +885,7 @@ _nvmet_target_setup() { local port p local resv_enable="" local num_ports=1 + local tls="none" local -a ARGS while [[ $# -gt 0 ]]; do @@ -910,6 +918,14 @@ _nvmet_target_setup() { num_ports="$2" shift 2 ;; + --tls) + tls="not-required" + shift 1 + ;; + --force-tls) + tls="required" + shift 1 + ;; *) echo "WARNING: unknown argument: $1" shift @@ -956,7 +972,7 @@ _nvmet_target_setup() { p=0 while (( p < num_ports )); do - port="$(_create_nvmet_port)" + port="$(_create_nvmet_port ${tls})" _add_nvmet_subsys_to_port "${port}" "${subsysnqn}" p=$(( p + 1 )) done From patchwork Wed Apr 2 07:09:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 14035598 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AE484235C1D for ; Wed, 2 Apr 2025 07:09:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577761; cv=none; b=HEnt20PRSj+adZuta1bANf1GKZcs3cIzYGITaQkTnHOj4P+V6q1qcvyUsZROS+/TiDvSoOXpfGg9xisBP40B+I6nCd39tVOBrX/XQ4MmKHv4XOiNNxOlEohDVUDyqpHGWYKXcfiwLJ7OuTg3JiBXbNuwiCHUHZ9TOGmR4UQHv3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577761; c=relaxed/simple; bh=NxBN7WHC+BPZl+big/3dpOEyGx/GAd3rlYitT6IXIRI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TMQvoGnfASlfmSphJMqvQ/GqUOU5styWsm5uCjH2zx0+CajaeEyfSYkTU8DJY+FkwN1q8hbNxJ5lMdFHr1ELM75ok4B9NnE42zohBFSNrZ3WR6OhbwE7kC0eFzg/4xYj548xLdvoEeAi0LEFmPDXh4c/Mx+B0agO3Vxarfd3/+E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=QCxRsNqD; arc=none smtp.client-ip=216.71.154.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="QCxRsNqD" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1743577759; x=1775113759; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NxBN7WHC+BPZl+big/3dpOEyGx/GAd3rlYitT6IXIRI=; b=QCxRsNqDtvmnrgGEYCNBQMPQjRfkzX540FiIL/yRrTH+z/8m9SLi9QzY AhbSHUbLTxGC36b9SPBH5o1hbVVU2Pzy9icq5nwSHBZ0O7KTJqSfb6/mn wl9SGsx6PHNr3DMsEjZqBVbNU8id+8heOUNq1ac+2bU3IEp9x4/sjbIIx UrNgQHDF3hzn/7fmdp7Zc5rpgdBp+ys+9TclqM2AE3NORAfZdnGZ7m1rY nZmFYfZNtPfQ+NOSK0IKdUy/UCt4RXY5FZNmZw6nrx+XHiljKpV3hGolN ohloF+Ouj3MLAUTzrImQdrYtp6jIvQgldgoHbv86FqSQZNvGK9bZG3mzc A==; X-CSE-ConnectionGUID: BH8Q4FxzS26jHuf2C+fkPg== X-CSE-MsgGUID: tpOi42W6RRygjF2KMYMCEQ== X-IronPort-AV: E=Sophos;i="6.14,295,1736784000"; d="scan'208";a="71367744" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Apr 2025 15:09:17 +0800 IronPort-SDR: 67ecd4a6_kdy0gFuBXWJFjT2MA68jSeSCqKkYMjbRuxMFXKvwb2RdjoX asEn5JpW/lBZ69fWe6f0DMXhGK6dn/sPv5aqYgw== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 01 Apr 2025 23:09:43 -0700 WDCIronportException: Internal Received: from 5cg2075fn7.ad.shared (HELO shinmob.wdc.com) ([10.224.102.114]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Apr 2025 00:09:18 -0700 From: Shin'ichiro Kawasaki To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Hannes Reinecke , Shin'ichiro Kawasaki Subject: [PATCH blktests 08/10] common/nvme: handle option '--concat' for _nvme_connect_subsys Date: Wed, 2 Apr 2025 16:09:04 +0900 Message-ID: <20250402070906.393160-9-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> References: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Hannes Reinecke To start secure concatenation the option '--concat' has to be passed to the 'nvme connect' command. Signed-off-by: Hannes Reinecke Signed-off-by: Shin'ichiro Kawasaki --- common/nvme | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/nvme b/common/nvme index 47bcdc9..402db18 100644 --- a/common/nvme +++ b/common/nvme @@ -275,6 +275,7 @@ _nvme_connect_subsys() { local hdr_digest=false local data_digest=false local tls=false + local concat=false local port local i local -a ARGS @@ -345,6 +346,10 @@ _nvme_connect_subsys() { tls=true shift 1 ;; + --concat) + concat=true + shift 1 + ;; *) echo "WARNING: unknown argument: $1" shift @@ -405,6 +410,9 @@ _nvme_connect_subsys() { if [[ ${tls} = true ]]; then ARGS+=(--tls) fi + if [[ ${concat} = true ]]; then + ARGS+=(--concat) + fi ARGS+=(-o json) connect=$(nvme connect "${ARGS[@]}" 2> /dev/null) From patchwork Wed Apr 2 07:09:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 14035597 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35B25237186 for ; Wed, 2 Apr 2025 07:09:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577760; cv=none; b=MZwi0uKFqssywM6gzrjUU8/63OjOWk+xB0u/+wV5eCRiWyMpIYcKfGeVc2nWgry1D+yOZRpH7S9tS6VjXCFzTjH8QcqrFM1mi1uCzmIxrhcQn8glzfYk3t4t1GR0KcmucxfssHylhP6/tmu586YPu4+KRhQ8pUrH2bIh9+Re6H0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577760; c=relaxed/simple; bh=ZUg4vWIrhMybKloELmU+beOmG39uzWztwz1klnfDxho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GrQM6YlzObiEr01xwVCFDHM59mIpyWvLsJS8SOkYdE/44bi2RlNbja2WhSphgf5PwC2213DZ9ywldfrMzoeGuDkZrt0M4mOySw6oz3xo9XAN+tqLz28Tb1wKT9zVYmwh7NYhLnLmBjh2AiRaXMdDphAguw8NPP/FSkTctej7XKE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=f++gpbxg; arc=none smtp.client-ip=216.71.154.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="f++gpbxg" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1743577759; x=1775113759; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZUg4vWIrhMybKloELmU+beOmG39uzWztwz1klnfDxho=; b=f++gpbxgC3w/q9iCU4964/InqVPBXMeHMQ1O/KJjOFaBjQnxa9M9rFlE z4aOVrjueiFrwi0qAx0Vu6SSw8AbsiRv5P/Y5jKyAl/UfroVXbXCjvxXB C1UlF6OHNgqYDFcOS7PZS0Qhel5+MZwscosQx6UyJ030813qCc8VQzew5 ydWOgwk36ykjikeEDGu4239RQYeWjdGVXZveK3IXC/8UUDp0Ng7IdtC4x As3EVH8rkt3FQFU5OAOW4TuI85E8mzcDRwNWmPGt4HmDZ1nTQ3qACqmI0 KwGuvx6rUioRhR4CayRWlJcl4r5S0sJeDgnHgZ1pQwvrHmcjc6dad16qe A==; X-CSE-ConnectionGUID: FFH/VCwbTAmJDbYnbDqFDQ== X-CSE-MsgGUID: GADc8GIgTY2Ba3cr57ledg== X-IronPort-AV: E=Sophos;i="6.14,295,1736784000"; d="scan'208";a="71367749" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Apr 2025 15:09:18 +0800 IronPort-SDR: 67ecd4a7_QwxykaXdSRiGVN5PZznDsiO/+ss2chu3ml9n2Nh30rnfXZf voVHFOf6jDIfWG4IbbBtVGe3g/bqfGbnmvyLbAg== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 01 Apr 2025 23:09:44 -0700 WDCIronportException: Internal Received: from 5cg2075fn7.ad.shared (HELO shinmob.wdc.com) ([10.224.102.114]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Apr 2025 00:09:19 -0700 From: Shin'ichiro Kawasaki To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Hannes Reinecke , Shin'ichiro Kawasaki Subject: [PATCH blktests 09/10] nvme: add testcase for TLS-encrypted connections Date: Wed, 2 Apr 2025 16:09:05 +0900 Message-ID: <20250402070906.393160-10-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> References: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Hannes Reinecke TCP connections can be encrypted using in-kernel TLS, so add a testcase to exercise the various combinations. Signed-off-by: Hannes Reinecke [Shin'ichiro: added _have_libnvme_ver and _have_systemd_tlshd_service] [Shin'ichiro: used _systemctl_start and _systemctl_stop] [Shin'ichiro: fixed file mode] Signed-off-by: Shin'ichiro Kawasaki --- tests/nvme/060 | 95 ++++++++++++++++++++++++++++++++++++++++++++++ tests/nvme/060.out | 10 +++++ tests/nvme/rc | 14 +++++++ 3 files changed, 119 insertions(+) create mode 100755 tests/nvme/060 create mode 100644 tests/nvme/060.out diff --git a/tests/nvme/060 b/tests/nvme/060 new file mode 100755 index 0000000..d7424ac --- /dev/null +++ b/tests/nvme/060 @@ -0,0 +1,95 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2024 Hannes Reinecke, SUSE Labs +# +# Create TLS-encrypted connections + +. tests/nvme/rc + +DESCRIPTION="Create TLS-encrypted connections" +QUICK=1 + +requires() { + _nvme_requires + _have_loop + _have_kernel_option NVME_TCP_TLS + _have_kernel_option NVME_TARGET_TCP_TLS + _require_kernel_nvme_fabrics_feature tls + _require_nvme_trtype tcp + _require_nvme_cli_tls + _have_libnvme_ver 1 11 + _have_systemd_tlshd_service +} + +set_conditions() { + _set_nvme_trtype "$@" +} + +test() { + echo "Running ${TEST_NAME}" + + _setup_nvmet + + local hostkey + local ctrl + + hostkey=$(nvme gen-tls-key -n "${def_hostnqn}" -c "${def_subsysnqn}" -m 1 -I 1 -i 2> /dev/null) + if [ -z "$hostkey" ] ; then + echo "nvme gen-tls-key failed" + return 1 + fi + + _systemctl_start tlshd + + _nvmet_target_setup --blkdev file --tls + + # Test unencrypted connection + echo "Test unencrypted connection w/ tls not required" + _nvme_connect_subsys + + ctrl=$(_find_nvme_dev "${def_subsysnqn}") + if _nvme_ctrl_tls_key "$ctrl" > /dev/null; then + echo "WARNING: connection is encrypted" + fi + + _nvme_disconnect_subsys + + # Test encrypted connection + echo "Test encrypted connection w/ tls not required" + _nvme_connect_subsys --tls + + ctrl=$(_find_nvme_dev "${def_subsysnqn}") + if ! _nvme_ctrl_tls_key "$ctrl" > /dev/null ; then + echo "WARNING: connection is not encrypted" + fi + + _nvme_disconnect_subsys + + # Reset target configuration + _nvmet_target_cleanup + + _nvmet_target_setup --blkdev file --force-tls + + # Test unencrypted connection + echo "Test unencrypted connection w/ tls required (should fail)" + _nvme_connect_subsys + + _nvme_disconnect_subsys + + # Test encrypted connection + echo "Test encrypted connection w/ tls required" + _nvme_connect_subsys --tls + + ctrl=$(_find_nvme_dev "${def_subsysnqn}") + if ! _nvme_ctrl_tls_key "$ctrl" > /dev/null; then + echo "WARNING: connection is not encrypted" + fi + + _nvme_disconnect_subsys + + _nvmet_target_cleanup + + _systemctl_stop + + echo "Test complete" +} diff --git a/tests/nvme/060.out b/tests/nvme/060.out new file mode 100644 index 0000000..b2975bb --- /dev/null +++ b/tests/nvme/060.out @@ -0,0 +1,10 @@ +Running nvme/060 +Test unencrypted connection w/ tls not required +disconnected 1 controller(s) +Test encrypted connection w/ tls not required +disconnected 1 controller(s) +Test unencrypted connection w/ tls required (should fail) +disconnected 0 controller(s) +Test encrypted connection w/ tls required +disconnected 1 controller(s) +Test complete diff --git a/tests/nvme/rc b/tests/nvme/rc index e52437f..ac3949a 100644 --- a/tests/nvme/rc +++ b/tests/nvme/rc @@ -175,6 +175,14 @@ _require_nvme_cli_auth() { return 0 } +_require_nvme_cli_tls() { + if ! nvme gen-tls-key --subsysnqn nvmf-test-subsys > /dev/null 2>&1; then + SKIP_REASON+=("nvme gen-tls-key command missing") + return 1 + fi + return 0 +} + _require_kernel_nvme_fabrics_feature() { local feature="$1" @@ -630,3 +638,9 @@ _have_libnvme_ver() { fi return 0 } + +_nvme_ctrl_tls_key() { + local ctrl="$1" + + cat /sys/class/nvme/"$ctrl"/tls_key 2>/dev/null +} From patchwork Wed Apr 2 07:09:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shinichiro Kawasaki X-Patchwork-Id: 14035599 Received: from esa6.hgst.iphmx.com (esa6.hgst.iphmx.com [216.71.154.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1120E23315C for ; Wed, 2 Apr 2025 07:09:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.71.154.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577763; cv=none; b=YEtl9k+iOkZdfvYJJweBii8ytxzoYaz4A4rKC0Xbnad/mvAmVc75lXaOpOFblh0Z0iLFD632FZahUBxVD1YZXZ6dwi5R4sfkIPF2OzNSZDQdKgLDsO9T2j9ZgPm6J4rbYbxoV8BkVBsicVJpMfdhim0z94GmbBYA0ZhasuH05ps= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743577763; c=relaxed/simple; bh=MgPxIncYoIu1IyU0/pxsqdBGr5YKFoGwEiRiwr1vak4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C9GO+ecoLCe5+IKn8Y+6X81HB2I3bZISYYYRnMVhsRyJqUgSVV73LpIhoWK58DontOUQz2FgGFDmV5QANDJ8A/z6frHse8c7npnJZPj47if9cVlXE+JIBtB1Pq2IAZvqFkYurneo73WlMY4/cTA5KIML3nB8Vc4rAyIBjmvgt6M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com; spf=pass smtp.mailfrom=wdc.com; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b=bKq11qpG; arc=none smtp.client-ip=216.71.154.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wdc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wdc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="bKq11qpG" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1743577761; x=1775113761; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MgPxIncYoIu1IyU0/pxsqdBGr5YKFoGwEiRiwr1vak4=; b=bKq11qpG+FeBd/1W2Kd3aiLOU0q+IwcVqOcqkeGOkfKbdGfffIRqx9EM rKeMGgPMKwcm0m6obqR94PGq3kqafw/Us2XP2kKygKTb8XpO6H7eDjYvH lmnWGi7Btb9lieAAflyrLTNydS4Iu1Z4uhKjJeer9b50LPIvoHY5hM6Y1 0vyPXXi/LsVQJ+/eKlT5DEnj/rFkYN11XgVw7c4Ue0G8haYj+2z8Lg5YX LbJDg6D9P5Afxyq4flVu/C6v+Vxl3XSx44dVfeR0tkI4sbDssm2ixumCq VQoBzP/mYxQnZxW8MvRiRAe+bCV21lLDMZ4Q0ft2XS4A9CuelQK23zfnu Q==; X-CSE-ConnectionGUID: FPTuqQWhRQSx0sUAO/1Prw== X-CSE-MsgGUID: 3deTz+z5QDCwgbn26VeyhA== X-IronPort-AV: E=Sophos;i="6.14,295,1736784000"; d="scan'208";a="71367750" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 02 Apr 2025 15:09:20 +0800 IronPort-SDR: 67ecd4a9_GZyGbwKYYUmXgRKymJxuDKwC469HVyDuwEzoIkrY4wGQij1 4GqkhJL7fefMEVD4YQX6IGM8A5pOeSBrjKJ0pZA== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 01 Apr 2025 23:09:45 -0700 WDCIronportException: Internal Received: from 5cg2075fn7.ad.shared (HELO shinmob.wdc.com) ([10.224.102.114]) by uls-op-cesaip02.wdc.com with ESMTP; 02 Apr 2025 00:09:20 -0700 From: Shin'ichiro Kawasaki To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Hannes Reinecke , Shin'ichiro Kawasaki Subject: [PATCH blktests 10/10] nvme: add testcase for secure concatenation Date: Wed, 2 Apr 2025 16:09:06 +0900 Message-ID: <20250402070906.393160-11-shinichiro.kawasaki@wdc.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> References: <20250402070906.393160-1-shinichiro.kawasaki@wdc.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Hannes Reinecke NVMe-TCP has a 'secure concatenation' mode, where the TLS PSK is generated from the secret negotiated by the DH-HMAC-CHAP authentication, and the TLS connection is started after authentication. Signed-off-by: Hannes Reinecke [Shin'ichiro: added _have_systemd_tlshd_service, avoided "exit 1"] [Shin'ichiro: used _systemctl_start and _systemctl_stop] Signed-off-by: Shin'ichiro Kawasaki --- tests/nvme/061 | 109 +++++++++++++++++++++++++++++++++++++++++++++ tests/nvme/061.out | 7 +++ 2 files changed, 116 insertions(+) create mode 100755 tests/nvme/061 create mode 100644 tests/nvme/061.out diff --git a/tests/nvme/061 b/tests/nvme/061 new file mode 100755 index 0000000..7477078 --- /dev/null +++ b/tests/nvme/061 @@ -0,0 +1,109 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2022 Hannes Reinecke, SUSE Labs +# +# Create secure concatenation for TCP connections + +. tests/nvme/rc + +DESCRIPTION="Create authenticated TCP connections with secure concatenation" +QUICK=1 + +requires() { + _nvme_requires + _have_loop + _have_kernel_option NVME_AUTH + _have_kernel_option NVME_TCP_TLS + _have_kernel_option NVME_TARGET_AUTH + _have_kernel_option NVME_TARGET_TCP_TLS + _require_kernel_nvme_fabrics_feature dhchap_ctrl_secret + _require_kernel_nvme_fabrics_feature concat + _require_nvme_trtype tcp + _require_nvme_cli_auth + _have_systemd_tlshd_service +} + +set_conditions() { + _set_nvme_trtype "$@" +} + +test() { + echo "Running ${TEST_NAME}" + + _setup_nvmet + + local hostkey + + _systemctl_start tlshd + + hostkey=$(nvme gen-dhchap-key -m 1 -n "${def_hostnqn}" 2> /dev/null) + if [ -z "$hostkey" ] ; then + echo "nvme gen-dhchap-key failed" + _systemctl_stop + return 1 + fi + + _nvmet_target_setup --blkdev file --hostkey "${hostkey}" --tls + _set_nvmet_hash "${def_hostnqn}" "hmac(sha256)" + _set_nvmet_dhgroup "${def_hostnqn}" "ffdhe2048" + + echo "Test secure concatenation with SHA256" + _nvme_connect_subsys --dhchap-secret "${hostkey}" --concat + + ctrl=$(_find_nvme_dev "${def_subsysnqn}") + if [[ -z "$ctrl" ]]; then + echo "WARNING: connection failed" + _systemctl_stop + return 1 + fi + tlskey=$(_nvme_ctrl_tls_key "$ctrl" || true) + if [[ -z "$tlskey" ]]; then + echo "WARNING: connection is not encrypted" + _systemctl_stop + return 1 + fi + + # Reset controller to force re-negotiation + echo "Reset controller" + if ! nvme reset "/dev/${ctrl}" ; then + echo "WARNING: failed to reset controller" + fi + + new_tlskey=$(_nvme_ctrl_tls_key "$ctrl" || true) + if [[ -z "$new_tlskey" ]]; then + echo "WARNING: connection is not encrypted" + elif [[ "$new_tlskey" = "$tlskey" ]]; then + echo "WARNING: TLS key has not been renegotiated" + fi + + _nvme_disconnect_subsys + + hostkey=$(nvme gen-dhchap-key -m 2 -n "${def_hostnqn}" 2> /dev/null) + if [ -z "$hostkey" ] ; then + echo "nvme gen-dhchap-key failed" + _systemctl_stop + return 1 + fi + + _set_nvmet_hostkey "${def_hostnqn}" "${hostkey}" + _set_nvmet_hash "${def_hostnqn}" "hmac(sha384)" + _set_nvmet_dhgroup "${def_hostnqn}" "ffdhe3072" + + echo "Test secure concatenation with SHA384" + _nvme_connect_subsys --dhchap-secret "${hostkey}" --concat + + ctrl=$(_find_nvme_dev "${def_subsysnqn}") + if _nvme_ctrl_tls_key "$ctrl" > /dev/null ; then + echo "WARNING: connection is not encrypted" + _systemctl_stop + return 1 + fi + + _nvme_disconnect_subsys + + _nvmet_target_cleanup + + _systemctl_stop + + echo "Test complete" +} diff --git a/tests/nvme/061.out b/tests/nvme/061.out new file mode 100644 index 0000000..97e8948 --- /dev/null +++ b/tests/nvme/061.out @@ -0,0 +1,7 @@ +Running nvme/061 +Test secure concatenation with SHA256 +Reset controller +disconnected 1 controller(s) +Test secure concatenation with SHA384 +disconnected 1 controller(s) +Test complete