xapi-project / nbd

Ocaml NBD library
https://xapi-project.github.io/nbd/
Other
14 stars 16 forks source link

Client.list does not obey the protocol when terminating the session #102

Closed gaborigloi closed 6 years ago

gaborigloi commented 7 years ago

Since it does not return a value representing the NBD session, Client.list should terminate the session itself. However, it does that using a hard disconnect, even when that is forbidden. The NBD protocol documentation says:

A party that is mandated by this document to terminate the session MUST initiate a hard disconnect if it is not possible to use a soft disconnect. Such circumstances include: where that party is the server and it cannot return an error (e.g. after an NBD_OPT_EXPORT_NAME it cannot satisfy), and where that party is the client following a failed TLS negotiation.

A party MUST NOT initiate a hard disconnect save where set out in this section. Therefore, unless a client's situation falls within the provisions of the previous paragraph or the client detects a breach of a mandatory condition, it MUST NOT use a hard disconnect, and hence its only option to terminate the session is via a soft disconnect.

The Client.list function MUST send NBD_OPT_ABORT if the list or a suitable error is returned from the server.

gaborigloi commented 6 years ago

Currently we do not seem use Client.list anywhere, so it'd be safe to fix this.