diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-30 22:36:07 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-30 22:36:07 +0000 |
commit | 97e3d220503a676acd81839dea289f4e700d8bd8 (patch) | |
tree | 69791901e1ca15319c5c63ffb52fe9cc686f8bee /test/nbft | |
parent | Adding upstream version 1.4. (diff) | |
download | libnvme-97e3d220503a676acd81839dea289f4e700d8bd8.tar.xz libnvme-97e3d220503a676acd81839dea289f4e700d8bd8.zip |
Adding upstream version 1.5.upstream/1.5
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
21 files changed, 517 insertions, 0 deletions
diff --git a/test/nbft/README b/test/nbft/README new file mode 100644 index 0000000..0f252a5 --- /dev/null +++ b/test/nbft/README @@ -0,0 +1,17 @@ +This is a simple testcase to verify the NBFT parser output over a set +of provided ACPI NBFT tables. + +The 'nbft-dump' test utility is a simple tool to print out all elements +and nested arrays of the nbft_info structs, bearing only minimal logic. + +The 'tables' directory contains sample binary files taken from +/sys/firmware/acpi/tables. The 'tables_bad' then contains experiments, older +table revisions or malformed data to test the parser error path. + +The "diffs" directory contains reference output generated by the 'nbft-dump' +utility that is being compared against actual testcase run output. Everytime +'nbft-dump.c' is modified these reference output files need to be regenerated +by calling `ninja -C .build nbft-diffs` over the configured meson project. + +The tests are typically ran as part of the standard `meson test -C .build` +invocation. diff --git a/test/nbft/diffs/NBFT-auto-ipv6 b/test/nbft/diffs/NBFT-auto-ipv6 new file mode 100644 index 0000000..32a8b60 --- /dev/null +++ b/test/nbft/diffs/NBFT-auto-ipv6 @@ -0,0 +1,39 @@ +raw_nbft_size=721 +host.id=1ee8b170eb4c864fb7957d179e201a +host.nqn=nqn.2014-08.org.nvmexpress:uuid:70b1e81e-4ceb-4f86-b709-57d1079e201a +host.host_id_configured=1 +host.host_nqn_configured=1 +host.primary=0 +hfi_list[0]->index=1 +hfi_list[0]->transport=tcp +hfi_list[0]->tcp_info.pci_sbdf=512 +hfi_list[0]->tcp_info.mac_addr=525409e201a +hfi_list[0]->tcp_info.vlan=0 +hfi_list[0]->tcp_info.ip_origin=1 +hfi_list[0]->tcp_info.ipaddr=fd09:9a46:b5c1:1ff:5054:ff:fe9e:201a +hfi_list[0]->tcp_info.subnet_mask_prefix=64 +hfi_list[0]->tcp_info.gateway_ipaddr=:: +hfi_list[0]->tcp_info.route_metric=0 +hfi_list[0]->tcp_info.primary_dns_ipaddr=:: +hfi_list[0]->tcp_info.secondary_dns_ipaddr=:: +hfi_list[0]->tcp_info.dhcp_server_ipaddr= +hfi_list[0]->tcp_info.host_name=nvmepoc-sles15-sp5 +hfi_list[0]->tcp_info.this_hfi_is_default_route=1 +hfi_list[0]->tcp_info.dhcp_override=0 +subsystem_ns_list[0]->index=1 +subsystem_ns_list[0]->num_hfis=1 +subsystem_ns_list[0]->hfis[0]->index=1 +subsystem_ns_list[0]->hfis[1]->index=1 +subsystem_ns_list[0]->transport=tcp +subsystem_ns_list[0]->traddr=fd09:9a46:b5c1:1ff:5054:ff:fefd:9e66 +subsystem_ns_list[0]->trsvcid=4420 +subsystem_ns_list[0]->subsys_port_id=0 +subsystem_ns_list[0]->nsid=1 +subsystem_ns_list[0]->nid_type=3 +subsystem_ns_list[0]->nid=848f4dc06d394968bf180569b8eea97 +subsystem_ns_list[0]->subsys_nqn=nqn.2022-12.de.suse.mwilck:zeus.vagrant-nvmet.subsys04 +subsystem_ns_list[0]->pdu_header_digest_required=0 +subsystem_ns_list[0]->data_digest_required=0 +subsystem_ns_list[0]->controller_id=1 +subsystem_ns_list[0]->asqsz=0 +subsystem_ns_list[0]->dhcp_root_path_string=(null) diff --git a/test/nbft/diffs/NBFT-dhcp-ipv4 b/test/nbft/diffs/NBFT-dhcp-ipv4 new file mode 100644 index 0000000..cb280d9 --- /dev/null +++ b/test/nbft/diffs/NBFT-dhcp-ipv4 @@ -0,0 +1,44 @@ +raw_nbft_size=825 +host.id=e359b7a15d37747b3cc1754b8b819b9 +host.nqn=nqn.2014-08.org.nvmexpress:uuid:a1b759e3-035d-4777-b3cc-1754b8b819b9 +host.host_id_configured=1 +host.host_nqn_configured=1 +host.primary=0 +hfi_list[0]->index=1 +hfi_list[0]->transport=tcp +hfi_list[0]->tcp_info.pci_sbdf=8 +hfi_list[0]->tcp_info.mac_addr=52540b819b9 +hfi_list[0]->tcp_info.vlan=0 +hfi_list[0]->tcp_info.ip_origin=3 +hfi_list[0]->tcp_info.ipaddr=192.168.49.155 +hfi_list[0]->tcp_info.subnet_mask_prefix=24 +hfi_list[0]->tcp_info.gateway_ipaddr=0.0.0.0 +hfi_list[0]->tcp_info.route_metric=0 +hfi_list[0]->tcp_info.primary_dns_ipaddr=192.168.49.1 +hfi_list[0]->tcp_info.secondary_dns_ipaddr=0.0.0.0 +hfi_list[0]->tcp_info.dhcp_server_ipaddr=192.168.49.1 +hfi_list[0]->tcp_info.host_name=nvmeof-sles +hfi_list[0]->tcp_info.this_hfi_is_default_route=1 +hfi_list[0]->tcp_info.dhcp_override=1 +discovery_list[0]->index=1 +discovery_list[0]->hfi->index=1 +discovery_list[0]->uri=nvme+tcp://192.168.49.10:4420/ +discovery_list[0]->nqn=nqn.2014-08.org.nvmexpress.discovery +subsystem_ns_list[0]->index=1 +subsystem_ns_list[0]->discovery->index=1 +subsystem_ns_list[0]->num_hfis=1 +subsystem_ns_list[0]->hfis[0]->index=1 +subsystem_ns_list[0]->hfis[1]->index=1 +subsystem_ns_list[0]->transport=tcp +subsystem_ns_list[0]->traddr=192.168.49.10 +subsystem_ns_list[0]->trsvcid=4420 +subsystem_ns_list[0]->subsys_port_id=0 +subsystem_ns_list[0]->nsid=1 +subsystem_ns_list[0]->nid_type=3 +subsystem_ns_list[0]->nid=df669a88bd6f4dd68a505f97eb55c835 +subsystem_ns_list[0]->subsys_nqn=nqn.2022-12.org.nvmexpress.boot.poc:bremer.vagrant-nvmet.subsys02 +subsystem_ns_list[0]->pdu_header_digest_required=0 +subsystem_ns_list[0]->data_digest_required=0 +subsystem_ns_list[0]->controller_id=7 +subsystem_ns_list[0]->asqsz=0 +subsystem_ns_list[0]->dhcp_root_path_string=(null) diff --git a/test/nbft/diffs/NBFT-dhcp-ipv6 b/test/nbft/diffs/NBFT-dhcp-ipv6 new file mode 100644 index 0000000..b94cc39 --- /dev/null +++ b/test/nbft/diffs/NBFT-dhcp-ipv6 @@ -0,0 +1,39 @@ +raw_nbft_size=725 +host.id=e359b7a15d37747b3cc1754b8b819b9 +host.nqn=nqn.2014-08.org.nvmexpress:uuid:a1b759e3-035d-4777-b3cc-1754b8b819b9 +host.host_id_configured=1 +host.host_nqn_configured=1 +host.primary=0 +hfi_list[0]->index=1 +hfi_list[0]->transport=tcp +hfi_list[0]->tcp_info.pci_sbdf=8 +hfi_list[0]->tcp_info.mac_addr=52540b819b9 +hfi_list[0]->tcp_info.vlan=0 +hfi_list[0]->tcp_info.ip_origin=3 +hfi_list[0]->tcp_info.ipaddr=fddf:d:f:49::eb +hfi_list[0]->tcp_info.subnet_mask_prefix=64 +hfi_list[0]->tcp_info.gateway_ipaddr=:: +hfi_list[0]->tcp_info.route_metric=0 +hfi_list[0]->tcp_info.primary_dns_ipaddr=:: +hfi_list[0]->tcp_info.secondary_dns_ipaddr=:: +hfi_list[0]->tcp_info.dhcp_server_ipaddr=:: +hfi_list[0]->tcp_info.host_name=nvmeof-sles +hfi_list[0]->tcp_info.this_hfi_is_default_route=1 +hfi_list[0]->tcp_info.dhcp_override=1 +subsystem_ns_list[0]->index=1 +subsystem_ns_list[0]->num_hfis=1 +subsystem_ns_list[0]->hfis[0]->index=1 +subsystem_ns_list[0]->hfis[1]->index=1 +subsystem_ns_list[0]->transport=tcp +subsystem_ns_list[0]->traddr=fddf:d:f:49::10 +subsystem_ns_list[0]->trsvcid=4420 +subsystem_ns_list[0]->subsys_port_id=0 +subsystem_ns_list[0]->nsid=1 +subsystem_ns_list[0]->nid_type=3 +subsystem_ns_list[0]->nid=df669a88bd6f4dd68a505f97eb55c835 +subsystem_ns_list[0]->subsys_nqn=nqn.2022-12.org.nvmexpress.boot.poc:bremer.vagrant-nvmet.subsys02 +subsystem_ns_list[0]->pdu_header_digest_required=0 +subsystem_ns_list[0]->data_digest_required=0 +subsystem_ns_list[0]->controller_id=34 +subsystem_ns_list[0]->asqsz=0 +subsystem_ns_list[0]->dhcp_root_path_string=(null) diff --git a/test/nbft/diffs/NBFT-rhpoc b/test/nbft/diffs/NBFT-rhpoc new file mode 100644 index 0000000..d4b4ad8 --- /dev/null +++ b/test/nbft/diffs/NBFT-rhpoc @@ -0,0 +1,39 @@ +raw_nbft_size=724 +host.id=b4bb164e7f9be448c7f77d8b4fc9f39 +host.nqn=nqn.2014-08.org.nvmexpress:uuid:f8131bac-cdef-4165-866b-5998c1e67890 +host.host_id_configured=1 +host.host_nqn_configured=1 +host.primary=0 +hfi_list[0]->index=1 +hfi_list[0]->transport=tcp +hfi_list[0]->tcp_info.pci_sbdf=40 +hfi_list[0]->tcp_info.mac_addr=eaebd3588958 +hfi_list[0]->tcp_info.vlan=0 +hfi_list[0]->tcp_info.ip_origin=1 +hfi_list[0]->tcp_info.ipaddr=192.168.101.30 +hfi_list[0]->tcp_info.subnet_mask_prefix=24 +hfi_list[0]->tcp_info.gateway_ipaddr=0.0.0.0 +hfi_list[0]->tcp_info.route_metric=0 +hfi_list[0]->tcp_info.primary_dns_ipaddr=0.0.0.0 +hfi_list[0]->tcp_info.secondary_dns_ipaddr=0.0.0.0 +hfi_list[0]->tcp_info.dhcp_server_ipaddr= +hfi_list[0]->tcp_info.host_name=host-vm +hfi_list[0]->tcp_info.this_hfi_is_default_route=1 +hfi_list[0]->tcp_info.dhcp_override=0 +subsystem_ns_list[0]->index=1 +subsystem_ns_list[0]->num_hfis=1 +subsystem_ns_list[0]->hfis[0]->index=1 +subsystem_ns_list[0]->hfis[1]->index=1 +subsystem_ns_list[0]->transport=tcp +subsystem_ns_list[0]->traddr=192.168.101.20 +subsystem_ns_list[0]->trsvcid=4420 +subsystem_ns_list[0]->subsys_port_id=0 +subsystem_ns_list[0]->nsid=1 +subsystem_ns_list[0]->nid_type=3 +subsystem_ns_list[0]->nid=bee9c2b7176144b5a4e6f69498a94b +subsystem_ns_list[0]->subsys_nqn=nqn.2014-08.org.nvmexpress:uuid:0c468c4d-a385-47e0-8299-6e95051277db +subsystem_ns_list[0]->pdu_header_digest_required=0 +subsystem_ns_list[0]->data_digest_required=0 +subsystem_ns_list[0]->controller_id=12 +subsystem_ns_list[0]->asqsz=0 +subsystem_ns_list[0]->dhcp_root_path_string=(null) diff --git a/test/nbft/diffs/NBFT-static-ipv4 b/test/nbft/diffs/NBFT-static-ipv4 new file mode 100644 index 0000000..715b30d --- /dev/null +++ b/test/nbft/diffs/NBFT-static-ipv4 @@ -0,0 +1,39 @@ +raw_nbft_size=725 +host.id=e359b7a15d37747b3cc1754b8b819b9 +host.nqn=nqn.2014-08.org.nvmexpress:uuid:a1b759e3-035d-4777-b3cc-1754b8b819b9 +host.host_id_configured=1 +host.host_nqn_configured=1 +host.primary=0 +hfi_list[0]->index=1 +hfi_list[0]->transport=tcp +hfi_list[0]->tcp_info.pci_sbdf=8 +hfi_list[0]->tcp_info.mac_addr=52540b819b9 +hfi_list[0]->tcp_info.vlan=0 +hfi_list[0]->tcp_info.ip_origin=1 +hfi_list[0]->tcp_info.ipaddr=192.168.49.50 +hfi_list[0]->tcp_info.subnet_mask_prefix=24 +hfi_list[0]->tcp_info.gateway_ipaddr=0.0.0.0 +hfi_list[0]->tcp_info.route_metric=0 +hfi_list[0]->tcp_info.primary_dns_ipaddr=0.0.0.0 +hfi_list[0]->tcp_info.secondary_dns_ipaddr=0.0.0.0 +hfi_list[0]->tcp_info.dhcp_server_ipaddr= +hfi_list[0]->tcp_info.host_name=nvmeof-sles +hfi_list[0]->tcp_info.this_hfi_is_default_route=1 +hfi_list[0]->tcp_info.dhcp_override=0 +subsystem_ns_list[0]->index=1 +subsystem_ns_list[0]->num_hfis=1 +subsystem_ns_list[0]->hfis[0]->index=1 +subsystem_ns_list[0]->hfis[1]->index=1 +subsystem_ns_list[0]->transport=tcp +subsystem_ns_list[0]->traddr=192.168.49.10 +subsystem_ns_list[0]->trsvcid=4420 +subsystem_ns_list[0]->subsys_port_id=0 +subsystem_ns_list[0]->nsid=1 +subsystem_ns_list[0]->nid_type=3 +subsystem_ns_list[0]->nid=df669a88bd6f4dd68a505f97eb55c835 +subsystem_ns_list[0]->subsys_nqn=nqn.2022-12.org.nvmexpress.boot.poc:bremer.vagrant-nvmet.subsys02 +subsystem_ns_list[0]->pdu_header_digest_required=0 +subsystem_ns_list[0]->data_digest_required=0 +subsystem_ns_list[0]->controller_id=38 +subsystem_ns_list[0]->asqsz=0 +subsystem_ns_list[0]->dhcp_root_path_string=(null) diff --git a/test/nbft/diffs/NBFT-static-ipv4-discovery b/test/nbft/diffs/NBFT-static-ipv4-discovery new file mode 100644 index 0000000..67881b6 --- /dev/null +++ b/test/nbft/diffs/NBFT-static-ipv4-discovery @@ -0,0 +1,44 @@ +raw_nbft_size=825 +host.id=e359b7a15d37747b3cc1754b8b819b9 +host.nqn=nqn.2014-08.org.nvmexpress:uuid:a1b759e3-035d-4777-b3cc-1754b8b819b9 +host.host_id_configured=1 +host.host_nqn_configured=1 +host.primary=0 +hfi_list[0]->index=1 +hfi_list[0]->transport=tcp +hfi_list[0]->tcp_info.pci_sbdf=8 +hfi_list[0]->tcp_info.mac_addr=52540b819b9 +hfi_list[0]->tcp_info.vlan=0 +hfi_list[0]->tcp_info.ip_origin=1 +hfi_list[0]->tcp_info.ipaddr=192.168.49.50 +hfi_list[0]->tcp_info.subnet_mask_prefix=24 +hfi_list[0]->tcp_info.gateway_ipaddr=0.0.0.0 +hfi_list[0]->tcp_info.route_metric=0 +hfi_list[0]->tcp_info.primary_dns_ipaddr=0.0.0.0 +hfi_list[0]->tcp_info.secondary_dns_ipaddr=0.0.0.0 +hfi_list[0]->tcp_info.dhcp_server_ipaddr= +hfi_list[0]->tcp_info.host_name=nvmeof-sles +hfi_list[0]->tcp_info.this_hfi_is_default_route=1 +hfi_list[0]->tcp_info.dhcp_override=0 +discovery_list[0]->index=1 +discovery_list[0]->hfi->index=1 +discovery_list[0]->uri=nvme+tcp://192.168.49.10:4420/ +discovery_list[0]->nqn=nqn.2014-08.org.nvmexpress.discovery +subsystem_ns_list[0]->index=1 +subsystem_ns_list[0]->discovery->index=1 +subsystem_ns_list[0]->num_hfis=1 +subsystem_ns_list[0]->hfis[0]->index=1 +subsystem_ns_list[0]->hfis[1]->index=1 +subsystem_ns_list[0]->transport=tcp +subsystem_ns_list[0]->traddr=192.168.49.10 +subsystem_ns_list[0]->trsvcid=4420 +subsystem_ns_list[0]->subsys_port_id=0 +subsystem_ns_list[0]->nsid=1 +subsystem_ns_list[0]->nid_type=3 +subsystem_ns_list[0]->nid=df669a88bd6f4dd68a505f97eb55c835 +subsystem_ns_list[0]->subsys_nqn=nqn.2022-12.org.nvmexpress.boot.poc:bremer.vagrant-nvmet.subsys02 +subsystem_ns_list[0]->pdu_header_digest_required=0 +subsystem_ns_list[0]->data_digest_required=0 +subsystem_ns_list[0]->controller_id=13 +subsystem_ns_list[0]->asqsz=0 +subsystem_ns_list[0]->dhcp_root_path_string=(null) diff --git a/test/nbft/diffs/NBFT-static-ipv6 b/test/nbft/diffs/NBFT-static-ipv6 new file mode 100644 index 0000000..a5b02c1 --- /dev/null +++ b/test/nbft/diffs/NBFT-static-ipv6 @@ -0,0 +1,39 @@ +raw_nbft_size=721 +host.id=1ee8b170eb4c864fb7957d179e201a +host.nqn=nqn.2014-08.org.nvmexpress:uuid:70b1e81e-4ceb-4f86-b709-57d1079e201a +host.host_id_configured=1 +host.host_nqn_configured=1 +host.primary=0 +hfi_list[0]->index=1 +hfi_list[0]->transport=tcp +hfi_list[0]->tcp_info.pci_sbdf=512 +hfi_list[0]->tcp_info.mac_addr=525409e201a +hfi_list[0]->tcp_info.vlan=0 +hfi_list[0]->tcp_info.ip_origin=1 +hfi_list[0]->tcp_info.ipaddr=fd09:9a46:b5c1:1fe::10 +hfi_list[0]->tcp_info.subnet_mask_prefix=64 +hfi_list[0]->tcp_info.gateway_ipaddr=:: +hfi_list[0]->tcp_info.route_metric=0 +hfi_list[0]->tcp_info.primary_dns_ipaddr=:: +hfi_list[0]->tcp_info.secondary_dns_ipaddr=:: +hfi_list[0]->tcp_info.dhcp_server_ipaddr= +hfi_list[0]->tcp_info.host_name=nvmepoc-sles15-sp5 +hfi_list[0]->tcp_info.this_hfi_is_default_route=1 +hfi_list[0]->tcp_info.dhcp_override=0 +subsystem_ns_list[0]->index=1 +subsystem_ns_list[0]->num_hfis=1 +subsystem_ns_list[0]->hfis[0]->index=1 +subsystem_ns_list[0]->hfis[1]->index=1 +subsystem_ns_list[0]->transport=tcp +subsystem_ns_list[0]->traddr=fd09:9a46:b5c1:1fe::13f +subsystem_ns_list[0]->trsvcid=4420 +subsystem_ns_list[0]->subsys_port_id=0 +subsystem_ns_list[0]->nsid=1 +subsystem_ns_list[0]->nid_type=3 +subsystem_ns_list[0]->nid=aab2c3c8444c47c599f23632e6364528 +subsystem_ns_list[0]->subsys_nqn=nqn.2022-12.de.suse.mwilck:zeus.vagrant-nvmet.subsys04 +subsystem_ns_list[0]->pdu_header_digest_required=0 +subsystem_ns_list[0]->data_digest_required=0 +subsystem_ns_list[0]->controller_id=9 +subsystem_ns_list[0]->asqsz=0 +subsystem_ns_list[0]->dhcp_root_path_string=(null) diff --git a/test/nbft/gen-nbft-diffs.sh.in b/test/nbft/gen-nbft-diffs.sh.in new file mode 100755 index 0000000..8b0b982 --- /dev/null +++ b/test/nbft/gen-nbft-diffs.sh.in @@ -0,0 +1,5 @@ +#!/bin/sh + +for T in "@TABLES_DIR@"/*; do + "@NBFT_DUMP_PATH@" "$T" > "@DIFF_DIR@/`basename $T`" +done diff --git a/test/nbft/meson.build b/test/nbft/meson.build new file mode 100644 index 0000000..67b2d95 --- /dev/null +++ b/test/nbft/meson.build @@ -0,0 +1,83 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# This file is part of libnvme. +# Copyright (c) 2023 Red Hat Inc. +# +# Authors: Tomas Bzatek <tbzatek@redhat.com> + +# NBFT parser tests over supplied NBFT ACPI table dumps + +tables_dir = 'tables' +tables_bad_dir = 'tables_bad' +diff_dir = 'diffs' + +tables = [ + 'NBFT-auto-ipv6', + 'NBFT-dhcp-ipv6', + 'NBFT-rhpoc', + 'NBFT-static-ipv4', + 'NBFT-static-ipv4-discovery', + 'NBFT-static-ipv6', +] + +tables_bad = [ + 'NBFT-bad-oldspec', + 'NBFT-random-noise', +] + +nbft_dump = executable( + 'nbft-dump', + ['nbft-dump.c'], + dependencies: libnvme_dep, + include_directories: [incdir, internal_incdir] +) + + +helper_data = configuration_data() +helper_data.set('NBFT_DUMP_PATH', nbft_dump.full_path()) +helper_data.set('TABLES_DIR', meson.current_source_dir()/tables_dir) +helper_data.set('DIFF_DIR', meson.current_source_dir()/diff_dir) + +dump_helper = configure_file( + input: 'nbft-dump-diff.sh.in', + output: '@BASENAME@', + configuration: helper_data +) + +gen_diffs_helper = configure_file( + input: 'gen-nbft-diffs.sh.in', + output: '@BASENAME@', + configuration: helper_data +) + + +run_target( + 'nbft-diffs', + depends: nbft_dump, + command: [gen_diffs_helper] +) + + +diffcmd = find_program( + 'diff', + required: false +) +if diffcmd.found() + foreach table: tables + test( + table, + dump_helper, + args: [files(tables_dir/table), + files(diff_dir/table)] + ) + endforeach +endif + +foreach table: tables_bad + test( + table, + nbft_dump, + args: [files(tables_bad_dir/table)], + should_fail: true + ) +endforeach diff --git a/test/nbft/nbft-dump-diff.sh.in b/test/nbft/nbft-dump-diff.sh.in new file mode 100755 index 0000000..f697bce --- /dev/null +++ b/test/nbft/nbft-dump-diff.sh.in @@ -0,0 +1,8 @@ +#!/bin/sh + +if [ $# -ne 2 ]; then + echo "Usage: $0 TABLE DIFF" >&2 + exit 255 +fi + +"@NBFT_DUMP_PATH@" "$1" | diff --unified "$2" - diff --git a/test/nbft/nbft-dump.c b/test/nbft/nbft-dump.c new file mode 100644 index 0000000..3ff5efa --- /dev/null +++ b/test/nbft/nbft-dump.c @@ -0,0 +1,121 @@ +// SPDX-License-Identifier: LGPL-2.1-or-later +/** + * This file is part of libnvme. + * Copyright (c) 2023 Red Hat Inc. + */ + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <inttypes.h> +#include "libnvme.h" + +static void print_hex(unsigned char *buf, int len) +{ + int i; + + for (i = 0; i < len; i++, buf++) + printf("%x", *buf); +} + +static void print_nbft(struct nbft_info *table) +{ + unsigned int i, j; + struct nbft_info_hfi **hfi; + struct nbft_info_security **sec; + struct nbft_info_discovery **disc; + struct nbft_info_subsystem_ns **ssns; + + printf("raw_nbft_size=%zd\n", table->raw_nbft_size); + + printf("host.id="); + print_hex(table->host.id, NVME_UUID_LEN); + printf("\n"); + printf("host.nqn=%s\n", table->host.nqn); + printf("host.host_id_configured=%d\n", table->host.host_id_configured); + printf("host.host_nqn_configured=%d\n", table->host.host_nqn_configured); + printf("host.primary=%d\n", table->host.primary); + + for (hfi = table->hfi_list, i = 0; hfi && *hfi; hfi++, i++) { + printf("hfi_list[%u]->index=%d\n", i, (*hfi)->index); + printf("hfi_list[%u]->transport=%.*s\n", i, (int)sizeof((*hfi)->transport), (*hfi)->transport); + printf("hfi_list[%u]->tcp_info.pci_sbdf=%"PRIu32"\n", i, (*hfi)->tcp_info.pci_sbdf); + printf("hfi_list[%u]->tcp_info.mac_addr=", i); + print_hex((*hfi)->tcp_info.mac_addr, sizeof((*hfi)->tcp_info.mac_addr)); + printf("\n"); + printf("hfi_list[%u]->tcp_info.vlan=%"PRIu16"\n", i, (*hfi)->tcp_info.vlan); + printf("hfi_list[%u]->tcp_info.ip_origin=%u\n", i, (*hfi)->tcp_info.ip_origin); + printf("hfi_list[%u]->tcp_info.ipaddr=%s\n", i, (*hfi)->tcp_info.ipaddr); + printf("hfi_list[%u]->tcp_info.subnet_mask_prefix=%u\n", i, (*hfi)->tcp_info.subnet_mask_prefix); + printf("hfi_list[%u]->tcp_info.gateway_ipaddr=%s\n", i, (*hfi)->tcp_info.gateway_ipaddr); + printf("hfi_list[%u]->tcp_info.route_metric=%"PRIu16"\n", i, (*hfi)->tcp_info.route_metric); + printf("hfi_list[%u]->tcp_info.primary_dns_ipaddr=%s\n", i, (*hfi)->tcp_info.primary_dns_ipaddr); + printf("hfi_list[%u]->tcp_info.secondary_dns_ipaddr=%s\n", i, (*hfi)->tcp_info.secondary_dns_ipaddr); + printf("hfi_list[%u]->tcp_info.dhcp_server_ipaddr=%s\n", i, (*hfi)->tcp_info.dhcp_server_ipaddr); + printf("hfi_list[%u]->tcp_info.host_name=%s\n", i, (*hfi)->tcp_info.host_name); + printf("hfi_list[%u]->tcp_info.this_hfi_is_default_route=%d\n", i, (*hfi)->tcp_info.this_hfi_is_default_route); + printf("hfi_list[%u]->tcp_info.dhcp_override=%d\n", i, (*hfi)->tcp_info.dhcp_override); + } + + for (sec = table->security_list, i = 0; sec && *sec; sec++, i++) { + printf("security_list[%u]->index=%d\n", i, (*sec)->index); + } + + for (disc = table->discovery_list, i = 0; disc && *disc; disc++, i++) { + printf("discovery_list[%u]->index=%d\n", i, (*disc)->index); + if ((*disc)->security) + printf("discovery_list[%u]->security->index=%d\n", i, (*disc)->security->index); + if ((*disc)->hfi) + printf("discovery_list[%u]->hfi->index=%d\n", i, (*disc)->hfi->index); + printf("discovery_list[%u]->uri=%s\n", i, (*disc)->uri); + printf("discovery_list[%u]->nqn=%s\n", i, (*disc)->nqn); + } + + for (ssns = table->subsystem_ns_list, i = 0; ssns && *ssns; ssns++, i++) { + printf("subsystem_ns_list[%u]->index=%d\n", i, (*ssns)->index); + if ((*ssns)->discovery) + printf("subsystem_ns_list[%u]->discovery->index=%d\n", i, (*ssns)->discovery->index); + if ((*ssns)->security) + printf("subsystem_ns_list[%u]->security->index=%d\n", i, (*ssns)->security->index); + printf("subsystem_ns_list[%u]->num_hfis=%d\n", i, (*ssns)->num_hfis); + for (hfi = (*ssns)->hfis, j = 0; hfi && *hfi; hfi++, j++) + printf("subsystem_ns_list[%u]->hfis[%u]->index=%d\n", i, j, (*hfi)->index); + printf("subsystem_ns_list[%u]->transport=%s\n", i, (*ssns)->transport); + printf("subsystem_ns_list[%u]->traddr=%s\n", i, (*ssns)->traddr); + printf("subsystem_ns_list[%u]->trsvcid=%s\n", i, (*ssns)->trsvcid); + printf("subsystem_ns_list[%u]->subsys_port_id=%"PRIu16"\n", i, (*ssns)->subsys_port_id); + printf("subsystem_ns_list[%u]->nsid=%"PRIu32"\n", i, (*ssns)->nsid); + printf("subsystem_ns_list[%u]->nid_type=%d\n", i, (*ssns)->nid_type); + printf("subsystem_ns_list[%u]->nid=", i); + print_hex((*ssns)->nid, 16); + printf("\n"); + printf("subsystem_ns_list[%u]->subsys_nqn=%s\n", i, (*ssns)->subsys_nqn); + printf("subsystem_ns_list[%u]->pdu_header_digest_required=%d\n", i, (*ssns)->pdu_header_digest_required); + printf("subsystem_ns_list[%u]->data_digest_required=%d\n", i, (*ssns)->data_digest_required); + printf("subsystem_ns_list[%u]->controller_id=%d\n", i, (*ssns)->controller_id); + printf("subsystem_ns_list[%u]->asqsz=%d\n", i, (*ssns)->asqsz); + printf("subsystem_ns_list[%u]->dhcp_root_path_string=%s\n", i, (*ssns)->dhcp_root_path_string); + } +} + +int main(int argc, char **argv) +{ + struct nbft_info *table = NULL; + + if (argc < 2) { + fprintf(stderr, "Usage: %s TABLE\n", argv[0]); + return 1; + } + + if (nvme_nbft_read(&table, argv[1]) != 0) { + fprintf(stderr, "Error parsing the NBFT table %s: %m\n", + argv[1]); + return 2; + } + + print_nbft(table); + + nvme_nbft_free(table); + return 0; +} diff --git a/test/nbft/tables/NBFT-auto-ipv6 b/test/nbft/tables/NBFT-auto-ipv6 Binary files differnew file mode 100644 index 0000000..64457d7 --- /dev/null +++ b/test/nbft/tables/NBFT-auto-ipv6 diff --git a/test/nbft/tables/NBFT-dhcp-ipv4 b/test/nbft/tables/NBFT-dhcp-ipv4 Binary files differnew file mode 100644 index 0000000..1af159d --- /dev/null +++ b/test/nbft/tables/NBFT-dhcp-ipv4 diff --git a/test/nbft/tables/NBFT-dhcp-ipv6 b/test/nbft/tables/NBFT-dhcp-ipv6 Binary files differnew file mode 100644 index 0000000..20715ee --- /dev/null +++ b/test/nbft/tables/NBFT-dhcp-ipv6 diff --git a/test/nbft/tables/NBFT-rhpoc b/test/nbft/tables/NBFT-rhpoc Binary files differnew file mode 100644 index 0000000..5d0a6cc --- /dev/null +++ b/test/nbft/tables/NBFT-rhpoc diff --git a/test/nbft/tables/NBFT-static-ipv4 b/test/nbft/tables/NBFT-static-ipv4 Binary files differnew file mode 100644 index 0000000..bf3f840 --- /dev/null +++ b/test/nbft/tables/NBFT-static-ipv4 diff --git a/test/nbft/tables/NBFT-static-ipv4-discovery b/test/nbft/tables/NBFT-static-ipv4-discovery Binary files differnew file mode 100644 index 0000000..7ebb40e --- /dev/null +++ b/test/nbft/tables/NBFT-static-ipv4-discovery diff --git a/test/nbft/tables/NBFT-static-ipv6 b/test/nbft/tables/NBFT-static-ipv6 Binary files differnew file mode 100644 index 0000000..07b09cf --- /dev/null +++ b/test/nbft/tables/NBFT-static-ipv6 diff --git a/test/nbft/tables_bad/NBFT-bad-oldspec b/test/nbft/tables_bad/NBFT-bad-oldspec Binary files differnew file mode 100644 index 0000000..e09d6ad --- /dev/null +++ b/test/nbft/tables_bad/NBFT-bad-oldspec diff --git a/test/nbft/tables_bad/NBFT-random-noise b/test/nbft/tables_bad/NBFT-random-noise Binary files differnew file mode 100644 index 0000000..296bcfe --- /dev/null +++ b/test/nbft/tables_bad/NBFT-random-noise |