Commit 55b09667 in v1.15.3 made it possible for nbd_can_meta_context()
to return an error if it is called too early during handshaking, which
is useful when doing manual control via nbd_set_opt_mode for
integration testing. But it had the unfortunate side effect of
treating ALL server errors as unknown state for meta contexts. This
didn't matter for clients that never attempt meta context negotiation,
or for servers that don't support structured replies (nbd-server
3.24); but for servers with structured replies but not meta contexts
(nbd-server 3.25), it means we are now reporting an error about
failure to negotiate rather than silently treating the query as false.
And with this patch in place, the one-off hack to nbdkit mentioned in
that commit (when a server fails after partial success, rather than
immediately) still has the desired effect of an error in
nbd_can_meta_context.
The test for this fix is in a separate commit, to make it easier to
rearrange the patch series to demonstrate that the issue at hand can
also be worked around in client code.
Fiexs: 55b09667 ("api: Fix nbd_can_meta_context if NBD_OPT_SET_META_CONTEXT
fails", v1.15.3)
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
generator/states-newstyle-opt-meta-context.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/generator/states-newstyle-opt-meta-context.c
b/generator/states-newstyle-opt-meta-context.c
index 47e0fcd5..b62a7df0 100644
--- a/generator/states-newstyle-opt-meta-context.c
+++ b/generator/states-newstyle-opt-meta-context.c
@@ -281,6 +281,8 @@ NEWSTYLE.OPT_META_CONTEXT.CHECK_REPLY:
SET_NEXT_STATE (%.NEGOTIATING);
}
else {
+ if (opt == NBD_OPT_SET_META_CONTEXT && h->meta_contexts.len == 0)
+ h->meta_valid = true;
debug (h, "handshake: ignoring unexpected error from "
"NBD_OPT_SET_META_CONTEXT (%" PRIu32 ")", reply);
SET_NEXT_STATE (%^OPT_GO.START);
--
2.43.2
Show replies by date