search for: handle_reply_error

Displaying 20 results from an estimated 28 matches for "handle_reply_error".

2019 Jun 14
0
[libnbd PATCH 7/7] states: Capture NBD_REP_ERR message
...iff --git a/generator/states-newstyle-opt-go.c b/generator/states-newstyle-opt-go.c index 3458f09..91a85ef 100644 --- a/generator/states-newstyle-opt-go.c +++ b/generator/states-newstyle-opt-go.c @@ -147,9 +147,10 @@ SET_NEXT_STATE (%^OPT_EXPORT_NAME.START); return 0; default: + if (handle_reply_error (h) == 0) + set_error (0, "handshake: unknown reply from NBD_OPT_GO: 0x%" PRIx32, + reply); SET_NEXT_STATE (%.DEAD); - set_error (0, "handshake: unknown reply from NBD_OPT_GO: 0x%" PRIx32, - reply); return -1; } diff --git a/ge...
2019 Sep 16
1
[libnbd PATCH] api: Add set_handshake_flags for integration
...!= 0) h->rlen -= sizeof h->sbuf.export_name_reply.zeroes; SET_NEXT_STATE (%RECV_REPLY); } diff --git a/generator/states-newstyle.c b/generator/states-newstyle.c index b4f2b80..8c3ae8a 100644 --- a/generator/states-newstyle.c +++ b/generator/states-newstyle.c @@ -112,8 +112,8 @@ handle_reply_error (struct nbd_handle *h) /* STATE MACHINE */ { NEWSTYLE.START: - h->rbuf = &h->gflags; - h->rlen = 2; + h->rbuf = &h->sbuf; + h->rlen = sizeof h->sbuf.gflags; SET_NEXT_STATE (%RECV_GFLAGS); return 0; @@ -127,16 +127,16 @@ handle_reply_error (struct nbd_hand...
2019 Jun 28
0
[libnbd PATCH] opt-go: Better decoding of known errors
...iff --git a/generator/states-newstyle-opt-go.c b/generator/states-newstyle-opt-go.c index 91a85ef..e245c75 100644 --- a/generator/states-newstyle-opt-go.c +++ b/generator/states-newstyle-opt-go.c @@ -147,9 +147,35 @@ SET_NEXT_STATE (%^OPT_EXPORT_NAME.START); return 0; default: - if (handle_reply_error (h) == 0) - set_error (0, "handshake: unknown reply from NBD_OPT_GO: 0x%" PRIx32, - reply); + if (handle_reply_error (h) == 0) { + /* Decode expected known errors into a nicer string */ + switch (reply) { + case NBD_REP_ERR_POLICY: + case NBD_RE...
2019 Jun 29
0
[libnbd PATCH 2/6] generator: Allow DEAD state actions to run
...%.DEAD); free (meta_context); - return -1; + return 0; } debug (h, "negotiated %s with context ID %" PRIu32, meta_context->name, meta_context->context_id); @@ -202,7 +202,7 @@ /* Anything else is an error, ignore it */ if (handle_reply_error (h) == -1) { SET_NEXT_STATE (%.DEAD); - return -1; + return 0; } debug (h, "handshake: unexpected error from " diff --git a/generator/states-newstyle-opt-starttls.c b/generator/states-newstyle-opt-starttls.c index 61f254f..0a18db0 100644 --- a/generator/states-...
2019 Sep 16
1
[libnbd PATCH] states: Avoid magic number for h->tls
...;); + "but handle TLS setting is 'require' (2)"); return 0; } diff --git a/generator/states-newstyle.c b/generator/states-newstyle.c index c8f817e..b4f2b80 100644 --- a/generator/states-newstyle.c +++ b/generator/states-newstyle.c @@ -129,10 +129,10 @@ handle_reply_error (struct nbd_handle *h) h->gflags = be16toh (h->gflags); if ((h->gflags & NBD_FLAG_FIXED_NEWSTYLE) == 0 && - h->tls == 2) { + h->tls == LIBNBD_TLS_REQUIRE) { SET_NEXT_STATE (%.DEAD); set_error (ENOTSUP, "handshake: server is not fixed newsty...
2019 Jun 14
10
[libnbd PATCH 0/7] state machine refactoring
I'm still playing with ideas on how to split rstate from wstate (so that we can send a request without waiting for POLLIN to complete a pending reply), but this is some preliminary refactoring I found useful. I also fixed a couple of bugs while in the area (already pushed). There's a question of whether we want nbd_handle to be nearly 5k, or if we should instead keep it small and add one
2019 Jun 14
1
Re: [libnbd PATCH 7/7] states: Capture NBD_REP_ERR message
...wstyle.c > @@ -77,6 +77,35 @@ prepare_for_reply_payload (struct nbd_handle *h, uint32_t opt) > return 0; > } > > +/* Check an unexpected server reply. If it is an error, log any > + * message from the server and return 0; otherwise, return -1. > + */ > +static int > +handle_reply_error (struct nbd_handle *h) > +{ > + uint32_t len; > + uint32_t reply; > + > + len = be32toh (h->sbuf.or.option_reply.replylen); > + reply = be32toh (h->sbuf.or.option_reply.reply); > + if (!NBD_REP_IS_ERR (reply)) { > + set_error (0, "handshake: unexpected opt...
2019 Sep 17
1
Re: [PATCH libnbd 2/2] api: New API for reading NBD protocol.
...oldstyle\">, > +C<\"newstyle\"> or C<\"newstyle-fixed\">. Other strings might > +be returned in future. Most modern NBD servers use C<\"newstyle-fixed\">. s/in/in the/ > +++ b/generator/states-newstyle.c > @@ -155,4 +155,13 @@ handle_reply_error (struct nbd_handle *h) > } > return 0; > > + NEWSTYLE.FINISHED: > + if ((h->gflags & NBD_FLAG_FIXED_NEWSTYLE) == 0) > + h->protocol = "newstyle"; > + else > + h->protocol = "newstyle-fixed"; Should work whether this lands bef...
2020 Jul 20
2
Re: [PATCH libnbd PROPOSAL] Add APIs for listing exports from an NBD server.
...gt;rlen = sizeof (h->sbuf.or.option_reply); > + SET_NEXT_STATE (%RECV_REPLY); > + return 0; > + > + case NBD_REP_ACK: > + /* Finished receiving the list. */ > + SET_NEXT_STATE (%^OPT_STRUCTURED_REPLY.START); > + return 0; > + > + default: > + if (handle_reply_error (h) == -1) { > + SET_NEXT_STATE (%.DEAD); Would this be better as %.CLOSED, or even a transition into a state where we send a clean NBD_OPT_ABORT for graceful shutdown rather than abrupt disconnect from the server? > + return 0; > + } > + set_error (ENOTSUP, "un...
2019 Sep 17
3
[PATCH libnbd 1/2] api: Add new API to read whether TLS was negotiated.
When LIBNBD_TLS_ALLOW is used we don't have a way to find out if TLS was really negotiated. This adds a flag and a way to read it back. Unfortunately there is no test yet, because LIBNBD_TLS_ALLOW is not tested -- it really should be but requires quite a complicated set of tests because ideally we'd like to find out whether it falls back correctly for all supported servers. --- TODO
2020 Aug 11
0
Re: [libnbd PATCH] API: Add nbd_set_opt_mode to expose NEGOTIATING state
...brary in userspace: state machine > - * Copyright (C) 2013-2019 Red Hat Inc. > + * Copyright (C) 2013-2020 Red Hat Inc. > * > * This library is free software; you can redistribute it and/or > * modify it under the terms of the GNU Lesser General Public > @@ -112,6 +112,25 @@ handle_reply_error (struct nbd_handle *h) > > STATE_MACHINE { > NEWSTYLE.START: > + if (h->opt_mode) { > + switch (h->sbuf.option.option) { > + case NBD_OPT_GO: > + SET_NEXT_STATE (%OPT_SET_META_CONTEXT.START); > + return 0; > + case NBD_OPT_ABORT: > +...
2020 Jul 20
0
Re: [PATCH libnbd PROPOSAL] Add APIs for listing exports from an NBD server.
...ening one new connection per export and just using the usual APIs to fetch the data. > >+ case NBD_REP_ACK: > >+ /* Finished receiving the list. */ > >+ SET_NEXT_STATE (%^OPT_STRUCTURED_REPLY.START); > >+ return 0; > >+ > >+ default: > >+ if (handle_reply_error (h) == -1) { > >+ SET_NEXT_STATE (%.DEAD); > > Would this be better as %.CLOSED, or even a transition into a state > where we send a clean NBD_OPT_ABORT for graceful shutdown rather > than abrupt disconnect from the server? In fact we cannot move to CLOSED. The reason is o...
2019 Sep 17
0
[PATCH libnbd 2/2] api: New API for reading NBD protocol.
...HED); return 0; case NBD_REP_INFO: if (len > maxpayload /* see RECV_NEWSTYLE_OPT_GO_REPLY */) diff --git a/generator/states-newstyle.c b/generator/states-newstyle.c index c8f817e..7742ea3 100644 --- a/generator/states-newstyle.c +++ b/generator/states-newstyle.c @@ -155,4 +155,13 @@ handle_reply_error (struct nbd_handle *h) } return 0; + NEWSTYLE.FINISHED: + if ((h->gflags & NBD_FLAG_FIXED_NEWSTYLE) == 0) + h->protocol = "newstyle"; + else + h->protocol = "newstyle-fixed"; + + SET_NEXT_STATE (%.READY); + return 0; + } /* END STATE MACHINE */ di...
2020 Aug 11
3
[libnbd PATCH] API: Add nbd_set_opt_mode to expose NEGOTIATING state
...-1,5 +1,5 @@ /* nbd client library in userspace: state machine - * Copyright (C) 2013-2019 Red Hat Inc. + * Copyright (C) 2013-2020 Red Hat Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -112,6 +112,25 @@ handle_reply_error (struct nbd_handle *h) STATE_MACHINE { NEWSTYLE.START: + if (h->opt_mode) { + switch (h->sbuf.option.option) { + case NBD_OPT_GO: + SET_NEXT_STATE (%OPT_SET_META_CONTEXT.START); + return 0; + case NBD_OPT_ABORT: + h->sbuf.option.version = htobe64 (NBD_NEW_VERSI...
2020 Jul 20
2
[PATCH libnbd PROPOSAL] Add APIs for listing exports from an NBD server.
Proposal for new APIs to list exports. The general shape of the API can probably best be seen from the examples/list-exports.c example. Rich.
2019 Jun 29
19
[libnbd PATCH 0/6] new APIs: aio_in_flight, aio_FOO_notify
I still need to wire in the use of *_notify functions into nbdkit to prove whether it makes the code any faster or easier to maintain, but at least the added example shows one good use case for the new API. Eric Blake (6): api: Add nbd_aio_in_flight generator: Allow DEAD state actions to run generator: Allow Int64 in callbacks states: Prepare for aio notify callback api: Add new
2020 Sep 28
0
[libnbd PATCH 3/3] api: Add nbd_opt_list_meta_context
...context->next = h->meta_contexts; + h->meta_contexts = meta_context; + } } SET_NEXT_STATE (%PREPARE_FOR_REPLY); break; default: - /* Anything else is an error, ignore it */ + /* Anything else is an error, ignore it for SET, report it for LIST */ if (handle_reply_error (h) == -1) { SET_NEXT_STATE (%.DEAD); return 0; } - debug (h, "handshake: unexpected error from " - "NBD_OPT_SET_META_CONTEXT (%" PRIu32 ")", reply); - SET_NEXT_STATE (%^OPT_GO.START); + if (opt == NBD_OPT_LIST_META_CONTEXT) { +...
2020 Jul 20
0
[PATCH libnbd PROPOSAL] Add APIs for listing exports from an NBD server.
...es. */ + h->rbuf = &h->sbuf; + h->rlen = sizeof (h->sbuf.or.option_reply); + SET_NEXT_STATE (%RECV_REPLY); + return 0; + + case NBD_REP_ACK: + /* Finished receiving the list. */ + SET_NEXT_STATE (%^OPT_STRUCTURED_REPLY.START); + return 0; + + default: + if (handle_reply_error (h) == -1) { + SET_NEXT_STATE (%.DEAD); + return 0; + } + set_error (ENOTSUP, "unexpected response, possibly the server does not " + "support listing exports"); + SET_NEXT_STATE (%.DEAD); + return 0; + } + return 0; + +} /* END STATE MACHINE...
2020 Aug 11
3
Re: [libnbd PATCH] API: Add nbd_set_opt_mode to expose NEGOTIATING state
...achine >> - * Copyright (C) 2013-2019 Red Hat Inc. >> + * Copyright (C) 2013-2020 Red Hat Inc. >> * >> * This library is free software; you can redistribute it and/or >> * modify it under the terms of the GNU Lesser General Public >> @@ -112,6 +112,25 @@ handle_reply_error (struct nbd_handle *h) >> >> STATE_MACHINE { >> NEWSTYLE.START: >> + if (h->opt_mode) { >> + switch (h->sbuf.option.option) { >> + case NBD_OPT_GO: >> + SET_NEXT_STATE (%OPT_SET_META_CONTEXT.START); >> + return 0; >>...
2020 Aug 14
0
[libnbd PATCH v2 06/13] api: Add nbd_opt_abort and nbd_aio_opt_abort
...IATING); + else + SET_NEXT_STATE (%^OPT_SET_META_CONTEXT.START); return 0; } /* END STATE MACHINE */ diff --git a/generator/states-newstyle.c b/generator/states-newstyle.c index 8da4617..6613f9f 100644 --- a/generator/states-newstyle.c +++ b/generator/states-newstyle.c @@ -112,6 +112,26 @@ handle_reply_error (struct nbd_handle *h) STATE_MACHINE { NEWSTYLE.START: + if (h->opt_mode) { + /* NEWSTYLE can be entered multiple times, from MAGIC.CHECK_MAGIC and + * during various nbd_opt_* calls during NEGOTIATION. Each previous + * state has informed us what we still need to do. + */ +...