search for: be64toh

Displaying 20 results from an estimated 87 matches for "be64toh".

2012 Dec 06
2
[PATCH 0/2] Two build fixes for libldm
Two simple build fixes for libldm. Well, the first isn't a build fix as such, but a code improvement. Rich.
2019 Jun 18
0
[libnbd PATCH 2/8] states: Consolidate search for current reply's command
...+++ b/generator/states-reply-simple.c @@ -20,24 +20,15 @@ /* STATE MACHINE */ { REPLY.SIMPLE_REPLY.START: - struct command_in_flight *cmd; + struct command_in_flight *cmd = h->reply_cmd; uint32_t error; uint64_t handle; error = be32toh (h->sbuf.simple_reply.error); handle = be64toh (h->sbuf.simple_reply.handle); - /* Find the command amongst the commands in flight. */ - for (cmd = h->cmds_in_flight; cmd != NULL; cmd = cmd->next) { - if (cmd->handle == handle) - break; - } - if (cmd == NULL) { - SET_NEXT_STATE (%.READY); - set_error (0, "no...
2023 Jun 20
1
[libnbd PATCH v4 4/4] internal: Refactor layout of replies in sbuf
...sizeof (h->sbuf.reply.hdr.simple), > stderr); > #endif > return 0; > @@ -158,7 +161,7 @@ REPLY.CHECK_REPLY_MAGIC: > * STATIC_ASSERT above in state REPLY.START that confirmed this. > */ > h->chunks_received++; > - cookie = be64toh (h->sbuf.simple_reply.cookie); > + cookie = be64toh (h->sbuf.reply.hdr.cookie); > /* Find the command amongst the commands in flight. If the server sends > * a reply for an unknown cookie, FINISH will diagnose that later. > */ > @@ -189,7 +192,7 @@ REPLY.FINISH_COM...
2019 May 23
0
[PATCH libnbd 1/3] states: Factor out common code for setting export size and eflags.
...opt-export-name.c b/generator/states-newstyle-opt-export-name.c index 8ff1c1c..07b6c9e 100644 --- a/generator/states-newstyle-opt-export-name.c +++ b/generator/states-newstyle-opt-export-name.c @@ -58,13 +58,13 @@ return 0; NEWSTYLE.OPT_EXPORT_NAME.CHECK_REPLY: - conn->h->exportsize = be64toh (conn->sbuf.export_name_reply.exportsize); - conn->h->eflags = be16toh (conn->sbuf.export_name_reply.eflags); - debug (conn->h, "exportsize: %" PRIu64 " eflags: 0x%" PRIx16, - conn->h->exportsize, conn->h->eflags); - if (conn->h->eflag...
2013 Aug 20
1
[PATCH] lib: avoid pragma usage in journal.c
...ndex cac8040..61ab352 100644 --- a/src/journal.c +++ b/src/journal.c @@ -117,10 +117,8 @@ guestfs__journal_get (guestfs_h *g) "size=%zu, i=%zu", size, i); goto err; } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wcast-align" - len = be64toh (* (uint64_t *) &buf[i]); -#pragma GCC diagnostic pop + memcpy(&len, &buf[i], sizeof(len)); + len = be64toh (len); i += 8; eofield = &buf[i+len]; if (eofield > eobuf) {
2019 Jun 18
0
[libnbd PATCH 1/8] states: Add state for structured reply completion
...struct command_in_flight *cmd; - uint16_t flags; uint64_t handle; uint32_t error; uint64_t offset; @@ -234,7 +233,6 @@ switch (recv_into_rbuf (h)) { case -1: SET_NEXT_STATE (%.DEAD); return -1; case 0: - flags = be16toh (h->sbuf.sr.structured_reply.flags); handle = be64toh (h->sbuf.sr.structured_reply.handle); error = be32toh (h->sbuf.sr.payload.error.error.error); type = be16toh (h->sbuf.sr.structured_reply.type); @@ -264,10 +262,7 @@ if (cmd->error == 0) cmd->error = nbd_internal_errno_of_nbd_error (error); - if (flags &...
2023 Jun 09
4
[libnbd PATCH v4 0/4] Saner reply header layout
This was v3 patch 2/22, reworked to address the confusion about how a structured reply header is read in two pieces before getting to the payload portion. I'm still working on rebasing the rest of my v3 series (patches 1, 3-22) from other comments given, but this seemed independent enough that it's worth posting now rather than holding it up for the rest of the series. Eric Blake (4):
2019 Apr 23
0
[nbdkit PATCH 6/7] nbd: Implement NBD_OPT_GO client request
...fixed_new_option_reply *reply, + char **payload) +{ + char *buffer; + + if (payload) + *payload = NULL; + if (read_full (h->fd, reply, sizeof *reply)) { + nbdkit_error ("unable to read option reply: %m"); + return -1; + } + reply->magic = be64toh (reply->magic); + reply->option = be32toh (reply->option); + reply->reply = be32toh (reply->reply); + reply->replylen = be32toh (reply->replylen); + if (reply->magic != NBD_REP_MAGIC || reply->option != option) { + nbdkit_error ("unexpected option reply")...
2019 May 23
2
[PATCH libnbd] api: Get rid of nbd_connection.
This isn't quite finished because not all of the tests or examples have been updated, but it demonstrates an idea: Should we forget about the concept of having multiple connections managed under a single handle? In this patch there is a single ‘struct nbd_handle *’ which manages a single state machine and connection (and therefore no nbd_connection). To connect to a multi-conn server you must
2019 Jun 14
0
[libnbd PATCH 5/7] states: Factor out NBD_REP payload prep
...OAD); } return 0; @@ -104,8 +96,6 @@ return 0; NEWSTYLE.OPT_GO.CHECK_REPLY: - uint64_t magic; - uint32_t option; uint32_t reply; uint32_t len; const size_t maxpayload = sizeof h->sbuf.or.payload; @@ -113,34 +103,18 @@ uint64_t exportsize; uint16_t eflags; - magic = be64toh (h->sbuf.or.option_reply.magic); - option = be32toh (h->sbuf.or.option_reply.option); reply = be32toh (h->sbuf.or.option_reply.reply); len = be32toh (h->sbuf.or.option_reply.replylen); - if (magic != NBD_REP_MAGIC || option != NBD_OPT_GO) { - SET_NEXT_STATE (%.DEAD); - set...
2019 May 23
5
[PATCH libnbd 0/3] Prevent some misuse of multi-conn.
Per recent discussion here: https://www.redhat.com/archives/libguestfs/2019-May/thread.html#00175
2019 Apr 23
1
Re: [nbdkit PATCH 7/7] nbd: Implement structured replies
...A: > + if (rep.structured.length <= sizeof offset) { > + nbdkit_error ("structured reply OFFSET_DATA too small"); > + free (buf); > + return nbd_mark_dead (h); > + } > + memcpy (&offset, buf, sizeof offset); > + offset = be64toh (offset); > + len = rep.structured.length - sizeof offset; > + break; leaks buf > + case NBD_REPLY_TYPE_OFFSET_HOLE: > + if (rep.structured.length != sizeof offset + sizeof len) { > + nbdkit_error ("structured reply OFFSET_HOLE size incorrect"); &...
2019 Sep 25
3
[nbdkit PATCH 0/2] more protocol.h tweaks
More nbd-protocol.h improvements Eric Blake (2): common/protocol: Switch nbdmagic to uint64_t common/protocol: Declare additional constants common/protocol/nbd-protocol.h | 16 ++++++++++------ server/protocol-handshake-newstyle.c | 2 +- server/protocol-handshake-oldstyle.c | 2 +- plugins/nbd/nbd-standalone.c | 2 +- tests/test-layers.c | 2 +- 5 files
2019 Jun 18
17
[libnbd PATCH 0/8] Add nbd_pread_callback
I've mentioned this topic before (in fact, the idea of adding NBD_CMD_FLAG_DF was first mentioned at [1]), but finally finished enough of an implementation to feel confident in posting it. I'd still like to add something under examples/ that uses the new API to implement strict checking of a server's structured replies read implementation (ensure that a server never sends data after
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 May 21
0
[libnbd PATCH 2/3] states: Split ISSUE_COMMAND.SEND_REQUEST
...+37,43 @@ return 0; ISSUE_COMMAND.SEND_REQUEST: - struct command_in_flight *cmd; - switch (send_from_wbuf (conn)) { case -1: SET_NEXT_STATE (%.DEAD); return -1; - case 0: - assert (conn->cmds_in_flight != NULL); - cmd = conn->cmds_in_flight; - assert (cmd->handle == be64toh (conn->sbuf.request.handle)); - if (cmd->type == NBD_CMD_WRITE) { - conn->wbuf = cmd->data; - conn->wlen = cmd->count; - SET_NEXT_STATE (%SEND_WRITE_PAYLOAD); - } - else - SET_NEXT_STATE (%.READY); + case 0: SET_NEXT_STATE (%PREPARE_WRITE_PAYLOAD);...
2014 Jan 30
4
[Bug 891] New: Build failure on Slackware AMD 64bit with GLIBC 2.7
...ipset ../lib/.libs/libipset.a(session.o): In function `rawdata2attr': /home/nick/targz/ipset-6.20.1/lib/session.c:1495: undefined reference to `htobe64' ../lib/.libs/libipset.a(session.o): In function `attr2data': /home/nick/targz/ipset-6.20.1/lib/session.c:618: undefined reference to `be64toh' collect2: ld returned 1 exit status Researching, it turns out I need GLIBC => 2.9 to supply this. I eventually managed to build ipset (and all works great!) by adding: #define be64toh(x) (x) #define htobe64(x) (x) to lib/sessions.c Now, I dunno if this is the correct fix or not - or if...
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 25
0
Re: [libnbd PATCH] states: Never block state machine inside REPLY
...> switch (recv_into_rbuf (h)) { > case -1: SET_NEXT_STATE (%.DEAD); return -1; > + case 1: > + save_reply_state (h); > + SET_NEXT_STATE (%.READY); > + return 0; > case 0: > length = be32toh (h->sbuf.sr.structured_reply.length); > offset = be64toh (h->sbuf.sr.payload.offset_data.offset); > @@ -324,6 +344,10 @@ > > switch (recv_into_rbuf (h)) { > case -1: SET_NEXT_STATE (%.DEAD); return -1; > + case 1: > + save_reply_state (h); > + SET_NEXT_STATE (%.READY); > + return 0; > case 0: > le...
2020 Mar 19
1
[nbdkit PATCH] nbd: Drop nbd-standalone fallback
...} - break; - case NBD_REPLY_TYPE_OFFSET_DATA: - if (rep.structured.length <= sizeof offset) { - nbdkit_error ("structured reply OFFSET_DATA too small"); - return nbd_mark_dead (h); - } - memcpy (&offset, payload, sizeof offset); - offset = be64toh (offset); - len = rep.structured.length - sizeof offset; - break; - case NBD_REPLY_TYPE_OFFSET_HOLE: - if (rep.structured.length != sizeof offset + sizeof len) { - nbdkit_error ("structured reply OFFSET_HOLE size incorrect"); - return nbd_mark_dead (h); -...