search for: htobe32

Displaying 20 results from an estimated 114 matches for "htobe32".

2019 Jun 08
0
[PATCH libnbd 3/3] states: Use MSG_MORE to coalesce messages into single packets.
...pt-set-meta-context.c | 5 +++++ 4 files changed, 11 insertions(+) diff --git a/generator/states-issue-command.c b/generator/states-issue-command.c index 627a54f..cce43d7 100644 --- a/generator/states-issue-command.c +++ b/generator/states-issue-command.c @@ -42,6 +42,8 @@ h->request.count = htobe32 ((uint32_t) cmd->count); h->wbuf = &h->request; h->wlen = sizeof (h->request); + if (cmd->type == NBD_CMD_WRITE) + h->wflags = MSG_MORE; SET_NEXT_STATE (%SEND_REQUEST); return 0; diff --git a/generator/states-newstyle-opt-export-name.c b/generator/states-n...
2019 Mar 08
2
[PATCH nbdkit] Minimal implementation of NBD Structured Replies.
...ple_reply (struct connection *conn, + uint64_t handle, uint16_t cmd, + const char *buf, uint32_t count, + uint32_t error) +{ + ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&conn->write_lock); + struct simple_reply reply; + int r; + + reply.magic = htobe32 (NBD_SIMPLE_REPLY_MAGIC); + reply.handle = handle; + reply.error = htobe32 (nbd_errno (error)); + + r = conn->send (conn, &reply, sizeof reply); + if (r == -1) { + nbdkit_error ("write reply: %s: %m", name_of_nbd_cmd (cmd)); + return set_status (conn, -1); + } + + /* Se...
2019 Apr 23
0
[nbdkit PATCH 3/7] RFC: protocol: Only send EOVERFLOW when valid
...no (int error) return NBD_ESHUTDOWN; #endif case EOVERFLOW: - return NBD_EOVERFLOW; + if (flag_df) + return NBD_EOVERFLOW; + /* fallthrough */ case EINVAL: default: return NBD_EINVAL; @@ -368,7 +370,7 @@ send_simple_reply (struct connection *conn, reply.magic = htobe32 (NBD_SIMPLE_REPLY_MAGIC); reply.handle = handle; - reply.error = htobe32 (nbd_errno (error)); + reply.error = htobe32 (nbd_errno (error, false)); r = conn->send (conn, &reply, sizeof reply); if (r == -1) { @@ -573,7 +575,8 @@ send_structured_reply_block_status (struct connection...
2019 Apr 23
12
[nbdkit PATCH 0/7] Implement structured replies in nbd plugin
I'm hoping to implement .extents for the nbd plugin; this is a prerequisite. I'm not sure about patch 3 - if we like it, I'll squash it to 2, if we don't, I think we are okay just dropping it. I'm also wondering if we have to worry about malicious plugins that don't populate the entire .pread buffer in an effort to get nbdkit to expose portions of the heap; my patch 7 loses
2019 Jun 07
0
[nbdkit PATCH v2 2/2] server: Group related transmission send()s
...>send (conn, &fixed_new_option_reply, - sizeof fixed_new_option_reply, 0) == -1) { + sizeof fixed_new_option_reply, SEND_MORE) == -1) { nbdkit_error ("write: %s: %m", name_of_nbd_opt (option)); return -1; } len = htobe32 (name_len); - if (conn->send (conn, &len, sizeof len, 0) == -1) { + if (conn->send (conn, &len, sizeof len, SEND_MORE) == -1) { nbdkit_error ("write: %s: %s: %m", name_of_nbd_opt (option), "sending length"); return -1; @@ -132,7 +132,...
2019 Mar 20
0
[PATCH nbdkit 3/8] server: Implement Block Status requests to read allocation status.
...const char *name) +{ + struct fixed_new_option_reply fixed_new_option_reply; + struct fixed_new_option_reply_meta_context context; + const size_t namelen = strlen (name); + + fixed_new_option_reply.magic = htobe64 (NBD_REP_MAGIC); + fixed_new_option_reply.option = htobe32 (option); + fixed_new_option_reply.reply = htobe32 (reply); + fixed_new_option_reply.replylen = htobe32 (sizeof context + namelen); + context.context_id = htobe32 (context_id); + + if (conn->send (conn, + &fixed_new_option_reply, + sizeof fixed_new_optio...
2019 Apr 23
0
[nbdkit PATCH 6/7] nbd: Implement NBD_OPT_GO client request
...otiate structured reads, block status, and NBD_OPT_GO. + Return 1 if haggling completed, 0 if haggling failed but + NBD_OPT_EXPORT_NAME is still viable, or -1 on inability to connect. */ +static int +nbd_newstyle_haggle (struct handle *h) +{ + struct new_option opt; + uint32_t exportnamelen = htobe32 (strlen (export)); + /* For now, we make no NBD_INFO_* requests, relying on the server to + send its defaults. TODO: nbdkit should let plugins report block + sizes, at which point we should request NBD_INFO_BLOCK_SIZE and + obey any sizes set by server. */ + uint16_t nrinfos = htobe16...
2019 Mar 18
0
[PATCH nbdkit 2/2] server: Split out NBD protocol code from connections code.
...e options. */ - -static int -send_newstyle_option_reply (struct connection *conn, - uint32_t option, uint32_t reply) -{ - struct fixed_new_option_reply fixed_new_option_reply; - - fixed_new_option_reply.magic = htobe64 (NBD_REP_MAGIC); - fixed_new_option_reply.option = htobe32 (option); - fixed_new_option_reply.reply = htobe32 (reply); - fixed_new_option_reply.replylen = htobe32 (0); - - if (conn->send (conn, - &fixed_new_option_reply, - sizeof fixed_new_option_reply) == -1) { - nbdkit_error ("write: %m"); - ret...
2019 Jun 07
4
[nbdkit PATCH v2 0/2] Reduce network overhead with MSG_MORE/corking
This time around, the numbers are indeed looking better than in v1; and I like the interface better. Eric Blake (2): server: Prefer send() over write() server: Group related transmission send()s server/internal.h | 7 +++- server/connections.c | 51 +++++++++++++++++++++++++--- server/crypto.c | 11 ++++--
2019 Mar 19
0
[PATCH nbdkit 3/9] server: Implement Block Status requests to read allocation status.
...const char *name) +{ + struct fixed_new_option_reply fixed_new_option_reply; + struct fixed_new_option_reply_meta_context context; + const size_t namelen = strlen (name); + + fixed_new_option_reply.magic = htobe64 (NBD_REP_MAGIC); + fixed_new_option_reply.option = htobe32 (option); + fixed_new_option_reply.reply = htobe32 (reply); + fixed_new_option_reply.replylen = htobe32 (sizeof context + namelen); + context.context_id = htobe32 (context_id); + + if (conn->send (conn, + &fixed_new_option_reply, + sizeof fixed_new_optio...
2019 Mar 18
3
[PATCH nbdkit 0/2] server: Split out NBD protocol code from connections code.
These are a couple of patches in preparation for the Block Status implementation. While the patches (especially the second one) are very large they are really just elementary code motion. Rich.
2023 May 30
2
[libnbd PATCH v3 04/22] states: Prepare to send 64-bit requests
...w are not possible in those lines of code (at most one simple reply is possible, and code in states-reply-structured.c ensures that cmd->data_seen is a saturating variable that never exceeds 2*MAX_REQUEST_SIZE). There is also pre-series: generator/states-issue-command.c: h->request.count = htobe32 (cmd->count); which is specifically updated in this patch to cover extended headers. > > +++ b/generator/states-issue-command.c > > @@ -41,15 +41,24 @@ ISSUE_COMMAND.START: > > return 0; > > } > > > > - h->request.magic = htobe32 (NBD_REQUEST_M...
2019 Mar 08
0
Re: [PATCH nbdkit] Minimal implementation of NBD Structured Replies.
...the whole function. > + */ Fair enough. > + ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&conn->write_lock); > + struct structured_reply reply; > + struct structured_reply_offset_data offset_data; > + int r; > + > + assert (cmd == NBD_CMD_READ); > + > + reply.magic = htobe32 (NBD_STRUCTURED_REPLY_MAGIC); > + reply.handle = handle; > + reply.flags = htobe16 (NBD_REPLY_FLAG_DONE); > + reply.type = htobe16 (NBD_REPLY_TYPE_OFFSET_DATA); > + reply.length = htobe32 (sizeof offset_data + count); This line is correct, but I had to remind myself of C precedence...
2019 Jun 06
0
[nbdkit PATCH 2/2] server: Cork around grouped transmission send()s
...eturns > 0), read an EOF (returns 0), or fail (returns -1). diff --git a/server/protocol.c b/server/protocol.c index 6d519e7..0057aed 100644 --- a/server/protocol.c +++ b/server/protocol.c @@ -398,6 +398,11 @@ send_simple_reply (struct connection *conn, reply.handle = handle; reply.error = htobe32 (nbd_errno (error, false)); + if (conn->cork) { + r = conn->cork (conn, true); + assert (r == 0); /* For now, only uncorking can fail */ + } + r = conn->send (conn, &reply, sizeof reply); if (r == -1) { nbdkit_error ("write reply: %s: %m", name_of_nbd_cmd...
2019 Jun 08
6
[PATCH libnbd 0/3] states: Use MSG_MORE to coalesce messages.
Appears to have a measurable benefit, see 3/3 for test results. Rich.
2019 Apr 25
6
[nbdkit PATCH v2 0/5] structured replies/.extents for nbd plugin
Updated based on other changes that have happened in the meantime: - rely more on cleanup.h (throughout) - split structured read for easier review (patch 2 and 3 were combined in v1) - rely on nbdkit not leaking a server's partial answer (patch 3) - add tests (patch 5) - other bug fixes I found while testing it - drop EOVERFLOW patch for now; it will be separate once upstream NBD protocol
2019 Sep 24
0
[PATCH nbdkit 3/4] common/protocol: Update nbd-protocol.h so it matches libnbd’s copy.
...ct connection *conn, uint32_t option, uint32_t reply) { - struct fixed_new_option_reply fixed_new_option_reply; + struct nbd_fixed_new_option_reply fixed_new_option_reply; fixed_new_option_reply.magic = htobe64 (NBD_REP_MAGIC); fixed_new_option_reply.option = htobe32 (option); @@ -83,7 +83,7 @@ static int send_newstyle_option_reply_exportname (struct connection *conn, uint32_t option, uint32_t reply) { - struct fixed_new_option_reply fixed_new_option_reply; + struct nbd_fixed_new_option_reply fixed_new_option_reply;...
2019 May 30
0
[nbdkit PATCH 3/4] nbd: Use libnbd 0.1
...Send a request, return 0 on success or -1 on write failure. */ -static int -nbdplug_request_raw (struct handle *h, uint16_t flags, uint16_t type, - uint64_t offset, uint32_t count, uint64_t cookie, - const void *buf) -{ - struct request req = { - .magic = htobe32 (NBD_REQUEST_MAGIC), - .flags = htobe16 (flags), - .type = htobe16 (type), - .handle = cookie, /* Opaque to server, so endianness doesn't matter */ - .offset = htobe64 (offset), - .count = htobe32 (count), - }; - int r; - - ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&h->write_lock...
2019 Jun 12
0
[nbdkit PATCH v3 3/5] nbd: Use libnbd 0.1.3+
...Send a request, return 0 on success or -1 on write failure. */ -static int -nbdplug_request_raw (struct handle *h, uint16_t flags, uint16_t type, - uint64_t offset, uint32_t count, uint64_t cookie, - const void *buf) -{ - struct request req = { - .magic = htobe32 (NBD_REQUEST_MAGIC), - .flags = htobe16 (flags), - .type = htobe16 (type), - .handle = cookie, /* Opaque to server, so endianness doesn't matter */ - .offset = htobe64 (offset), - .count = htobe32 (count), - }; - int r; - - ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&h->write_lock...
2020 Mar 19
1
[nbdkit PATCH] nbd: Drop nbd-standalone fallback
...} - -/* Send a request, return 0 on success or -1 on write failure. */ -static int -nbd_request_raw (struct handle *h, uint16_t flags, uint16_t type, - uint64_t offset, uint32_t count, uint64_t cookie, - const void *buf) -{ - struct nbd_request req = { - .magic = htobe32 (NBD_REQUEST_MAGIC), - .flags = htobe16 (flags), - .type = htobe16 (type), - .handle = cookie, /* Opaque to server, so endianness doesn't matter */ - .offset = htobe64 (offset), - .count = htobe32 (count), - }; - int r; - - ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&h->write_lock...