From 9281cbf8c0d9f763b9bfe99938b0bc24694c2128 Mon Sep 17 00:00:00 2001 From: Alex Bligh Date: Mon, 16 May 2011 10:35:07 +0100 Subject: [PATCH] Ensure all options have option length 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 --- doc/proto.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/proto.txt b/doc/proto.txt index aa247af..fe5e819 100644 --- a/doc/proto.txt +++ b/doc/proto.txt @@ -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) -- 1.7.10.4