Spdk/lib/nvmf
Jim Harris 9d0bd899ed nvmf: fix trid comparison for discovery subsystem entries
When generating a discovery log page, we will add entries
for the discovery subsystem for all listeners except the
one associated with the controller that generated the
log page command.  We do this comparison using
spdk_nvme_transport_id_compare().

But this function compares the subnqn of the trid, and
the subnqn is not set in either of the trids that we
are comparing.

The listener's trid always has an empty subnqn, but
the source trid has an uninitialized subnqn when
we do the comparison.  This means that sometimes the
subnqn may be empty (which always happens in debug
builds) but sometimes may contain garbage.  This
means that sometimes an entry would be added to the
log, even for the trid of the discovery controller
that generated the command (meaning the discovery
controller would end up referring to itself which
is not allowed).

There is an even more subtle issue with this.  If the
host reads just the log page header, the nvmf target
generates the entire log page, and just returns the
header contents.  Let's say in this case, the source
trid has an empty subnqn, so we don't generate an entry
for it, and report numrec = X and genctr = Y.  Then
the host reads the X log page entries.  But now the
source trid is garbage, so a discovery log page entry
is returned, replacing one of the "real" log page
entries.  And since genctr didn't change, the host
thinks the data is all valid, meaning there's a log
page entry for an NVM subsystem that ends up getting
dropped.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: I96cfc566ddaf17153aec089bf3d9b3480bec3e4b
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11933
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
2022-03-14 08:44:21 +00:00
..
ctrlr_bdev.c nvmf: make zcopy_end void 2022-01-06 18:53:42 +00:00
ctrlr_discovery.c nvmf: fix trid comparison for discovery subsystem entries 2022-03-14 08:44:21 +00:00
ctrlr.c nvmf: add internal set Controller Fatal Status API 2022-03-08 02:35:05 +00:00
fc_ls.c spelling: lib 2021-12-03 08:12:55 +00:00
fc.c nvmf/fc: call free() to the object allocated by calloc() 2022-02-28 11:08:16 +00:00
Makefile so_ver: increase all major versions 2022-01-31 15:29:56 +00:00
nvmf_fc.h spelling: lib 2021-12-03 08:12:55 +00:00
nvmf_internal.h nvmf: add internal set Controller Fatal Status API 2022-03-08 02:35:05 +00:00
nvmf_rpc.c nvmf: remove deprecated max_qpairs_per_ctrlr parameter 2022-02-15 14:38:37 +00:00
nvmf.c nvmf: pass poll group to transport during create 2022-02-23 10:05:15 +00:00
rdma.c nvmf/rdma: Fix overflow of RB tree comparison when qp_num is very big 2022-03-09 08:00:58 +00:00
spdk_nvmf.map lib/nvmf : Added support for ZCOPY 2021-07-23 08:34:43 +00:00
subsystem.c nvmf: deprecate automatic discovery listener 2022-02-28 11:06:16 +00:00
tcp.c nvmf: pass poll group to transport during create 2022-02-23 10:05:15 +00:00
transport.c nvmf: pass poll group to transport during create 2022-02-23 10:05:15 +00:00
transport.h nvmf: pass poll group to transport during create 2022-02-23 10:05:15 +00:00
vfio_user.c nvmf/vfio-user: correct vfu_run_ctx() handling 2022-03-08 03:33:42 +00:00