From c34515574f7a609d84fc6558b452344a961abcc0 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Mon, 3 Apr 2023 16:15:39 +0200 Subject: [PATCH 01/33] * Mon Apr 03 2023 Tomas Bzatek - 2.4-1 - Update to 2.4 --- .gitignore | 1 + nvme-cli.spec | 7 +++++-- sources | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 57b4e2e..5add3b2 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ /nvme-cli-2.2.tar.gz /nvme-cli-2.2.1.tar.gz /nvme-cli-2.3.tar.gz +/nvme-cli-2.4.tar.gz diff --git a/nvme-cli.spec b/nvme-cli.spec index f40b989..fd84a01 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -2,7 +2,7 @@ %{!?version_no_tilde: %define version_no_tilde %{shrink:%(echo '%{version}' | tr '~' '-')}} Name: nvme-cli -Version: 2.3 +Version: 2.4 Release: 1%{?dist} Summary: NVMe management command line interface @@ -17,7 +17,7 @@ BuildRequires: systemd-rpm-macros BuildRequires: zlib-devel BuildRequires: openssl-devel -BuildRequires: libnvme-devel >= 1.3 +BuildRequires: libnvme-devel >= 1.4 BuildRequires: json-c-devel >= 0.13 %if (0%{?rhel} == 0) @@ -83,6 +83,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Mon Apr 03 2023 Tomas Bzatek - 2.4-1 +- Update to 2.4 + * Wed Feb 01 2023 Tomas Bzatek - 2.3-1 - Update to 2.3 diff --git a/sources b/sources index e16fa7e..edbc0db 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (nvme-cli-2.3.tar.gz) = 9ef654e782ba737d3858fb11f24caf27aea820480179d07d32599731be204e52693062cdb86786ab5cdd1d94fe32ae9028baa0a58693d2eaee5a2b71155e3db2 +SHA512 (nvme-cli-2.4.tar.gz) = 155667a0b91e15267e3f991a30cf1d4ae26cb4c53b20c002e3d3341496dd463397e1afbfefcd7a8df88370d28417940ce44a060bda87c04482bbe3be4e901b73 From 062f3c94a1e92061f25fca53aa95428027480861 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Mon, 3 Apr 2023 16:15:39 +0200 Subject: [PATCH 02/33] * Mon Apr 03 2023 Tomas Bzatek - 2.4-1 - Update to 2.4 --- .gitignore | 1 + nvme-cli.spec | 7 +++++-- sources | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 57b4e2e..5add3b2 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ /nvme-cli-2.2.tar.gz /nvme-cli-2.2.1.tar.gz /nvme-cli-2.3.tar.gz +/nvme-cli-2.4.tar.gz diff --git a/nvme-cli.spec b/nvme-cli.spec index f40b989..fd84a01 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -2,7 +2,7 @@ %{!?version_no_tilde: %define version_no_tilde %{shrink:%(echo '%{version}' | tr '~' '-')}} Name: nvme-cli -Version: 2.3 +Version: 2.4 Release: 1%{?dist} Summary: NVMe management command line interface @@ -17,7 +17,7 @@ BuildRequires: systemd-rpm-macros BuildRequires: zlib-devel BuildRequires: openssl-devel -BuildRequires: libnvme-devel >= 1.3 +BuildRequires: libnvme-devel >= 1.4 BuildRequires: json-c-devel >= 0.13 %if (0%{?rhel} == 0) @@ -83,6 +83,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Mon Apr 03 2023 Tomas Bzatek - 2.4-1 +- Update to 2.4 + * Wed Feb 01 2023 Tomas Bzatek - 2.3-1 - Update to 2.3 diff --git a/sources b/sources index e16fa7e..edbc0db 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (nvme-cli-2.3.tar.gz) = 9ef654e782ba737d3858fb11f24caf27aea820480179d07d32599731be204e52693062cdb86786ab5cdd1d94fe32ae9028baa0a58693d2eaee5a2b71155e3db2 +SHA512 (nvme-cli-2.4.tar.gz) = 155667a0b91e15267e3f991a30cf1d4ae26cb4c53b20c002e3d3341496dd463397e1afbfefcd7a8df88370d28417940ce44a060bda87c04482bbe3be4e901b73 From 986ba7710f55c9e651366d774fe009ff3c0bc21f Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Thu, 20 Apr 2023 16:11:25 +0200 Subject: [PATCH 03/33] * Thu Apr 20 2023 Tomas Bzatek - 2.4-2 - Backport the NBFT support from git master --- ...bft-make-lookup_ctrl-function-public.patch | 75 ++ nvme-cli-2.5-nbft.patch | 451 ++++++++++++ nvme-cli-2.5-nbft_plugin.patch | 640 ++++++++++++++++++ nvme-cli.spec | 11 +- 4 files changed, 1175 insertions(+), 2 deletions(-) create mode 100644 nvme-cli-2.5-nbft-make-lookup_ctrl-function-public.patch create mode 100644 nvme-cli-2.5-nbft.patch create mode 100644 nvme-cli-2.5-nbft_plugin.patch diff --git a/nvme-cli-2.5-nbft-make-lookup_ctrl-function-public.patch b/nvme-cli-2.5-nbft-make-lookup_ctrl-function-public.patch new file mode 100644 index 0000000..78529b9 --- /dev/null +++ b/nvme-cli-2.5-nbft-make-lookup_ctrl-function-public.patch @@ -0,0 +1,75 @@ +From 34c197e0ac2d57734ab775f00b2d0758aca7b82f Mon Sep 17 00:00:00 2001 +From: John Meneghini +Date: Fri, 14 Apr 2023 10:53:58 -0400 +Subject: [PATCH 01/11] nbft: make lookup_ctrl function public + +To prepare for the addition of nbft functionality fixup the fabrics +declarations. + +Signed-off-by: John Meneghini +--- + fabrics.c | 12 ++---------- + fabrics.h | 10 ++++++++++ + 2 files changed, 12 insertions(+), 10 deletions(-) + +diff --git a/fabrics.c b/fabrics.c +index f8078e59..80827b16 100644 +--- a/fabrics.c ++++ b/fabrics.c +@@ -43,6 +43,7 @@ + #include "libnvme.h" + #include "nvme-print.h" + #include "nvme-print-json.h" ++#include "fabrics.h" + + #define PATH_NVMF_DISC SYSCONFDIR "/nvme/discovery.conf" + #define PATH_NVMF_CONFIG SYSCONFDIR "/nvme/config.json" +@@ -110,15 +111,6 @@ static const char *nvmf_config_file = "Use specified JSON configuration file or + OPT_FLAG("data-digest", 'G', &c.data_digest, nvmf_data_digest), \ + OPT_FLAG("tls", 0, &c.tls, nvmf_tls) \ + +-struct tr_config { +- const char *subsysnqn; +- const char *transport; +- const char *traddr; +- const char *host_traddr; +- const char *host_iface; +- const char *trsvcid; +-}; +- + /* + * Compare two C strings and handle NULL pointers gracefully. + * If either of the two strings is NULL, return 0 +@@ -202,7 +194,7 @@ static nvme_ctrl_t lookup_discovery_ctrl(nvme_root_t r, struct tr_config *trcfg) + return __lookup_ctrl(r, trcfg, disc_ctrl_config_match); + } + +-static nvme_ctrl_t lookup_ctrl(nvme_root_t r, struct tr_config *trcfg) ++nvme_ctrl_t lookup_ctrl(nvme_root_t r, struct tr_config *trcfg) + { + return __lookup_ctrl(r, trcfg, ctrl_config_match); + } +diff --git a/fabrics.h b/fabrics.h +index d1e16fc5..02cebf5d 100644 +--- a/fabrics.h ++++ b/fabrics.h +@@ -2,6 +2,16 @@ + #ifndef _FABRICS_H + #define _FABRICS_H + ++struct tr_config { ++ const char *subsysnqn; ++ const char *transport; ++ const char *traddr; ++ const char *host_traddr; ++ const char *host_iface; ++ const char *trsvcid; ++}; ++ ++extern nvme_ctrl_t lookup_ctrl(nvme_root_t r, struct tr_config *trcfg); + extern int nvmf_discover(const char *desc, int argc, char **argv, bool connect); + extern int nvmf_connect(const char *desc, int argc, char **argv); + extern int nvmf_disconnect(const char *desc, int argc, char **argv); +-- +2.39.2 + diff --git a/nvme-cli-2.5-nbft.patch b/nvme-cli-2.5-nbft.patch new file mode 100644 index 0000000..e54da19 --- /dev/null +++ b/nvme-cli-2.5-nbft.patch @@ -0,0 +1,451 @@ +From a71a08532b5f06ee19ee2ff118a23cec4ecb6719 Mon Sep 17 00:00:00 2001 +From: Stuart Hayes +Date: Wed, 15 Jun 2022 11:42:50 -0500 +Subject: [PATCH 02/11] nbft: added NBFT v1.0 table support + +Added support for parsing the contents of the NBFT table (per NVMe-oF +boot specification v1.0) with the connect-all and discover commands. + +nvme discover/connect-all --nbft ignore /etc/nvme config and use NBFT tables +nvme discover/connect-all --no-nbft ignore NBFT tables and use /etc/nvme config +nvme discover/connect-all --nbft-path= user-defined path for NBFT tables + +Signed-off-by: Stuart Hayes +Signed-off-by: Martin Belanger + +Use the new nbft public API. + +Signed-off-by: Tomas Bzatek +Signed-off-by: Martin Wilck +Signed-off-by: John Meneghini +--- + Documentation/nvme-connect-all.txt | 25 ++++ + Documentation/nvme-discover.txt | 27 +++- + fabrics.c | 17 +++ + meson.build | 1 + + nbft.c | 202 +++++++++++++++++++++++++++++ + nbft.h | 19 +++ + 6 files changed, 290 insertions(+), 1 deletion(-) + create mode 100644 nbft.c + create mode 100644 nbft.h + +diff --git a/Documentation/nvme-connect-all.txt b/Documentation/nvme-connect-all.txt +index 44bb4f94..cbb7ca6c 100644 +--- a/Documentation/nvme-connect-all.txt ++++ b/Documentation/nvme-connect-all.txt +@@ -35,6 +35,9 @@ SYNOPSIS + [--tls ] + [--quiet | -S] + [--dump-config | -O] ++ [--nbft] ++ [--no-nbft] ++ [--nbft-path=] + + DESCRIPTION + ----------- +@@ -198,6 +201,16 @@ OPTIONS + --dump-config:: + Print out resulting JSON configuration file to stdout. + ++--nbft:: ++ Only look at NBFT tables ++ ++--no-nbft:: ++ Do not look at NBFT tables ++ ++--nbft-path=:: ++ Use a user-defined path to the NBFT tables ++ ++ + + EXAMPLES + -------- +@@ -210,6 +223,18 @@ the RDMA network. Port 4420 is used by default: + --hostnqn=host1-rogue-nqn + ------------ + + ++* Issue a 'nvme connect-all' command using the default system defined NBFT tables: +++ ++----------- ++# nvme connect-all --nbft ++------------ +++ ++* Issue a 'nvme connect-all' command with a user-defined path for the NBFT table: +++ ++----------- ++# nvme connet-all --nbft-path=/sys/firmware/acpi/tables/NBFT1 ++------------ +++ + * Issue a 'nvme connect-all' command using a @SYSCONFDIR@/nvme/discovery.conf file: + + + ----------- +diff --git a/Documentation/nvme-discover.txt b/Documentation/nvme-discover.txt +index d4df75c2..b040c688 100644 +--- a/Documentation/nvme-discover.txt ++++ b/Documentation/nvme-discover.txt +@@ -37,6 +37,9 @@ SYNOPSIS + [--dump-config | -O] + [--output-format= | -o ] + [--force] ++ [--nbft] ++ [--no-nbft] ++ [--nbft-path=] + + DESCRIPTION + ----------- +@@ -68,7 +71,7 @@ Note that the base NVMe specification defines the NQN (NVMe Qualified + Name) format which an NVMe endpoint (device, subsystem, etc) must + follow to guarantee a unique name under the NVMe standard. + In particular, the Host NQN uniquely identifies the NVMe Host, and +-may be used by the the Discovery Controller to control what NVMe Target ++may be used by the Discovery Controller to control what NVMe Target + resources are allocated to the NVMe Host for a connection. + + A Discovery Controller has it's own NQN defined in the NVMe-over-Fabrics +@@ -229,6 +232,16 @@ OPTIONS + Combined with --persistent flag, always create new + persistent discovery connection. + ++--nbft:: ++ Only look at NBFT tables ++ ++--no-nbft:: ++ Do not look at NBFT tables ++ ++--nbft-path=:: ++ Use a user-defined path to the NBFT tables ++ ++ + EXAMPLES + -------- + * Query the Discover Controller with IP4 address 192.168.1.3 for all +@@ -240,6 +253,18 @@ Port 4420 is used by default: + --hostnqn=host1-rogue-nqn + ------------ + + ++* Issue a 'nvme discover' command using the default system defined NBFT tables: +++ ++----------- ++# nvme discover --nbft ++------------ +++ ++* Issue a 'nvme discover' command with a user-defined path for the NBFT table: +++ ++----------- ++# nvme discover --nbft-path=/sys/firmware/acpi/tables/NBFT1 ++------------ +++ + * Issue a 'nvme discover' command using a @SYSCONFDIR@/nvme/discovery.conf file: + + + ----------- +diff --git a/fabrics.c b/fabrics.c +index 80827b16..0edbd299 100644 +--- a/fabrics.c ++++ b/fabrics.c +@@ -40,6 +40,7 @@ + + #include "common.h" + #include "nvme.h" ++#include "nbft.h" + #include "libnvme.h" + #include "nvme-print.h" + #include "nvme-print-json.h" +@@ -710,6 +711,7 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) + { + char *subsysnqn = NVME_DISC_SUBSYS_NAME; + char *hostnqn = NULL, *hostid = NULL, *hostkey = NULL; ++ char *hostnqn_arg, *hostid_arg; + char *transport = NULL, *traddr = NULL, *trsvcid = NULL; + char *config_file = PATH_NVMF_CONFIG; + char *hnqn = NULL, *hid = NULL; +@@ -724,6 +726,8 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) + char *device = NULL; + bool force = false; + bool json_config = false; ++ bool nbft = false, nonbft = false; ++ char *nbft_path = NBFT_SYSFS_PATH; + + OPT_ARGS(opts) = { + OPT_STRING("device", 'd', "DEV", &device, "use existing discovery controller device"), +@@ -736,6 +740,9 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) + OPT_INCR("verbose", 'v', &verbose, "Increase logging verbosity"), + OPT_FLAG("dump-config", 'O', &dump_config, "Dump configuration file to stdout"), + OPT_FLAG("force", 0, &force, "Force persistent discovery controller creation"), ++ OPT_FLAG("nbft", 0, &nbft, "Only look at NBFT tables"), ++ OPT_FLAG("no-nbft", 0, &nonbft, "Do not look at NBFT tables"), ++ OPT_STRING("nbft-path", 0, "STR", &nbft_path, "user-defined path for NBFT tables"), + OPT_END() + }; + +@@ -768,6 +775,8 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) + if (!nvme_read_config(r, config_file)) + json_config = true; + ++ hostnqn_arg = hostnqn; ++ hostid_arg = hostid; + if (!hostnqn) + hostnqn = hnqn = nvmf_hostnqn_from_file(); + if (!hostnqn) +@@ -789,6 +798,14 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) + nvme_host_set_dhchap_key(h, hostkey); + + if (!device && !transport && !traddr) { ++ if (!nonbft) ++ discover_from_nbft(r, hostnqn_arg, hostid_arg, ++ hostnqn, hostid, desc, connect, ++ &cfg, nbft_path, flags, verbose); ++ ++ if (nbft) ++ goto out_free; ++ + if (json_config) + ret = discover_from_json_config_file(r, h, desc, + connect, &cfg, +diff --git a/meson.build b/meson.build +index 43ce5f9b..7ec357a9 100644 +--- a/meson.build ++++ b/meson.build +@@ -240,6 +240,7 @@ incdir = include_directories(['ccan']) + + ################################################################################ + sources = [ ++ 'nbft.c', + 'fabrics.c', + 'nvme.c', + 'nvme-models.c', +diff --git a/nbft.c b/nbft.c +new file mode 100644 +index 00000000..14347287 +--- /dev/null ++++ b/nbft.c +@@ -0,0 +1,202 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later ++ ++#include ++#include ++#include ++ ++#include "nvme.h" ++#include "nbft.h" ++#include "libnvme.h" ++#include "fabrics.h" ++ ++#define NBFT_SYSFS_FILENAME "NBFT*" ++ ++static void print_connect_msg(nvme_ctrl_t c) ++{ ++ printf("device: %s\n", nvme_ctrl_get_name(c)); ++} ++ ++static void json_connect_msg(nvme_ctrl_t c) ++{ ++ struct json_object *root; ++ ++ root = json_create_object(); ++ json_object_add_value_string(root, "device", nvme_ctrl_get_name(c)); ++ ++ json_print_object(root, NULL); ++ printf("\n"); ++ json_free_object(root); ++} ++ ++int nbft_filter(const struct dirent *dent) ++{ ++ return !fnmatch(NBFT_SYSFS_FILENAME, dent->d_name, FNM_PATHNAME); ++} ++ ++int read_nbft_files(struct list_head *nbft_list, char *path) ++{ ++ struct dirent **dent; ++ char filename[PATH_MAX]; ++ int i, count, ret; ++ struct nbft_file_entry *entry; ++ struct nbft_info *nbft; ++ ++ count = scandir(path, &dent, nbft_filter, NULL); ++ if (count < 0) { ++ fprintf(stderr, "Failed to open %s.\n", path); ++ return -1; ++ } ++ ++ for (i = 0; i < count; i++) { ++ snprintf(filename, sizeof(filename), "%s/%s", path, dent[i]->d_name); ++ ret = nvme_nbft_read(&nbft, filename); ++ if (!ret) { ++ entry = calloc(1, sizeof(*entry)); ++ entry->nbft = nbft; ++ list_add_tail(nbft_list, &entry->node); ++ } ++ free(dent[i]); ++ } ++ free(dent); ++ return 0; ++} ++ ++void free_nbfts(struct list_head *nbft_list) ++{ ++ struct nbft_file_entry *entry; ++ ++ while ((entry = list_pop(nbft_list, struct nbft_file_entry, node))) { ++ nvme_nbft_free(entry->nbft); ++ free(entry); ++ } ++} ++ ++int discover_from_nbft(nvme_root_t r, char *hostnqn_arg, char *hostid_arg, ++ char *hostnqn_sys, char *hostid_sys, ++ const char *desc, bool connect, ++ const struct nvme_fabrics_config *cfg, char *nbft_path, ++ enum nvme_print_flags flags, bool verbose) ++{ ++ char *hostnqn = NULL, *hostid = NULL, *host_traddr = NULL; ++ nvme_host_t h; ++ nvme_ctrl_t c; ++ int ret, i; ++ struct list_head nbft_list; ++ struct nbft_file_entry *entry; ++ struct nbft_info_subsystem_ns **ss; ++ struct nbft_info_hfi *hfi; ++ ++ if (!connect) ++ /* to do: print discovery-type info from NBFT tables */ ++ return 0; ++ ++ list_head_init(&nbft_list); ++ ret = read_nbft_files(&nbft_list, nbft_path); ++ if (ret) ++ goto out_free_2; ++ ++ list_for_each(&nbft_list, entry, node) ++ for (ss = entry->nbft->subsystem_ns_list; ss && *ss; ss++) ++ for (i = 0; i < (*ss)->num_hfis; i++) { ++ nvme_ctrl_t cl; ++ ++ hfi = (*ss)->hfis[i]; ++ if (hostnqn_arg) ++ hostnqn = hostnqn_arg; ++ else { ++ hostnqn = entry->nbft->host.nqn; ++ if (!hostnqn) ++ hostnqn = hostnqn_sys; ++ } ++ ++ if (hostid_arg) ++ hostid = hostid_arg; ++ else if (*entry->nbft->host.id) { ++ hostid = (char *)util_uuid_to_string(entry->nbft->host.id); ++ if (!hostid) ++ hostid = hostid_sys; ++ } ++ ++ h = nvme_lookup_host(r, hostnqn, hostid); ++ if (!h) { ++ errno = ENOMEM; ++ goto out_free; ++ } ++ ++ if (!cfg->host_traddr) { ++ host_traddr = NULL; ++ if (!strncmp((*ss)->transport, "tcp", 3)) ++ host_traddr = hfi->tcp_info.ipaddr; ++ } ++ ++ struct tr_config trcfg = { ++ .subsysnqn = (*ss)->subsys_nqn, ++ .transport = (*ss)->transport, ++ .traddr = (*ss)->traddr, ++ .host_traddr = host_traddr, ++ .host_iface = NULL, ++ .trsvcid = (*ss)->trsvcid, ++ }; ++ ++ /* Already connected ? */ ++ cl = lookup_ctrl(r, &trcfg); ++ if (cl && nvme_ctrl_get_name(cl)) ++ continue; ++ ++ c = nvme_create_ctrl(r, (*ss)->subsys_nqn, (*ss)->transport, ++ (*ss)->traddr, host_traddr, NULL, ++ (*ss)->trsvcid); ++ if (!c) { ++ errno = ENOMEM; ++ goto out_free; ++ } ++ ++ errno = 0; ++ ret = nvmf_add_ctrl(h, c, cfg); ++ ++ /* ++ * With TCP/DHCP, it can happen that the OS ++ * obtains a different local IP address than the ++ * firmware had. Retry without host_traddr. ++ */ ++ if (ret == -1 && errno == ENVME_CONNECT_WRITE && ++ !strcmp((*ss)->transport, "tcp") && ++ strlen(hfi->tcp_info.dhcp_server_ipaddr) > 0) { ++ nvme_free_ctrl(c); ++ ++ trcfg.host_traddr = NULL; ++ cl = lookup_ctrl(r, &trcfg); ++ if (cl && nvme_ctrl_get_name(cl)) ++ continue; ++ ++ c = nvme_create_ctrl(r, (*ss)->subsys_nqn, (*ss)->transport, ++ (*ss)->traddr, ++ NULL, NULL, (*ss)->trsvcid); ++ if (!c) { ++ errno = ENOMEM; ++ goto out_free; ++ } ++ errno = 0; ++ ret = nvmf_add_ctrl(h, c, cfg); ++ if (ret == 0 && verbose >= 1) ++ fprintf(stderr, ++ "connect with host_traddr=\"%s\" failed, success after omitting host_traddr\n", ++ host_traddr); ++ } ++ ++ if (ret) ++ fprintf(stderr, "no controller found\n"); ++ else { ++ if (flags == NORMAL) ++ print_connect_msg(c); ++ else if (flags == JSON) ++ json_connect_msg(c); ++ } ++out_free: ++ if (errno == ENOMEM) ++ goto out_free_2; ++ } ++out_free_2: ++ free_nbfts(&nbft_list); ++ return errno; ++} +diff --git a/nbft.h b/nbft.h +new file mode 100644 +index 00000000..0e09733f +--- /dev/null ++++ b/nbft.h +@@ -0,0 +1,19 @@ ++/* SPDX-License-Identifier: GPL-2.0-or-later */ ++ ++#include ++ ++#define NBFT_SYSFS_PATH "/sys/firmware/acpi/tables" ++ ++struct nbft_file_entry { ++ struct list_node node; ++ struct nbft_info *nbft; ++}; ++ ++int read_nbft_files(struct list_head *nbft_list, char *path); ++void free_nbfts(struct list_head *nbft_list); ++ ++extern int discover_from_nbft(nvme_root_t r, char *hostnqn_arg, char *hostid_arg, ++ char *hostnqn_sys, char *hostid_sys, ++ const char *desc, bool connect, ++ const struct nvme_fabrics_config *cfg, char *nbft_path, ++ enum nvme_print_flags flags, bool verbose); +-- +2.39.2 + diff --git a/nvme-cli-2.5-nbft_plugin.patch b/nvme-cli-2.5-nbft_plugin.patch new file mode 100644 index 0000000..b70d26e --- /dev/null +++ b/nvme-cli-2.5-nbft_plugin.patch @@ -0,0 +1,640 @@ +From 23daeedc53be9b5225cc6806434888c0a7a8e9bf Mon Sep 17 00:00:00 2001 +From: Stuart Hayes +Date: Fri, 14 Apr 2023 22:01:07 -0400 +Subject: [PATCH 03/11] nbft: add the nbft show plugin + +Display contents of the ACPI NBFT files. + +Usage: nvme nbft show [OPTIONS] + +Options: + [ --output-format=, -o ] --- Output format: normal|json + [ --subsystem, -s ] --- show NBFT subsystems + [ --hfi, -H ] --- show NBFT HFIs + [ --discovery, -d ] --- show NBFT discovery controllers + [ --nbft-path= ] --- user-defined path for NBFT tables + +Signed-off-by: Stuart Hayes +Signed-off-by: Martin Wilck +Signed-off-by: John Meneghini +--- + plugins/meson.build | 1 + + plugins/nbft/nbft-plugin.c | 568 +++++++++++++++++++++++++++++++++++++ + plugins/nbft/nbft-plugin.h | 18 ++ + 3 files changed, 587 insertions(+) + create mode 100644 plugins/nbft/nbft-plugin.c + create mode 100644 plugins/nbft/nbft-plugin.h + +diff --git a/plugins/meson.build b/plugins/meson.build +index 2cf2486f..38b7cded 100644 +--- a/plugins/meson.build ++++ b/plugins/meson.build +@@ -12,6 +12,7 @@ if json_c_dep.found() + 'plugins/intel/intel-nvme.c', + 'plugins/memblaze/memblaze-nvme.c', + 'plugins/micron/micron-nvme.c', ++ 'plugins/nbft/nbft-plugin.c', + 'plugins/netapp/netapp-nvme.c', + 'plugins/nvidia/nvidia-nvme.c', + 'plugins/scaleflux/sfx-nvme.c', +diff --git a/plugins/nbft/nbft-plugin.c b/plugins/nbft/nbft-plugin.c +new file mode 100644 +index 00000000..6ae2525a +--- /dev/null ++++ b/plugins/nbft/nbft-plugin.c +@@ -0,0 +1,568 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later ++ ++#include ++#include ++#include ++ ++#include "nvme-print.h" ++#include "nvme.h" ++#include "nbft.h" ++#include "libnvme.h" ++#include "fabrics.h" ++ ++#define CREATE_CMD ++#include "nbft-plugin.h" ++ ++static const char dash[100] = {[0 ... 98] = '-', [99] = '\0'}; ++ ++#define PCI_SEGMENT(sbdf) ((sbdf & 0xffff0000) >> 16) ++#define PCI_BUS(sbdf) ((sbdf & 0x0000ff00) >> 8) ++#define PCI_DEV(sbdf) ((sbdf & 0x000000f8) >> 3) ++#define PCI_FUNC(sbdf) ((sbdf & 0x00000007) >> 0) ++ ++static const char *pci_sbdf_to_string(__u16 pci_sbdf) ++{ ++ static char pcidev[13]; ++ ++ snprintf(pcidev, sizeof(pcidev), "%x:%x:%x.%x", ++ PCI_SEGMENT(pci_sbdf), ++ PCI_BUS(pci_sbdf), ++ PCI_DEV(pci_sbdf), ++ PCI_FUNC(pci_sbdf)); ++ return pcidev; ++} ++ ++static char *mac_addr_to_string(unsigned char mac_addr[6]) ++{ ++ static char mac_string[18]; ++ ++ snprintf(mac_string, sizeof(mac_string), "%02x:%02x:%02x:%02x:%02x:%02x", ++ mac_addr[0], ++ mac_addr[1], ++ mac_addr[2], ++ mac_addr[3], ++ mac_addr[4], ++ mac_addr[5]); ++ return mac_string; ++} ++ ++static json_object *hfi_to_json(struct nbft_info_hfi *hfi) ++{ ++ struct json_object *hfi_json; ++ ++ hfi_json = json_create_object(); ++ if (!hfi_json) ++ return NULL; ++ ++ if (json_object_add_value_int(hfi_json, "index", hfi->index) ++ || json_object_add_value_string(hfi_json, "transport", hfi->transport)) ++ goto fail; ++ ++ if (strcmp(hfi->transport, "tcp") == 0) { ++ if (json_object_add_value_string(hfi_json, "pcidev", ++ pci_sbdf_to_string(hfi->tcp_info.pci_sbdf)) ++ || json_object_add_value_string(hfi_json, "mac_addr", ++ mac_addr_to_string(hfi->tcp_info.mac_addr)) ++ || json_object_add_value_int(hfi_json, "vlan", ++ hfi->tcp_info.vlan) ++ || json_object_add_value_int(hfi_json, "ip_origin", ++ hfi->tcp_info.ip_origin) ++ || json_object_add_value_string(hfi_json, "ipaddr", ++ hfi->tcp_info.ipaddr) ++ || json_object_add_value_int(hfi_json, "subnet_mask_prefix", ++ hfi->tcp_info.subnet_mask_prefix) ++ || json_object_add_value_string(hfi_json, "gateway_ipaddr", ++ hfi->tcp_info.gateway_ipaddr) ++ || json_object_add_value_int(hfi_json, "route_metric", ++ hfi->tcp_info.route_metric) ++ || json_object_add_value_string(hfi_json, "primary_dns_ipaddr", ++ hfi->tcp_info.primary_dns_ipaddr) ++ || json_object_add_value_string(hfi_json, "secondary_dns_ipaddr", ++ hfi->tcp_info.secondary_dns_ipaddr) ++ || json_object_add_value_string(hfi_json, "dhcp_server_ipaddr", ++ hfi->tcp_info.dhcp_server_ipaddr) ++ || (hfi->tcp_info.host_name ++ && json_object_add_value_string(hfi_json, "host_name", ++ hfi->tcp_info.host_name)) ++ || json_object_add_value_int(hfi_json, "this_hfi_is_default_route", ++ hfi->tcp_info.this_hfi_is_default_route) ++ || json_object_add_value_int(hfi_json, "dhcp_override", ++ hfi->tcp_info.dhcp_override)) ++ goto fail; ++ else ++ return hfi_json; ++ } ++fail: ++ json_free_object(hfi_json); ++ return NULL; ++} ++ ++static json_object *ssns_to_json(struct nbft_info_subsystem_ns *ss) ++{ ++ struct json_object *ss_json; ++ struct json_object *hfi_array_json; ++ char json_str[40]; ++ char *json_str_p; ++ int i; ++ ++ ss_json = json_create_object(); ++ if (!ss_json) ++ return NULL; ++ ++ hfi_array_json = json_create_array(); ++ if (!hfi_array_json) ++ goto fail; ++ ++ for (i = 0; i < ss->num_hfis; i++) ++ if (json_array_add_value_object(hfi_array_json, ++ json_object_new_int(ss->hfis[i]->index))) ++ goto fail; ++ ++ if (json_object_add_value_int(ss_json, "index", ss->index) ++ || json_object_add_value_int(ss_json, "num_hfis", ss->num_hfis) ++ || json_object_object_add(ss_json, "hfis", hfi_array_json) ++ || json_object_add_value_string(ss_json, "transport", ss->transport) ++ || json_object_add_value_string(ss_json, "traddr", ss->traddr) ++ || json_object_add_value_string(ss_json, "trsvcid", ss->trsvcid) ++ || json_object_add_value_int(ss_json, "subsys_port_id", ss->subsys_port_id) ++ || json_object_add_value_int(ss_json, "nsid", ss->nsid)) ++ goto fail; ++ ++ memset(json_str, 0, sizeof(json_str)); ++ json_str_p = json_str; ++ ++ switch (ss->nid_type) { ++ case NBFT_INFO_NID_TYPE_EUI64: ++ if (json_object_add_value_string(ss_json, "nid_type", "eui64")) ++ goto fail; ++ for (i = 0; i < 8; i++) ++ json_str_p += sprintf(json_str_p, "%02x", ss->nid[i]); ++ break; ++ ++ case NBFT_INFO_NID_TYPE_NGUID: ++ if (json_object_add_value_string(ss_json, "nid_type", "nguid")) ++ goto fail; ++ for (i = 0; i < 16; i++) ++ json_str_p += sprintf(json_str_p, "%02x", ss->nid[i]); ++ break; ++ ++ case NBFT_INFO_NID_TYPE_NS_UUID: ++ if (json_object_add_value_string(ss_json, "nid_type", "uuid")) ++ goto fail; ++ nvme_uuid_to_string(ss->nid, json_str); ++ break; ++ ++ default: ++ break; ++ } ++ if (json_object_add_value_string(ss_json, "nid", json_str)) ++ goto fail; ++ ++ if ((ss->subsys_nqn ++ && json_object_add_value_string(ss_json, "subsys_nqn", ss->subsys_nqn)) ++ || json_object_add_value_int(ss_json, "controller_id", ss->controller_id) ++ || json_object_add_value_int(ss_json, "asqsz", ss->asqsz) ++ || (ss->dhcp_root_path_string ++ && json_object_add_value_string(ss_json, "dhcp_root_path_string", ++ ss->dhcp_root_path_string)) ++ || json_object_add_value_int(ss_json, "pdu_header_digest_required", ++ ss->pdu_header_digest_required) ++ || json_object_add_value_int(ss_json, "data_digest_required", ++ ss->data_digest_required)) ++ goto fail; ++ ++ return ss_json; ++fail: ++ json_free_object(ss_json); ++ return NULL; ++} ++ ++static json_object *discovery_to_json(struct nbft_info_discovery *disc) ++{ ++ struct json_object *disc_json; ++ ++ disc_json = json_create_object(); ++ if (!disc_json) ++ return NULL; ++ ++ if (json_object_add_value_int(disc_json, "index", disc->index) ++ || (disc->security ++ && json_object_add_value_int(disc_json, "security", disc->security->index)) ++ || (disc->hfi ++ && json_object_add_value_int(disc_json, "hfi", disc->hfi->index)) ++ || (disc->uri ++ && json_object_add_value_string(disc_json, "uri", disc->uri)) ++ || (disc->nqn ++ && json_object_add_value_string(disc_json, "nqn", disc->nqn))) { ++ json_free_object(disc_json); ++ return NULL; ++ } else ++ return disc_json; ++} ++ ++static const char *primary_admin_host_flag_to_str(unsigned int primary) ++{ ++ static const char * const str[] = { ++ [NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_NOT_INDICATED] = "not indicated", ++ [NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_UNSELECTED] = "unselected", ++ [NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_SELECTED] = "selected", ++ [NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_RESERVED] = "reserved", ++ }; ++ ++ if (primary > NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_RESERVED) ++ return "INVALID"; ++ return str[primary]; ++} ++ ++static struct json_object *nbft_to_json(struct nbft_info *nbft, bool show_subsys, ++ bool show_hfi, bool show_discovery) ++{ ++ struct json_object *nbft_json, *host_json; ++ ++ nbft_json = json_create_object(); ++ if (!nbft_json) ++ return NULL; ++ ++ if (json_object_add_value_string(nbft_json, "filename", nbft->filename)) ++ goto fail; ++ ++ host_json = json_create_object(); ++ if (!host_json) ++ goto fail; ++ if ((nbft->host.nqn ++ && json_object_add_value_string(host_json, "nqn", nbft->host.nqn)) ++ || (nbft->host.id ++ && json_object_add_value_string(host_json, "id", ++ util_uuid_to_string(nbft->host.id)))) ++ goto fail; ++ json_object_add_value_int(host_json, "host_id_configured", ++ nbft->host.host_id_configured); ++ json_object_add_value_int(host_json, "host_nqn_configured", ++ nbft->host.host_nqn_configured); ++ json_object_add_value_string(host_json, "primary_admin_host_flag", ++ primary_admin_host_flag_to_str(nbft->host.primary)); ++ if (json_object_object_add(nbft_json, "host", host_json)) { ++ json_free_object(host_json); ++ goto fail; ++ } ++ ++ if (show_subsys) { ++ struct json_object *subsys_array_json, *subsys_json; ++ struct nbft_info_subsystem_ns **ss; ++ ++ subsys_array_json = json_create_array(); ++ if (!subsys_array_json) ++ goto fail; ++ for (ss = nbft->subsystem_ns_list; ss && *ss; ss++) { ++ subsys_json = ssns_to_json(*ss); ++ if (!subsys_json) ++ goto fail; ++ if (json_object_array_add(subsys_array_json, subsys_json)) { ++ json_free_object(subsys_json); ++ goto fail; ++ } ++ } ++ if (json_object_object_add(nbft_json, "subsystem", subsys_array_json)) { ++ json_free_object(subsys_array_json); ++ goto fail; ++ } ++ } ++ if (show_hfi) { ++ struct json_object *hfi_array_json, *hfi_json; ++ struct nbft_info_hfi **hfi; ++ ++ hfi_array_json = json_create_array(); ++ if (!hfi_array_json) ++ goto fail; ++ for (hfi = nbft->hfi_list; hfi && *hfi; hfi++) { ++ hfi_json = hfi_to_json(*hfi); ++ if (!hfi_json) ++ goto fail; ++ if (json_object_array_add(hfi_array_json, hfi_json)) { ++ json_free_object(hfi_json); ++ goto fail; ++ } ++ } ++ if (json_object_object_add(nbft_json, "hfi", hfi_array_json)) { ++ json_free_object(hfi_array_json); ++ goto fail; ++ } ++ } ++ if (show_discovery) { ++ struct json_object *discovery_array_json, *discovery_json; ++ struct nbft_info_discovery **disc; ++ ++ discovery_array_json = json_create_array(); ++ if (!discovery_array_json) ++ goto fail; ++ for (disc = nbft->discovery_list; disc && *disc; disc++) { ++ discovery_json = discovery_to_json(*disc); ++ if (!discovery_json) ++ goto fail; ++ if (json_object_array_add(discovery_array_json, discovery_json)) { ++ json_free_object(discovery_json); ++ goto fail; ++ } ++ } ++ if (json_object_object_add(nbft_json, "discovery", discovery_array_json)) { ++ json_free_object(discovery_array_json); ++ goto fail; ++ } ++ } ++ return nbft_json; ++fail: ++ json_free_object(nbft_json); ++ return NULL; ++} ++ ++static int json_show_nbfts(struct list_head *nbft_list, bool show_subsys, ++ bool show_hfi, bool show_discovery) ++{ ++ struct json_object *nbft_json_array, *nbft_json; ++ struct nbft_file_entry *entry; ++ ++ nbft_json_array = json_create_array(); ++ if (!nbft_json_array) ++ return ENOMEM; ++ ++ list_for_each(nbft_list, entry, node) { ++ nbft_json = nbft_to_json(entry->nbft, show_subsys, show_hfi, show_discovery); ++ if (!nbft_json) ++ goto fail; ++ if (json_object_array_add(nbft_json_array, nbft_json)) { ++ json_free_object(nbft_json); ++ goto fail; ++ } ++ } ++ ++ json_print_object(nbft_json_array, NULL); ++ printf("\n"); ++ json_free_object(nbft_json_array); ++ return 0; ++fail: ++ json_free_object(nbft_json_array); ++ return ENOMEM; ++} ++ ++static void print_nbft_hfi_info(struct nbft_info *nbft) ++{ ++ struct nbft_info_hfi **hfi; ++ unsigned int ip_width = 8, gw_width = 8, dns_width = 8; ++ ++ hfi = nbft->hfi_list; ++ if (!hfi || !*hfi) ++ return; ++ ++ for (; *hfi; hfi++) { ++ unsigned int len; ++ ++ len = strlen((*hfi)->tcp_info.ipaddr); ++ if (len > ip_width) ++ ip_width = len; ++ len = strlen((*hfi)->tcp_info.gateway_ipaddr); ++ if (len > gw_width) ++ gw_width = len; ++ len = strlen((*hfi)->tcp_info.primary_dns_ipaddr); ++ if (len > dns_width) ++ dns_width = len; ++ } ++ ++ printf("\nNBFT HFIs:\n\n"); ++ printf("%-3.3s|%-4.4s|%-10.10s|%-17.17s|%-4.4s|%-*.*s|%-4.4s|%-*.*s|%-*.*s\n", ++ "Idx", "Trsp", "PCI Addr", "MAC Addr", "DHCP", ++ ip_width, ip_width, "IP Addr", "Mask", ++ gw_width, gw_width, "Gateway", dns_width, dns_width, "DNS"); ++ printf("%-.3s+%-.4s+%-.10s+%-.17s+%-.4s+%-.*s+%-.4s+%-.*s+%-.*s\n", ++ dash, dash, dash, dash, dash, ip_width, dash, dash, ++ gw_width, dash, dns_width, dash); ++ for (hfi = nbft->hfi_list; *hfi; hfi++) ++ printf("%-3d|%-4.4s|%-10.10s|%-17.17s|%-4.4s|%-*.*s|%-4d|%-*.*s|%-*.*s\n", ++ (*hfi)->index, ++ (*hfi)->transport, ++ pci_sbdf_to_string((*hfi)->tcp_info.pci_sbdf), ++ mac_addr_to_string((*hfi)->tcp_info.mac_addr), ++ (*hfi)->tcp_info.dhcp_override ? "yes" : "no", ++ ip_width, ip_width, (*hfi)->tcp_info.ipaddr, ++ (*hfi)->tcp_info.subnet_mask_prefix, ++ gw_width, gw_width, (*hfi)->tcp_info.gateway_ipaddr, ++ dns_width, dns_width, (*hfi)->tcp_info.primary_dns_ipaddr); ++} ++ ++static void print_nbft_discovery_info(struct nbft_info *nbft) ++{ ++ struct nbft_info_discovery **disc; ++ unsigned int nqn_width = 20, uri_width = 12; ++ ++ disc = nbft->discovery_list; ++ if (!disc || !*disc) ++ return; ++ ++ for (; *disc; disc++) { ++ size_t len; ++ ++ len = strlen((*disc)->uri); ++ if (len > uri_width) ++ uri_width = len; ++ len = strlen((*disc)->nqn); ++ if (len > nqn_width) ++ nqn_width = len; ++ } ++ ++ printf("\nNBFT Discovery Controllers:\n\n"); ++ printf("%-3.3s|%-*.*s|%-*.*s\n", "Idx", uri_width, uri_width, "URI", ++ nqn_width, nqn_width, "NQN"); ++ printf("%-.3s+%-.*s+%-.*s\n", dash, uri_width, dash, nqn_width, dash); ++ for (disc = nbft->discovery_list; *disc; disc++) ++ printf("%-3d|%-*.*s|%-*.*s\n", (*disc)->index, ++ uri_width, uri_width, (*disc)->uri, ++ nqn_width, nqn_width, (*disc)->nqn); ++} ++ ++#define HFIS_LEN 20 ++static size_t print_hfis(const struct nbft_info_subsystem_ns *ss, char buf[HFIS_LEN]) ++{ ++ char hfi_buf[HFIS_LEN]; ++ size_t len, ofs; ++ int i; ++ ++ len = snprintf(hfi_buf, sizeof(hfi_buf), "%d", ss->hfis[0]->index); ++ for (i = 1; i < ss->num_hfis; i++) { ++ ofs = len; ++ len += snprintf(hfi_buf + ofs, sizeof(hfi_buf) - ofs, ",%d", ++ ss->hfis[i]->index); ++ /* ++ * If the list doesn't fit in HFIS_LEN characters, ++ * truncate and end with "..." ++ */ ++ if (len >= sizeof(hfi_buf)) { ++ while (ofs < sizeof(hfi_buf) - 1) ++ hfi_buf[ofs++] = '.'; ++ hfi_buf[ofs] = '\0'; ++ len = sizeof(hfi_buf) - 1; ++ break; ++ } ++ } ++ if (buf) ++ memcpy(buf, hfi_buf, len + 1); ++ return len; ++} ++ ++ ++static void print_nbft_subsys_info(struct nbft_info *nbft) ++{ ++ struct nbft_info_subsystem_ns **ss; ++ unsigned int nqn_width = 20, adr_width = 8, hfi_width = 4; ++ ++ ss = nbft->subsystem_ns_list; ++ if (!ss || !*ss) ++ return; ++ for (; *ss; ss++) { ++ size_t len; ++ ++ len = strlen((*ss)->subsys_nqn); ++ if (len > nqn_width) ++ nqn_width = len; ++ len = strlen((*ss)->traddr); ++ if (len > adr_width) ++ adr_width = len; ++ len = print_hfis(*ss, NULL); ++ if (len > hfi_width) ++ hfi_width = len; ++ } ++ ++ printf("\nNBFT Subsystems:\n\n"); ++ printf("%-3.3s|%-*.*s|%-4.4s|%-*.*s|%-5.5s|%-*.*s\n", ++ "Idx", nqn_width, nqn_width, "NQN", ++ "Trsp", adr_width, adr_width, "Address", "SvcId", hfi_width, hfi_width, "HFIs"); ++ printf("%-.3s+%-.*s+%-.4s+%-.*s+%-.5s+%-.*s\n", ++ dash, nqn_width, dash, dash, adr_width, dash, dash, hfi_width, dash); ++ for (ss = nbft->subsystem_ns_list; *ss; ss++) { ++ char hfi_buf[HFIS_LEN]; ++ ++ print_hfis(*ss, hfi_buf); ++ printf("%-3d|%-*.*s|%-4.4s|%-*.*s|%-5.5s|%-*.*s\n", ++ (*ss)->index, nqn_width, nqn_width, (*ss)->subsys_nqn, ++ (*ss)->transport, adr_width, adr_width, (*ss)->traddr, ++ (*ss)->trsvcid, hfi_width, hfi_width, hfi_buf); ++ } ++} ++ ++static void normal_show_nbft(struct nbft_info *nbft, bool show_subsys, ++ bool show_hfi, bool show_discovery) ++{ ++ printf("%s:\n", nbft->filename); ++ if ((!nbft->hfi_list || !*nbft->hfi_list) && ++ (!nbft->security_list || !*nbft->security_list) && ++ (!nbft->discovery_list || !*nbft->discovery_list) && ++ (!nbft->subsystem_ns_list || !*nbft->subsystem_ns_list)) ++ printf("(empty)\n"); ++ else { ++ if (show_subsys) ++ print_nbft_subsys_info(nbft); ++ if (show_hfi) ++ print_nbft_hfi_info(nbft); ++ if (show_discovery) ++ print_nbft_discovery_info(nbft); ++ } ++} ++ ++static void normal_show_nbfts(struct list_head *nbft_list, bool show_subsys, ++ bool show_hfi, bool show_discovery) ++{ ++ bool not_first = false; ++ struct nbft_file_entry *entry; ++ ++ list_for_each(nbft_list, entry, node) { ++ if (not_first) ++ printf("\n"); ++ normal_show_nbft(entry->nbft, show_subsys, show_hfi, show_discovery); ++ not_first = true; ++ } ++} ++ ++int show_nbft(int argc, char **argv, struct command *cmd, struct plugin *plugin) ++{ ++ const char *desc = "Display contents of the ACPI NBFT files."; ++ struct list_head nbft_list; ++ char *format = "normal"; ++ char *nbft_path = NBFT_SYSFS_PATH; ++ enum nvme_print_flags flags = -1; ++ int ret; ++ bool show_subsys = false, show_hfi = false, show_discovery = false; ++ ++ OPT_ARGS(opts) = { ++ OPT_FMT("output-format", 'o', &format, "Output format: normal|json"), ++ OPT_FLAG("subsystem", 's', &show_subsys, "show NBFT subsystems"), ++ OPT_FLAG("hfi", 'H', &show_hfi, "show NBFT HFIs"), ++ OPT_FLAG("discovery", 'd', &show_discovery, "show NBFT discovery controllers"), ++ OPT_STRING("nbft-path", 0, "STR", &nbft_path, "user-defined path for NBFT tables"), ++ OPT_END() ++ }; ++ ++ ret = argconfig_parse(argc, argv, desc, opts); ++ if (ret) ++ return ret; ++ ++ if (!(show_subsys || show_hfi || show_discovery)) ++ show_subsys = show_hfi = show_discovery = true; ++ ++ if (!strcmp(format, "")) ++ flags = -1; ++ else if (!strcmp(format, "normal")) ++ flags = NORMAL; ++ else if (!strcmp(format, "json")) ++ flags = JSON; ++ else ++ return EINVAL; ++ ++ list_head_init(&nbft_list); ++ ret = read_nbft_files(&nbft_list, nbft_path); ++ if (!ret) { ++ if (flags == NORMAL) ++ normal_show_nbfts(&nbft_list, show_subsys, show_hfi, show_discovery); ++ else if (flags == JSON) ++ ret = json_show_nbfts(&nbft_list, show_subsys, show_hfi, show_discovery); ++ free_nbfts(&nbft_list); ++ } ++ return ret; ++} +diff --git a/plugins/nbft/nbft-plugin.h b/plugins/nbft/nbft-plugin.h +new file mode 100644 +index 00000000..018349d9 +--- /dev/null ++++ b/plugins/nbft/nbft-plugin.h +@@ -0,0 +1,18 @@ ++/* SPDX-License-Identifier: GPL-2.0-or-later */ ++#undef CMD_INC_FILE ++#define CMD_INC_FILE plugins/nbft/nbft-plugin ++ ++#if !defined(NBFT) || defined(CMD_HEADER_MULTI_READ) ++#define NBFT ++ ++#include "cmd.h" ++ ++PLUGIN(NAME("nbft", "ACPI NBFT table extensions", NVME_VERSION), ++ COMMAND_LIST( ++ ENTRY("show", "Show contents of ACPI NBFT tables", show_nbft) ++ ) ++); ++ ++#endif ++ ++#include "define_cmd.h" +-- +2.39.2 + diff --git a/nvme-cli.spec b/nvme-cli.spec index fd84a01..06bb083 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -3,13 +3,17 @@ Name: nvme-cli Version: 2.4 -Release: 1%{?dist} +Release: 2%{?dist} Summary: NVMe management command line interface License: GPLv2 URL: https://github.com/linux-nvme/nvme-cli Source0: %{url}/archive/v%{version_no_tilde}/%{name}-%{version_no_tilde}.tar.gz +Patch100: nvme-cli-2.5-nbft-make-lookup_ctrl-function-public.patch +Patch101: nvme-cli-2.5-nbft.patch +Patch102: nvme-cli-2.5-nbft_plugin.patch + BuildRequires: meson >= 0.50.0 BuildRequires: gcc gcc-c++ BuildRequires: systemd-devel @@ -17,7 +21,7 @@ BuildRequires: systemd-rpm-macros BuildRequires: zlib-devel BuildRequires: openssl-devel -BuildRequires: libnvme-devel >= 1.4 +BuildRequires: libnvme-devel >= 1.4-2 BuildRequires: json-c-devel >= 0.13 %if (0%{?rhel} == 0) @@ -83,6 +87,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Thu Apr 20 2023 Tomas Bzatek - 2.4-2 +- Backport the NBFT support from git master + * Mon Apr 03 2023 Tomas Bzatek - 2.4-1 - Update to 2.4 From b00e380b51b7e4cef3d1aca4a6a08020a29f1865 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Thu, 20 Apr 2023 16:11:25 +0200 Subject: [PATCH 04/33] * Thu Apr 20 2023 Tomas Bzatek - 2.4-2 - Backport the NBFT support from git master --- ...bft-make-lookup_ctrl-function-public.patch | 75 ++ nvme-cli-2.5-nbft.patch | 451 ++++++++++++ nvme-cli-2.5-nbft_plugin.patch | 640 ++++++++++++++++++ nvme-cli.spec | 11 +- 4 files changed, 1175 insertions(+), 2 deletions(-) create mode 100644 nvme-cli-2.5-nbft-make-lookup_ctrl-function-public.patch create mode 100644 nvme-cli-2.5-nbft.patch create mode 100644 nvme-cli-2.5-nbft_plugin.patch diff --git a/nvme-cli-2.5-nbft-make-lookup_ctrl-function-public.patch b/nvme-cli-2.5-nbft-make-lookup_ctrl-function-public.patch new file mode 100644 index 0000000..78529b9 --- /dev/null +++ b/nvme-cli-2.5-nbft-make-lookup_ctrl-function-public.patch @@ -0,0 +1,75 @@ +From 34c197e0ac2d57734ab775f00b2d0758aca7b82f Mon Sep 17 00:00:00 2001 +From: John Meneghini +Date: Fri, 14 Apr 2023 10:53:58 -0400 +Subject: [PATCH 01/11] nbft: make lookup_ctrl function public + +To prepare for the addition of nbft functionality fixup the fabrics +declarations. + +Signed-off-by: John Meneghini +--- + fabrics.c | 12 ++---------- + fabrics.h | 10 ++++++++++ + 2 files changed, 12 insertions(+), 10 deletions(-) + +diff --git a/fabrics.c b/fabrics.c +index f8078e59..80827b16 100644 +--- a/fabrics.c ++++ b/fabrics.c +@@ -43,6 +43,7 @@ + #include "libnvme.h" + #include "nvme-print.h" + #include "nvme-print-json.h" ++#include "fabrics.h" + + #define PATH_NVMF_DISC SYSCONFDIR "/nvme/discovery.conf" + #define PATH_NVMF_CONFIG SYSCONFDIR "/nvme/config.json" +@@ -110,15 +111,6 @@ static const char *nvmf_config_file = "Use specified JSON configuration file or + OPT_FLAG("data-digest", 'G', &c.data_digest, nvmf_data_digest), \ + OPT_FLAG("tls", 0, &c.tls, nvmf_tls) \ + +-struct tr_config { +- const char *subsysnqn; +- const char *transport; +- const char *traddr; +- const char *host_traddr; +- const char *host_iface; +- const char *trsvcid; +-}; +- + /* + * Compare two C strings and handle NULL pointers gracefully. + * If either of the two strings is NULL, return 0 +@@ -202,7 +194,7 @@ static nvme_ctrl_t lookup_discovery_ctrl(nvme_root_t r, struct tr_config *trcfg) + return __lookup_ctrl(r, trcfg, disc_ctrl_config_match); + } + +-static nvme_ctrl_t lookup_ctrl(nvme_root_t r, struct tr_config *trcfg) ++nvme_ctrl_t lookup_ctrl(nvme_root_t r, struct tr_config *trcfg) + { + return __lookup_ctrl(r, trcfg, ctrl_config_match); + } +diff --git a/fabrics.h b/fabrics.h +index d1e16fc5..02cebf5d 100644 +--- a/fabrics.h ++++ b/fabrics.h +@@ -2,6 +2,16 @@ + #ifndef _FABRICS_H + #define _FABRICS_H + ++struct tr_config { ++ const char *subsysnqn; ++ const char *transport; ++ const char *traddr; ++ const char *host_traddr; ++ const char *host_iface; ++ const char *trsvcid; ++}; ++ ++extern nvme_ctrl_t lookup_ctrl(nvme_root_t r, struct tr_config *trcfg); + extern int nvmf_discover(const char *desc, int argc, char **argv, bool connect); + extern int nvmf_connect(const char *desc, int argc, char **argv); + extern int nvmf_disconnect(const char *desc, int argc, char **argv); +-- +2.39.2 + diff --git a/nvme-cli-2.5-nbft.patch b/nvme-cli-2.5-nbft.patch new file mode 100644 index 0000000..e54da19 --- /dev/null +++ b/nvme-cli-2.5-nbft.patch @@ -0,0 +1,451 @@ +From a71a08532b5f06ee19ee2ff118a23cec4ecb6719 Mon Sep 17 00:00:00 2001 +From: Stuart Hayes +Date: Wed, 15 Jun 2022 11:42:50 -0500 +Subject: [PATCH 02/11] nbft: added NBFT v1.0 table support + +Added support for parsing the contents of the NBFT table (per NVMe-oF +boot specification v1.0) with the connect-all and discover commands. + +nvme discover/connect-all --nbft ignore /etc/nvme config and use NBFT tables +nvme discover/connect-all --no-nbft ignore NBFT tables and use /etc/nvme config +nvme discover/connect-all --nbft-path= user-defined path for NBFT tables + +Signed-off-by: Stuart Hayes +Signed-off-by: Martin Belanger + +Use the new nbft public API. + +Signed-off-by: Tomas Bzatek +Signed-off-by: Martin Wilck +Signed-off-by: John Meneghini +--- + Documentation/nvme-connect-all.txt | 25 ++++ + Documentation/nvme-discover.txt | 27 +++- + fabrics.c | 17 +++ + meson.build | 1 + + nbft.c | 202 +++++++++++++++++++++++++++++ + nbft.h | 19 +++ + 6 files changed, 290 insertions(+), 1 deletion(-) + create mode 100644 nbft.c + create mode 100644 nbft.h + +diff --git a/Documentation/nvme-connect-all.txt b/Documentation/nvme-connect-all.txt +index 44bb4f94..cbb7ca6c 100644 +--- a/Documentation/nvme-connect-all.txt ++++ b/Documentation/nvme-connect-all.txt +@@ -35,6 +35,9 @@ SYNOPSIS + [--tls ] + [--quiet | -S] + [--dump-config | -O] ++ [--nbft] ++ [--no-nbft] ++ [--nbft-path=] + + DESCRIPTION + ----------- +@@ -198,6 +201,16 @@ OPTIONS + --dump-config:: + Print out resulting JSON configuration file to stdout. + ++--nbft:: ++ Only look at NBFT tables ++ ++--no-nbft:: ++ Do not look at NBFT tables ++ ++--nbft-path=:: ++ Use a user-defined path to the NBFT tables ++ ++ + + EXAMPLES + -------- +@@ -210,6 +223,18 @@ the RDMA network. Port 4420 is used by default: + --hostnqn=host1-rogue-nqn + ------------ + + ++* Issue a 'nvme connect-all' command using the default system defined NBFT tables: +++ ++----------- ++# nvme connect-all --nbft ++------------ +++ ++* Issue a 'nvme connect-all' command with a user-defined path for the NBFT table: +++ ++----------- ++# nvme connet-all --nbft-path=/sys/firmware/acpi/tables/NBFT1 ++------------ +++ + * Issue a 'nvme connect-all' command using a @SYSCONFDIR@/nvme/discovery.conf file: + + + ----------- +diff --git a/Documentation/nvme-discover.txt b/Documentation/nvme-discover.txt +index d4df75c2..b040c688 100644 +--- a/Documentation/nvme-discover.txt ++++ b/Documentation/nvme-discover.txt +@@ -37,6 +37,9 @@ SYNOPSIS + [--dump-config | -O] + [--output-format= | -o ] + [--force] ++ [--nbft] ++ [--no-nbft] ++ [--nbft-path=] + + DESCRIPTION + ----------- +@@ -68,7 +71,7 @@ Note that the base NVMe specification defines the NQN (NVMe Qualified + Name) format which an NVMe endpoint (device, subsystem, etc) must + follow to guarantee a unique name under the NVMe standard. + In particular, the Host NQN uniquely identifies the NVMe Host, and +-may be used by the the Discovery Controller to control what NVMe Target ++may be used by the Discovery Controller to control what NVMe Target + resources are allocated to the NVMe Host for a connection. + + A Discovery Controller has it's own NQN defined in the NVMe-over-Fabrics +@@ -229,6 +232,16 @@ OPTIONS + Combined with --persistent flag, always create new + persistent discovery connection. + ++--nbft:: ++ Only look at NBFT tables ++ ++--no-nbft:: ++ Do not look at NBFT tables ++ ++--nbft-path=:: ++ Use a user-defined path to the NBFT tables ++ ++ + EXAMPLES + -------- + * Query the Discover Controller with IP4 address 192.168.1.3 for all +@@ -240,6 +253,18 @@ Port 4420 is used by default: + --hostnqn=host1-rogue-nqn + ------------ + + ++* Issue a 'nvme discover' command using the default system defined NBFT tables: +++ ++----------- ++# nvme discover --nbft ++------------ +++ ++* Issue a 'nvme discover' command with a user-defined path for the NBFT table: +++ ++----------- ++# nvme discover --nbft-path=/sys/firmware/acpi/tables/NBFT1 ++------------ +++ + * Issue a 'nvme discover' command using a @SYSCONFDIR@/nvme/discovery.conf file: + + + ----------- +diff --git a/fabrics.c b/fabrics.c +index 80827b16..0edbd299 100644 +--- a/fabrics.c ++++ b/fabrics.c +@@ -40,6 +40,7 @@ + + #include "common.h" + #include "nvme.h" ++#include "nbft.h" + #include "libnvme.h" + #include "nvme-print.h" + #include "nvme-print-json.h" +@@ -710,6 +711,7 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) + { + char *subsysnqn = NVME_DISC_SUBSYS_NAME; + char *hostnqn = NULL, *hostid = NULL, *hostkey = NULL; ++ char *hostnqn_arg, *hostid_arg; + char *transport = NULL, *traddr = NULL, *trsvcid = NULL; + char *config_file = PATH_NVMF_CONFIG; + char *hnqn = NULL, *hid = NULL; +@@ -724,6 +726,8 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) + char *device = NULL; + bool force = false; + bool json_config = false; ++ bool nbft = false, nonbft = false; ++ char *nbft_path = NBFT_SYSFS_PATH; + + OPT_ARGS(opts) = { + OPT_STRING("device", 'd', "DEV", &device, "use existing discovery controller device"), +@@ -736,6 +740,9 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) + OPT_INCR("verbose", 'v', &verbose, "Increase logging verbosity"), + OPT_FLAG("dump-config", 'O', &dump_config, "Dump configuration file to stdout"), + OPT_FLAG("force", 0, &force, "Force persistent discovery controller creation"), ++ OPT_FLAG("nbft", 0, &nbft, "Only look at NBFT tables"), ++ OPT_FLAG("no-nbft", 0, &nonbft, "Do not look at NBFT tables"), ++ OPT_STRING("nbft-path", 0, "STR", &nbft_path, "user-defined path for NBFT tables"), + OPT_END() + }; + +@@ -768,6 +775,8 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) + if (!nvme_read_config(r, config_file)) + json_config = true; + ++ hostnqn_arg = hostnqn; ++ hostid_arg = hostid; + if (!hostnqn) + hostnqn = hnqn = nvmf_hostnqn_from_file(); + if (!hostnqn) +@@ -789,6 +798,14 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) + nvme_host_set_dhchap_key(h, hostkey); + + if (!device && !transport && !traddr) { ++ if (!nonbft) ++ discover_from_nbft(r, hostnqn_arg, hostid_arg, ++ hostnqn, hostid, desc, connect, ++ &cfg, nbft_path, flags, verbose); ++ ++ if (nbft) ++ goto out_free; ++ + if (json_config) + ret = discover_from_json_config_file(r, h, desc, + connect, &cfg, +diff --git a/meson.build b/meson.build +index 43ce5f9b..7ec357a9 100644 +--- a/meson.build ++++ b/meson.build +@@ -240,6 +240,7 @@ incdir = include_directories(['ccan']) + + ################################################################################ + sources = [ ++ 'nbft.c', + 'fabrics.c', + 'nvme.c', + 'nvme-models.c', +diff --git a/nbft.c b/nbft.c +new file mode 100644 +index 00000000..14347287 +--- /dev/null ++++ b/nbft.c +@@ -0,0 +1,202 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later ++ ++#include ++#include ++#include ++ ++#include "nvme.h" ++#include "nbft.h" ++#include "libnvme.h" ++#include "fabrics.h" ++ ++#define NBFT_SYSFS_FILENAME "NBFT*" ++ ++static void print_connect_msg(nvme_ctrl_t c) ++{ ++ printf("device: %s\n", nvme_ctrl_get_name(c)); ++} ++ ++static void json_connect_msg(nvme_ctrl_t c) ++{ ++ struct json_object *root; ++ ++ root = json_create_object(); ++ json_object_add_value_string(root, "device", nvme_ctrl_get_name(c)); ++ ++ json_print_object(root, NULL); ++ printf("\n"); ++ json_free_object(root); ++} ++ ++int nbft_filter(const struct dirent *dent) ++{ ++ return !fnmatch(NBFT_SYSFS_FILENAME, dent->d_name, FNM_PATHNAME); ++} ++ ++int read_nbft_files(struct list_head *nbft_list, char *path) ++{ ++ struct dirent **dent; ++ char filename[PATH_MAX]; ++ int i, count, ret; ++ struct nbft_file_entry *entry; ++ struct nbft_info *nbft; ++ ++ count = scandir(path, &dent, nbft_filter, NULL); ++ if (count < 0) { ++ fprintf(stderr, "Failed to open %s.\n", path); ++ return -1; ++ } ++ ++ for (i = 0; i < count; i++) { ++ snprintf(filename, sizeof(filename), "%s/%s", path, dent[i]->d_name); ++ ret = nvme_nbft_read(&nbft, filename); ++ if (!ret) { ++ entry = calloc(1, sizeof(*entry)); ++ entry->nbft = nbft; ++ list_add_tail(nbft_list, &entry->node); ++ } ++ free(dent[i]); ++ } ++ free(dent); ++ return 0; ++} ++ ++void free_nbfts(struct list_head *nbft_list) ++{ ++ struct nbft_file_entry *entry; ++ ++ while ((entry = list_pop(nbft_list, struct nbft_file_entry, node))) { ++ nvme_nbft_free(entry->nbft); ++ free(entry); ++ } ++} ++ ++int discover_from_nbft(nvme_root_t r, char *hostnqn_arg, char *hostid_arg, ++ char *hostnqn_sys, char *hostid_sys, ++ const char *desc, bool connect, ++ const struct nvme_fabrics_config *cfg, char *nbft_path, ++ enum nvme_print_flags flags, bool verbose) ++{ ++ char *hostnqn = NULL, *hostid = NULL, *host_traddr = NULL; ++ nvme_host_t h; ++ nvme_ctrl_t c; ++ int ret, i; ++ struct list_head nbft_list; ++ struct nbft_file_entry *entry; ++ struct nbft_info_subsystem_ns **ss; ++ struct nbft_info_hfi *hfi; ++ ++ if (!connect) ++ /* to do: print discovery-type info from NBFT tables */ ++ return 0; ++ ++ list_head_init(&nbft_list); ++ ret = read_nbft_files(&nbft_list, nbft_path); ++ if (ret) ++ goto out_free_2; ++ ++ list_for_each(&nbft_list, entry, node) ++ for (ss = entry->nbft->subsystem_ns_list; ss && *ss; ss++) ++ for (i = 0; i < (*ss)->num_hfis; i++) { ++ nvme_ctrl_t cl; ++ ++ hfi = (*ss)->hfis[i]; ++ if (hostnqn_arg) ++ hostnqn = hostnqn_arg; ++ else { ++ hostnqn = entry->nbft->host.nqn; ++ if (!hostnqn) ++ hostnqn = hostnqn_sys; ++ } ++ ++ if (hostid_arg) ++ hostid = hostid_arg; ++ else if (*entry->nbft->host.id) { ++ hostid = (char *)util_uuid_to_string(entry->nbft->host.id); ++ if (!hostid) ++ hostid = hostid_sys; ++ } ++ ++ h = nvme_lookup_host(r, hostnqn, hostid); ++ if (!h) { ++ errno = ENOMEM; ++ goto out_free; ++ } ++ ++ if (!cfg->host_traddr) { ++ host_traddr = NULL; ++ if (!strncmp((*ss)->transport, "tcp", 3)) ++ host_traddr = hfi->tcp_info.ipaddr; ++ } ++ ++ struct tr_config trcfg = { ++ .subsysnqn = (*ss)->subsys_nqn, ++ .transport = (*ss)->transport, ++ .traddr = (*ss)->traddr, ++ .host_traddr = host_traddr, ++ .host_iface = NULL, ++ .trsvcid = (*ss)->trsvcid, ++ }; ++ ++ /* Already connected ? */ ++ cl = lookup_ctrl(r, &trcfg); ++ if (cl && nvme_ctrl_get_name(cl)) ++ continue; ++ ++ c = nvme_create_ctrl(r, (*ss)->subsys_nqn, (*ss)->transport, ++ (*ss)->traddr, host_traddr, NULL, ++ (*ss)->trsvcid); ++ if (!c) { ++ errno = ENOMEM; ++ goto out_free; ++ } ++ ++ errno = 0; ++ ret = nvmf_add_ctrl(h, c, cfg); ++ ++ /* ++ * With TCP/DHCP, it can happen that the OS ++ * obtains a different local IP address than the ++ * firmware had. Retry without host_traddr. ++ */ ++ if (ret == -1 && errno == ENVME_CONNECT_WRITE && ++ !strcmp((*ss)->transport, "tcp") && ++ strlen(hfi->tcp_info.dhcp_server_ipaddr) > 0) { ++ nvme_free_ctrl(c); ++ ++ trcfg.host_traddr = NULL; ++ cl = lookup_ctrl(r, &trcfg); ++ if (cl && nvme_ctrl_get_name(cl)) ++ continue; ++ ++ c = nvme_create_ctrl(r, (*ss)->subsys_nqn, (*ss)->transport, ++ (*ss)->traddr, ++ NULL, NULL, (*ss)->trsvcid); ++ if (!c) { ++ errno = ENOMEM; ++ goto out_free; ++ } ++ errno = 0; ++ ret = nvmf_add_ctrl(h, c, cfg); ++ if (ret == 0 && verbose >= 1) ++ fprintf(stderr, ++ "connect with host_traddr=\"%s\" failed, success after omitting host_traddr\n", ++ host_traddr); ++ } ++ ++ if (ret) ++ fprintf(stderr, "no controller found\n"); ++ else { ++ if (flags == NORMAL) ++ print_connect_msg(c); ++ else if (flags == JSON) ++ json_connect_msg(c); ++ } ++out_free: ++ if (errno == ENOMEM) ++ goto out_free_2; ++ } ++out_free_2: ++ free_nbfts(&nbft_list); ++ return errno; ++} +diff --git a/nbft.h b/nbft.h +new file mode 100644 +index 00000000..0e09733f +--- /dev/null ++++ b/nbft.h +@@ -0,0 +1,19 @@ ++/* SPDX-License-Identifier: GPL-2.0-or-later */ ++ ++#include ++ ++#define NBFT_SYSFS_PATH "/sys/firmware/acpi/tables" ++ ++struct nbft_file_entry { ++ struct list_node node; ++ struct nbft_info *nbft; ++}; ++ ++int read_nbft_files(struct list_head *nbft_list, char *path); ++void free_nbfts(struct list_head *nbft_list); ++ ++extern int discover_from_nbft(nvme_root_t r, char *hostnqn_arg, char *hostid_arg, ++ char *hostnqn_sys, char *hostid_sys, ++ const char *desc, bool connect, ++ const struct nvme_fabrics_config *cfg, char *nbft_path, ++ enum nvme_print_flags flags, bool verbose); +-- +2.39.2 + diff --git a/nvme-cli-2.5-nbft_plugin.patch b/nvme-cli-2.5-nbft_plugin.patch new file mode 100644 index 0000000..b70d26e --- /dev/null +++ b/nvme-cli-2.5-nbft_plugin.patch @@ -0,0 +1,640 @@ +From 23daeedc53be9b5225cc6806434888c0a7a8e9bf Mon Sep 17 00:00:00 2001 +From: Stuart Hayes +Date: Fri, 14 Apr 2023 22:01:07 -0400 +Subject: [PATCH 03/11] nbft: add the nbft show plugin + +Display contents of the ACPI NBFT files. + +Usage: nvme nbft show [OPTIONS] + +Options: + [ --output-format=, -o ] --- Output format: normal|json + [ --subsystem, -s ] --- show NBFT subsystems + [ --hfi, -H ] --- show NBFT HFIs + [ --discovery, -d ] --- show NBFT discovery controllers + [ --nbft-path= ] --- user-defined path for NBFT tables + +Signed-off-by: Stuart Hayes +Signed-off-by: Martin Wilck +Signed-off-by: John Meneghini +--- + plugins/meson.build | 1 + + plugins/nbft/nbft-plugin.c | 568 +++++++++++++++++++++++++++++++++++++ + plugins/nbft/nbft-plugin.h | 18 ++ + 3 files changed, 587 insertions(+) + create mode 100644 plugins/nbft/nbft-plugin.c + create mode 100644 plugins/nbft/nbft-plugin.h + +diff --git a/plugins/meson.build b/plugins/meson.build +index 2cf2486f..38b7cded 100644 +--- a/plugins/meson.build ++++ b/plugins/meson.build +@@ -12,6 +12,7 @@ if json_c_dep.found() + 'plugins/intel/intel-nvme.c', + 'plugins/memblaze/memblaze-nvme.c', + 'plugins/micron/micron-nvme.c', ++ 'plugins/nbft/nbft-plugin.c', + 'plugins/netapp/netapp-nvme.c', + 'plugins/nvidia/nvidia-nvme.c', + 'plugins/scaleflux/sfx-nvme.c', +diff --git a/plugins/nbft/nbft-plugin.c b/plugins/nbft/nbft-plugin.c +new file mode 100644 +index 00000000..6ae2525a +--- /dev/null ++++ b/plugins/nbft/nbft-plugin.c +@@ -0,0 +1,568 @@ ++// SPDX-License-Identifier: GPL-2.0-or-later ++ ++#include ++#include ++#include ++ ++#include "nvme-print.h" ++#include "nvme.h" ++#include "nbft.h" ++#include "libnvme.h" ++#include "fabrics.h" ++ ++#define CREATE_CMD ++#include "nbft-plugin.h" ++ ++static const char dash[100] = {[0 ... 98] = '-', [99] = '\0'}; ++ ++#define PCI_SEGMENT(sbdf) ((sbdf & 0xffff0000) >> 16) ++#define PCI_BUS(sbdf) ((sbdf & 0x0000ff00) >> 8) ++#define PCI_DEV(sbdf) ((sbdf & 0x000000f8) >> 3) ++#define PCI_FUNC(sbdf) ((sbdf & 0x00000007) >> 0) ++ ++static const char *pci_sbdf_to_string(__u16 pci_sbdf) ++{ ++ static char pcidev[13]; ++ ++ snprintf(pcidev, sizeof(pcidev), "%x:%x:%x.%x", ++ PCI_SEGMENT(pci_sbdf), ++ PCI_BUS(pci_sbdf), ++ PCI_DEV(pci_sbdf), ++ PCI_FUNC(pci_sbdf)); ++ return pcidev; ++} ++ ++static char *mac_addr_to_string(unsigned char mac_addr[6]) ++{ ++ static char mac_string[18]; ++ ++ snprintf(mac_string, sizeof(mac_string), "%02x:%02x:%02x:%02x:%02x:%02x", ++ mac_addr[0], ++ mac_addr[1], ++ mac_addr[2], ++ mac_addr[3], ++ mac_addr[4], ++ mac_addr[5]); ++ return mac_string; ++} ++ ++static json_object *hfi_to_json(struct nbft_info_hfi *hfi) ++{ ++ struct json_object *hfi_json; ++ ++ hfi_json = json_create_object(); ++ if (!hfi_json) ++ return NULL; ++ ++ if (json_object_add_value_int(hfi_json, "index", hfi->index) ++ || json_object_add_value_string(hfi_json, "transport", hfi->transport)) ++ goto fail; ++ ++ if (strcmp(hfi->transport, "tcp") == 0) { ++ if (json_object_add_value_string(hfi_json, "pcidev", ++ pci_sbdf_to_string(hfi->tcp_info.pci_sbdf)) ++ || json_object_add_value_string(hfi_json, "mac_addr", ++ mac_addr_to_string(hfi->tcp_info.mac_addr)) ++ || json_object_add_value_int(hfi_json, "vlan", ++ hfi->tcp_info.vlan) ++ || json_object_add_value_int(hfi_json, "ip_origin", ++ hfi->tcp_info.ip_origin) ++ || json_object_add_value_string(hfi_json, "ipaddr", ++ hfi->tcp_info.ipaddr) ++ || json_object_add_value_int(hfi_json, "subnet_mask_prefix", ++ hfi->tcp_info.subnet_mask_prefix) ++ || json_object_add_value_string(hfi_json, "gateway_ipaddr", ++ hfi->tcp_info.gateway_ipaddr) ++ || json_object_add_value_int(hfi_json, "route_metric", ++ hfi->tcp_info.route_metric) ++ || json_object_add_value_string(hfi_json, "primary_dns_ipaddr", ++ hfi->tcp_info.primary_dns_ipaddr) ++ || json_object_add_value_string(hfi_json, "secondary_dns_ipaddr", ++ hfi->tcp_info.secondary_dns_ipaddr) ++ || json_object_add_value_string(hfi_json, "dhcp_server_ipaddr", ++ hfi->tcp_info.dhcp_server_ipaddr) ++ || (hfi->tcp_info.host_name ++ && json_object_add_value_string(hfi_json, "host_name", ++ hfi->tcp_info.host_name)) ++ || json_object_add_value_int(hfi_json, "this_hfi_is_default_route", ++ hfi->tcp_info.this_hfi_is_default_route) ++ || json_object_add_value_int(hfi_json, "dhcp_override", ++ hfi->tcp_info.dhcp_override)) ++ goto fail; ++ else ++ return hfi_json; ++ } ++fail: ++ json_free_object(hfi_json); ++ return NULL; ++} ++ ++static json_object *ssns_to_json(struct nbft_info_subsystem_ns *ss) ++{ ++ struct json_object *ss_json; ++ struct json_object *hfi_array_json; ++ char json_str[40]; ++ char *json_str_p; ++ int i; ++ ++ ss_json = json_create_object(); ++ if (!ss_json) ++ return NULL; ++ ++ hfi_array_json = json_create_array(); ++ if (!hfi_array_json) ++ goto fail; ++ ++ for (i = 0; i < ss->num_hfis; i++) ++ if (json_array_add_value_object(hfi_array_json, ++ json_object_new_int(ss->hfis[i]->index))) ++ goto fail; ++ ++ if (json_object_add_value_int(ss_json, "index", ss->index) ++ || json_object_add_value_int(ss_json, "num_hfis", ss->num_hfis) ++ || json_object_object_add(ss_json, "hfis", hfi_array_json) ++ || json_object_add_value_string(ss_json, "transport", ss->transport) ++ || json_object_add_value_string(ss_json, "traddr", ss->traddr) ++ || json_object_add_value_string(ss_json, "trsvcid", ss->trsvcid) ++ || json_object_add_value_int(ss_json, "subsys_port_id", ss->subsys_port_id) ++ || json_object_add_value_int(ss_json, "nsid", ss->nsid)) ++ goto fail; ++ ++ memset(json_str, 0, sizeof(json_str)); ++ json_str_p = json_str; ++ ++ switch (ss->nid_type) { ++ case NBFT_INFO_NID_TYPE_EUI64: ++ if (json_object_add_value_string(ss_json, "nid_type", "eui64")) ++ goto fail; ++ for (i = 0; i < 8; i++) ++ json_str_p += sprintf(json_str_p, "%02x", ss->nid[i]); ++ break; ++ ++ case NBFT_INFO_NID_TYPE_NGUID: ++ if (json_object_add_value_string(ss_json, "nid_type", "nguid")) ++ goto fail; ++ for (i = 0; i < 16; i++) ++ json_str_p += sprintf(json_str_p, "%02x", ss->nid[i]); ++ break; ++ ++ case NBFT_INFO_NID_TYPE_NS_UUID: ++ if (json_object_add_value_string(ss_json, "nid_type", "uuid")) ++ goto fail; ++ nvme_uuid_to_string(ss->nid, json_str); ++ break; ++ ++ default: ++ break; ++ } ++ if (json_object_add_value_string(ss_json, "nid", json_str)) ++ goto fail; ++ ++ if ((ss->subsys_nqn ++ && json_object_add_value_string(ss_json, "subsys_nqn", ss->subsys_nqn)) ++ || json_object_add_value_int(ss_json, "controller_id", ss->controller_id) ++ || json_object_add_value_int(ss_json, "asqsz", ss->asqsz) ++ || (ss->dhcp_root_path_string ++ && json_object_add_value_string(ss_json, "dhcp_root_path_string", ++ ss->dhcp_root_path_string)) ++ || json_object_add_value_int(ss_json, "pdu_header_digest_required", ++ ss->pdu_header_digest_required) ++ || json_object_add_value_int(ss_json, "data_digest_required", ++ ss->data_digest_required)) ++ goto fail; ++ ++ return ss_json; ++fail: ++ json_free_object(ss_json); ++ return NULL; ++} ++ ++static json_object *discovery_to_json(struct nbft_info_discovery *disc) ++{ ++ struct json_object *disc_json; ++ ++ disc_json = json_create_object(); ++ if (!disc_json) ++ return NULL; ++ ++ if (json_object_add_value_int(disc_json, "index", disc->index) ++ || (disc->security ++ && json_object_add_value_int(disc_json, "security", disc->security->index)) ++ || (disc->hfi ++ && json_object_add_value_int(disc_json, "hfi", disc->hfi->index)) ++ || (disc->uri ++ && json_object_add_value_string(disc_json, "uri", disc->uri)) ++ || (disc->nqn ++ && json_object_add_value_string(disc_json, "nqn", disc->nqn))) { ++ json_free_object(disc_json); ++ return NULL; ++ } else ++ return disc_json; ++} ++ ++static const char *primary_admin_host_flag_to_str(unsigned int primary) ++{ ++ static const char * const str[] = { ++ [NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_NOT_INDICATED] = "not indicated", ++ [NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_UNSELECTED] = "unselected", ++ [NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_SELECTED] = "selected", ++ [NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_RESERVED] = "reserved", ++ }; ++ ++ if (primary > NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_RESERVED) ++ return "INVALID"; ++ return str[primary]; ++} ++ ++static struct json_object *nbft_to_json(struct nbft_info *nbft, bool show_subsys, ++ bool show_hfi, bool show_discovery) ++{ ++ struct json_object *nbft_json, *host_json; ++ ++ nbft_json = json_create_object(); ++ if (!nbft_json) ++ return NULL; ++ ++ if (json_object_add_value_string(nbft_json, "filename", nbft->filename)) ++ goto fail; ++ ++ host_json = json_create_object(); ++ if (!host_json) ++ goto fail; ++ if ((nbft->host.nqn ++ && json_object_add_value_string(host_json, "nqn", nbft->host.nqn)) ++ || (nbft->host.id ++ && json_object_add_value_string(host_json, "id", ++ util_uuid_to_string(nbft->host.id)))) ++ goto fail; ++ json_object_add_value_int(host_json, "host_id_configured", ++ nbft->host.host_id_configured); ++ json_object_add_value_int(host_json, "host_nqn_configured", ++ nbft->host.host_nqn_configured); ++ json_object_add_value_string(host_json, "primary_admin_host_flag", ++ primary_admin_host_flag_to_str(nbft->host.primary)); ++ if (json_object_object_add(nbft_json, "host", host_json)) { ++ json_free_object(host_json); ++ goto fail; ++ } ++ ++ if (show_subsys) { ++ struct json_object *subsys_array_json, *subsys_json; ++ struct nbft_info_subsystem_ns **ss; ++ ++ subsys_array_json = json_create_array(); ++ if (!subsys_array_json) ++ goto fail; ++ for (ss = nbft->subsystem_ns_list; ss && *ss; ss++) { ++ subsys_json = ssns_to_json(*ss); ++ if (!subsys_json) ++ goto fail; ++ if (json_object_array_add(subsys_array_json, subsys_json)) { ++ json_free_object(subsys_json); ++ goto fail; ++ } ++ } ++ if (json_object_object_add(nbft_json, "subsystem", subsys_array_json)) { ++ json_free_object(subsys_array_json); ++ goto fail; ++ } ++ } ++ if (show_hfi) { ++ struct json_object *hfi_array_json, *hfi_json; ++ struct nbft_info_hfi **hfi; ++ ++ hfi_array_json = json_create_array(); ++ if (!hfi_array_json) ++ goto fail; ++ for (hfi = nbft->hfi_list; hfi && *hfi; hfi++) { ++ hfi_json = hfi_to_json(*hfi); ++ if (!hfi_json) ++ goto fail; ++ if (json_object_array_add(hfi_array_json, hfi_json)) { ++ json_free_object(hfi_json); ++ goto fail; ++ } ++ } ++ if (json_object_object_add(nbft_json, "hfi", hfi_array_json)) { ++ json_free_object(hfi_array_json); ++ goto fail; ++ } ++ } ++ if (show_discovery) { ++ struct json_object *discovery_array_json, *discovery_json; ++ struct nbft_info_discovery **disc; ++ ++ discovery_array_json = json_create_array(); ++ if (!discovery_array_json) ++ goto fail; ++ for (disc = nbft->discovery_list; disc && *disc; disc++) { ++ discovery_json = discovery_to_json(*disc); ++ if (!discovery_json) ++ goto fail; ++ if (json_object_array_add(discovery_array_json, discovery_json)) { ++ json_free_object(discovery_json); ++ goto fail; ++ } ++ } ++ if (json_object_object_add(nbft_json, "discovery", discovery_array_json)) { ++ json_free_object(discovery_array_json); ++ goto fail; ++ } ++ } ++ return nbft_json; ++fail: ++ json_free_object(nbft_json); ++ return NULL; ++} ++ ++static int json_show_nbfts(struct list_head *nbft_list, bool show_subsys, ++ bool show_hfi, bool show_discovery) ++{ ++ struct json_object *nbft_json_array, *nbft_json; ++ struct nbft_file_entry *entry; ++ ++ nbft_json_array = json_create_array(); ++ if (!nbft_json_array) ++ return ENOMEM; ++ ++ list_for_each(nbft_list, entry, node) { ++ nbft_json = nbft_to_json(entry->nbft, show_subsys, show_hfi, show_discovery); ++ if (!nbft_json) ++ goto fail; ++ if (json_object_array_add(nbft_json_array, nbft_json)) { ++ json_free_object(nbft_json); ++ goto fail; ++ } ++ } ++ ++ json_print_object(nbft_json_array, NULL); ++ printf("\n"); ++ json_free_object(nbft_json_array); ++ return 0; ++fail: ++ json_free_object(nbft_json_array); ++ return ENOMEM; ++} ++ ++static void print_nbft_hfi_info(struct nbft_info *nbft) ++{ ++ struct nbft_info_hfi **hfi; ++ unsigned int ip_width = 8, gw_width = 8, dns_width = 8; ++ ++ hfi = nbft->hfi_list; ++ if (!hfi || !*hfi) ++ return; ++ ++ for (; *hfi; hfi++) { ++ unsigned int len; ++ ++ len = strlen((*hfi)->tcp_info.ipaddr); ++ if (len > ip_width) ++ ip_width = len; ++ len = strlen((*hfi)->tcp_info.gateway_ipaddr); ++ if (len > gw_width) ++ gw_width = len; ++ len = strlen((*hfi)->tcp_info.primary_dns_ipaddr); ++ if (len > dns_width) ++ dns_width = len; ++ } ++ ++ printf("\nNBFT HFIs:\n\n"); ++ printf("%-3.3s|%-4.4s|%-10.10s|%-17.17s|%-4.4s|%-*.*s|%-4.4s|%-*.*s|%-*.*s\n", ++ "Idx", "Trsp", "PCI Addr", "MAC Addr", "DHCP", ++ ip_width, ip_width, "IP Addr", "Mask", ++ gw_width, gw_width, "Gateway", dns_width, dns_width, "DNS"); ++ printf("%-.3s+%-.4s+%-.10s+%-.17s+%-.4s+%-.*s+%-.4s+%-.*s+%-.*s\n", ++ dash, dash, dash, dash, dash, ip_width, dash, dash, ++ gw_width, dash, dns_width, dash); ++ for (hfi = nbft->hfi_list; *hfi; hfi++) ++ printf("%-3d|%-4.4s|%-10.10s|%-17.17s|%-4.4s|%-*.*s|%-4d|%-*.*s|%-*.*s\n", ++ (*hfi)->index, ++ (*hfi)->transport, ++ pci_sbdf_to_string((*hfi)->tcp_info.pci_sbdf), ++ mac_addr_to_string((*hfi)->tcp_info.mac_addr), ++ (*hfi)->tcp_info.dhcp_override ? "yes" : "no", ++ ip_width, ip_width, (*hfi)->tcp_info.ipaddr, ++ (*hfi)->tcp_info.subnet_mask_prefix, ++ gw_width, gw_width, (*hfi)->tcp_info.gateway_ipaddr, ++ dns_width, dns_width, (*hfi)->tcp_info.primary_dns_ipaddr); ++} ++ ++static void print_nbft_discovery_info(struct nbft_info *nbft) ++{ ++ struct nbft_info_discovery **disc; ++ unsigned int nqn_width = 20, uri_width = 12; ++ ++ disc = nbft->discovery_list; ++ if (!disc || !*disc) ++ return; ++ ++ for (; *disc; disc++) { ++ size_t len; ++ ++ len = strlen((*disc)->uri); ++ if (len > uri_width) ++ uri_width = len; ++ len = strlen((*disc)->nqn); ++ if (len > nqn_width) ++ nqn_width = len; ++ } ++ ++ printf("\nNBFT Discovery Controllers:\n\n"); ++ printf("%-3.3s|%-*.*s|%-*.*s\n", "Idx", uri_width, uri_width, "URI", ++ nqn_width, nqn_width, "NQN"); ++ printf("%-.3s+%-.*s+%-.*s\n", dash, uri_width, dash, nqn_width, dash); ++ for (disc = nbft->discovery_list; *disc; disc++) ++ printf("%-3d|%-*.*s|%-*.*s\n", (*disc)->index, ++ uri_width, uri_width, (*disc)->uri, ++ nqn_width, nqn_width, (*disc)->nqn); ++} ++ ++#define HFIS_LEN 20 ++static size_t print_hfis(const struct nbft_info_subsystem_ns *ss, char buf[HFIS_LEN]) ++{ ++ char hfi_buf[HFIS_LEN]; ++ size_t len, ofs; ++ int i; ++ ++ len = snprintf(hfi_buf, sizeof(hfi_buf), "%d", ss->hfis[0]->index); ++ for (i = 1; i < ss->num_hfis; i++) { ++ ofs = len; ++ len += snprintf(hfi_buf + ofs, sizeof(hfi_buf) - ofs, ",%d", ++ ss->hfis[i]->index); ++ /* ++ * If the list doesn't fit in HFIS_LEN characters, ++ * truncate and end with "..." ++ */ ++ if (len >= sizeof(hfi_buf)) { ++ while (ofs < sizeof(hfi_buf) - 1) ++ hfi_buf[ofs++] = '.'; ++ hfi_buf[ofs] = '\0'; ++ len = sizeof(hfi_buf) - 1; ++ break; ++ } ++ } ++ if (buf) ++ memcpy(buf, hfi_buf, len + 1); ++ return len; ++} ++ ++ ++static void print_nbft_subsys_info(struct nbft_info *nbft) ++{ ++ struct nbft_info_subsystem_ns **ss; ++ unsigned int nqn_width = 20, adr_width = 8, hfi_width = 4; ++ ++ ss = nbft->subsystem_ns_list; ++ if (!ss || !*ss) ++ return; ++ for (; *ss; ss++) { ++ size_t len; ++ ++ len = strlen((*ss)->subsys_nqn); ++ if (len > nqn_width) ++ nqn_width = len; ++ len = strlen((*ss)->traddr); ++ if (len > adr_width) ++ adr_width = len; ++ len = print_hfis(*ss, NULL); ++ if (len > hfi_width) ++ hfi_width = len; ++ } ++ ++ printf("\nNBFT Subsystems:\n\n"); ++ printf("%-3.3s|%-*.*s|%-4.4s|%-*.*s|%-5.5s|%-*.*s\n", ++ "Idx", nqn_width, nqn_width, "NQN", ++ "Trsp", adr_width, adr_width, "Address", "SvcId", hfi_width, hfi_width, "HFIs"); ++ printf("%-.3s+%-.*s+%-.4s+%-.*s+%-.5s+%-.*s\n", ++ dash, nqn_width, dash, dash, adr_width, dash, dash, hfi_width, dash); ++ for (ss = nbft->subsystem_ns_list; *ss; ss++) { ++ char hfi_buf[HFIS_LEN]; ++ ++ print_hfis(*ss, hfi_buf); ++ printf("%-3d|%-*.*s|%-4.4s|%-*.*s|%-5.5s|%-*.*s\n", ++ (*ss)->index, nqn_width, nqn_width, (*ss)->subsys_nqn, ++ (*ss)->transport, adr_width, adr_width, (*ss)->traddr, ++ (*ss)->trsvcid, hfi_width, hfi_width, hfi_buf); ++ } ++} ++ ++static void normal_show_nbft(struct nbft_info *nbft, bool show_subsys, ++ bool show_hfi, bool show_discovery) ++{ ++ printf("%s:\n", nbft->filename); ++ if ((!nbft->hfi_list || !*nbft->hfi_list) && ++ (!nbft->security_list || !*nbft->security_list) && ++ (!nbft->discovery_list || !*nbft->discovery_list) && ++ (!nbft->subsystem_ns_list || !*nbft->subsystem_ns_list)) ++ printf("(empty)\n"); ++ else { ++ if (show_subsys) ++ print_nbft_subsys_info(nbft); ++ if (show_hfi) ++ print_nbft_hfi_info(nbft); ++ if (show_discovery) ++ print_nbft_discovery_info(nbft); ++ } ++} ++ ++static void normal_show_nbfts(struct list_head *nbft_list, bool show_subsys, ++ bool show_hfi, bool show_discovery) ++{ ++ bool not_first = false; ++ struct nbft_file_entry *entry; ++ ++ list_for_each(nbft_list, entry, node) { ++ if (not_first) ++ printf("\n"); ++ normal_show_nbft(entry->nbft, show_subsys, show_hfi, show_discovery); ++ not_first = true; ++ } ++} ++ ++int show_nbft(int argc, char **argv, struct command *cmd, struct plugin *plugin) ++{ ++ const char *desc = "Display contents of the ACPI NBFT files."; ++ struct list_head nbft_list; ++ char *format = "normal"; ++ char *nbft_path = NBFT_SYSFS_PATH; ++ enum nvme_print_flags flags = -1; ++ int ret; ++ bool show_subsys = false, show_hfi = false, show_discovery = false; ++ ++ OPT_ARGS(opts) = { ++ OPT_FMT("output-format", 'o', &format, "Output format: normal|json"), ++ OPT_FLAG("subsystem", 's', &show_subsys, "show NBFT subsystems"), ++ OPT_FLAG("hfi", 'H', &show_hfi, "show NBFT HFIs"), ++ OPT_FLAG("discovery", 'd', &show_discovery, "show NBFT discovery controllers"), ++ OPT_STRING("nbft-path", 0, "STR", &nbft_path, "user-defined path for NBFT tables"), ++ OPT_END() ++ }; ++ ++ ret = argconfig_parse(argc, argv, desc, opts); ++ if (ret) ++ return ret; ++ ++ if (!(show_subsys || show_hfi || show_discovery)) ++ show_subsys = show_hfi = show_discovery = true; ++ ++ if (!strcmp(format, "")) ++ flags = -1; ++ else if (!strcmp(format, "normal")) ++ flags = NORMAL; ++ else if (!strcmp(format, "json")) ++ flags = JSON; ++ else ++ return EINVAL; ++ ++ list_head_init(&nbft_list); ++ ret = read_nbft_files(&nbft_list, nbft_path); ++ if (!ret) { ++ if (flags == NORMAL) ++ normal_show_nbfts(&nbft_list, show_subsys, show_hfi, show_discovery); ++ else if (flags == JSON) ++ ret = json_show_nbfts(&nbft_list, show_subsys, show_hfi, show_discovery); ++ free_nbfts(&nbft_list); ++ } ++ return ret; ++} +diff --git a/plugins/nbft/nbft-plugin.h b/plugins/nbft/nbft-plugin.h +new file mode 100644 +index 00000000..018349d9 +--- /dev/null ++++ b/plugins/nbft/nbft-plugin.h +@@ -0,0 +1,18 @@ ++/* SPDX-License-Identifier: GPL-2.0-or-later */ ++#undef CMD_INC_FILE ++#define CMD_INC_FILE plugins/nbft/nbft-plugin ++ ++#if !defined(NBFT) || defined(CMD_HEADER_MULTI_READ) ++#define NBFT ++ ++#include "cmd.h" ++ ++PLUGIN(NAME("nbft", "ACPI NBFT table extensions", NVME_VERSION), ++ COMMAND_LIST( ++ ENTRY("show", "Show contents of ACPI NBFT tables", show_nbft) ++ ) ++); ++ ++#endif ++ ++#include "define_cmd.h" +-- +2.39.2 + diff --git a/nvme-cli.spec b/nvme-cli.spec index fd84a01..06bb083 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -3,13 +3,17 @@ Name: nvme-cli Version: 2.4 -Release: 1%{?dist} +Release: 2%{?dist} Summary: NVMe management command line interface License: GPLv2 URL: https://github.com/linux-nvme/nvme-cli Source0: %{url}/archive/v%{version_no_tilde}/%{name}-%{version_no_tilde}.tar.gz +Patch100: nvme-cli-2.5-nbft-make-lookup_ctrl-function-public.patch +Patch101: nvme-cli-2.5-nbft.patch +Patch102: nvme-cli-2.5-nbft_plugin.patch + BuildRequires: meson >= 0.50.0 BuildRequires: gcc gcc-c++ BuildRequires: systemd-devel @@ -17,7 +21,7 @@ BuildRequires: systemd-rpm-macros BuildRequires: zlib-devel BuildRequires: openssl-devel -BuildRequires: libnvme-devel >= 1.4 +BuildRequires: libnvme-devel >= 1.4-2 BuildRequires: json-c-devel >= 0.13 %if (0%{?rhel} == 0) @@ -83,6 +87,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Thu Apr 20 2023 Tomas Bzatek - 2.4-2 +- Backport the NBFT support from git master + * Mon Apr 03 2023 Tomas Bzatek - 2.4-1 - Update to 2.4 From aa5fc08451b6ae8febbda2adeb918dd99de62d7f Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Tue, 4 Jul 2023 15:47:56 +0200 Subject: [PATCH 05/33] * Tue Jul 04 2023 Tomas Bzatek - 2.5-1 - Update to 2.5 --- .gitignore | 1 + ...bft-make-lookup_ctrl-function-public.patch | 75 -- nvme-cli-2.5-nbft.patch | 451 ------------ nvme-cli-2.5-nbft_plugin.patch | 640 ------------------ nvme-cli.spec | 15 +- sources | 2 +- 6 files changed, 9 insertions(+), 1175 deletions(-) delete mode 100644 nvme-cli-2.5-nbft-make-lookup_ctrl-function-public.patch delete mode 100644 nvme-cli-2.5-nbft.patch delete mode 100644 nvme-cli-2.5-nbft_plugin.patch diff --git a/.gitignore b/.gitignore index 5add3b2..3555f05 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ /nvme-cli-2.2.1.tar.gz /nvme-cli-2.3.tar.gz /nvme-cli-2.4.tar.gz +/nvme-cli-2.5.tar.gz diff --git a/nvme-cli-2.5-nbft-make-lookup_ctrl-function-public.patch b/nvme-cli-2.5-nbft-make-lookup_ctrl-function-public.patch deleted file mode 100644 index 78529b9..0000000 --- a/nvme-cli-2.5-nbft-make-lookup_ctrl-function-public.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 34c197e0ac2d57734ab775f00b2d0758aca7b82f Mon Sep 17 00:00:00 2001 -From: John Meneghini -Date: Fri, 14 Apr 2023 10:53:58 -0400 -Subject: [PATCH 01/11] nbft: make lookup_ctrl function public - -To prepare for the addition of nbft functionality fixup the fabrics -declarations. - -Signed-off-by: John Meneghini ---- - fabrics.c | 12 ++---------- - fabrics.h | 10 ++++++++++ - 2 files changed, 12 insertions(+), 10 deletions(-) - -diff --git a/fabrics.c b/fabrics.c -index f8078e59..80827b16 100644 ---- a/fabrics.c -+++ b/fabrics.c -@@ -43,6 +43,7 @@ - #include "libnvme.h" - #include "nvme-print.h" - #include "nvme-print-json.h" -+#include "fabrics.h" - - #define PATH_NVMF_DISC SYSCONFDIR "/nvme/discovery.conf" - #define PATH_NVMF_CONFIG SYSCONFDIR "/nvme/config.json" -@@ -110,15 +111,6 @@ static const char *nvmf_config_file = "Use specified JSON configuration file or - OPT_FLAG("data-digest", 'G', &c.data_digest, nvmf_data_digest), \ - OPT_FLAG("tls", 0, &c.tls, nvmf_tls) \ - --struct tr_config { -- const char *subsysnqn; -- const char *transport; -- const char *traddr; -- const char *host_traddr; -- const char *host_iface; -- const char *trsvcid; --}; -- - /* - * Compare two C strings and handle NULL pointers gracefully. - * If either of the two strings is NULL, return 0 -@@ -202,7 +194,7 @@ static nvme_ctrl_t lookup_discovery_ctrl(nvme_root_t r, struct tr_config *trcfg) - return __lookup_ctrl(r, trcfg, disc_ctrl_config_match); - } - --static nvme_ctrl_t lookup_ctrl(nvme_root_t r, struct tr_config *trcfg) -+nvme_ctrl_t lookup_ctrl(nvme_root_t r, struct tr_config *trcfg) - { - return __lookup_ctrl(r, trcfg, ctrl_config_match); - } -diff --git a/fabrics.h b/fabrics.h -index d1e16fc5..02cebf5d 100644 ---- a/fabrics.h -+++ b/fabrics.h -@@ -2,6 +2,16 @@ - #ifndef _FABRICS_H - #define _FABRICS_H - -+struct tr_config { -+ const char *subsysnqn; -+ const char *transport; -+ const char *traddr; -+ const char *host_traddr; -+ const char *host_iface; -+ const char *trsvcid; -+}; -+ -+extern nvme_ctrl_t lookup_ctrl(nvme_root_t r, struct tr_config *trcfg); - extern int nvmf_discover(const char *desc, int argc, char **argv, bool connect); - extern int nvmf_connect(const char *desc, int argc, char **argv); - extern int nvmf_disconnect(const char *desc, int argc, char **argv); --- -2.39.2 - diff --git a/nvme-cli-2.5-nbft.patch b/nvme-cli-2.5-nbft.patch deleted file mode 100644 index e54da19..0000000 --- a/nvme-cli-2.5-nbft.patch +++ /dev/null @@ -1,451 +0,0 @@ -From a71a08532b5f06ee19ee2ff118a23cec4ecb6719 Mon Sep 17 00:00:00 2001 -From: Stuart Hayes -Date: Wed, 15 Jun 2022 11:42:50 -0500 -Subject: [PATCH 02/11] nbft: added NBFT v1.0 table support - -Added support for parsing the contents of the NBFT table (per NVMe-oF -boot specification v1.0) with the connect-all and discover commands. - -nvme discover/connect-all --nbft ignore /etc/nvme config and use NBFT tables -nvme discover/connect-all --no-nbft ignore NBFT tables and use /etc/nvme config -nvme discover/connect-all --nbft-path= user-defined path for NBFT tables - -Signed-off-by: Stuart Hayes -Signed-off-by: Martin Belanger - -Use the new nbft public API. - -Signed-off-by: Tomas Bzatek -Signed-off-by: Martin Wilck -Signed-off-by: John Meneghini ---- - Documentation/nvme-connect-all.txt | 25 ++++ - Documentation/nvme-discover.txt | 27 +++- - fabrics.c | 17 +++ - meson.build | 1 + - nbft.c | 202 +++++++++++++++++++++++++++++ - nbft.h | 19 +++ - 6 files changed, 290 insertions(+), 1 deletion(-) - create mode 100644 nbft.c - create mode 100644 nbft.h - -diff --git a/Documentation/nvme-connect-all.txt b/Documentation/nvme-connect-all.txt -index 44bb4f94..cbb7ca6c 100644 ---- a/Documentation/nvme-connect-all.txt -+++ b/Documentation/nvme-connect-all.txt -@@ -35,6 +35,9 @@ SYNOPSIS - [--tls ] - [--quiet | -S] - [--dump-config | -O] -+ [--nbft] -+ [--no-nbft] -+ [--nbft-path=] - - DESCRIPTION - ----------- -@@ -198,6 +201,16 @@ OPTIONS - --dump-config:: - Print out resulting JSON configuration file to stdout. - -+--nbft:: -+ Only look at NBFT tables -+ -+--no-nbft:: -+ Do not look at NBFT tables -+ -+--nbft-path=:: -+ Use a user-defined path to the NBFT tables -+ -+ - - EXAMPLES - -------- -@@ -210,6 +223,18 @@ the RDMA network. Port 4420 is used by default: - --hostnqn=host1-rogue-nqn - ------------ - + -+* Issue a 'nvme connect-all' command using the default system defined NBFT tables: -++ -+----------- -+# nvme connect-all --nbft -+------------ -++ -+* Issue a 'nvme connect-all' command with a user-defined path for the NBFT table: -++ -+----------- -+# nvme connet-all --nbft-path=/sys/firmware/acpi/tables/NBFT1 -+------------ -++ - * Issue a 'nvme connect-all' command using a @SYSCONFDIR@/nvme/discovery.conf file: - + - ----------- -diff --git a/Documentation/nvme-discover.txt b/Documentation/nvme-discover.txt -index d4df75c2..b040c688 100644 ---- a/Documentation/nvme-discover.txt -+++ b/Documentation/nvme-discover.txt -@@ -37,6 +37,9 @@ SYNOPSIS - [--dump-config | -O] - [--output-format= | -o ] - [--force] -+ [--nbft] -+ [--no-nbft] -+ [--nbft-path=] - - DESCRIPTION - ----------- -@@ -68,7 +71,7 @@ Note that the base NVMe specification defines the NQN (NVMe Qualified - Name) format which an NVMe endpoint (device, subsystem, etc) must - follow to guarantee a unique name under the NVMe standard. - In particular, the Host NQN uniquely identifies the NVMe Host, and --may be used by the the Discovery Controller to control what NVMe Target -+may be used by the Discovery Controller to control what NVMe Target - resources are allocated to the NVMe Host for a connection. - - A Discovery Controller has it's own NQN defined in the NVMe-over-Fabrics -@@ -229,6 +232,16 @@ OPTIONS - Combined with --persistent flag, always create new - persistent discovery connection. - -+--nbft:: -+ Only look at NBFT tables -+ -+--no-nbft:: -+ Do not look at NBFT tables -+ -+--nbft-path=:: -+ Use a user-defined path to the NBFT tables -+ -+ - EXAMPLES - -------- - * Query the Discover Controller with IP4 address 192.168.1.3 for all -@@ -240,6 +253,18 @@ Port 4420 is used by default: - --hostnqn=host1-rogue-nqn - ------------ - + -+* Issue a 'nvme discover' command using the default system defined NBFT tables: -++ -+----------- -+# nvme discover --nbft -+------------ -++ -+* Issue a 'nvme discover' command with a user-defined path for the NBFT table: -++ -+----------- -+# nvme discover --nbft-path=/sys/firmware/acpi/tables/NBFT1 -+------------ -++ - * Issue a 'nvme discover' command using a @SYSCONFDIR@/nvme/discovery.conf file: - + - ----------- -diff --git a/fabrics.c b/fabrics.c -index 80827b16..0edbd299 100644 ---- a/fabrics.c -+++ b/fabrics.c -@@ -40,6 +40,7 @@ - - #include "common.h" - #include "nvme.h" -+#include "nbft.h" - #include "libnvme.h" - #include "nvme-print.h" - #include "nvme-print-json.h" -@@ -710,6 +711,7 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) - { - char *subsysnqn = NVME_DISC_SUBSYS_NAME; - char *hostnqn = NULL, *hostid = NULL, *hostkey = NULL; -+ char *hostnqn_arg, *hostid_arg; - char *transport = NULL, *traddr = NULL, *trsvcid = NULL; - char *config_file = PATH_NVMF_CONFIG; - char *hnqn = NULL, *hid = NULL; -@@ -724,6 +726,8 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) - char *device = NULL; - bool force = false; - bool json_config = false; -+ bool nbft = false, nonbft = false; -+ char *nbft_path = NBFT_SYSFS_PATH; - - OPT_ARGS(opts) = { - OPT_STRING("device", 'd', "DEV", &device, "use existing discovery controller device"), -@@ -736,6 +740,9 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) - OPT_INCR("verbose", 'v', &verbose, "Increase logging verbosity"), - OPT_FLAG("dump-config", 'O', &dump_config, "Dump configuration file to stdout"), - OPT_FLAG("force", 0, &force, "Force persistent discovery controller creation"), -+ OPT_FLAG("nbft", 0, &nbft, "Only look at NBFT tables"), -+ OPT_FLAG("no-nbft", 0, &nonbft, "Do not look at NBFT tables"), -+ OPT_STRING("nbft-path", 0, "STR", &nbft_path, "user-defined path for NBFT tables"), - OPT_END() - }; - -@@ -768,6 +775,8 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) - if (!nvme_read_config(r, config_file)) - json_config = true; - -+ hostnqn_arg = hostnqn; -+ hostid_arg = hostid; - if (!hostnqn) - hostnqn = hnqn = nvmf_hostnqn_from_file(); - if (!hostnqn) -@@ -789,6 +798,14 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) - nvme_host_set_dhchap_key(h, hostkey); - - if (!device && !transport && !traddr) { -+ if (!nonbft) -+ discover_from_nbft(r, hostnqn_arg, hostid_arg, -+ hostnqn, hostid, desc, connect, -+ &cfg, nbft_path, flags, verbose); -+ -+ if (nbft) -+ goto out_free; -+ - if (json_config) - ret = discover_from_json_config_file(r, h, desc, - connect, &cfg, -diff --git a/meson.build b/meson.build -index 43ce5f9b..7ec357a9 100644 ---- a/meson.build -+++ b/meson.build -@@ -240,6 +240,7 @@ incdir = include_directories(['ccan']) - - ################################################################################ - sources = [ -+ 'nbft.c', - 'fabrics.c', - 'nvme.c', - 'nvme-models.c', -diff --git a/nbft.c b/nbft.c -new file mode 100644 -index 00000000..14347287 ---- /dev/null -+++ b/nbft.c -@@ -0,0 +1,202 @@ -+// SPDX-License-Identifier: GPL-2.0-or-later -+ -+#include -+#include -+#include -+ -+#include "nvme.h" -+#include "nbft.h" -+#include "libnvme.h" -+#include "fabrics.h" -+ -+#define NBFT_SYSFS_FILENAME "NBFT*" -+ -+static void print_connect_msg(nvme_ctrl_t c) -+{ -+ printf("device: %s\n", nvme_ctrl_get_name(c)); -+} -+ -+static void json_connect_msg(nvme_ctrl_t c) -+{ -+ struct json_object *root; -+ -+ root = json_create_object(); -+ json_object_add_value_string(root, "device", nvme_ctrl_get_name(c)); -+ -+ json_print_object(root, NULL); -+ printf("\n"); -+ json_free_object(root); -+} -+ -+int nbft_filter(const struct dirent *dent) -+{ -+ return !fnmatch(NBFT_SYSFS_FILENAME, dent->d_name, FNM_PATHNAME); -+} -+ -+int read_nbft_files(struct list_head *nbft_list, char *path) -+{ -+ struct dirent **dent; -+ char filename[PATH_MAX]; -+ int i, count, ret; -+ struct nbft_file_entry *entry; -+ struct nbft_info *nbft; -+ -+ count = scandir(path, &dent, nbft_filter, NULL); -+ if (count < 0) { -+ fprintf(stderr, "Failed to open %s.\n", path); -+ return -1; -+ } -+ -+ for (i = 0; i < count; i++) { -+ snprintf(filename, sizeof(filename), "%s/%s", path, dent[i]->d_name); -+ ret = nvme_nbft_read(&nbft, filename); -+ if (!ret) { -+ entry = calloc(1, sizeof(*entry)); -+ entry->nbft = nbft; -+ list_add_tail(nbft_list, &entry->node); -+ } -+ free(dent[i]); -+ } -+ free(dent); -+ return 0; -+} -+ -+void free_nbfts(struct list_head *nbft_list) -+{ -+ struct nbft_file_entry *entry; -+ -+ while ((entry = list_pop(nbft_list, struct nbft_file_entry, node))) { -+ nvme_nbft_free(entry->nbft); -+ free(entry); -+ } -+} -+ -+int discover_from_nbft(nvme_root_t r, char *hostnqn_arg, char *hostid_arg, -+ char *hostnqn_sys, char *hostid_sys, -+ const char *desc, bool connect, -+ const struct nvme_fabrics_config *cfg, char *nbft_path, -+ enum nvme_print_flags flags, bool verbose) -+{ -+ char *hostnqn = NULL, *hostid = NULL, *host_traddr = NULL; -+ nvme_host_t h; -+ nvme_ctrl_t c; -+ int ret, i; -+ struct list_head nbft_list; -+ struct nbft_file_entry *entry; -+ struct nbft_info_subsystem_ns **ss; -+ struct nbft_info_hfi *hfi; -+ -+ if (!connect) -+ /* to do: print discovery-type info from NBFT tables */ -+ return 0; -+ -+ list_head_init(&nbft_list); -+ ret = read_nbft_files(&nbft_list, nbft_path); -+ if (ret) -+ goto out_free_2; -+ -+ list_for_each(&nbft_list, entry, node) -+ for (ss = entry->nbft->subsystem_ns_list; ss && *ss; ss++) -+ for (i = 0; i < (*ss)->num_hfis; i++) { -+ nvme_ctrl_t cl; -+ -+ hfi = (*ss)->hfis[i]; -+ if (hostnqn_arg) -+ hostnqn = hostnqn_arg; -+ else { -+ hostnqn = entry->nbft->host.nqn; -+ if (!hostnqn) -+ hostnqn = hostnqn_sys; -+ } -+ -+ if (hostid_arg) -+ hostid = hostid_arg; -+ else if (*entry->nbft->host.id) { -+ hostid = (char *)util_uuid_to_string(entry->nbft->host.id); -+ if (!hostid) -+ hostid = hostid_sys; -+ } -+ -+ h = nvme_lookup_host(r, hostnqn, hostid); -+ if (!h) { -+ errno = ENOMEM; -+ goto out_free; -+ } -+ -+ if (!cfg->host_traddr) { -+ host_traddr = NULL; -+ if (!strncmp((*ss)->transport, "tcp", 3)) -+ host_traddr = hfi->tcp_info.ipaddr; -+ } -+ -+ struct tr_config trcfg = { -+ .subsysnqn = (*ss)->subsys_nqn, -+ .transport = (*ss)->transport, -+ .traddr = (*ss)->traddr, -+ .host_traddr = host_traddr, -+ .host_iface = NULL, -+ .trsvcid = (*ss)->trsvcid, -+ }; -+ -+ /* Already connected ? */ -+ cl = lookup_ctrl(r, &trcfg); -+ if (cl && nvme_ctrl_get_name(cl)) -+ continue; -+ -+ c = nvme_create_ctrl(r, (*ss)->subsys_nqn, (*ss)->transport, -+ (*ss)->traddr, host_traddr, NULL, -+ (*ss)->trsvcid); -+ if (!c) { -+ errno = ENOMEM; -+ goto out_free; -+ } -+ -+ errno = 0; -+ ret = nvmf_add_ctrl(h, c, cfg); -+ -+ /* -+ * With TCP/DHCP, it can happen that the OS -+ * obtains a different local IP address than the -+ * firmware had. Retry without host_traddr. -+ */ -+ if (ret == -1 && errno == ENVME_CONNECT_WRITE && -+ !strcmp((*ss)->transport, "tcp") && -+ strlen(hfi->tcp_info.dhcp_server_ipaddr) > 0) { -+ nvme_free_ctrl(c); -+ -+ trcfg.host_traddr = NULL; -+ cl = lookup_ctrl(r, &trcfg); -+ if (cl && nvme_ctrl_get_name(cl)) -+ continue; -+ -+ c = nvme_create_ctrl(r, (*ss)->subsys_nqn, (*ss)->transport, -+ (*ss)->traddr, -+ NULL, NULL, (*ss)->trsvcid); -+ if (!c) { -+ errno = ENOMEM; -+ goto out_free; -+ } -+ errno = 0; -+ ret = nvmf_add_ctrl(h, c, cfg); -+ if (ret == 0 && verbose >= 1) -+ fprintf(stderr, -+ "connect with host_traddr=\"%s\" failed, success after omitting host_traddr\n", -+ host_traddr); -+ } -+ -+ if (ret) -+ fprintf(stderr, "no controller found\n"); -+ else { -+ if (flags == NORMAL) -+ print_connect_msg(c); -+ else if (flags == JSON) -+ json_connect_msg(c); -+ } -+out_free: -+ if (errno == ENOMEM) -+ goto out_free_2; -+ } -+out_free_2: -+ free_nbfts(&nbft_list); -+ return errno; -+} -diff --git a/nbft.h b/nbft.h -new file mode 100644 -index 00000000..0e09733f ---- /dev/null -+++ b/nbft.h -@@ -0,0 +1,19 @@ -+/* SPDX-License-Identifier: GPL-2.0-or-later */ -+ -+#include -+ -+#define NBFT_SYSFS_PATH "/sys/firmware/acpi/tables" -+ -+struct nbft_file_entry { -+ struct list_node node; -+ struct nbft_info *nbft; -+}; -+ -+int read_nbft_files(struct list_head *nbft_list, char *path); -+void free_nbfts(struct list_head *nbft_list); -+ -+extern int discover_from_nbft(nvme_root_t r, char *hostnqn_arg, char *hostid_arg, -+ char *hostnqn_sys, char *hostid_sys, -+ const char *desc, bool connect, -+ const struct nvme_fabrics_config *cfg, char *nbft_path, -+ enum nvme_print_flags flags, bool verbose); --- -2.39.2 - diff --git a/nvme-cli-2.5-nbft_plugin.patch b/nvme-cli-2.5-nbft_plugin.patch deleted file mode 100644 index b70d26e..0000000 --- a/nvme-cli-2.5-nbft_plugin.patch +++ /dev/null @@ -1,640 +0,0 @@ -From 23daeedc53be9b5225cc6806434888c0a7a8e9bf Mon Sep 17 00:00:00 2001 -From: Stuart Hayes -Date: Fri, 14 Apr 2023 22:01:07 -0400 -Subject: [PATCH 03/11] nbft: add the nbft show plugin - -Display contents of the ACPI NBFT files. - -Usage: nvme nbft show [OPTIONS] - -Options: - [ --output-format=, -o ] --- Output format: normal|json - [ --subsystem, -s ] --- show NBFT subsystems - [ --hfi, -H ] --- show NBFT HFIs - [ --discovery, -d ] --- show NBFT discovery controllers - [ --nbft-path= ] --- user-defined path for NBFT tables - -Signed-off-by: Stuart Hayes -Signed-off-by: Martin Wilck -Signed-off-by: John Meneghini ---- - plugins/meson.build | 1 + - plugins/nbft/nbft-plugin.c | 568 +++++++++++++++++++++++++++++++++++++ - plugins/nbft/nbft-plugin.h | 18 ++ - 3 files changed, 587 insertions(+) - create mode 100644 plugins/nbft/nbft-plugin.c - create mode 100644 plugins/nbft/nbft-plugin.h - -diff --git a/plugins/meson.build b/plugins/meson.build -index 2cf2486f..38b7cded 100644 ---- a/plugins/meson.build -+++ b/plugins/meson.build -@@ -12,6 +12,7 @@ if json_c_dep.found() - 'plugins/intel/intel-nvme.c', - 'plugins/memblaze/memblaze-nvme.c', - 'plugins/micron/micron-nvme.c', -+ 'plugins/nbft/nbft-plugin.c', - 'plugins/netapp/netapp-nvme.c', - 'plugins/nvidia/nvidia-nvme.c', - 'plugins/scaleflux/sfx-nvme.c', -diff --git a/plugins/nbft/nbft-plugin.c b/plugins/nbft/nbft-plugin.c -new file mode 100644 -index 00000000..6ae2525a ---- /dev/null -+++ b/plugins/nbft/nbft-plugin.c -@@ -0,0 +1,568 @@ -+// SPDX-License-Identifier: GPL-2.0-or-later -+ -+#include -+#include -+#include -+ -+#include "nvme-print.h" -+#include "nvme.h" -+#include "nbft.h" -+#include "libnvme.h" -+#include "fabrics.h" -+ -+#define CREATE_CMD -+#include "nbft-plugin.h" -+ -+static const char dash[100] = {[0 ... 98] = '-', [99] = '\0'}; -+ -+#define PCI_SEGMENT(sbdf) ((sbdf & 0xffff0000) >> 16) -+#define PCI_BUS(sbdf) ((sbdf & 0x0000ff00) >> 8) -+#define PCI_DEV(sbdf) ((sbdf & 0x000000f8) >> 3) -+#define PCI_FUNC(sbdf) ((sbdf & 0x00000007) >> 0) -+ -+static const char *pci_sbdf_to_string(__u16 pci_sbdf) -+{ -+ static char pcidev[13]; -+ -+ snprintf(pcidev, sizeof(pcidev), "%x:%x:%x.%x", -+ PCI_SEGMENT(pci_sbdf), -+ PCI_BUS(pci_sbdf), -+ PCI_DEV(pci_sbdf), -+ PCI_FUNC(pci_sbdf)); -+ return pcidev; -+} -+ -+static char *mac_addr_to_string(unsigned char mac_addr[6]) -+{ -+ static char mac_string[18]; -+ -+ snprintf(mac_string, sizeof(mac_string), "%02x:%02x:%02x:%02x:%02x:%02x", -+ mac_addr[0], -+ mac_addr[1], -+ mac_addr[2], -+ mac_addr[3], -+ mac_addr[4], -+ mac_addr[5]); -+ return mac_string; -+} -+ -+static json_object *hfi_to_json(struct nbft_info_hfi *hfi) -+{ -+ struct json_object *hfi_json; -+ -+ hfi_json = json_create_object(); -+ if (!hfi_json) -+ return NULL; -+ -+ if (json_object_add_value_int(hfi_json, "index", hfi->index) -+ || json_object_add_value_string(hfi_json, "transport", hfi->transport)) -+ goto fail; -+ -+ if (strcmp(hfi->transport, "tcp") == 0) { -+ if (json_object_add_value_string(hfi_json, "pcidev", -+ pci_sbdf_to_string(hfi->tcp_info.pci_sbdf)) -+ || json_object_add_value_string(hfi_json, "mac_addr", -+ mac_addr_to_string(hfi->tcp_info.mac_addr)) -+ || json_object_add_value_int(hfi_json, "vlan", -+ hfi->tcp_info.vlan) -+ || json_object_add_value_int(hfi_json, "ip_origin", -+ hfi->tcp_info.ip_origin) -+ || json_object_add_value_string(hfi_json, "ipaddr", -+ hfi->tcp_info.ipaddr) -+ || json_object_add_value_int(hfi_json, "subnet_mask_prefix", -+ hfi->tcp_info.subnet_mask_prefix) -+ || json_object_add_value_string(hfi_json, "gateway_ipaddr", -+ hfi->tcp_info.gateway_ipaddr) -+ || json_object_add_value_int(hfi_json, "route_metric", -+ hfi->tcp_info.route_metric) -+ || json_object_add_value_string(hfi_json, "primary_dns_ipaddr", -+ hfi->tcp_info.primary_dns_ipaddr) -+ || json_object_add_value_string(hfi_json, "secondary_dns_ipaddr", -+ hfi->tcp_info.secondary_dns_ipaddr) -+ || json_object_add_value_string(hfi_json, "dhcp_server_ipaddr", -+ hfi->tcp_info.dhcp_server_ipaddr) -+ || (hfi->tcp_info.host_name -+ && json_object_add_value_string(hfi_json, "host_name", -+ hfi->tcp_info.host_name)) -+ || json_object_add_value_int(hfi_json, "this_hfi_is_default_route", -+ hfi->tcp_info.this_hfi_is_default_route) -+ || json_object_add_value_int(hfi_json, "dhcp_override", -+ hfi->tcp_info.dhcp_override)) -+ goto fail; -+ else -+ return hfi_json; -+ } -+fail: -+ json_free_object(hfi_json); -+ return NULL; -+} -+ -+static json_object *ssns_to_json(struct nbft_info_subsystem_ns *ss) -+{ -+ struct json_object *ss_json; -+ struct json_object *hfi_array_json; -+ char json_str[40]; -+ char *json_str_p; -+ int i; -+ -+ ss_json = json_create_object(); -+ if (!ss_json) -+ return NULL; -+ -+ hfi_array_json = json_create_array(); -+ if (!hfi_array_json) -+ goto fail; -+ -+ for (i = 0; i < ss->num_hfis; i++) -+ if (json_array_add_value_object(hfi_array_json, -+ json_object_new_int(ss->hfis[i]->index))) -+ goto fail; -+ -+ if (json_object_add_value_int(ss_json, "index", ss->index) -+ || json_object_add_value_int(ss_json, "num_hfis", ss->num_hfis) -+ || json_object_object_add(ss_json, "hfis", hfi_array_json) -+ || json_object_add_value_string(ss_json, "transport", ss->transport) -+ || json_object_add_value_string(ss_json, "traddr", ss->traddr) -+ || json_object_add_value_string(ss_json, "trsvcid", ss->trsvcid) -+ || json_object_add_value_int(ss_json, "subsys_port_id", ss->subsys_port_id) -+ || json_object_add_value_int(ss_json, "nsid", ss->nsid)) -+ goto fail; -+ -+ memset(json_str, 0, sizeof(json_str)); -+ json_str_p = json_str; -+ -+ switch (ss->nid_type) { -+ case NBFT_INFO_NID_TYPE_EUI64: -+ if (json_object_add_value_string(ss_json, "nid_type", "eui64")) -+ goto fail; -+ for (i = 0; i < 8; i++) -+ json_str_p += sprintf(json_str_p, "%02x", ss->nid[i]); -+ break; -+ -+ case NBFT_INFO_NID_TYPE_NGUID: -+ if (json_object_add_value_string(ss_json, "nid_type", "nguid")) -+ goto fail; -+ for (i = 0; i < 16; i++) -+ json_str_p += sprintf(json_str_p, "%02x", ss->nid[i]); -+ break; -+ -+ case NBFT_INFO_NID_TYPE_NS_UUID: -+ if (json_object_add_value_string(ss_json, "nid_type", "uuid")) -+ goto fail; -+ nvme_uuid_to_string(ss->nid, json_str); -+ break; -+ -+ default: -+ break; -+ } -+ if (json_object_add_value_string(ss_json, "nid", json_str)) -+ goto fail; -+ -+ if ((ss->subsys_nqn -+ && json_object_add_value_string(ss_json, "subsys_nqn", ss->subsys_nqn)) -+ || json_object_add_value_int(ss_json, "controller_id", ss->controller_id) -+ || json_object_add_value_int(ss_json, "asqsz", ss->asqsz) -+ || (ss->dhcp_root_path_string -+ && json_object_add_value_string(ss_json, "dhcp_root_path_string", -+ ss->dhcp_root_path_string)) -+ || json_object_add_value_int(ss_json, "pdu_header_digest_required", -+ ss->pdu_header_digest_required) -+ || json_object_add_value_int(ss_json, "data_digest_required", -+ ss->data_digest_required)) -+ goto fail; -+ -+ return ss_json; -+fail: -+ json_free_object(ss_json); -+ return NULL; -+} -+ -+static json_object *discovery_to_json(struct nbft_info_discovery *disc) -+{ -+ struct json_object *disc_json; -+ -+ disc_json = json_create_object(); -+ if (!disc_json) -+ return NULL; -+ -+ if (json_object_add_value_int(disc_json, "index", disc->index) -+ || (disc->security -+ && json_object_add_value_int(disc_json, "security", disc->security->index)) -+ || (disc->hfi -+ && json_object_add_value_int(disc_json, "hfi", disc->hfi->index)) -+ || (disc->uri -+ && json_object_add_value_string(disc_json, "uri", disc->uri)) -+ || (disc->nqn -+ && json_object_add_value_string(disc_json, "nqn", disc->nqn))) { -+ json_free_object(disc_json); -+ return NULL; -+ } else -+ return disc_json; -+} -+ -+static const char *primary_admin_host_flag_to_str(unsigned int primary) -+{ -+ static const char * const str[] = { -+ [NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_NOT_INDICATED] = "not indicated", -+ [NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_UNSELECTED] = "unselected", -+ [NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_SELECTED] = "selected", -+ [NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_RESERVED] = "reserved", -+ }; -+ -+ if (primary > NBFT_INFO_PRIMARY_ADMIN_HOST_FLAG_RESERVED) -+ return "INVALID"; -+ return str[primary]; -+} -+ -+static struct json_object *nbft_to_json(struct nbft_info *nbft, bool show_subsys, -+ bool show_hfi, bool show_discovery) -+{ -+ struct json_object *nbft_json, *host_json; -+ -+ nbft_json = json_create_object(); -+ if (!nbft_json) -+ return NULL; -+ -+ if (json_object_add_value_string(nbft_json, "filename", nbft->filename)) -+ goto fail; -+ -+ host_json = json_create_object(); -+ if (!host_json) -+ goto fail; -+ if ((nbft->host.nqn -+ && json_object_add_value_string(host_json, "nqn", nbft->host.nqn)) -+ || (nbft->host.id -+ && json_object_add_value_string(host_json, "id", -+ util_uuid_to_string(nbft->host.id)))) -+ goto fail; -+ json_object_add_value_int(host_json, "host_id_configured", -+ nbft->host.host_id_configured); -+ json_object_add_value_int(host_json, "host_nqn_configured", -+ nbft->host.host_nqn_configured); -+ json_object_add_value_string(host_json, "primary_admin_host_flag", -+ primary_admin_host_flag_to_str(nbft->host.primary)); -+ if (json_object_object_add(nbft_json, "host", host_json)) { -+ json_free_object(host_json); -+ goto fail; -+ } -+ -+ if (show_subsys) { -+ struct json_object *subsys_array_json, *subsys_json; -+ struct nbft_info_subsystem_ns **ss; -+ -+ subsys_array_json = json_create_array(); -+ if (!subsys_array_json) -+ goto fail; -+ for (ss = nbft->subsystem_ns_list; ss && *ss; ss++) { -+ subsys_json = ssns_to_json(*ss); -+ if (!subsys_json) -+ goto fail; -+ if (json_object_array_add(subsys_array_json, subsys_json)) { -+ json_free_object(subsys_json); -+ goto fail; -+ } -+ } -+ if (json_object_object_add(nbft_json, "subsystem", subsys_array_json)) { -+ json_free_object(subsys_array_json); -+ goto fail; -+ } -+ } -+ if (show_hfi) { -+ struct json_object *hfi_array_json, *hfi_json; -+ struct nbft_info_hfi **hfi; -+ -+ hfi_array_json = json_create_array(); -+ if (!hfi_array_json) -+ goto fail; -+ for (hfi = nbft->hfi_list; hfi && *hfi; hfi++) { -+ hfi_json = hfi_to_json(*hfi); -+ if (!hfi_json) -+ goto fail; -+ if (json_object_array_add(hfi_array_json, hfi_json)) { -+ json_free_object(hfi_json); -+ goto fail; -+ } -+ } -+ if (json_object_object_add(nbft_json, "hfi", hfi_array_json)) { -+ json_free_object(hfi_array_json); -+ goto fail; -+ } -+ } -+ if (show_discovery) { -+ struct json_object *discovery_array_json, *discovery_json; -+ struct nbft_info_discovery **disc; -+ -+ discovery_array_json = json_create_array(); -+ if (!discovery_array_json) -+ goto fail; -+ for (disc = nbft->discovery_list; disc && *disc; disc++) { -+ discovery_json = discovery_to_json(*disc); -+ if (!discovery_json) -+ goto fail; -+ if (json_object_array_add(discovery_array_json, discovery_json)) { -+ json_free_object(discovery_json); -+ goto fail; -+ } -+ } -+ if (json_object_object_add(nbft_json, "discovery", discovery_array_json)) { -+ json_free_object(discovery_array_json); -+ goto fail; -+ } -+ } -+ return nbft_json; -+fail: -+ json_free_object(nbft_json); -+ return NULL; -+} -+ -+static int json_show_nbfts(struct list_head *nbft_list, bool show_subsys, -+ bool show_hfi, bool show_discovery) -+{ -+ struct json_object *nbft_json_array, *nbft_json; -+ struct nbft_file_entry *entry; -+ -+ nbft_json_array = json_create_array(); -+ if (!nbft_json_array) -+ return ENOMEM; -+ -+ list_for_each(nbft_list, entry, node) { -+ nbft_json = nbft_to_json(entry->nbft, show_subsys, show_hfi, show_discovery); -+ if (!nbft_json) -+ goto fail; -+ if (json_object_array_add(nbft_json_array, nbft_json)) { -+ json_free_object(nbft_json); -+ goto fail; -+ } -+ } -+ -+ json_print_object(nbft_json_array, NULL); -+ printf("\n"); -+ json_free_object(nbft_json_array); -+ return 0; -+fail: -+ json_free_object(nbft_json_array); -+ return ENOMEM; -+} -+ -+static void print_nbft_hfi_info(struct nbft_info *nbft) -+{ -+ struct nbft_info_hfi **hfi; -+ unsigned int ip_width = 8, gw_width = 8, dns_width = 8; -+ -+ hfi = nbft->hfi_list; -+ if (!hfi || !*hfi) -+ return; -+ -+ for (; *hfi; hfi++) { -+ unsigned int len; -+ -+ len = strlen((*hfi)->tcp_info.ipaddr); -+ if (len > ip_width) -+ ip_width = len; -+ len = strlen((*hfi)->tcp_info.gateway_ipaddr); -+ if (len > gw_width) -+ gw_width = len; -+ len = strlen((*hfi)->tcp_info.primary_dns_ipaddr); -+ if (len > dns_width) -+ dns_width = len; -+ } -+ -+ printf("\nNBFT HFIs:\n\n"); -+ printf("%-3.3s|%-4.4s|%-10.10s|%-17.17s|%-4.4s|%-*.*s|%-4.4s|%-*.*s|%-*.*s\n", -+ "Idx", "Trsp", "PCI Addr", "MAC Addr", "DHCP", -+ ip_width, ip_width, "IP Addr", "Mask", -+ gw_width, gw_width, "Gateway", dns_width, dns_width, "DNS"); -+ printf("%-.3s+%-.4s+%-.10s+%-.17s+%-.4s+%-.*s+%-.4s+%-.*s+%-.*s\n", -+ dash, dash, dash, dash, dash, ip_width, dash, dash, -+ gw_width, dash, dns_width, dash); -+ for (hfi = nbft->hfi_list; *hfi; hfi++) -+ printf("%-3d|%-4.4s|%-10.10s|%-17.17s|%-4.4s|%-*.*s|%-4d|%-*.*s|%-*.*s\n", -+ (*hfi)->index, -+ (*hfi)->transport, -+ pci_sbdf_to_string((*hfi)->tcp_info.pci_sbdf), -+ mac_addr_to_string((*hfi)->tcp_info.mac_addr), -+ (*hfi)->tcp_info.dhcp_override ? "yes" : "no", -+ ip_width, ip_width, (*hfi)->tcp_info.ipaddr, -+ (*hfi)->tcp_info.subnet_mask_prefix, -+ gw_width, gw_width, (*hfi)->tcp_info.gateway_ipaddr, -+ dns_width, dns_width, (*hfi)->tcp_info.primary_dns_ipaddr); -+} -+ -+static void print_nbft_discovery_info(struct nbft_info *nbft) -+{ -+ struct nbft_info_discovery **disc; -+ unsigned int nqn_width = 20, uri_width = 12; -+ -+ disc = nbft->discovery_list; -+ if (!disc || !*disc) -+ return; -+ -+ for (; *disc; disc++) { -+ size_t len; -+ -+ len = strlen((*disc)->uri); -+ if (len > uri_width) -+ uri_width = len; -+ len = strlen((*disc)->nqn); -+ if (len > nqn_width) -+ nqn_width = len; -+ } -+ -+ printf("\nNBFT Discovery Controllers:\n\n"); -+ printf("%-3.3s|%-*.*s|%-*.*s\n", "Idx", uri_width, uri_width, "URI", -+ nqn_width, nqn_width, "NQN"); -+ printf("%-.3s+%-.*s+%-.*s\n", dash, uri_width, dash, nqn_width, dash); -+ for (disc = nbft->discovery_list; *disc; disc++) -+ printf("%-3d|%-*.*s|%-*.*s\n", (*disc)->index, -+ uri_width, uri_width, (*disc)->uri, -+ nqn_width, nqn_width, (*disc)->nqn); -+} -+ -+#define HFIS_LEN 20 -+static size_t print_hfis(const struct nbft_info_subsystem_ns *ss, char buf[HFIS_LEN]) -+{ -+ char hfi_buf[HFIS_LEN]; -+ size_t len, ofs; -+ int i; -+ -+ len = snprintf(hfi_buf, sizeof(hfi_buf), "%d", ss->hfis[0]->index); -+ for (i = 1; i < ss->num_hfis; i++) { -+ ofs = len; -+ len += snprintf(hfi_buf + ofs, sizeof(hfi_buf) - ofs, ",%d", -+ ss->hfis[i]->index); -+ /* -+ * If the list doesn't fit in HFIS_LEN characters, -+ * truncate and end with "..." -+ */ -+ if (len >= sizeof(hfi_buf)) { -+ while (ofs < sizeof(hfi_buf) - 1) -+ hfi_buf[ofs++] = '.'; -+ hfi_buf[ofs] = '\0'; -+ len = sizeof(hfi_buf) - 1; -+ break; -+ } -+ } -+ if (buf) -+ memcpy(buf, hfi_buf, len + 1); -+ return len; -+} -+ -+ -+static void print_nbft_subsys_info(struct nbft_info *nbft) -+{ -+ struct nbft_info_subsystem_ns **ss; -+ unsigned int nqn_width = 20, adr_width = 8, hfi_width = 4; -+ -+ ss = nbft->subsystem_ns_list; -+ if (!ss || !*ss) -+ return; -+ for (; *ss; ss++) { -+ size_t len; -+ -+ len = strlen((*ss)->subsys_nqn); -+ if (len > nqn_width) -+ nqn_width = len; -+ len = strlen((*ss)->traddr); -+ if (len > adr_width) -+ adr_width = len; -+ len = print_hfis(*ss, NULL); -+ if (len > hfi_width) -+ hfi_width = len; -+ } -+ -+ printf("\nNBFT Subsystems:\n\n"); -+ printf("%-3.3s|%-*.*s|%-4.4s|%-*.*s|%-5.5s|%-*.*s\n", -+ "Idx", nqn_width, nqn_width, "NQN", -+ "Trsp", adr_width, adr_width, "Address", "SvcId", hfi_width, hfi_width, "HFIs"); -+ printf("%-.3s+%-.*s+%-.4s+%-.*s+%-.5s+%-.*s\n", -+ dash, nqn_width, dash, dash, adr_width, dash, dash, hfi_width, dash); -+ for (ss = nbft->subsystem_ns_list; *ss; ss++) { -+ char hfi_buf[HFIS_LEN]; -+ -+ print_hfis(*ss, hfi_buf); -+ printf("%-3d|%-*.*s|%-4.4s|%-*.*s|%-5.5s|%-*.*s\n", -+ (*ss)->index, nqn_width, nqn_width, (*ss)->subsys_nqn, -+ (*ss)->transport, adr_width, adr_width, (*ss)->traddr, -+ (*ss)->trsvcid, hfi_width, hfi_width, hfi_buf); -+ } -+} -+ -+static void normal_show_nbft(struct nbft_info *nbft, bool show_subsys, -+ bool show_hfi, bool show_discovery) -+{ -+ printf("%s:\n", nbft->filename); -+ if ((!nbft->hfi_list || !*nbft->hfi_list) && -+ (!nbft->security_list || !*nbft->security_list) && -+ (!nbft->discovery_list || !*nbft->discovery_list) && -+ (!nbft->subsystem_ns_list || !*nbft->subsystem_ns_list)) -+ printf("(empty)\n"); -+ else { -+ if (show_subsys) -+ print_nbft_subsys_info(nbft); -+ if (show_hfi) -+ print_nbft_hfi_info(nbft); -+ if (show_discovery) -+ print_nbft_discovery_info(nbft); -+ } -+} -+ -+static void normal_show_nbfts(struct list_head *nbft_list, bool show_subsys, -+ bool show_hfi, bool show_discovery) -+{ -+ bool not_first = false; -+ struct nbft_file_entry *entry; -+ -+ list_for_each(nbft_list, entry, node) { -+ if (not_first) -+ printf("\n"); -+ normal_show_nbft(entry->nbft, show_subsys, show_hfi, show_discovery); -+ not_first = true; -+ } -+} -+ -+int show_nbft(int argc, char **argv, struct command *cmd, struct plugin *plugin) -+{ -+ const char *desc = "Display contents of the ACPI NBFT files."; -+ struct list_head nbft_list; -+ char *format = "normal"; -+ char *nbft_path = NBFT_SYSFS_PATH; -+ enum nvme_print_flags flags = -1; -+ int ret; -+ bool show_subsys = false, show_hfi = false, show_discovery = false; -+ -+ OPT_ARGS(opts) = { -+ OPT_FMT("output-format", 'o', &format, "Output format: normal|json"), -+ OPT_FLAG("subsystem", 's', &show_subsys, "show NBFT subsystems"), -+ OPT_FLAG("hfi", 'H', &show_hfi, "show NBFT HFIs"), -+ OPT_FLAG("discovery", 'd', &show_discovery, "show NBFT discovery controllers"), -+ OPT_STRING("nbft-path", 0, "STR", &nbft_path, "user-defined path for NBFT tables"), -+ OPT_END() -+ }; -+ -+ ret = argconfig_parse(argc, argv, desc, opts); -+ if (ret) -+ return ret; -+ -+ if (!(show_subsys || show_hfi || show_discovery)) -+ show_subsys = show_hfi = show_discovery = true; -+ -+ if (!strcmp(format, "")) -+ flags = -1; -+ else if (!strcmp(format, "normal")) -+ flags = NORMAL; -+ else if (!strcmp(format, "json")) -+ flags = JSON; -+ else -+ return EINVAL; -+ -+ list_head_init(&nbft_list); -+ ret = read_nbft_files(&nbft_list, nbft_path); -+ if (!ret) { -+ if (flags == NORMAL) -+ normal_show_nbfts(&nbft_list, show_subsys, show_hfi, show_discovery); -+ else if (flags == JSON) -+ ret = json_show_nbfts(&nbft_list, show_subsys, show_hfi, show_discovery); -+ free_nbfts(&nbft_list); -+ } -+ return ret; -+} -diff --git a/plugins/nbft/nbft-plugin.h b/plugins/nbft/nbft-plugin.h -new file mode 100644 -index 00000000..018349d9 ---- /dev/null -+++ b/plugins/nbft/nbft-plugin.h -@@ -0,0 +1,18 @@ -+/* SPDX-License-Identifier: GPL-2.0-or-later */ -+#undef CMD_INC_FILE -+#define CMD_INC_FILE plugins/nbft/nbft-plugin -+ -+#if !defined(NBFT) || defined(CMD_HEADER_MULTI_READ) -+#define NBFT -+ -+#include "cmd.h" -+ -+PLUGIN(NAME("nbft", "ACPI NBFT table extensions", NVME_VERSION), -+ COMMAND_LIST( -+ ENTRY("show", "Show contents of ACPI NBFT tables", show_nbft) -+ ) -+); -+ -+#endif -+ -+#include "define_cmd.h" --- -2.39.2 - diff --git a/nvme-cli.spec b/nvme-cli.spec index 06bb083..00a530b 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -2,18 +2,14 @@ %{!?version_no_tilde: %define version_no_tilde %{shrink:%(echo '%{version}' | tr '~' '-')}} Name: nvme-cli -Version: 2.4 -Release: 2%{?dist} +Version: 2.5 +Release: 1%{?dist} Summary: NVMe management command line interface License: GPLv2 URL: https://github.com/linux-nvme/nvme-cli Source0: %{url}/archive/v%{version_no_tilde}/%{name}-%{version_no_tilde}.tar.gz -Patch100: nvme-cli-2.5-nbft-make-lookup_ctrl-function-public.patch -Patch101: nvme-cli-2.5-nbft.patch -Patch102: nvme-cli-2.5-nbft_plugin.patch - BuildRequires: meson >= 0.50.0 BuildRequires: gcc gcc-c++ BuildRequires: systemd-devel @@ -21,7 +17,7 @@ BuildRequires: systemd-rpm-macros BuildRequires: zlib-devel BuildRequires: openssl-devel -BuildRequires: libnvme-devel >= 1.4-2 +BuildRequires: libnvme-devel >= 1.5 BuildRequires: json-c-devel >= 0.13 %if (0%{?rhel} == 0) @@ -44,7 +40,7 @@ nvme-cli provides NVM-Express user space tooling for Linux. %build -%meson -Dudevrulesdir=%{_udevrulesdir} -Dsystemddir=%{_unitdir} -Ddocs=all -Ddocs-build=true -Dhtmldir=%{_pkgdocdir} +%meson -Dudevrulesdir=%{_udevrulesdir} -Dsystemddir=%{_unitdir} -Dpdc-enabled=true -Ddocs=all -Ddocs-build=true -Dhtmldir=%{_pkgdocdir} %meson_build @@ -87,6 +83,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Tue Jul 04 2023 Tomas Bzatek - 2.5-1 +- Update to 2.5 + * Thu Apr 20 2023 Tomas Bzatek - 2.4-2 - Backport the NBFT support from git master diff --git a/sources b/sources index edbc0db..f820245 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (nvme-cli-2.4.tar.gz) = 155667a0b91e15267e3f991a30cf1d4ae26cb4c53b20c002e3d3341496dd463397e1afbfefcd7a8df88370d28417940ce44a060bda87c04482bbe3be4e901b73 +SHA512 (nvme-cli-2.5.tar.gz) = 50c557e86e95b27a0ad57779c33bbb847e12dd45c30e792f5ce1d52dedd4bc704ac25fa0af2fdebd281c9dfe0059f7ed7c1620fccfde9323f6f9a97afdf8c3cb From f698c8b972212757ca4381b3647358bc1c048bca Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 20 Jul 2023 17:02:07 +0000 Subject: [PATCH 06/33] Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- nvme-cli.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nvme-cli.spec b/nvme-cli.spec index 00a530b..ee910bc 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -3,7 +3,7 @@ Name: nvme-cli Version: 2.5 -Release: 1%{?dist} +Release: 2%{?dist} Summary: NVMe management command line interface License: GPLv2 @@ -83,6 +83,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Thu Jul 20 2023 Fedora Release Engineering - 2.5-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + * Tue Jul 04 2023 Tomas Bzatek - 2.5-1 - Update to 2.5 From cab2a0bb500c09e6b02b406d4f735b9d865664bc Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Tue, 1 Aug 2023 23:59:03 -0400 Subject: [PATCH 07/33] Drop linter and formatter dependencies This is to conform to Python packaging guidelines, not to mention that the tests are not even run during the build. Additionally, autopep8 is not yet compatible with Python 3.12, thereby blocking this from building. https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters --- nvme-cli.spec | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nvme-cli.spec b/nvme-cli.spec index ee910bc..8f80740 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -22,10 +22,11 @@ BuildRequires: json-c-devel >= 0.13 %if (0%{?rhel} == 0) BuildRequires: python3-nose2 -BuildRequires: python3-mypy -BuildRequires: python3-flake8 -BuildRequires: python3-autopep8 -BuildRequires: python3-isort +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters +#BuildRequires: python3-mypy +#BuildRequires: python3-flake8 +#BuildRequires: python3-autopep8 +#BuildRequires: python3-isort %endif BuildRequires: asciidoc BuildRequires: xmlto From 9814f5822c50b1de675ba865339f7e851ddbc041 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Mon, 14 Aug 2023 17:47:53 +0200 Subject: [PATCH 08/33] * Mon Aug 14 2023 Tomas Bzatek - 2.5-3 - Backport 'fabrics: Use corresponding hostid when hostnqn is generated' --- ...ing_hostid_when_hostnqn_is_generated.patch | 103 ++++++++++++++++++ nvme-cli.spec | 15 +-- 2 files changed, 109 insertions(+), 9 deletions(-) create mode 100644 nvme-cli-2.6-fabrics-Use_corresponding_hostid_when_hostnqn_is_generated.patch diff --git a/nvme-cli-2.6-fabrics-Use_corresponding_hostid_when_hostnqn_is_generated.patch b/nvme-cli-2.6-fabrics-Use_corresponding_hostid_when_hostnqn_is_generated.patch new file mode 100644 index 0000000..f9fc2fe --- /dev/null +++ b/nvme-cli-2.6-fabrics-Use_corresponding_hostid_when_hostnqn_is_generated.patch @@ -0,0 +1,103 @@ +From 7d1c18f581e489e0cedfd9991bc97a2f8239cf82 Mon Sep 17 00:00:00 2001 +From: Shin'ichiro Kawasaki +Date: Thu, 3 Aug 2023 20:21:39 +0900 +Subject: [PATCH] fabrics: Use corresponding hostid when hostnqn is generated + +After the kernel commit ae8bd606e09b ("nvme-fabrics: prevent overriding +of existing host"), kernel ensures hostid and hostnqn maintain 1:1 +mapping and "non 1:1 mapping will be rejected". This makes 'nvme +discover' and 'nvme connect' commands fail when they generate hostnqn, +since it does not use corresponding hostid. + +To avoid the failures, prepare and use corresponding hostid to the +generated hostnqn, taking the hostid from the hostnqn string. Also add +checks for prepared hostnqn and hostid. If the hostid taken from the +generated hostnqn is different from the hostid from file, print a +warning message. Also, if the prepared hostnqn are inconsistent with the +prepared hostid, print a warning. + +Link: https://lore.kernel.org/linux-nvme/l7vk7fnzltpmvkwujsbf2btrzip6wh7ug62iwa3totqcda25l6@siqx7tj6lt3l/ +Signed-off-by: Shin'ichiro Kawasaki +Signed-off-by: Daniel Wagner +--- + fabrics.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 45 insertions(+), 2 deletions(-) + +diff --git a/fabrics.c b/fabrics.c +index 14a91cc6b..40aef6932 100644 +--- a/fabrics.c ++++ b/fabrics.c +@@ -689,6 +689,43 @@ static int nvme_read_volatile_config(nvme_root_t r) + return ret; + } + ++char *nvmf_hostid_from_hostnqn(const char *hostnqn) ++{ ++ const char *uuid; ++ ++ if (!hostnqn) ++ return NULL; ++ ++ uuid = strstr(hostnqn, "uuid:"); ++ if (!uuid) ++ return NULL; ++ ++ return strdup(uuid + strlen("uuid:")); ++} ++ ++void nvmf_check_hostid_and_hostnqn(const char *hostid, const char *hostnqn) ++{ ++ char *hostid_from_file, *hostid_from_hostnqn; ++ ++ if (!hostid) ++ return; ++ ++ hostid_from_file = nvmf_hostid_from_file(); ++ if (hostid_from_file && strcmp(hostid_from_file, hostid)) { ++ fprintf(stderr, "warning: use generated hostid instead of hostid file\n"); ++ free(hostid_from_file); ++ } ++ ++ if (!hostnqn) ++ return; ++ ++ hostid_from_hostnqn = nvmf_hostid_from_hostnqn(hostnqn); ++ if (hostid_from_hostnqn && strcmp(hostid_from_hostnqn, hostid)) { ++ fprintf(stderr, "warning: use hostid which does not match uuid in hostnqn\n"); ++ free(hostid_from_hostnqn); ++ } ++} ++ + int nvmf_discover(const char *desc, int argc, char **argv, bool connect) + { + char *subsysnqn = NVME_DISC_SUBSYS_NAME; +@@ -765,10 +802,13 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) + hostid_arg = hostid; + if (!hostnqn) + hostnqn = hnqn = nvmf_hostnqn_from_file(); +- if (!hostnqn) ++ if (!hostnqn) { + hostnqn = hnqn = nvmf_hostnqn_generate(); ++ hostid = hid = nvmf_hostid_from_hostnqn(hostnqn); ++ } + if (!hostid) + hostid = hid = nvmf_hostid_from_file(); ++ nvmf_check_hostid_and_hostnqn(hostid, hostnqn); + h = nvme_lookup_host(r, hostnqn, hostid); + if (!h) { + ret = ENOMEM; +@@ -978,10 +1018,13 @@ int nvmf_connect(const char *desc, int argc, char **argv) + + if (!hostnqn) + hostnqn = hnqn = nvmf_hostnqn_from_file(); +- if (!hostnqn) ++ if (!hostnqn) { + hostnqn = hnqn = nvmf_hostnqn_generate(); ++ hostid = hid = nvmf_hostid_from_hostnqn(hostnqn); ++ } + if (!hostid) + hostid = hid = nvmf_hostid_from_file(); ++ nvmf_check_hostid_and_hostnqn(hostid, hostnqn); + h = nvme_lookup_host(r, hostnqn, hostid); + if (!h) { + errno = ENOMEM; diff --git a/nvme-cli.spec b/nvme-cli.spec index 8f80740..e5145ac 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -3,7 +3,7 @@ Name: nvme-cli Version: 2.5 -Release: 2%{?dist} +Release: 3%{?dist} Summary: NVMe management command line interface License: GPLv2 @@ -20,19 +20,13 @@ BuildRequires: openssl-devel BuildRequires: libnvme-devel >= 1.5 BuildRequires: json-c-devel >= 0.13 -%if (0%{?rhel} == 0) -BuildRequires: python3-nose2 -# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters -#BuildRequires: python3-mypy -#BuildRequires: python3-flake8 -#BuildRequires: python3-autopep8 -#BuildRequires: python3-isort -%endif BuildRequires: asciidoc BuildRequires: xmlto Requires: util-linux +Patch0: nvme-cli-2.6-fabrics-Use_corresponding_hostid_when_hostnqn_is_generated.patch + %description nvme-cli provides NVM-Express user space tooling for Linux. @@ -84,6 +78,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Mon Aug 14 2023 Tomas Bzatek - 2.5-3 +- Backport 'fabrics: Use corresponding hostid when hostnqn is generated' + * Thu Jul 20 2023 Fedora Release Engineering - 2.5-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild From 75620ef422c534b51d3542e81a07e9e0d12ffe33 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Thu, 17 Aug 2023 17:31:51 +0200 Subject: [PATCH 09/33] * Thu Aug 17 2023 Tomas Bzatek - 2.5-4 - Mark /etc/nvme/discovery.conf as (noreplace) --- nvme-cli.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nvme-cli.spec b/nvme-cli.spec index e5145ac..0a029d2 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -3,7 +3,7 @@ Name: nvme-cli Version: 2.5 -Release: 3%{?dist} +Release: 4%{?dist} Summary: NVMe management command line interface License: GPLv2 @@ -66,7 +66,7 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %{_datadir}/bash-completion/completions/nvme %{_datadir}/zsh/site-functions/_nvme %dir %{_sysconfdir}/nvme -%{_sysconfdir}/nvme/discovery.conf +%config(noreplace) %{_sysconfdir}/nvme/discovery.conf %{_unitdir}/nvmefc-boot-connections.service %{_unitdir}/nvmf-autoconnect.service %{_unitdir}/nvmf-connect.target @@ -78,6 +78,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Thu Aug 17 2023 Tomas Bzatek - 2.5-4 +- Mark /etc/nvme/discovery.conf as (noreplace) + * Mon Aug 14 2023 Tomas Bzatek - 2.5-3 - Backport 'fabrics: Use corresponding hostid when hostnqn is generated' From 1f94235a8ff2acd2a8a80376fdafd0d66e17404e Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Fri, 29 Sep 2023 15:49:48 +0200 Subject: [PATCH 10/33] * Fri Sep 29 2023 Tomas Bzatek - 2.6-1 - Update to 2.6 --- .gitignore | 1 + ...ing_hostid_when_hostnqn_is_generated.patch | 103 ------------------ nvme-cli.spec | 13 ++- sources | 2 +- 4 files changed, 9 insertions(+), 110 deletions(-) delete mode 100644 nvme-cli-2.6-fabrics-Use_corresponding_hostid_when_hostnqn_is_generated.patch diff --git a/.gitignore b/.gitignore index 3555f05..c0a99be 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ /nvme-cli-2.3.tar.gz /nvme-cli-2.4.tar.gz /nvme-cli-2.5.tar.gz +/nvme-cli-2.6.tar.gz diff --git a/nvme-cli-2.6-fabrics-Use_corresponding_hostid_when_hostnqn_is_generated.patch b/nvme-cli-2.6-fabrics-Use_corresponding_hostid_when_hostnqn_is_generated.patch deleted file mode 100644 index f9fc2fe..0000000 --- a/nvme-cli-2.6-fabrics-Use_corresponding_hostid_when_hostnqn_is_generated.patch +++ /dev/null @@ -1,103 +0,0 @@ -From 7d1c18f581e489e0cedfd9991bc97a2f8239cf82 Mon Sep 17 00:00:00 2001 -From: Shin'ichiro Kawasaki -Date: Thu, 3 Aug 2023 20:21:39 +0900 -Subject: [PATCH] fabrics: Use corresponding hostid when hostnqn is generated - -After the kernel commit ae8bd606e09b ("nvme-fabrics: prevent overriding -of existing host"), kernel ensures hostid and hostnqn maintain 1:1 -mapping and "non 1:1 mapping will be rejected". This makes 'nvme -discover' and 'nvme connect' commands fail when they generate hostnqn, -since it does not use corresponding hostid. - -To avoid the failures, prepare and use corresponding hostid to the -generated hostnqn, taking the hostid from the hostnqn string. Also add -checks for prepared hostnqn and hostid. If the hostid taken from the -generated hostnqn is different from the hostid from file, print a -warning message. Also, if the prepared hostnqn are inconsistent with the -prepared hostid, print a warning. - -Link: https://lore.kernel.org/linux-nvme/l7vk7fnzltpmvkwujsbf2btrzip6wh7ug62iwa3totqcda25l6@siqx7tj6lt3l/ -Signed-off-by: Shin'ichiro Kawasaki -Signed-off-by: Daniel Wagner ---- - fabrics.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-- - 1 file changed, 45 insertions(+), 2 deletions(-) - -diff --git a/fabrics.c b/fabrics.c -index 14a91cc6b..40aef6932 100644 ---- a/fabrics.c -+++ b/fabrics.c -@@ -689,6 +689,43 @@ static int nvme_read_volatile_config(nvme_root_t r) - return ret; - } - -+char *nvmf_hostid_from_hostnqn(const char *hostnqn) -+{ -+ const char *uuid; -+ -+ if (!hostnqn) -+ return NULL; -+ -+ uuid = strstr(hostnqn, "uuid:"); -+ if (!uuid) -+ return NULL; -+ -+ return strdup(uuid + strlen("uuid:")); -+} -+ -+void nvmf_check_hostid_and_hostnqn(const char *hostid, const char *hostnqn) -+{ -+ char *hostid_from_file, *hostid_from_hostnqn; -+ -+ if (!hostid) -+ return; -+ -+ hostid_from_file = nvmf_hostid_from_file(); -+ if (hostid_from_file && strcmp(hostid_from_file, hostid)) { -+ fprintf(stderr, "warning: use generated hostid instead of hostid file\n"); -+ free(hostid_from_file); -+ } -+ -+ if (!hostnqn) -+ return; -+ -+ hostid_from_hostnqn = nvmf_hostid_from_hostnqn(hostnqn); -+ if (hostid_from_hostnqn && strcmp(hostid_from_hostnqn, hostid)) { -+ fprintf(stderr, "warning: use hostid which does not match uuid in hostnqn\n"); -+ free(hostid_from_hostnqn); -+ } -+} -+ - int nvmf_discover(const char *desc, int argc, char **argv, bool connect) - { - char *subsysnqn = NVME_DISC_SUBSYS_NAME; -@@ -765,10 +802,13 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) - hostid_arg = hostid; - if (!hostnqn) - hostnqn = hnqn = nvmf_hostnqn_from_file(); -- if (!hostnqn) -+ if (!hostnqn) { - hostnqn = hnqn = nvmf_hostnqn_generate(); -+ hostid = hid = nvmf_hostid_from_hostnqn(hostnqn); -+ } - if (!hostid) - hostid = hid = nvmf_hostid_from_file(); -+ nvmf_check_hostid_and_hostnqn(hostid, hostnqn); - h = nvme_lookup_host(r, hostnqn, hostid); - if (!h) { - ret = ENOMEM; -@@ -978,10 +1018,13 @@ int nvmf_connect(const char *desc, int argc, char **argv) - - if (!hostnqn) - hostnqn = hnqn = nvmf_hostnqn_from_file(); -- if (!hostnqn) -+ if (!hostnqn) { - hostnqn = hnqn = nvmf_hostnqn_generate(); -+ hostid = hid = nvmf_hostid_from_hostnqn(hostnqn); -+ } - if (!hostid) - hostid = hid = nvmf_hostid_from_file(); -+ nvmf_check_hostid_and_hostnqn(hostid, hostnqn); - h = nvme_lookup_host(r, hostnqn, hostid); - if (!h) { - errno = ENOMEM; diff --git a/nvme-cli.spec b/nvme-cli.spec index 0a029d2..d94873e 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -2,11 +2,11 @@ %{!?version_no_tilde: %define version_no_tilde %{shrink:%(echo '%{version}' | tr '~' '-')}} Name: nvme-cli -Version: 2.5 -Release: 4%{?dist} +Version: 2.6 +Release: 1%{?dist} Summary: NVMe management command line interface -License: GPLv2 +License: GPL-2.0-only URL: https://github.com/linux-nvme/nvme-cli Source0: %{url}/archive/v%{version_no_tilde}/%{name}-%{version_no_tilde}.tar.gz @@ -17,7 +17,7 @@ BuildRequires: systemd-rpm-macros BuildRequires: zlib-devel BuildRequires: openssl-devel -BuildRequires: libnvme-devel >= 1.5 +BuildRequires: libnvme-devel >= 1.6 BuildRequires: json-c-devel >= 0.13 BuildRequires: asciidoc @@ -25,8 +25,6 @@ BuildRequires: xmlto Requires: util-linux -Patch0: nvme-cli-2.6-fabrics-Use_corresponding_hostid_when_hostnqn_is_generated.patch - %description nvme-cli provides NVM-Express user space tooling for Linux. @@ -78,6 +76,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Fri Sep 29 2023 Tomas Bzatek - 2.6-1 +- Update to 2.6 + * Thu Aug 17 2023 Tomas Bzatek - 2.5-4 - Mark /etc/nvme/discovery.conf as (noreplace) diff --git a/sources b/sources index f820245..844ac50 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (nvme-cli-2.5.tar.gz) = 50c557e86e95b27a0ad57779c33bbb847e12dd45c30e792f5ce1d52dedd4bc704ac25fa0af2fdebd281c9dfe0059f7ed7c1620fccfde9323f6f9a97afdf8c3cb +SHA512 (nvme-cli-2.6.tar.gz) = da4daef2d7c554455e0c195c03f92188e0e946409a3bd8a5b421d9a106746e82fb1309901d2893639b1a3447bda094c80a9f49f59bf43cf2b00402f82beea3fc From 5bdc888a260550de4ecf8e6476524f8e5e8fd6a1 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Fri, 6 Oct 2023 14:57:47 +0200 Subject: [PATCH 11/33] * Fri Oct 06 2023 Tomas Bzatek - 2.4-3 - Backport 'fabrics: Use corresponding hostid when hostnqn is generated' --- ...ing_hostid_when_hostnqn_is_generated.patch | 103 ++++++++++++++++++ nvme-cli.spec | 14 +-- 2 files changed, 109 insertions(+), 8 deletions(-) create mode 100644 nvme-cli-2.6-fabrics-Use_corresponding_hostid_when_hostnqn_is_generated.patch diff --git a/nvme-cli-2.6-fabrics-Use_corresponding_hostid_when_hostnqn_is_generated.patch b/nvme-cli-2.6-fabrics-Use_corresponding_hostid_when_hostnqn_is_generated.patch new file mode 100644 index 0000000..f9fc2fe --- /dev/null +++ b/nvme-cli-2.6-fabrics-Use_corresponding_hostid_when_hostnqn_is_generated.patch @@ -0,0 +1,103 @@ +From 7d1c18f581e489e0cedfd9991bc97a2f8239cf82 Mon Sep 17 00:00:00 2001 +From: Shin'ichiro Kawasaki +Date: Thu, 3 Aug 2023 20:21:39 +0900 +Subject: [PATCH] fabrics: Use corresponding hostid when hostnqn is generated + +After the kernel commit ae8bd606e09b ("nvme-fabrics: prevent overriding +of existing host"), kernel ensures hostid and hostnqn maintain 1:1 +mapping and "non 1:1 mapping will be rejected". This makes 'nvme +discover' and 'nvme connect' commands fail when they generate hostnqn, +since it does not use corresponding hostid. + +To avoid the failures, prepare and use corresponding hostid to the +generated hostnqn, taking the hostid from the hostnqn string. Also add +checks for prepared hostnqn and hostid. If the hostid taken from the +generated hostnqn is different from the hostid from file, print a +warning message. Also, if the prepared hostnqn are inconsistent with the +prepared hostid, print a warning. + +Link: https://lore.kernel.org/linux-nvme/l7vk7fnzltpmvkwujsbf2btrzip6wh7ug62iwa3totqcda25l6@siqx7tj6lt3l/ +Signed-off-by: Shin'ichiro Kawasaki +Signed-off-by: Daniel Wagner +--- + fabrics.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 45 insertions(+), 2 deletions(-) + +diff --git a/fabrics.c b/fabrics.c +index 14a91cc6b..40aef6932 100644 +--- a/fabrics.c ++++ b/fabrics.c +@@ -689,6 +689,43 @@ static int nvme_read_volatile_config(nvme_root_t r) + return ret; + } + ++char *nvmf_hostid_from_hostnqn(const char *hostnqn) ++{ ++ const char *uuid; ++ ++ if (!hostnqn) ++ return NULL; ++ ++ uuid = strstr(hostnqn, "uuid:"); ++ if (!uuid) ++ return NULL; ++ ++ return strdup(uuid + strlen("uuid:")); ++} ++ ++void nvmf_check_hostid_and_hostnqn(const char *hostid, const char *hostnqn) ++{ ++ char *hostid_from_file, *hostid_from_hostnqn; ++ ++ if (!hostid) ++ return; ++ ++ hostid_from_file = nvmf_hostid_from_file(); ++ if (hostid_from_file && strcmp(hostid_from_file, hostid)) { ++ fprintf(stderr, "warning: use generated hostid instead of hostid file\n"); ++ free(hostid_from_file); ++ } ++ ++ if (!hostnqn) ++ return; ++ ++ hostid_from_hostnqn = nvmf_hostid_from_hostnqn(hostnqn); ++ if (hostid_from_hostnqn && strcmp(hostid_from_hostnqn, hostid)) { ++ fprintf(stderr, "warning: use hostid which does not match uuid in hostnqn\n"); ++ free(hostid_from_hostnqn); ++ } ++} ++ + int nvmf_discover(const char *desc, int argc, char **argv, bool connect) + { + char *subsysnqn = NVME_DISC_SUBSYS_NAME; +@@ -765,10 +802,13 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) + hostid_arg = hostid; + if (!hostnqn) + hostnqn = hnqn = nvmf_hostnqn_from_file(); +- if (!hostnqn) ++ if (!hostnqn) { + hostnqn = hnqn = nvmf_hostnqn_generate(); ++ hostid = hid = nvmf_hostid_from_hostnqn(hostnqn); ++ } + if (!hostid) + hostid = hid = nvmf_hostid_from_file(); ++ nvmf_check_hostid_and_hostnqn(hostid, hostnqn); + h = nvme_lookup_host(r, hostnqn, hostid); + if (!h) { + ret = ENOMEM; +@@ -978,10 +1018,13 @@ int nvmf_connect(const char *desc, int argc, char **argv) + + if (!hostnqn) + hostnqn = hnqn = nvmf_hostnqn_from_file(); +- if (!hostnqn) ++ if (!hostnqn) { + hostnqn = hnqn = nvmf_hostnqn_generate(); ++ hostid = hid = nvmf_hostid_from_hostnqn(hostnqn); ++ } + if (!hostid) + hostid = hid = nvmf_hostid_from_file(); ++ nvmf_check_hostid_and_hostnqn(hostid, hostnqn); + h = nvme_lookup_host(r, hostnqn, hostid); + if (!h) { + errno = ENOMEM; diff --git a/nvme-cli.spec b/nvme-cli.spec index 06bb083..2535a24 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -3,7 +3,7 @@ Name: nvme-cli Version: 2.4 -Release: 2%{?dist} +Release: 3%{?dist} Summary: NVMe management command line interface License: GPLv2 @@ -24,18 +24,13 @@ BuildRequires: openssl-devel BuildRequires: libnvme-devel >= 1.4-2 BuildRequires: json-c-devel >= 0.13 -%if (0%{?rhel} == 0) -BuildRequires: python3-nose2 -BuildRequires: python3-mypy -BuildRequires: python3-flake8 -BuildRequires: python3-autopep8 -BuildRequires: python3-isort -%endif BuildRequires: asciidoc BuildRequires: xmlto Requires: util-linux +Patch0: nvme-cli-2.6-fabrics-Use_corresponding_hostid_when_hostnqn_is_generated.patch + %description nvme-cli provides NVM-Express user space tooling for Linux. @@ -87,6 +82,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Fri Oct 06 2023 Tomas Bzatek - 2.4-3 +- Backport 'fabrics: Use corresponding hostid when hostnqn is generated' + * Thu Apr 20 2023 Tomas Bzatek - 2.4-2 - Backport the NBFT support from git master From 896366b17e4af9f831d578e6342e6faf7998c956 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Thu, 28 Dec 2023 17:55:23 +0100 Subject: [PATCH 12/33] * Thu Dec 28 2023 Tomas Bzatek - 2.7.1-1 - Update to 2.7.1 --- .gitignore | 1 + nvme-cli.spec | 11 ++++++++--- sources | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c0a99be..8fdd0f5 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,4 @@ /nvme-cli-2.4.tar.gz /nvme-cli-2.5.tar.gz /nvme-cli-2.6.tar.gz +/nvme-cli-2.7.1.tar.gz diff --git a/nvme-cli.spec b/nvme-cli.spec index d94873e..1a064d5 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -2,7 +2,7 @@ %{!?version_no_tilde: %define version_no_tilde %{shrink:%(echo '%{version}' | tr '~' '-')}} Name: nvme-cli -Version: 2.6 +Version: 2.7.1 Release: 1%{?dist} Summary: NVMe management command line interface @@ -17,7 +17,7 @@ BuildRequires: systemd-rpm-macros BuildRequires: zlib-devel BuildRequires: openssl-devel -BuildRequires: libnvme-devel >= 1.6 +BuildRequires: libnvme-devel >= 1.7 BuildRequires: json-c-devel >= 0.13 BuildRequires: asciidoc @@ -69,13 +69,18 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %{_unitdir}/nvmf-autoconnect.service %{_unitdir}/nvmf-connect.target %{_unitdir}/nvmf-connect@.service +%{_unitdir}/nvmf-connect-nbft.service +%{_udevrulesdir}/65-persistent-net-nbft.rules %{_udevrulesdir}/70-nvmf-autoconnect.rules -%{_udevrulesdir}/71-nvmf-iopolicy-netapp.rules +%{_udevrulesdir}/71-nvmf-netapp.rules # Do not install the dracut rule yet. See rhbz 1742764 # /usr/lib/dracut/dracut.conf.d/70-nvmf-autoconnect.conf %changelog +* Thu Dec 28 2023 Tomas Bzatek - 2.7.1-1 +- Update to 2.7.1 + * Fri Sep 29 2023 Tomas Bzatek - 2.6-1 - Update to 2.6 diff --git a/sources b/sources index 844ac50..a7c2d60 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (nvme-cli-2.6.tar.gz) = da4daef2d7c554455e0c195c03f92188e0e946409a3bd8a5b421d9a106746e82fb1309901d2893639b1a3447bda094c80a9f49f59bf43cf2b00402f82beea3fc +SHA512 (nvme-cli-2.7.1.tar.gz) = 6a9f3574dfd4375e6f7a76ed95f698efb26da5b72a490579caeba9d46c4811ae31650844e0a0e1047dc627158d5ffbdc020112a5059d3195e7eadff902b70b19 From 3e759bfe3cb8ca5503e64b8ab83c54473663961e Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sun, 21 Jan 2024 10:03:06 +0000 Subject: [PATCH 13/33] Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild --- nvme-cli.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nvme-cli.spec b/nvme-cli.spec index 1a064d5..1042817 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -3,7 +3,7 @@ Name: nvme-cli Version: 2.7.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: NVMe management command line interface License: GPL-2.0-only @@ -78,6 +78,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Sun Jan 21 2024 Fedora Release Engineering - 2.7.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + * Thu Dec 28 2023 Tomas Bzatek - 2.7.1-1 - Update to 2.7.1 From 2b8ee26cf3fce61a654aab2de8ee216553558f21 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 25 Jan 2024 09:33:49 +0000 Subject: [PATCH 14/33] Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild --- nvme-cli.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nvme-cli.spec b/nvme-cli.spec index 1042817..d5aadb6 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -3,7 +3,7 @@ Name: nvme-cli Version: 2.7.1 -Release: 2%{?dist} +Release: 3%{?dist} Summary: NVMe management command line interface License: GPL-2.0-only @@ -78,6 +78,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Thu Jan 25 2024 Fedora Release Engineering - 2.7.1-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + * Sun Jan 21 2024 Fedora Release Engineering - 2.7.1-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild From 7c6488aa09cbbd8592cda47ca55645e01fe02df8 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Fri, 9 Feb 2024 14:47:14 +0100 Subject: [PATCH 15/33] * Fri Feb 09 2024 Tomas Bzatek - 2.7.1-4 - Lower the verbosity of TP4126 hostnqn-hostid consistency checks --- ...-2.8.0-TP4126-lower_hostnqn_warnings.patch | 68 +++++++++++++++++++ nvme-cli.spec | 8 ++- 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 nvme-cli-2.8.0-TP4126-lower_hostnqn_warnings.patch diff --git a/nvme-cli-2.8.0-TP4126-lower_hostnqn_warnings.patch b/nvme-cli-2.8.0-TP4126-lower_hostnqn_warnings.patch new file mode 100644 index 0000000..b1c0306 --- /dev/null +++ b/nvme-cli-2.8.0-TP4126-lower_hostnqn_warnings.patch @@ -0,0 +1,68 @@ +From 252929069d6c9042e9c95f41788006cb3eb2f452 Mon Sep 17 00:00:00 2001 +From: Martin George +Date: Tue, 19 Dec 2023 21:59:07 +0530 +Subject: [PATCH] fabrics: move hostid/hostnqn warnings to verbose level + +Currently nvme connect prints an annoying "use hostid which +does not match uuid in hostnqn" warning even for normal +scenarios when both the hostid and hostnqn files are present. +So move these warnings to verbose level instead. + +Signed-off-by: Martin George +--- + fabrics.c | 14 +++++++++----- + 1 file changed, 9 insertions(+), 5 deletions(-) + +diff --git a/fabrics.c b/fabrics.c +index 2a0ad7089..dcae9aead 100644 +--- a/fabrics.c ++++ b/fabrics.c +@@ -632,7 +632,7 @@ char *nvmf_hostid_from_hostnqn(const char *hostnqn) + return strdup(uuid + strlen("uuid:")); + } + +-void nvmf_check_hostid_and_hostnqn(const char *hostid, const char *hostnqn) ++void nvmf_check_hostid_and_hostnqn(const char *hostid, const char *hostnqn, unsigned int verbose) + { + char *hostid_from_file, *hostid_from_hostnqn; + +@@ -641,7 +641,9 @@ void nvmf_check_hostid_and_hostnqn(const char *hostid, const char *hostnqn) + + hostid_from_file = nvmf_hostid_from_file(); + if (hostid_from_file && strcmp(hostid_from_file, hostid)) { +- fprintf(stderr, "warning: use generated hostid instead of hostid file\n"); ++ if (verbose) ++ fprintf(stderr, ++ "warning: use generated hostid instead of hostid file\n"); + free(hostid_from_file); + } + +@@ -650,7 +652,9 @@ void nvmf_check_hostid_and_hostnqn(const char *hostid, const char *hostnqn) + + hostid_from_hostnqn = nvmf_hostid_from_hostnqn(hostnqn); + if (hostid_from_hostnqn && strcmp(hostid_from_hostnqn, hostid)) { +- fprintf(stderr, "warning: use hostid which does not match uuid in hostnqn\n"); ++ if (verbose) ++ fprintf(stderr, ++ "warning: use hostid which does not match uuid in hostnqn\n"); + free(hostid_from_hostnqn); + } + } +@@ -741,7 +745,7 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) + hostid = hid = nvmf_hostid_from_file(); + if (!hostid && hostnqn) + hostid = hid = nvmf_hostid_from_hostnqn(hostnqn); +- nvmf_check_hostid_and_hostnqn(hostid, hostnqn); ++ nvmf_check_hostid_and_hostnqn(hostid, hostnqn, verbose); + h = nvme_lookup_host(r, hostnqn, hostid); + if (!h) { + ret = ENOMEM; +@@ -964,7 +968,7 @@ int nvmf_connect(const char *desc, int argc, char **argv) + hostid = hid = nvmf_hostid_from_file(); + if (!hostid && hostnqn) + hostid = hid = nvmf_hostid_from_hostnqn(hostnqn); +- nvmf_check_hostid_and_hostnqn(hostid, hostnqn); ++ nvmf_check_hostid_and_hostnqn(hostid, hostnqn, verbose); + h = nvme_lookup_host(r, hostnqn, hostid); + if (!h) { + errno = ENOMEM; diff --git a/nvme-cli.spec b/nvme-cli.spec index d5aadb6..02510e1 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -3,13 +3,16 @@ Name: nvme-cli Version: 2.7.1 -Release: 3%{?dist} +Release: 4%{?dist} Summary: NVMe management command line interface License: GPL-2.0-only URL: https://github.com/linux-nvme/nvme-cli Source0: %{url}/archive/v%{version_no_tilde}/%{name}-%{version_no_tilde}.tar.gz +# https://github.com/linux-nvme/nvme-cli/pull/2165 +Patch0: nvme-cli-2.8.0-TP4126-lower_hostnqn_warnings.patch + BuildRequires: meson >= 0.50.0 BuildRequires: gcc gcc-c++ BuildRequires: systemd-devel @@ -78,6 +81,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Fri Feb 09 2024 Tomas Bzatek - 2.7.1-4 +- Lower the verbosity of TP4126 hostnqn-hostid consistency checks + * Thu Jan 25 2024 Fedora Release Engineering - 2.7.1-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild From 8db1f0f09ea1e0630c7699d15f1a09adca35fc9b Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Wed, 14 Feb 2024 14:33:22 +0100 Subject: [PATCH 16/33] * Wed Feb 14 2024 Tomas Bzatek - 2.8-1 - Update to 2.8 --- .gitignore | 1 + ...-2.8.0-TP4126-lower_hostnqn_warnings.patch | 68 ------------------- nvme-cli.spec | 15 ++-- sources | 2 +- 4 files changed, 11 insertions(+), 75 deletions(-) delete mode 100644 nvme-cli-2.8.0-TP4126-lower_hostnqn_warnings.patch diff --git a/.gitignore b/.gitignore index 8fdd0f5..84ef6fb 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ /nvme-cli-2.5.tar.gz /nvme-cli-2.6.tar.gz /nvme-cli-2.7.1.tar.gz +/nvme-cli-2.8.tar.gz diff --git a/nvme-cli-2.8.0-TP4126-lower_hostnqn_warnings.patch b/nvme-cli-2.8.0-TP4126-lower_hostnqn_warnings.patch deleted file mode 100644 index b1c0306..0000000 --- a/nvme-cli-2.8.0-TP4126-lower_hostnqn_warnings.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 252929069d6c9042e9c95f41788006cb3eb2f452 Mon Sep 17 00:00:00 2001 -From: Martin George -Date: Tue, 19 Dec 2023 21:59:07 +0530 -Subject: [PATCH] fabrics: move hostid/hostnqn warnings to verbose level - -Currently nvme connect prints an annoying "use hostid which -does not match uuid in hostnqn" warning even for normal -scenarios when both the hostid and hostnqn files are present. -So move these warnings to verbose level instead. - -Signed-off-by: Martin George ---- - fabrics.c | 14 +++++++++----- - 1 file changed, 9 insertions(+), 5 deletions(-) - -diff --git a/fabrics.c b/fabrics.c -index 2a0ad7089..dcae9aead 100644 ---- a/fabrics.c -+++ b/fabrics.c -@@ -632,7 +632,7 @@ char *nvmf_hostid_from_hostnqn(const char *hostnqn) - return strdup(uuid + strlen("uuid:")); - } - --void nvmf_check_hostid_and_hostnqn(const char *hostid, const char *hostnqn) -+void nvmf_check_hostid_and_hostnqn(const char *hostid, const char *hostnqn, unsigned int verbose) - { - char *hostid_from_file, *hostid_from_hostnqn; - -@@ -641,7 +641,9 @@ void nvmf_check_hostid_and_hostnqn(const char *hostid, const char *hostnqn) - - hostid_from_file = nvmf_hostid_from_file(); - if (hostid_from_file && strcmp(hostid_from_file, hostid)) { -- fprintf(stderr, "warning: use generated hostid instead of hostid file\n"); -+ if (verbose) -+ fprintf(stderr, -+ "warning: use generated hostid instead of hostid file\n"); - free(hostid_from_file); - } - -@@ -650,7 +652,9 @@ void nvmf_check_hostid_and_hostnqn(const char *hostid, const char *hostnqn) - - hostid_from_hostnqn = nvmf_hostid_from_hostnqn(hostnqn); - if (hostid_from_hostnqn && strcmp(hostid_from_hostnqn, hostid)) { -- fprintf(stderr, "warning: use hostid which does not match uuid in hostnqn\n"); -+ if (verbose) -+ fprintf(stderr, -+ "warning: use hostid which does not match uuid in hostnqn\n"); - free(hostid_from_hostnqn); - } - } -@@ -741,7 +745,7 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) - hostid = hid = nvmf_hostid_from_file(); - if (!hostid && hostnqn) - hostid = hid = nvmf_hostid_from_hostnqn(hostnqn); -- nvmf_check_hostid_and_hostnqn(hostid, hostnqn); -+ nvmf_check_hostid_and_hostnqn(hostid, hostnqn, verbose); - h = nvme_lookup_host(r, hostnqn, hostid); - if (!h) { - ret = ENOMEM; -@@ -964,7 +968,7 @@ int nvmf_connect(const char *desc, int argc, char **argv) - hostid = hid = nvmf_hostid_from_file(); - if (!hostid && hostnqn) - hostid = hid = nvmf_hostid_from_hostnqn(hostnqn); -- nvmf_check_hostid_and_hostnqn(hostid, hostnqn); -+ nvmf_check_hostid_and_hostnqn(hostid, hostnqn, verbose); - h = nvme_lookup_host(r, hostnqn, hostid); - if (!h) { - errno = ENOMEM; diff --git a/nvme-cli.spec b/nvme-cli.spec index 02510e1..2472c15 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -2,25 +2,25 @@ %{!?version_no_tilde: %define version_no_tilde %{shrink:%(echo '%{version}' | tr '~' '-')}} Name: nvme-cli -Version: 2.7.1 -Release: 4%{?dist} +Version: 2.8 +Release: 1%{?dist} Summary: NVMe management command line interface License: GPL-2.0-only URL: https://github.com/linux-nvme/nvme-cli Source0: %{url}/archive/v%{version_no_tilde}/%{name}-%{version_no_tilde}.tar.gz -# https://github.com/linux-nvme/nvme-cli/pull/2165 -Patch0: nvme-cli-2.8.0-TP4126-lower_hostnqn_warnings.patch - BuildRequires: meson >= 0.50.0 BuildRequires: gcc gcc-c++ BuildRequires: systemd-devel BuildRequires: systemd-rpm-macros BuildRequires: zlib-devel BuildRequires: openssl-devel +%if (0%{?rhel} == 0) || (0%{?rhel} > 9) +BuildRequires: kernel-headers +%endif -BuildRequires: libnvme-devel >= 1.7 +BuildRequires: libnvme-devel >= 1.8 BuildRequires: json-c-devel >= 0.13 BuildRequires: asciidoc @@ -81,6 +81,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Wed Feb 14 2024 Tomas Bzatek - 2.8-1 +- Update to 2.8 + * Fri Feb 09 2024 Tomas Bzatek - 2.7.1-4 - Lower the verbosity of TP4126 hostnqn-hostid consistency checks diff --git a/sources b/sources index a7c2d60..5f3c195 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (nvme-cli-2.7.1.tar.gz) = 6a9f3574dfd4375e6f7a76ed95f698efb26da5b72a490579caeba9d46c4811ae31650844e0a0e1047dc627158d5ffbdc020112a5059d3195e7eadff902b70b19 +SHA512 (nvme-cli-2.8.tar.gz) = 1be0bed4e1bf8a25229f301c2b00b78d2de4eaf8ff2b815fa75e44dd35ddd7787604152bdf00696130df3281206a734c5f408c3f2127440e05c2e4b1cdbb79d4 From ae14179a66514f8e45e29749567858b7b4b1ec9d Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Tue, 23 Apr 2024 15:33:41 +0200 Subject: [PATCH 17/33] * Tue Apr 23 2024 Tomas Bzatek - 2.8-2 - Harden the systemd units --- nvme-cli-2.9-systemd-hardening.patch | 110 +++++++++++++++++++++++++++ nvme-cli.spec | 8 +- 2 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 nvme-cli-2.9-systemd-hardening.patch diff --git a/nvme-cli-2.9-systemd-hardening.patch b/nvme-cli-2.9-systemd-hardening.patch new file mode 100644 index 0000000..803b407 --- /dev/null +++ b/nvme-cli-2.9-systemd-hardening.patch @@ -0,0 +1,110 @@ +From 3d08dcfc5c7ba7cc777ba8b669af78bb9130001b Mon Sep 17 00:00:00 2001 +From: Daniel Wagner +Date: Tue, 4 Apr 2023 14:06:03 +0200 +Subject: [PATCH] nvmf-connect: systemd hardening effort + +Apply the recommended hardening settings as recommended by openSUSE +and Fedor project. A few of the hardening option have to turned of +because nvme-cli needs write access to sysfs and /dev/nvme devices. + +Links: https://en.opensuse.org/openSUSE:Security_Features#Systemd_hardening_effort +Links: https://fedoraproject.org/wiki/Changes/SystemdSecurityHardening +Signed-off-by: Daniel Wagner +--- + .../systemd/nvmefc-boot-connections.service.in | 12 ++++++++++++ + nvmf-autoconnect/systemd/nvmf-autoconnect.service.in | 12 ++++++++++++ + .../systemd/nvmf-connect-nbft.service.in | 12 ++++++++++++ + nvmf-autoconnect/systemd/nvmf-connect@.service.in | 12 ++++++++++++ + 4 files changed, 48 insertions(+) + +diff --git a/nvmf-autoconnect/systemd/nvmefc-boot-connections.service.in b/nvmf-autoconnect/systemd/nvmefc-boot-connections.service.in +index 7036625c7..783feb067 100644 +--- a/nvmf-autoconnect/systemd/nvmefc-boot-connections.service.in ++++ b/nvmf-autoconnect/systemd/nvmefc-boot-connections.service.in +@@ -6,6 +6,18 @@ After=systemd-udevd.service + Before=local-fs-pre.target + + [Service] ++ProtectSystem=full ++ProtectHome=true ++ProtectHostname=true ++ProtectKernelModules=true ++ProtectKernelLogs=true ++ProtectControlGroups=true ++ProtectProc=invisible ++RestrictRealtime=true ++LockPersonality=yes ++MemoryDenyWriteExecute=yes ++RemoveIPC=yes ++RestrictAddressFamilies=none + Type=oneshot + ExecStart=/bin/sh -c "echo add > /sys/class/fc/fc_udev_device/nvme_discovery" + +diff --git a/nvmf-autoconnect/systemd/nvmf-autoconnect.service.in b/nvmf-autoconnect/systemd/nvmf-autoconnect.service.in +index 92960cde6..1ac158846 100644 +--- a/nvmf-autoconnect/systemd/nvmf-autoconnect.service.in ++++ b/nvmf-autoconnect/systemd/nvmf-autoconnect.service.in +@@ -8,6 +8,18 @@ After=network-online.target + Before=remote-fs-pre.target + + [Service] ++ProtectSystem=full ++ProtectHome=true ++ProtectHostname=true ++ProtectKernelModules=true ++ProtectKernelLogs=true ++ProtectControlGroups=true ++ProtectProc=invisible ++RestrictRealtime=true ++LockPersonality=yes ++MemoryDenyWriteExecute=yes ++RemoveIPC=yes ++RestrictAddressFamilies=AF_INET AF_INET6 + Type=oneshot + ExecStart=@SBINDIR@/nvme connect-all --context=autoconnect + +diff --git a/nvmf-autoconnect/systemd/nvmf-connect-nbft.service.in b/nvmf-autoconnect/systemd/nvmf-connect-nbft.service.in +index 820e6ced2..e3934fe70 100644 +--- a/nvmf-autoconnect/systemd/nvmf-connect-nbft.service.in ++++ b/nvmf-autoconnect/systemd/nvmf-connect-nbft.service.in +@@ -10,5 +10,17 @@ After=network-online.target + Before=remote-fs-pre.target + + [Service] ++ProtectSystem=full ++ProtectHome=true ++ProtectHostname=true ++ProtectKernelModules=true ++ProtectKernelLogs=true ++ProtectControlGroups=true ++ProtectProc=invisible ++RestrictRealtime=true ++LockPersonality=yes ++MemoryDenyWriteExecute=yes ++RemoveIPC=yes ++RestrictAddressFamilies=AF_INET AF_INET6 + Type=oneshot + ExecStart=@SBINDIR@/nvme connect-all --nbft +diff --git a/nvmf-autoconnect/systemd/nvmf-connect@.service.in b/nvmf-autoconnect/systemd/nvmf-connect@.service.in +index 5ba70863e..3cec3476f 100644 +--- a/nvmf-autoconnect/systemd/nvmf-connect@.service.in ++++ b/nvmf-autoconnect/systemd/nvmf-connect@.service.in +@@ -11,6 +11,18 @@ PartOf=nvmf-connect.target + Requires=nvmf-connect.target + + [Service] ++ProtectSystem=full ++ProtectHome=true ++ProtectHostname=true ++ProtectKernelModules=true ++ProtectKernelLogs=true ++ProtectControlGroups=true ++ProtectProc=invisible ++RestrictRealtime=true ++LockPersonality=yes ++MemoryDenyWriteExecute=yes ++RemoveIPC=yes ++RestrictAddressFamilies=AF_INET AF_INET6 + Type=simple + Environment="CONNECT_ARGS=%i" + ExecStart=/bin/sh -c "@SBINDIR@/nvme connect-all --context=autoconnect --quiet `/bin/echo -e '${CONNECT_ARGS}'`" diff --git a/nvme-cli.spec b/nvme-cli.spec index 2472c15..8e15e7d 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -3,7 +3,7 @@ Name: nvme-cli Version: 2.8 -Release: 1%{?dist} +Release: 2%{?dist} Summary: NVMe management command line interface License: GPL-2.0-only @@ -28,6 +28,9 @@ BuildRequires: xmlto Requires: util-linux +# https://github.com/linux-nvme/nvme-cli/pull/2284 +Patch0: nvme-cli-2.9-systemd-hardening.patch + %description nvme-cli provides NVM-Express user space tooling for Linux. @@ -81,6 +84,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Tue Apr 23 2024 Tomas Bzatek - 2.8-2 +- Harden the systemd units + * Wed Feb 14 2024 Tomas Bzatek - 2.8-1 - Update to 2.8 From d3fe246793d1eacab5276f4a83613c2e507d3ea5 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Fri, 3 May 2024 17:52:31 +0200 Subject: [PATCH 18/33] * Fri May 03 2024 Tomas Bzatek - 2.9.1-1 - Update to 2.9.1 --- .gitignore | 1 + nvme-cli-2.9-systemd-hardening.patch | 110 --------------------------- nvme-cli.spec | 11 +-- sources | 2 +- 4 files changed, 8 insertions(+), 116 deletions(-) delete mode 100644 nvme-cli-2.9-systemd-hardening.patch diff --git a/.gitignore b/.gitignore index 84ef6fb..79f773d 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ /nvme-cli-2.6.tar.gz /nvme-cli-2.7.1.tar.gz /nvme-cli-2.8.tar.gz +/nvme-cli-2.9.1.tar.gz diff --git a/nvme-cli-2.9-systemd-hardening.patch b/nvme-cli-2.9-systemd-hardening.patch deleted file mode 100644 index 803b407..0000000 --- a/nvme-cli-2.9-systemd-hardening.patch +++ /dev/null @@ -1,110 +0,0 @@ -From 3d08dcfc5c7ba7cc777ba8b669af78bb9130001b Mon Sep 17 00:00:00 2001 -From: Daniel Wagner -Date: Tue, 4 Apr 2023 14:06:03 +0200 -Subject: [PATCH] nvmf-connect: systemd hardening effort - -Apply the recommended hardening settings as recommended by openSUSE -and Fedor project. A few of the hardening option have to turned of -because nvme-cli needs write access to sysfs and /dev/nvme devices. - -Links: https://en.opensuse.org/openSUSE:Security_Features#Systemd_hardening_effort -Links: https://fedoraproject.org/wiki/Changes/SystemdSecurityHardening -Signed-off-by: Daniel Wagner ---- - .../systemd/nvmefc-boot-connections.service.in | 12 ++++++++++++ - nvmf-autoconnect/systemd/nvmf-autoconnect.service.in | 12 ++++++++++++ - .../systemd/nvmf-connect-nbft.service.in | 12 ++++++++++++ - nvmf-autoconnect/systemd/nvmf-connect@.service.in | 12 ++++++++++++ - 4 files changed, 48 insertions(+) - -diff --git a/nvmf-autoconnect/systemd/nvmefc-boot-connections.service.in b/nvmf-autoconnect/systemd/nvmefc-boot-connections.service.in -index 7036625c7..783feb067 100644 ---- a/nvmf-autoconnect/systemd/nvmefc-boot-connections.service.in -+++ b/nvmf-autoconnect/systemd/nvmefc-boot-connections.service.in -@@ -6,6 +6,18 @@ After=systemd-udevd.service - Before=local-fs-pre.target - - [Service] -+ProtectSystem=full -+ProtectHome=true -+ProtectHostname=true -+ProtectKernelModules=true -+ProtectKernelLogs=true -+ProtectControlGroups=true -+ProtectProc=invisible -+RestrictRealtime=true -+LockPersonality=yes -+MemoryDenyWriteExecute=yes -+RemoveIPC=yes -+RestrictAddressFamilies=none - Type=oneshot - ExecStart=/bin/sh -c "echo add > /sys/class/fc/fc_udev_device/nvme_discovery" - -diff --git a/nvmf-autoconnect/systemd/nvmf-autoconnect.service.in b/nvmf-autoconnect/systemd/nvmf-autoconnect.service.in -index 92960cde6..1ac158846 100644 ---- a/nvmf-autoconnect/systemd/nvmf-autoconnect.service.in -+++ b/nvmf-autoconnect/systemd/nvmf-autoconnect.service.in -@@ -8,6 +8,18 @@ After=network-online.target - Before=remote-fs-pre.target - - [Service] -+ProtectSystem=full -+ProtectHome=true -+ProtectHostname=true -+ProtectKernelModules=true -+ProtectKernelLogs=true -+ProtectControlGroups=true -+ProtectProc=invisible -+RestrictRealtime=true -+LockPersonality=yes -+MemoryDenyWriteExecute=yes -+RemoveIPC=yes -+RestrictAddressFamilies=AF_INET AF_INET6 - Type=oneshot - ExecStart=@SBINDIR@/nvme connect-all --context=autoconnect - -diff --git a/nvmf-autoconnect/systemd/nvmf-connect-nbft.service.in b/nvmf-autoconnect/systemd/nvmf-connect-nbft.service.in -index 820e6ced2..e3934fe70 100644 ---- a/nvmf-autoconnect/systemd/nvmf-connect-nbft.service.in -+++ b/nvmf-autoconnect/systemd/nvmf-connect-nbft.service.in -@@ -10,5 +10,17 @@ After=network-online.target - Before=remote-fs-pre.target - - [Service] -+ProtectSystem=full -+ProtectHome=true -+ProtectHostname=true -+ProtectKernelModules=true -+ProtectKernelLogs=true -+ProtectControlGroups=true -+ProtectProc=invisible -+RestrictRealtime=true -+LockPersonality=yes -+MemoryDenyWriteExecute=yes -+RemoveIPC=yes -+RestrictAddressFamilies=AF_INET AF_INET6 - Type=oneshot - ExecStart=@SBINDIR@/nvme connect-all --nbft -diff --git a/nvmf-autoconnect/systemd/nvmf-connect@.service.in b/nvmf-autoconnect/systemd/nvmf-connect@.service.in -index 5ba70863e..3cec3476f 100644 ---- a/nvmf-autoconnect/systemd/nvmf-connect@.service.in -+++ b/nvmf-autoconnect/systemd/nvmf-connect@.service.in -@@ -11,6 +11,18 @@ PartOf=nvmf-connect.target - Requires=nvmf-connect.target - - [Service] -+ProtectSystem=full -+ProtectHome=true -+ProtectHostname=true -+ProtectKernelModules=true -+ProtectKernelLogs=true -+ProtectControlGroups=true -+ProtectProc=invisible -+RestrictRealtime=true -+LockPersonality=yes -+MemoryDenyWriteExecute=yes -+RemoveIPC=yes -+RestrictAddressFamilies=AF_INET AF_INET6 - Type=simple - Environment="CONNECT_ARGS=%i" - ExecStart=/bin/sh -c "@SBINDIR@/nvme connect-all --context=autoconnect --quiet `/bin/echo -e '${CONNECT_ARGS}'`" diff --git a/nvme-cli.spec b/nvme-cli.spec index 8e15e7d..e60ea89 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -2,8 +2,8 @@ %{!?version_no_tilde: %define version_no_tilde %{shrink:%(echo '%{version}' | tr '~' '-')}} Name: nvme-cli -Version: 2.8 -Release: 2%{?dist} +Version: 2.9.1 +Release: 1%{?dist} Summary: NVMe management command line interface License: GPL-2.0-only @@ -20,7 +20,7 @@ BuildRequires: openssl-devel BuildRequires: kernel-headers %endif -BuildRequires: libnvme-devel >= 1.8 +BuildRequires: libnvme-devel >= 1.9 BuildRequires: json-c-devel >= 0.13 BuildRequires: asciidoc @@ -28,8 +28,6 @@ BuildRequires: xmlto Requires: util-linux -# https://github.com/linux-nvme/nvme-cli/pull/2284 -Patch0: nvme-cli-2.9-systemd-hardening.patch %description nvme-cli provides NVM-Express user space tooling for Linux. @@ -84,6 +82,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Fri May 03 2024 Tomas Bzatek - 2.9.1-1 +- Update to 2.9.1 + * Tue Apr 23 2024 Tomas Bzatek - 2.8-2 - Harden the systemd units diff --git a/sources b/sources index 5f3c195..117185f 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (nvme-cli-2.8.tar.gz) = 1be0bed4e1bf8a25229f301c2b00b78d2de4eaf8ff2b815fa75e44dd35ddd7787604152bdf00696130df3281206a734c5f408c3f2127440e05c2e4b1cdbb79d4 +SHA512 (nvme-cli-2.9.1.tar.gz) = c9c86e7567c2d4c59aff1eb9d18f4775923db3c81a89c628b819121c32150d4bc2d65d0dacac764c64594369890b380d0fd06bc7c1f83f4a7f3e71a51a6fee24 From acaa02a06facc5d439fd10208ac85170646d92b0 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Mon, 3 Jun 2024 15:53:37 +0200 Subject: [PATCH 19/33] * Mon Jun 03 2024 Tomas Bzatek - 2.9.1-2 - Install custom nvmf-connect-nbft.sh NetworkManager hook --- nvme-cli.spec | 9 ++++++++- nvmf-connect-nbft.sh | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 nvmf-connect-nbft.sh diff --git a/nvme-cli.spec b/nvme-cli.spec index e60ea89..fe1f350 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -3,12 +3,13 @@ Name: nvme-cli Version: 2.9.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: NVMe management command line interface License: GPL-2.0-only URL: https://github.com/linux-nvme/nvme-cli Source0: %{url}/archive/v%{version_no_tilde}/%{name}-%{version_no_tilde}.tar.gz +Source1: nvmf-connect-nbft.sh BuildRequires: meson >= 0.50.0 BuildRequires: gcc gcc-c++ @@ -44,6 +45,8 @@ nvme-cli provides NVM-Express user space tooling for Linux. %install %meson_install %{__install} -pm 644 README.md %{buildroot}%{_pkgdocdir} +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/dispatcher.d +%{__install} -pm 755 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/dispatcher.d # hostid and hostnqn are supposed to be unique per machine. We obviously # can't package them. @@ -79,9 +82,13 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %{_udevrulesdir}/71-nvmf-netapp.rules # Do not install the dracut rule yet. See rhbz 1742764 # /usr/lib/dracut/dracut.conf.d/70-nvmf-autoconnect.conf +%{_sysconfdir}/NetworkManager/dispatcher.d/nvmf-connect-nbft.sh %changelog +* Mon Jun 03 2024 Tomas Bzatek - 2.9.1-2 +- Install custom nvmf-connect-nbft.sh NetworkManager hook + * Fri May 03 2024 Tomas Bzatek - 2.9.1-1 - Update to 2.9.1 diff --git a/nvmf-connect-nbft.sh b/nvmf-connect-nbft.sh new file mode 100644 index 0000000..1dc0324 --- /dev/null +++ b/nvmf-connect-nbft.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +if [[ "$1" == nbft* ]] && [[ "$2" == "up" ]]; then + systemctl start nvmf-connect-nbft.service +fi From c8cd07d864ad6453501e4ee0b029d11f231b0904 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 18 Jul 2024 19:53:24 +0000 Subject: [PATCH 20/33] Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild --- nvme-cli.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nvme-cli.spec b/nvme-cli.spec index fe1f350..403d7f1 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -3,7 +3,7 @@ Name: nvme-cli Version: 2.9.1 -Release: 2%{?dist} +Release: 3%{?dist} Summary: NVMe management command line interface License: GPL-2.0-only @@ -86,6 +86,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Thu Jul 18 2024 Fedora Release Engineering - 2.9.1-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + * Mon Jun 03 2024 Tomas Bzatek - 2.9.1-2 - Install custom nvmf-connect-nbft.sh NetworkManager hook From c636547ae241dc5a4dc4e91bd1f2d2d91ef1e9f7 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Mon, 5 Aug 2024 14:26:55 +0200 Subject: [PATCH 21/33] * Mon Aug 05 2024 Tomas Bzatek - 2.10-1 - Update to 2.10 --- .gitignore | 1 + ...-rename_ocp-unsupported-req-log_file.patch | 31 +++++++++++++++++++ nvme-cli.spec | 11 +++++-- sources | 2 +- 4 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 nvme-cli-2.11-rename_ocp-unsupported-req-log_file.patch diff --git a/.gitignore b/.gitignore index 79f773d..32c5bc5 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ /nvme-cli-2.7.1.tar.gz /nvme-cli-2.8.tar.gz /nvme-cli-2.9.1.tar.gz +/nvme-cli-2.10.tar.gz diff --git a/nvme-cli-2.11-rename_ocp-unsupported-req-log_file.patch b/nvme-cli-2.11-rename_ocp-unsupported-req-log_file.patch new file mode 100644 index 0000000..5eed9cb --- /dev/null +++ b/nvme-cli-2.11-rename_ocp-unsupported-req-log_file.patch @@ -0,0 +1,31 @@ +From 03b14a27fb1e38a320600727fdef1fd244c0f9bc Mon Sep 17 00:00:00 2001 +From: Daniel Wagner +Date: Fri, 2 Aug 2024 11:46:49 +0200 +Subject: [PATCH] docs: rename ocp-unsupported-req-log file + +The filename has to match the command name, thus rename the filename. + +Signed-off-by: Daniel Wagner +--- + Documentation/meson.build | 2 +- + ...ted-reqs-log-pages.txt => nvme-ocp-unsupported-reqs-log.txt} | 0 + 2 files changed, 1 insertion(+), 1 deletion(-) + rename Documentation/{nvme-ocp-unsupported-reqs-log-pages.txt => nvme-ocp-unsupported-reqs-log.txt} (100%) + +diff --git a/Documentation/meson.build b/Documentation/meson.build +index 30c0efc418..1478134175 100644 +--- a/Documentation/meson.build ++++ b/Documentation/meson.build +@@ -103,7 +103,7 @@ adoc_sources = [ + 'nvme-ocp-set-telemetry-profile', + 'nvme-ocp-smart-add-log', + 'nvme-ocp-telemetry-string-log-page', +- 'nvme-ocp-unsupported-reqs-log-pages', ++ 'nvme-ocp-unsupported-reqs-log', + 'nvme-ocp-internal-log', + 'nvme-persistent-event-log', + 'nvme-pred-lat-event-agg-log', +diff --git a/Documentation/nvme-ocp-unsupported-reqs-log-pages.txt b/Documentation/nvme-ocp-unsupported-reqs-log.txt +similarity index 100% +rename from Documentation/nvme-ocp-unsupported-reqs-log-pages.txt +rename to Documentation/nvme-ocp-unsupported-reqs-log.txt diff --git a/nvme-cli.spec b/nvme-cli.spec index 403d7f1..92eb6e7 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -2,8 +2,8 @@ %{!?version_no_tilde: %define version_no_tilde %{shrink:%(echo '%{version}' | tr '~' '-')}} Name: nvme-cli -Version: 2.9.1 -Release: 3%{?dist} +Version: 2.10 +Release: 1%{?dist} Summary: NVMe management command line interface License: GPL-2.0-only @@ -11,6 +11,8 @@ URL: https://github.com/linux-nvme/nvme-cli Source0: %{url}/archive/v%{version_no_tilde}/%{name}-%{version_no_tilde}.tar.gz Source1: nvmf-connect-nbft.sh +Patch0: nvme-cli-2.11-rename_ocp-unsupported-req-log_file.patch + BuildRequires: meson >= 0.50.0 BuildRequires: gcc gcc-c++ BuildRequires: systemd-devel @@ -21,7 +23,7 @@ BuildRequires: openssl-devel BuildRequires: kernel-headers %endif -BuildRequires: libnvme-devel >= 1.9 +BuildRequires: libnvme-devel >= 1.10 BuildRequires: json-c-devel >= 0.13 BuildRequires: asciidoc @@ -86,6 +88,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Mon Aug 05 2024 Tomas Bzatek - 2.10-1 +- Update to 2.10 + * Thu Jul 18 2024 Fedora Release Engineering - 2.9.1-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild diff --git a/sources b/sources index 117185f..b880676 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (nvme-cli-2.9.1.tar.gz) = c9c86e7567c2d4c59aff1eb9d18f4775923db3c81a89c628b819121c32150d4bc2d65d0dacac764c64594369890b380d0fd06bc7c1f83f4a7f3e71a51a6fee24 +SHA512 (nvme-cli-2.10.tar.gz) = e1ce2e3d5990dce6794cc8e2e7a601895ff8474a4ba1c7c1722fab1986ae82bce8d41c18b2b553ffc55b1f3393d716e861acf92ba1262b1576d6e4bfb18ad9d0 From 75fb90a003f5650444352d263fc8533a899390d2 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Mon, 5 Aug 2024 15:50:05 +0200 Subject: [PATCH 22/33] * Mon Aug 05 2024 Tomas Bzatek - 2.10.2-1 - Update to 2.10.2 --- .gitignore | 1 + ...-rename_ocp-unsupported-req-log_file.patch | 31 ------------------- nvme-cli.spec | 7 +++-- sources | 2 +- 4 files changed, 6 insertions(+), 35 deletions(-) delete mode 100644 nvme-cli-2.11-rename_ocp-unsupported-req-log_file.patch diff --git a/.gitignore b/.gitignore index 32c5bc5..5246427 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ /nvme-cli-2.8.tar.gz /nvme-cli-2.9.1.tar.gz /nvme-cli-2.10.tar.gz +/nvme-cli-2.10.2.tar.gz diff --git a/nvme-cli-2.11-rename_ocp-unsupported-req-log_file.patch b/nvme-cli-2.11-rename_ocp-unsupported-req-log_file.patch deleted file mode 100644 index 5eed9cb..0000000 --- a/nvme-cli-2.11-rename_ocp-unsupported-req-log_file.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 03b14a27fb1e38a320600727fdef1fd244c0f9bc Mon Sep 17 00:00:00 2001 -From: Daniel Wagner -Date: Fri, 2 Aug 2024 11:46:49 +0200 -Subject: [PATCH] docs: rename ocp-unsupported-req-log file - -The filename has to match the command name, thus rename the filename. - -Signed-off-by: Daniel Wagner ---- - Documentation/meson.build | 2 +- - ...ted-reqs-log-pages.txt => nvme-ocp-unsupported-reqs-log.txt} | 0 - 2 files changed, 1 insertion(+), 1 deletion(-) - rename Documentation/{nvme-ocp-unsupported-reqs-log-pages.txt => nvme-ocp-unsupported-reqs-log.txt} (100%) - -diff --git a/Documentation/meson.build b/Documentation/meson.build -index 30c0efc418..1478134175 100644 ---- a/Documentation/meson.build -+++ b/Documentation/meson.build -@@ -103,7 +103,7 @@ adoc_sources = [ - 'nvme-ocp-set-telemetry-profile', - 'nvme-ocp-smart-add-log', - 'nvme-ocp-telemetry-string-log-page', -- 'nvme-ocp-unsupported-reqs-log-pages', -+ 'nvme-ocp-unsupported-reqs-log', - 'nvme-ocp-internal-log', - 'nvme-persistent-event-log', - 'nvme-pred-lat-event-agg-log', -diff --git a/Documentation/nvme-ocp-unsupported-reqs-log-pages.txt b/Documentation/nvme-ocp-unsupported-reqs-log.txt -similarity index 100% -rename from Documentation/nvme-ocp-unsupported-reqs-log-pages.txt -rename to Documentation/nvme-ocp-unsupported-reqs-log.txt diff --git a/nvme-cli.spec b/nvme-cli.spec index 92eb6e7..ab8f1a6 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -2,7 +2,7 @@ %{!?version_no_tilde: %define version_no_tilde %{shrink:%(echo '%{version}' | tr '~' '-')}} Name: nvme-cli -Version: 2.10 +Version: 2.10.2 Release: 1%{?dist} Summary: NVMe management command line interface @@ -11,8 +11,6 @@ URL: https://github.com/linux-nvme/nvme-cli Source0: %{url}/archive/v%{version_no_tilde}/%{name}-%{version_no_tilde}.tar.gz Source1: nvmf-connect-nbft.sh -Patch0: nvme-cli-2.11-rename_ocp-unsupported-req-log_file.patch - BuildRequires: meson >= 0.50.0 BuildRequires: gcc gcc-c++ BuildRequires: systemd-devel @@ -88,6 +86,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Mon Aug 05 2024 Tomas Bzatek - 2.10.2-1 +- Update to 2.10.2 + * Mon Aug 05 2024 Tomas Bzatek - 2.10-1 - Update to 2.10 diff --git a/sources b/sources index b880676..e394b84 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (nvme-cli-2.10.tar.gz) = e1ce2e3d5990dce6794cc8e2e7a601895ff8474a4ba1c7c1722fab1986ae82bce8d41c18b2b553ffc55b1f3393d716e861acf92ba1262b1576d6e4bfb18ad9d0 +SHA512 (nvme-cli-2.10.2.tar.gz) = 98ecb2488cdf21c83004204f4cb7e7d9327fef5a33e5a37d977c659d76be3cef861473676fa7fbd1d40f38742b365b98431e17d9b0318ddb4cc407953acdde87 From c6b0b0ba590f6c49002ce106b1b9dc8146f47f2a Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Mon, 26 Aug 2024 15:49:38 +0200 Subject: [PATCH 23/33] * Mon Aug 26 2024 Tomas Bzatek - 2.10.2-2 - Install NetworkManager override for nbft interfaces - Rename reconnect NetworkManager hook to 99-nvme-nbft-connect.sh --- ...connect-nbft.sh => 99-nvme-nbft-connect.sh | 0 99-nvme-nbft-no-ignore-carrier.conf | 15 ++++++++++++++ nvme-cli.spec | 20 ++++++++++++++----- 3 files changed, 30 insertions(+), 5 deletions(-) rename nvmf-connect-nbft.sh => 99-nvme-nbft-connect.sh (100%) create mode 100644 99-nvme-nbft-no-ignore-carrier.conf diff --git a/nvmf-connect-nbft.sh b/99-nvme-nbft-connect.sh similarity index 100% rename from nvmf-connect-nbft.sh rename to 99-nvme-nbft-connect.sh diff --git a/99-nvme-nbft-no-ignore-carrier.conf b/99-nvme-nbft-no-ignore-carrier.conf new file mode 100644 index 0000000..4f19515 --- /dev/null +++ b/99-nvme-nbft-no-ignore-carrier.conf @@ -0,0 +1,15 @@ +# Boot from NVMe over TCP (NBFT) +# +# For NVMe/TCP connections that provide namespaces containing rootfs +# it is crucial to react on carrier events and reconnect any missing +# NVMe/TCP connections as defined in the ACPI NBFT table. A custom +# /usr/lib/NetworkManager/dispatcher.d/99-nvme-nbft-connect.sh hook +# will respawn nvmf-connect-nbft.service on such occasion. + +[device-nbft-no-ignore-carrier] + +# only affects nbft0, nbft1, ... interfaces +match-device=interface-name:nbft* + +# react on link up/down events +ignore-carrier=no diff --git a/nvme-cli.spec b/nvme-cli.spec index ab8f1a6..efc09a7 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -1,15 +1,18 @@ # RHEL 8 compatibility %{!?version_no_tilde: %define version_no_tilde %{shrink:%(echo '%{version}' | tr '~' '-')}} +%global nmlibdir %{_prefix}/lib/NetworkManager + Name: nvme-cli Version: 2.10.2 -Release: 1%{?dist} +Release: 2%{?dist} Summary: NVMe management command line interface License: GPL-2.0-only URL: https://github.com/linux-nvme/nvme-cli Source0: %{url}/archive/v%{version_no_tilde}/%{name}-%{version_no_tilde}.tar.gz -Source1: nvmf-connect-nbft.sh +Source1: 99-nvme-nbft-connect.sh +Source2: 99-nvme-nbft-no-ignore-carrier.conf BuildRequires: meson >= 0.50.0 BuildRequires: gcc gcc-c++ @@ -45,8 +48,10 @@ nvme-cli provides NVM-Express user space tooling for Linux. %install %meson_install %{__install} -pm 644 README.md %{buildroot}%{_pkgdocdir} -mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/dispatcher.d -%{__install} -pm 755 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/NetworkManager/dispatcher.d +mkdir -p $RPM_BUILD_ROOT%{nmlibdir}/dispatcher.d +mkdir -p $RPM_BUILD_ROOT%{nmlibdir}/conf.d +%{__install} -pm 755 %{SOURCE1} $RPM_BUILD_ROOT%{nmlibdir}/dispatcher.d/ +%{__install} -pm 644 %{SOURCE2} $RPM_BUILD_ROOT%{nmlibdir}/conf.d/ # hostid and hostnqn are supposed to be unique per machine. We obviously # can't package them. @@ -82,10 +87,15 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %{_udevrulesdir}/71-nvmf-netapp.rules # Do not install the dracut rule yet. See rhbz 1742764 # /usr/lib/dracut/dracut.conf.d/70-nvmf-autoconnect.conf -%{_sysconfdir}/NetworkManager/dispatcher.d/nvmf-connect-nbft.sh +%{nmlibdir}/dispatcher.d/99-nvme-nbft-connect.sh +%{nmlibdir}/conf.d/99-nvme-nbft-no-ignore-carrier.conf %changelog +* Mon Aug 26 2024 Tomas Bzatek - 2.10.2-2 +- Install NetworkManager override for nbft interfaces +- Rename reconnect NetworkManager hook to 99-nvme-nbft-connect.sh + * Mon Aug 05 2024 Tomas Bzatek - 2.10.2-1 - Update to 2.10.2 From babcc96ccdedadfa9b6af8c6b7b13250cea2437e Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Thu, 31 Oct 2024 17:17:30 +0100 Subject: [PATCH 24/33] * Thu Oct 31 2024 Tomas Bzatek - 2.11-1 - Update to 2.11 --- .gitignore | 1 + nvme-cli.spec | 10 +++++++--- sources | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 5246427..bb36b97 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ /nvme-cli-2.9.1.tar.gz /nvme-cli-2.10.tar.gz /nvme-cli-2.10.2.tar.gz +/nvme-cli-2.11.tar.gz diff --git a/nvme-cli.spec b/nvme-cli.spec index efc09a7..bb32427 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -4,8 +4,8 @@ %global nmlibdir %{_prefix}/lib/NetworkManager Name: nvme-cli -Version: 2.10.2 -Release: 2%{?dist} +Version: 2.11 +Release: 1%{?dist} Summary: NVMe management command line interface License: GPL-2.0-only @@ -24,7 +24,7 @@ BuildRequires: openssl-devel BuildRequires: kernel-headers %endif -BuildRequires: libnvme-devel >= 1.10 +BuildRequires: libnvme-devel >= 1.11 BuildRequires: json-c-devel >= 0.13 BuildRequires: asciidoc @@ -84,6 +84,7 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %{_unitdir}/nvmf-connect-nbft.service %{_udevrulesdir}/65-persistent-net-nbft.rules %{_udevrulesdir}/70-nvmf-autoconnect.rules +%{_udevrulesdir}/70-nvmf-keys.rules %{_udevrulesdir}/71-nvmf-netapp.rules # Do not install the dracut rule yet. See rhbz 1742764 # /usr/lib/dracut/dracut.conf.d/70-nvmf-autoconnect.conf @@ -92,6 +93,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Thu Oct 31 2024 Tomas Bzatek - 2.11-1 +- Update to 2.11 + * Mon Aug 26 2024 Tomas Bzatek - 2.10.2-2 - Install NetworkManager override for nbft interfaces - Rename reconnect NetworkManager hook to 99-nvme-nbft-connect.sh diff --git a/sources b/sources index e394b84..919e3b6 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (nvme-cli-2.10.2.tar.gz) = 98ecb2488cdf21c83004204f4cb7e7d9327fef5a33e5a37d977c659d76be3cef861473676fa7fbd1d40f38742b365b98431e17d9b0318ddb4cc407953acdde87 +SHA512 (nvme-cli-2.11.tar.gz) = 33de20ad990a3b87fef46fa486832edde41907223aa6b8a47606e605b360745fd7e2054226bf93a59b2a09c6bc04d0b684e4b3bb27c3fc0e6110c64a558cadc0 From 6e6c26f8a6cedf911b2528a3c038afb01183a52d Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 17 Jan 2025 20:32:54 +0000 Subject: [PATCH 25/33] Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild --- nvme-cli.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nvme-cli.spec b/nvme-cli.spec index bb32427..2642394 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -5,7 +5,7 @@ Name: nvme-cli Version: 2.11 -Release: 1%{?dist} +Release: 2%{?dist} Summary: NVMe management command line interface License: GPL-2.0-only @@ -93,6 +93,9 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Fri Jan 17 2025 Fedora Release Engineering - 2.11-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild + * Thu Oct 31 2024 Tomas Bzatek - 2.11-1 - Update to 2.11 From 3dfbefd5541d4231150e50899b65278a38274463 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Tue, 4 Feb 2025 16:55:22 +0100 Subject: [PATCH 26/33] * Tue Feb 04 2025 Tomas Bzatek - 2.11-3 - Add systemd units scriptlets - Reload udevd after installing udev rules https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_systemd --- nvme-cli.spec | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/nvme-cli.spec b/nvme-cli.spec index 2642394..d167232 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -5,7 +5,7 @@ Name: nvme-cli Version: 2.11 -Release: 2%{?dist} +Release: 3%{?dist} Summary: NVMe management command line interface License: GPL-2.0-only @@ -68,6 +68,30 @@ mv %{buildroot}%{_pkgdocdir}/nvme %{buildroot}%{_pkgdocdir}/html rm -rf %{buildroot}%{_pkgdocdir}/nvme +%post +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_systemd +%systemd_post nvmefc-boot-connections.service +%systemd_post nvmf-autoconnect.service +%systemd_post nvmf-connect@.service +%systemd_post nvmf-connect-nbft.service +if [ -S /run/udev/control ]; then + udevadm control --reload + udevadm trigger +fi + +%preun +%systemd_preun nvmefc-boot-connections.service +%systemd_preun nvmf-autoconnect.service +%systemd_preun nvmf-connect@.service +%systemd_preun nvmf-connect-nbft.service + +%postun +%systemd_postun nvmefc-boot-connections.service +%systemd_postun nvmf-autoconnect.service +%systemd_postun nvmf-connect@.service +%systemd_postun nvmf-connect-nbft.service + + %files %license LICENSE %doc %{_pkgdocdir} @@ -93,6 +117,10 @@ rm -rf %{buildroot}%{_pkgdocdir}/nvme %changelog +* Tue Feb 04 2025 Tomas Bzatek - 2.11-3 +- Add systemd units scriptlets +- Reload udevd after installing udev rules + * Fri Jan 17 2025 Fedora Release Engineering - 2.11-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild From 58dfd6f0b1b57154326f64c97dd836d981c3cf14 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Mon, 17 Mar 2025 15:55:39 +0100 Subject: [PATCH 27/33] * Mon Mar 17 2025 Tomas Bzatek - 2.12-1 - Update to 2.12 --- .gitignore | 1 + nvme-cli.spec | 13 ++++++++----- sources | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index bb36b97..63fde27 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,4 @@ /nvme-cli-2.10.tar.gz /nvme-cli-2.10.2.tar.gz /nvme-cli-2.11.tar.gz +/nvme-cli-2.12.tar.gz diff --git a/nvme-cli.spec b/nvme-cli.spec index d167232..7e8460b 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -4,8 +4,8 @@ %global nmlibdir %{_prefix}/lib/NetworkManager Name: nvme-cli -Version: 2.11 -Release: 3%{?dist} +Version: 2.12 +Release: 1%{?dist} Summary: NVMe management command line interface License: GPL-2.0-only @@ -14,7 +14,7 @@ Source0: %{url}/archive/v%{version_no_tilde}/%{name}-%{version_no_tilde}. Source1: 99-nvme-nbft-connect.sh Source2: 99-nvme-nbft-no-ignore-carrier.conf -BuildRequires: meson >= 0.50.0 +BuildRequires: meson >= 0.53 BuildRequires: gcc gcc-c++ BuildRequires: systemd-devel BuildRequires: systemd-rpm-macros @@ -24,8 +24,8 @@ BuildRequires: openssl-devel BuildRequires: kernel-headers %endif -BuildRequires: libnvme-devel >= 1.11 -BuildRequires: json-c-devel >= 0.13 +BuildRequires: libnvme-devel >= 1.12 +BuildRequires: json-c-devel >= 0.14 BuildRequires: asciidoc BuildRequires: xmlto @@ -117,6 +117,9 @@ fi %changelog +* Mon Mar 17 2025 Tomas Bzatek - 2.12-1 +- Update to 2.12 + * Tue Feb 04 2025 Tomas Bzatek - 2.11-3 - Add systemd units scriptlets - Reload udevd after installing udev rules diff --git a/sources b/sources index 919e3b6..76e19d3 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (nvme-cli-2.11.tar.gz) = 33de20ad990a3b87fef46fa486832edde41907223aa6b8a47606e605b360745fd7e2054226bf93a59b2a09c6bc04d0b684e4b3bb27c3fc0e6110c64a558cadc0 +SHA512 (nvme-cli-2.12.tar.gz) = 569a60302e4ce71713906417f34a8922b4788d77220a01f2f11dd12fc787ac6590c00588353cbbba292640688995fcefee4ab28c274bedcc02a2e3439c258938 From c0028af7fa1d7a674277285d6e96cac75538e010 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Fri, 11 Apr 2025 16:41:02 +0200 Subject: [PATCH 28/33] * Fri Apr 11 2025 Tomas Bzatek - 2.13-1 - Update to 2.13 --- .gitignore | 1 + nvme-cli.spec | 7 +++++-- sources | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 63fde27..2c55855 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,4 @@ /nvme-cli-2.10.2.tar.gz /nvme-cli-2.11.tar.gz /nvme-cli-2.12.tar.gz +/nvme-cli-2.13.tar.gz diff --git a/nvme-cli.spec b/nvme-cli.spec index 7e8460b..3d50c14 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -4,7 +4,7 @@ %global nmlibdir %{_prefix}/lib/NetworkManager Name: nvme-cli -Version: 2.12 +Version: 2.13 Release: 1%{?dist} Summary: NVMe management command line interface @@ -24,7 +24,7 @@ BuildRequires: openssl-devel BuildRequires: kernel-headers %endif -BuildRequires: libnvme-devel >= 1.12 +BuildRequires: libnvme-devel >= 1.13 BuildRequires: json-c-devel >= 0.14 BuildRequires: asciidoc @@ -117,6 +117,9 @@ fi %changelog +* Fri Apr 11 2025 Tomas Bzatek - 2.13-1 +- Update to 2.13 + * Mon Mar 17 2025 Tomas Bzatek - 2.12-1 - Update to 2.12 diff --git a/sources b/sources index 76e19d3..fbddce2 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (nvme-cli-2.12.tar.gz) = 569a60302e4ce71713906417f34a8922b4788d77220a01f2f11dd12fc787ac6590c00588353cbbba292640688995fcefee4ab28c274bedcc02a2e3439c258938 +SHA512 (nvme-cli-2.13.tar.gz) = 71ade7b97354bf70e4909d85265db157715c1afe52fba6d1e2aa614900a8059830e85029f71680884966476363e8846d6cfbc1dcfe57330c749775acc39df6e7 From e8eb04bafce9e39c023c0223753c0ef6ff9a7e6c Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Wed, 9 Jul 2025 14:35:50 +0200 Subject: [PATCH 29/33] * Wed Jul 09 2025 Tomas Bzatek - 2.14-1 - Update to 2.14 - Disable Persistent Discovery Controllers by default --- .gitignore | 1 + nvme-cli.spec | 11 ++++++++--- sources | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 2c55855..5cab049 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ /nvme-cli-2.11.tar.gz /nvme-cli-2.12.tar.gz /nvme-cli-2.13.tar.gz +/nvme-cli-2.14.tar.gz diff --git a/nvme-cli.spec b/nvme-cli.spec index 3d50c14..7edf192 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -4,7 +4,7 @@ %global nmlibdir %{_prefix}/lib/NetworkManager Name: nvme-cli -Version: 2.13 +Version: 2.14 Release: 1%{?dist} Summary: NVMe management command line interface @@ -24,7 +24,7 @@ BuildRequires: openssl-devel BuildRequires: kernel-headers %endif -BuildRequires: libnvme-devel >= 1.13 +BuildRequires: libnvme-devel >= 1.14 BuildRequires: json-c-devel >= 0.14 BuildRequires: asciidoc @@ -41,7 +41,7 @@ nvme-cli provides NVM-Express user space tooling for Linux. %build -%meson -Dudevrulesdir=%{_udevrulesdir} -Dsystemddir=%{_unitdir} -Dpdc-enabled=true -Ddocs=all -Ddocs-build=true -Dhtmldir=%{_pkgdocdir} +%meson -Dudevrulesdir=%{_udevrulesdir} -Dsystemddir=%{_unitdir} -Dpdc-enabled=false -Ddocs=all -Ddocs-build=true -Dhtmldir=%{_pkgdocdir} %meson_build @@ -110,6 +110,7 @@ fi %{_udevrulesdir}/70-nvmf-autoconnect.rules %{_udevrulesdir}/70-nvmf-keys.rules %{_udevrulesdir}/71-nvmf-netapp.rules +%{_udevrulesdir}/71-nvmf-vastdata.rules # Do not install the dracut rule yet. See rhbz 1742764 # /usr/lib/dracut/dracut.conf.d/70-nvmf-autoconnect.conf %{nmlibdir}/dispatcher.d/99-nvme-nbft-connect.sh @@ -117,6 +118,10 @@ fi %changelog +* Wed Jul 09 2025 Tomas Bzatek - 2.14-1 +- Update to 2.14 +- Disable Persistent Discovery Controllers by default + * Fri Apr 11 2025 Tomas Bzatek - 2.13-1 - Update to 2.13 diff --git a/sources b/sources index fbddce2..18a45bc 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (nvme-cli-2.13.tar.gz) = 71ade7b97354bf70e4909d85265db157715c1afe52fba6d1e2aa614900a8059830e85029f71680884966476363e8846d6cfbc1dcfe57330c749775acc39df6e7 +SHA512 (nvme-cli-2.14.tar.gz) = 7f600ee719f06283e136427a0f9eb0b22412f7f4549c774768caff54150207ba87e2a431ea1569e5ed86a554aecd23c00c4e8c351aa0168a81807c86a0cb2edc From d8a5bb174c50195371f4f5963c789457755333a8 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 24 Jul 2025 23:02:44 +0000 Subject: [PATCH 30/33] Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild --- nvme-cli.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nvme-cli.spec b/nvme-cli.spec index 7edf192..bf058fe 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -5,7 +5,7 @@ Name: nvme-cli Version: 2.14 -Release: 1%{?dist} +Release: 2%{?dist} Summary: NVMe management command line interface License: GPL-2.0-only @@ -118,6 +118,9 @@ fi %changelog +* Thu Jul 24 2025 Fedora Release Engineering - 2.14-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild + * Wed Jul 09 2025 Tomas Bzatek - 2.14-1 - Update to 2.14 - Disable Persistent Discovery Controllers by default From e01b55c71f095345eed4588ab605f2273d1768c2 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Fri, 25 Jul 2025 23:22:16 +0200 Subject: [PATCH 31/33] * Fri Jul 25 2025 Tomas Bzatek - 2.15-1 - Update to 2.15 --- .gitignore | 1 + nvme-cli.spec | 10 +++++++--- sources | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 5cab049..3f61a44 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ /nvme-cli-2.12.tar.gz /nvme-cli-2.13.tar.gz /nvme-cli-2.14.tar.gz +/nvme-cli-2.15.tar.gz diff --git a/nvme-cli.spec b/nvme-cli.spec index bf058fe..d898953 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -4,8 +4,8 @@ %global nmlibdir %{_prefix}/lib/NetworkManager Name: nvme-cli -Version: 2.14 -Release: 2%{?dist} +Version: 2.15 +Release: 1%{?dist} Summary: NVMe management command line interface License: GPL-2.0-only @@ -24,7 +24,7 @@ BuildRequires: openssl-devel BuildRequires: kernel-headers %endif -BuildRequires: libnvme-devel >= 1.14 +BuildRequires: libnvme-devel >= 1.15 BuildRequires: json-c-devel >= 0.14 BuildRequires: asciidoc @@ -111,6 +111,7 @@ fi %{_udevrulesdir}/70-nvmf-keys.rules %{_udevrulesdir}/71-nvmf-netapp.rules %{_udevrulesdir}/71-nvmf-vastdata.rules +%{_udevrulesdir}/71-nvme-hpe.rules # Do not install the dracut rule yet. See rhbz 1742764 # /usr/lib/dracut/dracut.conf.d/70-nvmf-autoconnect.conf %{nmlibdir}/dispatcher.d/99-nvme-nbft-connect.sh @@ -118,6 +119,9 @@ fi %changelog +* Fri Jul 25 2025 Tomas Bzatek - 2.15-1 +- Update to 2.15 + * Thu Jul 24 2025 Fedora Release Engineering - 2.14-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild diff --git a/sources b/sources index 18a45bc..9336ddd 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (nvme-cli-2.14.tar.gz) = 7f600ee719f06283e136427a0f9eb0b22412f7f4549c774768caff54150207ba87e2a431ea1569e5ed86a554aecd23c00c4e8c351aa0168a81807c86a0cb2edc +SHA512 (nvme-cli-2.15.tar.gz) = 6f4c9fe52883df5424ba28d8b66b00e61f4b6f7226d7385f026c1d3b8aeb473bdf637102d9cf7e049349c4f7e61eccbb33f7400cc09056f74be03a80b7d51c0d From 3618605a763d9397b8095fe86aaa35c39fd52023 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Fri, 15 Aug 2025 18:02:46 +0200 Subject: [PATCH 32/33] * Fri Aug 15 2025 Tomas Bzatek - 2.15-2 - Fix nvme-list JSON output compatibility - Rename 71-nvme-hpe.rules to 71-nvmf-hpe.rules --- nvme-cli-2.16-nvme_list_JSON_regression.patch | 173 ++++++++++++++++++ nvme-cli-2.16-rename_71-nvme-hpe.rules.patch | 32 ++++ nvme-cli.spec | 13 +- 3 files changed, 216 insertions(+), 2 deletions(-) create mode 100644 nvme-cli-2.16-nvme_list_JSON_regression.patch create mode 100644 nvme-cli-2.16-rename_71-nvme-hpe.rules.patch diff --git a/nvme-cli-2.16-nvme_list_JSON_regression.patch b/nvme-cli-2.16-nvme_list_JSON_regression.patch new file mode 100644 index 0000000..658fca8 --- /dev/null +++ b/nvme-cli-2.16-nvme_list_JSON_regression.patch @@ -0,0 +1,173 @@ +From 80ad62ba75f1f1dd5b99c6f56769141b48344485 Mon Sep 17 00:00:00 2001 +From: Nilay Shroff +Date: Tue, 5 Aug 2025 15:50:50 +0530 +Subject: [PATCH] nvme-list: make verbose JSON output backward compatible + +The commit 64bed0a87a23 ("nvme-list: fix verbose JSON output for 'nvme +list' command") changed the JSON output format of the nvme list --verbose +command. While the new format is more structured, it introduced a +regression by breaking compatibility with tools and scripts relying on +the previous JSON schema. + +So to restore backward compatibility, we now leverage the existing +--output-format-version option. With this patch, +1. The default --output-format-version=1 retains the original (legacy) JSON +format for nvme list --verbose. +2. If the user explicitly sets --output-format-version=2 then the newer +JSON structure introduced by commit 64bed0a87a23 ("nvme-list: fix verbose +JSON output for 'nvme list' command") is used. + +This ensures that existing users and automation relying on the older format +do not break, while still supporting the newer schema for forward-looking +users. + +Fixes: 64bed0a87a23 ("nvme-list: fix verbose JSON output for 'nvme list' command") +Signed-off-by: Nilay Shroff +Link: https://patch.msgid.link/20250805102055.3375272-1-nilay@linux.ibm.com +Signed-off-by: Daniel Wagner +--- + nvme-print-json.c | 117 ++++++++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 113 insertions(+), 4 deletions(-) + +diff --git a/nvme-print-json.c b/nvme-print-json.c +index 11b6661624..829ba718e8 100644 +--- a/nvme-print-json.c ++++ b/nvme-print-json.c +@@ -4519,7 +4519,7 @@ static void json_print_detail_list(nvme_subsystem_t s, struct json_object *jss) + obj_add_obj(jss, "Controllers", jctrls); + } + +-static void json_detail_list(nvme_root_t t) ++static void json_detail_list_v2(nvme_root_t t) + { + struct json_object *r = json_create_object(); + struct json_object *jdev = json_create_array(); +@@ -4560,6 +4560,112 @@ static void json_detail_list(nvme_root_t t) + json_print(r); + } + ++static void json_detail_list(nvme_root_t t) ++{ ++ struct json_object *r = json_create_object(); ++ struct json_object *jdev = json_create_array(); ++ ++ nvme_host_t h; ++ nvme_subsystem_t s; ++ nvme_ctrl_t c; ++ nvme_path_t p; ++ nvme_ns_t n; ++ ++ nvme_for_each_host(t, h) { ++ struct json_object *hss = json_create_object(); ++ struct json_object *jsslist = json_create_array(); ++ const char *hostid; ++ ++ obj_add_str(hss, "HostNQN", nvme_host_get_hostnqn(h)); ++ hostid = nvme_host_get_hostid(h); ++ if (hostid) ++ obj_add_str(hss, "HostID", hostid); ++ ++ nvme_for_each_subsystem(h, s) { ++ struct json_object *jss = json_create_object(); ++ struct json_object *jctrls = json_create_array(); ++ struct json_object *jnss = json_create_array(); ++ ++ obj_add_str(jss, "Subsystem", nvme_subsystem_get_name(s)); ++ obj_add_str(jss, "SubsystemNQN", nvme_subsystem_get_nqn(s)); ++ ++ nvme_subsystem_for_each_ctrl(s, c) { ++ struct json_object *jctrl = json_create_object(); ++ struct json_object *jnss = json_create_array(); ++ struct json_object *jpaths = json_create_array(); ++ ++ obj_add_str(jctrl, "Controller", nvme_ctrl_get_name(c)); ++ obj_add_str(jctrl, "Cntlid", nvme_ctrl_get_cntlid(c)); ++ obj_add_str(jctrl, "SerialNumber", nvme_ctrl_get_serial(c)); ++ obj_add_str(jctrl, "ModelNumber", nvme_ctrl_get_model(c)); ++ obj_add_str(jctrl, "Firmware", nvme_ctrl_get_firmware(c)); ++ obj_add_str(jctrl, "Transport", nvme_ctrl_get_transport(c)); ++ obj_add_str(jctrl, "Address", nvme_ctrl_get_address(c)); ++ obj_add_str(jctrl, "Slot", nvme_ctrl_get_phy_slot(c)); ++ ++ nvme_ctrl_for_each_ns(c, n) { ++ struct json_object *jns = json_create_object(); ++ int lba = nvme_ns_get_lba_size(n); ++ uint64_t nsze = nvme_ns_get_lba_count(n) * lba; ++ uint64_t nuse = nvme_ns_get_lba_util(n) * lba; ++ ++ obj_add_str(jns, "NameSpace", nvme_ns_get_name(n)); ++ obj_add_str(jns, "Generic", nvme_ns_get_generic_name(n)); ++ obj_add_int(jns, "NSID", nvme_ns_get_nsid(n)); ++ obj_add_uint64(jns, "UsedBytes", nuse); ++ obj_add_uint64(jns, "MaximumLBA", nvme_ns_get_lba_count(n)); ++ obj_add_uint64(jns, "PhysicalSize", nsze); ++ obj_add_int(jns, "SectorSize", lba); ++ ++ array_add_obj(jnss, jns); ++ } ++ obj_add_obj(jctrl, "Namespaces", jnss); ++ ++ nvme_ctrl_for_each_path(c, p) { ++ struct json_object *jpath = json_create_object(); ++ ++ obj_add_str(jpath, "Path", nvme_path_get_name(p)); ++ obj_add_str(jpath, "ANAState", nvme_path_get_ana_state(p)); ++ ++ array_add_obj(jpaths, jpath); ++ } ++ obj_add_obj(jctrl, "Paths", jpaths); ++ ++ array_add_obj(jctrls, jctrl); ++ } ++ obj_add_obj(jss, "Controllers", jctrls); ++ ++ nvme_subsystem_for_each_ns(s, n) { ++ struct json_object *jns = json_create_object(); ++ ++ int lba = nvme_ns_get_lba_size(n); ++ uint64_t nsze = nvme_ns_get_lba_count(n) * lba; ++ uint64_t nuse = nvme_ns_get_lba_util(n) * lba; ++ ++ obj_add_str(jns, "NameSpace", nvme_ns_get_name(n)); ++ obj_add_str(jns, "Generic", nvme_ns_get_generic_name(n)); ++ obj_add_int(jns, "NSID", nvme_ns_get_nsid(n)); ++ obj_add_uint64(jns, "UsedBytes", nuse); ++ obj_add_uint64(jns, "MaximumLBA", nvme_ns_get_lba_count(n)); ++ obj_add_uint64(jns, "PhysicalSize", nsze); ++ obj_add_int(jns, "SectorSize", lba); ++ ++ array_add_obj(jnss, jns); ++ } ++ obj_add_obj(jss, "Namespaces", jnss); ++ ++ array_add_obj(jsslist, jss); ++ } ++ ++ obj_add_obj(hss, "Subsystems", jsslist); ++ array_add_obj(jdev, hss); ++ } ++ ++ obj_add_array(r, "Devices", jdev); ++ ++ json_print(r); ++} ++ + static struct json_object *json_list_item_obj(nvme_ns_t n) + { + struct json_object *r = json_create_object(); +@@ -4622,9 +4728,12 @@ static void json_list_item(nvme_ns_t n) + + static void json_print_list_items(nvme_root_t t) + { +- if (verbose_mode()) +- json_detail_list(t); +- else ++ if (json_print_ops.flags & VERBOSE) { ++ if (nvme_cfg.output_format_ver == 2) ++ json_detail_list_v2(t); ++ else ++ json_detail_list(t); ++ } else + json_simple_list(t); + } + diff --git a/nvme-cli-2.16-rename_71-nvme-hpe.rules.patch b/nvme-cli-2.16-rename_71-nvme-hpe.rules.patch new file mode 100644 index 0000000..7707737 --- /dev/null +++ b/nvme-cli-2.16-rename_71-nvme-hpe.rules.patch @@ -0,0 +1,32 @@ +From 1141d617dfb3f50783fe80edd49728b8035a955f Mon Sep 17 00:00:00 2001 +From: Daniel Wagner +Date: Fri, 25 Jul 2025 13:30:19 +0200 +Subject: [PATCH] udev: rename 71-nvme-hpe.rules to 71-nvmf-hpe.rules + +The rules file naming is inconsistent with the other rules. Use the +nvmf- prefix. + +Signed-off-by: Daniel Wagner +--- + meson.build | 2 +- + .../udev-rules/{71-nvme-hpe.rules.in => 71-nvmf-hpe.rules.in} | 0 + 2 files changed, 1 insertion(+), 1 deletion(-) + rename nvmf-autoconnect/udev-rules/{71-nvme-hpe.rules.in => 71-nvmf-hpe.rules.in} (100%) + +diff --git a/meson.build b/meson.build +index 1d57748605..3afd8ba3b1 100644 +--- a/meson.build ++++ b/meson.build +@@ -267,7 +267,7 @@ udev_files = [ + '65-persistent-net-nbft.rules', + '70-nvmf-autoconnect.rules', + '70-nvmf-keys.rules', +- '71-nvme-hpe.rules', ++ '71-nvmf-hpe.rules', + '71-nvmf-netapp.rules', + '71-nvmf-vastdata.rules', + ] +diff --git a/nvmf-autoconnect/udev-rules/71-nvme-hpe.rules.in b/nvmf-autoconnect/udev-rules/71-nvmf-hpe.rules.in +similarity index 100% +rename from nvmf-autoconnect/udev-rules/71-nvme-hpe.rules.in +rename to nvmf-autoconnect/udev-rules/71-nvmf-hpe.rules.in diff --git a/nvme-cli.spec b/nvme-cli.spec index d898953..0e6abd1 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -5,7 +5,7 @@ Name: nvme-cli Version: 2.15 -Release: 1%{?dist} +Release: 2%{?dist} Summary: NVMe management command line interface License: GPL-2.0-only @@ -14,6 +14,11 @@ Source0: %{url}/archive/v%{version_no_tilde}/%{name}-%{version_no_tilde}. Source1: 99-nvme-nbft-connect.sh Source2: 99-nvme-nbft-no-ignore-carrier.conf +# https://github.com/linux-nvme/nvme-cli/issues/2886 +Patch0: nvme-cli-2.16-nvme_list_JSON_regression.patch +# https://github.com/linux-nvme/nvme-cli/pull/2880 +Patch1: nvme-cli-2.16-rename_71-nvme-hpe.rules.patch + BuildRequires: meson >= 0.53 BuildRequires: gcc gcc-c++ BuildRequires: systemd-devel @@ -111,7 +116,7 @@ fi %{_udevrulesdir}/70-nvmf-keys.rules %{_udevrulesdir}/71-nvmf-netapp.rules %{_udevrulesdir}/71-nvmf-vastdata.rules -%{_udevrulesdir}/71-nvme-hpe.rules +%{_udevrulesdir}/71-nvmf-hpe.rules # Do not install the dracut rule yet. See rhbz 1742764 # /usr/lib/dracut/dracut.conf.d/70-nvmf-autoconnect.conf %{nmlibdir}/dispatcher.d/99-nvme-nbft-connect.sh @@ -119,6 +124,10 @@ fi %changelog +* Fri Aug 15 2025 Tomas Bzatek - 2.15-2 +- Fix nvme-list JSON output compatibility +- Rename 71-nvme-hpe.rules to 71-nvmf-hpe.rules + * Fri Jul 25 2025 Tomas Bzatek - 2.15-1 - Update to 2.15 From 6e6a6d49fc8384f2fc97addf9e66042cf799c5ec Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Thu, 4 Dec 2025 14:43:53 +0100 Subject: [PATCH 33/33] * Thu Dec 04 2025 Tomas Bzatek - 2.16-1 - Update to 2.16 --- .gitignore | 1 + nvme-cli-2.16-nvme_list_JSON_regression.patch | 173 ------------------ nvme-cli-2.16-rename_71-nvme-hpe.rules.patch | 32 ---- nvme-cli.spec | 14 +- sources | 2 +- 5 files changed, 8 insertions(+), 214 deletions(-) delete mode 100644 nvme-cli-2.16-nvme_list_JSON_regression.patch delete mode 100644 nvme-cli-2.16-rename_71-nvme-hpe.rules.patch diff --git a/.gitignore b/.gitignore index 3f61a44..1580e5b 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ /nvme-cli-2.13.tar.gz /nvme-cli-2.14.tar.gz /nvme-cli-2.15.tar.gz +/nvme-cli-2.16.tar.gz diff --git a/nvme-cli-2.16-nvme_list_JSON_regression.patch b/nvme-cli-2.16-nvme_list_JSON_regression.patch deleted file mode 100644 index 658fca8..0000000 --- a/nvme-cli-2.16-nvme_list_JSON_regression.patch +++ /dev/null @@ -1,173 +0,0 @@ -From 80ad62ba75f1f1dd5b99c6f56769141b48344485 Mon Sep 17 00:00:00 2001 -From: Nilay Shroff -Date: Tue, 5 Aug 2025 15:50:50 +0530 -Subject: [PATCH] nvme-list: make verbose JSON output backward compatible - -The commit 64bed0a87a23 ("nvme-list: fix verbose JSON output for 'nvme -list' command") changed the JSON output format of the nvme list --verbose -command. While the new format is more structured, it introduced a -regression by breaking compatibility with tools and scripts relying on -the previous JSON schema. - -So to restore backward compatibility, we now leverage the existing ---output-format-version option. With this patch, -1. The default --output-format-version=1 retains the original (legacy) JSON -format for nvme list --verbose. -2. If the user explicitly sets --output-format-version=2 then the newer -JSON structure introduced by commit 64bed0a87a23 ("nvme-list: fix verbose -JSON output for 'nvme list' command") is used. - -This ensures that existing users and automation relying on the older format -do not break, while still supporting the newer schema for forward-looking -users. - -Fixes: 64bed0a87a23 ("nvme-list: fix verbose JSON output for 'nvme list' command") -Signed-off-by: Nilay Shroff -Link: https://patch.msgid.link/20250805102055.3375272-1-nilay@linux.ibm.com -Signed-off-by: Daniel Wagner ---- - nvme-print-json.c | 117 ++++++++++++++++++++++++++++++++++++++++++++-- - 1 file changed, 113 insertions(+), 4 deletions(-) - -diff --git a/nvme-print-json.c b/nvme-print-json.c -index 11b6661624..829ba718e8 100644 ---- a/nvme-print-json.c -+++ b/nvme-print-json.c -@@ -4519,7 +4519,7 @@ static void json_print_detail_list(nvme_subsystem_t s, struct json_object *jss) - obj_add_obj(jss, "Controllers", jctrls); - } - --static void json_detail_list(nvme_root_t t) -+static void json_detail_list_v2(nvme_root_t t) - { - struct json_object *r = json_create_object(); - struct json_object *jdev = json_create_array(); -@@ -4560,6 +4560,112 @@ static void json_detail_list(nvme_root_t t) - json_print(r); - } - -+static void json_detail_list(nvme_root_t t) -+{ -+ struct json_object *r = json_create_object(); -+ struct json_object *jdev = json_create_array(); -+ -+ nvme_host_t h; -+ nvme_subsystem_t s; -+ nvme_ctrl_t c; -+ nvme_path_t p; -+ nvme_ns_t n; -+ -+ nvme_for_each_host(t, h) { -+ struct json_object *hss = json_create_object(); -+ struct json_object *jsslist = json_create_array(); -+ const char *hostid; -+ -+ obj_add_str(hss, "HostNQN", nvme_host_get_hostnqn(h)); -+ hostid = nvme_host_get_hostid(h); -+ if (hostid) -+ obj_add_str(hss, "HostID", hostid); -+ -+ nvme_for_each_subsystem(h, s) { -+ struct json_object *jss = json_create_object(); -+ struct json_object *jctrls = json_create_array(); -+ struct json_object *jnss = json_create_array(); -+ -+ obj_add_str(jss, "Subsystem", nvme_subsystem_get_name(s)); -+ obj_add_str(jss, "SubsystemNQN", nvme_subsystem_get_nqn(s)); -+ -+ nvme_subsystem_for_each_ctrl(s, c) { -+ struct json_object *jctrl = json_create_object(); -+ struct json_object *jnss = json_create_array(); -+ struct json_object *jpaths = json_create_array(); -+ -+ obj_add_str(jctrl, "Controller", nvme_ctrl_get_name(c)); -+ obj_add_str(jctrl, "Cntlid", nvme_ctrl_get_cntlid(c)); -+ obj_add_str(jctrl, "SerialNumber", nvme_ctrl_get_serial(c)); -+ obj_add_str(jctrl, "ModelNumber", nvme_ctrl_get_model(c)); -+ obj_add_str(jctrl, "Firmware", nvme_ctrl_get_firmware(c)); -+ obj_add_str(jctrl, "Transport", nvme_ctrl_get_transport(c)); -+ obj_add_str(jctrl, "Address", nvme_ctrl_get_address(c)); -+ obj_add_str(jctrl, "Slot", nvme_ctrl_get_phy_slot(c)); -+ -+ nvme_ctrl_for_each_ns(c, n) { -+ struct json_object *jns = json_create_object(); -+ int lba = nvme_ns_get_lba_size(n); -+ uint64_t nsze = nvme_ns_get_lba_count(n) * lba; -+ uint64_t nuse = nvme_ns_get_lba_util(n) * lba; -+ -+ obj_add_str(jns, "NameSpace", nvme_ns_get_name(n)); -+ obj_add_str(jns, "Generic", nvme_ns_get_generic_name(n)); -+ obj_add_int(jns, "NSID", nvme_ns_get_nsid(n)); -+ obj_add_uint64(jns, "UsedBytes", nuse); -+ obj_add_uint64(jns, "MaximumLBA", nvme_ns_get_lba_count(n)); -+ obj_add_uint64(jns, "PhysicalSize", nsze); -+ obj_add_int(jns, "SectorSize", lba); -+ -+ array_add_obj(jnss, jns); -+ } -+ obj_add_obj(jctrl, "Namespaces", jnss); -+ -+ nvme_ctrl_for_each_path(c, p) { -+ struct json_object *jpath = json_create_object(); -+ -+ obj_add_str(jpath, "Path", nvme_path_get_name(p)); -+ obj_add_str(jpath, "ANAState", nvme_path_get_ana_state(p)); -+ -+ array_add_obj(jpaths, jpath); -+ } -+ obj_add_obj(jctrl, "Paths", jpaths); -+ -+ array_add_obj(jctrls, jctrl); -+ } -+ obj_add_obj(jss, "Controllers", jctrls); -+ -+ nvme_subsystem_for_each_ns(s, n) { -+ struct json_object *jns = json_create_object(); -+ -+ int lba = nvme_ns_get_lba_size(n); -+ uint64_t nsze = nvme_ns_get_lba_count(n) * lba; -+ uint64_t nuse = nvme_ns_get_lba_util(n) * lba; -+ -+ obj_add_str(jns, "NameSpace", nvme_ns_get_name(n)); -+ obj_add_str(jns, "Generic", nvme_ns_get_generic_name(n)); -+ obj_add_int(jns, "NSID", nvme_ns_get_nsid(n)); -+ obj_add_uint64(jns, "UsedBytes", nuse); -+ obj_add_uint64(jns, "MaximumLBA", nvme_ns_get_lba_count(n)); -+ obj_add_uint64(jns, "PhysicalSize", nsze); -+ obj_add_int(jns, "SectorSize", lba); -+ -+ array_add_obj(jnss, jns); -+ } -+ obj_add_obj(jss, "Namespaces", jnss); -+ -+ array_add_obj(jsslist, jss); -+ } -+ -+ obj_add_obj(hss, "Subsystems", jsslist); -+ array_add_obj(jdev, hss); -+ } -+ -+ obj_add_array(r, "Devices", jdev); -+ -+ json_print(r); -+} -+ - static struct json_object *json_list_item_obj(nvme_ns_t n) - { - struct json_object *r = json_create_object(); -@@ -4622,9 +4728,12 @@ static void json_list_item(nvme_ns_t n) - - static void json_print_list_items(nvme_root_t t) - { -- if (verbose_mode()) -- json_detail_list(t); -- else -+ if (json_print_ops.flags & VERBOSE) { -+ if (nvme_cfg.output_format_ver == 2) -+ json_detail_list_v2(t); -+ else -+ json_detail_list(t); -+ } else - json_simple_list(t); - } - diff --git a/nvme-cli-2.16-rename_71-nvme-hpe.rules.patch b/nvme-cli-2.16-rename_71-nvme-hpe.rules.patch deleted file mode 100644 index 7707737..0000000 --- a/nvme-cli-2.16-rename_71-nvme-hpe.rules.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 1141d617dfb3f50783fe80edd49728b8035a955f Mon Sep 17 00:00:00 2001 -From: Daniel Wagner -Date: Fri, 25 Jul 2025 13:30:19 +0200 -Subject: [PATCH] udev: rename 71-nvme-hpe.rules to 71-nvmf-hpe.rules - -The rules file naming is inconsistent with the other rules. Use the -nvmf- prefix. - -Signed-off-by: Daniel Wagner ---- - meson.build | 2 +- - .../udev-rules/{71-nvme-hpe.rules.in => 71-nvmf-hpe.rules.in} | 0 - 2 files changed, 1 insertion(+), 1 deletion(-) - rename nvmf-autoconnect/udev-rules/{71-nvme-hpe.rules.in => 71-nvmf-hpe.rules.in} (100%) - -diff --git a/meson.build b/meson.build -index 1d57748605..3afd8ba3b1 100644 ---- a/meson.build -+++ b/meson.build -@@ -267,7 +267,7 @@ udev_files = [ - '65-persistent-net-nbft.rules', - '70-nvmf-autoconnect.rules', - '70-nvmf-keys.rules', -- '71-nvme-hpe.rules', -+ '71-nvmf-hpe.rules', - '71-nvmf-netapp.rules', - '71-nvmf-vastdata.rules', - ] -diff --git a/nvmf-autoconnect/udev-rules/71-nvme-hpe.rules.in b/nvmf-autoconnect/udev-rules/71-nvmf-hpe.rules.in -similarity index 100% -rename from nvmf-autoconnect/udev-rules/71-nvme-hpe.rules.in -rename to nvmf-autoconnect/udev-rules/71-nvmf-hpe.rules.in diff --git a/nvme-cli.spec b/nvme-cli.spec index 0e6abd1..5fa7a3a 100644 --- a/nvme-cli.spec +++ b/nvme-cli.spec @@ -4,8 +4,8 @@ %global nmlibdir %{_prefix}/lib/NetworkManager Name: nvme-cli -Version: 2.15 -Release: 2%{?dist} +Version: 2.16 +Release: 1%{?dist} Summary: NVMe management command line interface License: GPL-2.0-only @@ -14,11 +14,6 @@ Source0: %{url}/archive/v%{version_no_tilde}/%{name}-%{version_no_tilde}. Source1: 99-nvme-nbft-connect.sh Source2: 99-nvme-nbft-no-ignore-carrier.conf -# https://github.com/linux-nvme/nvme-cli/issues/2886 -Patch0: nvme-cli-2.16-nvme_list_JSON_regression.patch -# https://github.com/linux-nvme/nvme-cli/pull/2880 -Patch1: nvme-cli-2.16-rename_71-nvme-hpe.rules.patch - BuildRequires: meson >= 0.53 BuildRequires: gcc gcc-c++ BuildRequires: systemd-devel @@ -29,7 +24,7 @@ BuildRequires: openssl-devel BuildRequires: kernel-headers %endif -BuildRequires: libnvme-devel >= 1.15 +BuildRequires: libnvme-devel >= 1.16.1 BuildRequires: json-c-devel >= 0.14 BuildRequires: asciidoc @@ -124,6 +119,9 @@ fi %changelog +* Thu Dec 04 2025 Tomas Bzatek - 2.16-1 +- Update to 2.16 + * Fri Aug 15 2025 Tomas Bzatek - 2.15-2 - Fix nvme-list JSON output compatibility - Rename 71-nvme-hpe.rules to 71-nvmf-hpe.rules diff --git a/sources b/sources index 9336ddd..e58ea56 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (nvme-cli-2.15.tar.gz) = 6f4c9fe52883df5424ba28d8b66b00e61f4b6f7226d7385f026c1d3b8aeb473bdf637102d9cf7e049349c4f7e61eccbb33f7400cc09056f74be03a80b7d51c0d +SHA512 (nvme-cli-2.16.tar.gz) = 507018ff41832574bef5b88ea6a17336b9792c54f8e5c619d041bce23124e1d6d5e5e824407f46d4f1b4d6899125885eb14289f3399e61c7e7a59a603f1635e2