Skip to content

Commit 9418ec5

Browse files
committed
protocol: Diagnose extra use of NBD_OPT_STRUCTURED_REPLY
The NBD spec states that when dealing with redundant NBD_OPT_STRUCTURED_REPLY, "the server MAY fail the repeated message with NBD_REP_ERR_INVALID". Although this is not mandatory, it is the behavior qemu-nbd uses. To date, it's mostly academic: existing clients don't send redundant requests without one-off hacks. But an upcoming patch to add a new API nbd_opt_structured_reply() to libnbd will make it easier to trigger the scenario, at which point diagnosing the redundancy is a nicer default.
1 parent 9f0226e commit 9418ec5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

server/protocol-handshake-newstyle.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,14 @@ negotiate_handshake_newstyle_options (void)
742742
break;
743743
}
744744

745+
if (conn->structured_replies) {
746+
if (send_newstyle_option_reply (option, NBD_REP_ERR_INVALID) == -1)
747+
return -1;
748+
debug ("newstyle negotiation: %s: structured replies already in use",
749+
name_of_nbd_opt (option));
750+
break;
751+
}
752+
745753
if (send_newstyle_option_reply (option, NBD_REP_ACK) == -1)
746754
return -1;
747755

0 commit comments

Comments
 (0)