1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

ctdb-protocol: Add marshalling for control ECHO_DATA

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
Volker Lendecke 2020-04-07 17:26:26 +02:00 committed by Ralph Boehme
parent 6f56f45639
commit bdabf78122
7 changed files with 83 additions and 2 deletions

View File

@ -611,6 +611,10 @@ void ctdb_req_control_db_vacuum(struct ctdb_req_control *request,
struct ctdb_db_vacuum *db_vacuum);
int ctdb_reply_control_db_vacuum(struct ctdb_reply_control *reply);
void ctdb_req_control_echo_data(struct ctdb_req_control *request,
struct ctdb_echo_data *echo_data);
int ctdb_reply_control_echo_data(struct ctdb_reply_control *reply);
/* From protocol/protocol_debug.c */
void ctdb_packet_print(uint8_t *buf, size_t buflen, FILE *fp);

View File

@ -2385,3 +2385,27 @@ int ctdb_reply_control_db_vacuum(struct ctdb_reply_control *reply)
return reply->status;
}
/* CTDB_CONTROL_ECHO_DATA */
void ctdb_req_control_echo_data(struct ctdb_req_control *request,
struct ctdb_echo_data *echo_data)
{
request->opcode = CTDB_CONTROL_ECHO_DATA;
request->pad = 0;
request->srvid = 0;
request->client_id = 0;
request->flags = 0;
request->rdata.opcode = CTDB_CONTROL_ECHO_DATA;
request->rdata.data.echo_data = echo_data;
}
int ctdb_reply_control_echo_data(struct ctdb_reply_control *reply)
{
if (reply->rdata.opcode != CTDB_CONTROL_ECHO_DATA) {
return EPROTO;
}
return reply->status;
}

View File

@ -415,6 +415,10 @@ static size_t ctdb_req_control_data_len(struct ctdb_req_control_data *cd)
case CTDB_CONTROL_DB_VACUUM:
len = ctdb_db_vacuum_len(cd->data.db_vacuum);
break;
case CTDB_CONTROL_ECHO_DATA:
len = ctdb_echo_data_len(cd->data.echo_data);
break;
}
return len;
@ -698,6 +702,10 @@ static void ctdb_req_control_data_push(struct ctdb_req_control_data *cd,
case CTDB_CONTROL_DB_VACUUM:
ctdb_db_vacuum_push(cd->data.db_vacuum, buf, &np);
break;
case CTDB_CONTROL_ECHO_DATA:
ctdb_echo_data_push(cd->data.echo_data, buf, &np);
break;
}
*npush = np;
@ -1035,6 +1043,14 @@ static int ctdb_req_control_data_pull(uint8_t *buf, size_t buflen,
&cd->data.db_vacuum,
&np);
break;
case CTDB_CONTROL_ECHO_DATA:
ret = ctdb_echo_data_pull(buf,
buflen,
mem_ctx,
&cd->data.echo_data,
&np);
break;
}
if (ret != 0) {
@ -1398,6 +1414,10 @@ static size_t ctdb_reply_control_data_len(struct ctdb_reply_control_data *cd)
case CTDB_CONTROL_DB_VACUUM:
break;
case CTDB_CONTROL_ECHO_DATA:
len = ctdb_echo_data_len(cd->data.echo_data);
break;
}
return len;
@ -1558,6 +1578,10 @@ static void ctdb_reply_control_data_push(struct ctdb_reply_control_data *cd,
case CTDB_CONTROL_DB_VACUUM:
break;
case CTDB_CONTROL_ECHO_DATA:
ctdb_echo_data_push(cd->data.echo_data, buf, &np);
break;
}
*npush = np;
@ -1748,6 +1772,14 @@ static int ctdb_reply_control_data_pull(uint8_t *buf, size_t buflen,
case CTDB_CONTROL_DB_VACUUM:
break;
case CTDB_CONTROL_ECHO_DATA:
ret = ctdb_echo_data_pull(buf,
buflen,
mem_ctx,
&cd->data.echo_data,
&np);
break;
}
if (ret != 0) {

View File

@ -244,6 +244,7 @@ static void ctdb_opcode_print(uint32_t opcode, FILE *fp)
{ CTDB_CONTROL_TUNNEL_DEREGISTER, "TUNNEL_DEREGISTER" },
{ CTDB_CONTROL_VACUUM_FETCH, "VACUUM_FETCH" },
{ CTDB_CONTROL_DB_VACUUM, "DB_VACUUM" },
{ CTDB_CONTROL_ECHO_DATA, "ECHO_DATA" },
{ MAP_END, "" },
};

View File

@ -2,7 +2,7 @@
. "${TEST_SCRIPTS_DIR}/unit.sh"
last_control=155
last_control=156
generate_control_output ()
{

View File

@ -600,6 +600,12 @@ void fill_ctdb_req_control_data(TALLOC_CTX *mem_ctx,
assert(cd->data.db_vacuum != NULL);
fill_ctdb_db_vacuum(mem_ctx, cd->data.db_vacuum);
break;
case CTDB_CONTROL_ECHO_DATA:
cd->data.echo_data = talloc(mem_ctx, struct ctdb_echo_data);
assert(cd->data.echo_data != NULL);
fill_ctdb_echo_data(mem_ctx, cd->data.echo_data);
break;
}
}
@ -994,6 +1000,10 @@ void verify_ctdb_req_control_data(struct ctdb_req_control_data *cd,
case CTDB_CONTROL_DB_VACUUM:
verify_ctdb_db_vacuum(cd->data.db_vacuum, cd2->data.db_vacuum);
break;
case CTDB_CONTROL_ECHO_DATA:
verify_ctdb_echo_data(cd->data.echo_data, cd2->data.echo_data);
break;
}
}
@ -1393,6 +1403,12 @@ void fill_ctdb_reply_control_data(TALLOC_CTX *mem_ctx,
case CTDB_CONTROL_DB_VACUUM:
break;
case CTDB_CONTROL_ECHO_DATA:
cd->data.echo_data = talloc(mem_ctx, struct ctdb_echo_data);
assert(cd->data.echo_data != NULL);
fill_ctdb_echo_data(mem_ctx, cd->data.echo_data);
break;
}
}
@ -1733,6 +1749,10 @@ void verify_ctdb_reply_control_data(struct ctdb_reply_control_data *cd,
case CTDB_CONTROL_DB_VACUUM:
break;
case CTDB_CONTROL_ECHO_DATA:
verify_ctdb_echo_data(cd->data.echo_data, cd2->data.echo_data);
break;
}
}

View File

@ -284,7 +284,7 @@ PROTOCOL_CTDB4_TEST(struct ctdb_req_dmaster, ctdb_req_dmaster,
PROTOCOL_CTDB4_TEST(struct ctdb_reply_dmaster, ctdb_reply_dmaster,
CTDB_REPLY_DMASTER);
#define NUM_CONTROLS 156
#define NUM_CONTROLS 157
PROTOCOL_CTDB2_TEST(struct ctdb_req_control_data, ctdb_req_control_data);
PROTOCOL_CTDB2_TEST(struct ctdb_reply_control_data, ctdb_reply_control_data);