mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
ctdb-protocol: Fix marshalling for GET_DB_SEQNUM control
In the control request, database id which is a 32-bit integer is sent on wire as a 64-bit integer rather than a 32-bit integer. If we convert the database id to 64-bit integer before sending, the order of 32-bits with database id will vary depending on the endian-ness. Instead send the database id as first 32-bits and zeros as next 32-bits. Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
parent
936fc23e3c
commit
c16d2585bc
@ -1882,9 +1882,11 @@ int ctdb_ctrl_getdbseqnum(struct ctdb_context *ctdb, struct timeval timeout,
|
||||
int ret;
|
||||
int32_t res;
|
||||
TDB_DATA data, outdata;
|
||||
uint8_t buf[sizeof(uint64_t)] = { 0 };
|
||||
|
||||
data.dptr = (uint8_t *)&dbid;
|
||||
data.dsize = sizeof(uint64_t); /* This is just wrong */
|
||||
*(uint32_t *)buf = dbid;
|
||||
data.dptr = buf;
|
||||
data.dsize = sizeof(uint64_t);
|
||||
|
||||
ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_GET_DB_SEQNUM,
|
||||
0, data, ctdb, &outdata, &res, &timeout, NULL);
|
||||
|
@ -318,7 +318,7 @@ static size_t ctdb_req_control_data_len(struct ctdb_req_control_data *cd)
|
||||
break;
|
||||
|
||||
case CTDB_CONTROL_GET_DB_SEQNUM:
|
||||
len = ctdb_uint64_len((uint64_t)cd->data.db_id);
|
||||
len = ctdb_uint32_len(cd->data.db_id) + ctdb_uint32_len(0);
|
||||
break;
|
||||
|
||||
case CTDB_CONTROL_DB_SET_HEALTHY:
|
||||
@ -607,6 +607,7 @@ static void ctdb_req_control_data_push(struct ctdb_req_control_data *cd,
|
||||
|
||||
case CTDB_CONTROL_GET_DB_SEQNUM:
|
||||
ctdb_uint32_push(cd->data.db_id, buf);
|
||||
ctdb_uint32_push(0, buf+4);
|
||||
break;
|
||||
|
||||
case CTDB_CONTROL_DB_SET_HEALTHY:
|
||||
@ -711,6 +712,7 @@ static int ctdb_req_control_data_pull(uint8_t *buf, size_t buflen,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
struct ctdb_req_control_data *cd)
|
||||
{
|
||||
uint32_t u32;
|
||||
int ret = 0;
|
||||
|
||||
cd->opcode = opcode;
|
||||
@ -920,8 +922,11 @@ static int ctdb_req_control_data_pull(uint8_t *buf, size_t buflen,
|
||||
break;
|
||||
|
||||
case CTDB_CONTROL_GET_DB_SEQNUM:
|
||||
ret = ctdb_uint32_pull(buf, buflen, mem_ctx,
|
||||
&cd->data.db_id);
|
||||
ret = ctdb_uint32_pull(buf, buflen, mem_ctx, &cd->data.db_id);
|
||||
if (ret != 0) {
|
||||
break;
|
||||
}
|
||||
ret = ctdb_uint32_pull(buf+4, buflen-4, mem_ctx, &u32);
|
||||
break;
|
||||
|
||||
case CTDB_CONTROL_DB_SET_HEALTHY:
|
||||
|
Loading…
Reference in New Issue
Block a user