Ensure all options have option length
authorAlex Bligh <alex@alex.org.uk>
Mon, 16 May 2011 09:35:07 +0000 (10:35 +0100)
committerWouter Verhelst <w@uter.be>
Mon, 16 May 2011 11:59:42 +0000 (13:59 +0200)
This is a documentation only patch to the new handshake protocol, but
changes the protocol in completely back compatible manner.

Under the current handshake protocol, it is impliedly necessary for the
server to understand every option presented by the client, as there is
no way for the server to skip options it does not understand (as the
length field is not always part of the option).

My proposal is to include the length field as a 32 bit unsigned length
in the same way that it currently forms the first 4 octets of the
NBD_OPT_EXPORT_NAME. So the length field has technically moved out
of the option data and into the option header (obviously there is
no code change required). This will allow servers to skip options
presented by clients that the server does not understand.

--
Alex Bligh

Signed-off-by: Alex Bligh <alex@alex.org.uk>

doc/proto.txt

index aa247af..fe5e819 100644 (file)
@@ -107,14 +107,17 @@ The generic format of setting an option is as follows:
 C: 0x49484156454F5054 (note same new-style handshake's magic number)
 C: 32 bits denoting the chosen option (NBD_OPT_EXPORT_NAME is the only
    possible value currently)
+C: unsigned 32 bit length of option data
 C: (any data needed for the chosen option)
 S: (any response as needed and defined by the chosen option; currently
    this does not happen).
 
+The presence of the option length in every option allows the server
+to skip any options presented by the client that it does not
+understand.
+
 The data needed for the NBD_OPT_EXPORT_NAME option is:
 
-C: unsigned 32 bit length (denotes the length of the name used, not
-   including any terminating NUL byte)
 C: name of the export (character string of length as specified,
    not terminated by any NUL bytes or similar)