mirror of
https://github.com/samba-team/samba.git
synced 2025-01-10 01:18:15 +03:00
ctdb-protocol: Fix marshalling for ctdb_public_ip
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
parent
d7c247dd72
commit
9e11de448d
@ -571,11 +571,11 @@ static void ctdb_req_control_data_push(struct ctdb_req_control_data *cd,
|
||||
break;
|
||||
|
||||
case CTDB_CONTROL_RELEASE_IP:
|
||||
ctdb_public_ip_push(cd->data.pubip, buf);
|
||||
ctdb_public_ip_push(cd->data.pubip, buf, &np);
|
||||
break;
|
||||
|
||||
case CTDB_CONTROL_TAKEOVER_IP:
|
||||
ctdb_public_ip_push(cd->data.pubip, buf);
|
||||
ctdb_public_ip_push(cd->data.pubip, buf, &np);
|
||||
break;
|
||||
|
||||
case CTDB_CONTROL_TRAVERSE_KILL:
|
||||
@ -878,12 +878,12 @@ static int ctdb_req_control_data_pull(uint8_t *buf, size_t buflen,
|
||||
|
||||
case CTDB_CONTROL_RELEASE_IP:
|
||||
ret = ctdb_public_ip_pull(buf, buflen, mem_ctx,
|
||||
&cd->data.pubip);
|
||||
&cd->data.pubip, &np);
|
||||
break;
|
||||
|
||||
case CTDB_CONTROL_TAKEOVER_IP:
|
||||
ret = ctdb_public_ip_pull(buf, buflen, mem_ctx,
|
||||
&cd->data.pubip);
|
||||
&cd->data.pubip, &np);
|
||||
break;
|
||||
|
||||
case CTDB_CONTROL_TRAVERSE_KILL:
|
||||
|
@ -144,7 +144,7 @@ static void ctdb_message_data_push(union ctdb_message_data *mdata,
|
||||
break;
|
||||
|
||||
case CTDB_SRVID_RECD_UPDATE_IP:
|
||||
ctdb_public_ip_push(mdata->pubip, buf);
|
||||
ctdb_public_ip_push(mdata->pubip, buf, &np);
|
||||
break;
|
||||
|
||||
case CTDB_SRVID_VACUUM_FETCH:
|
||||
@ -229,7 +229,7 @@ static int ctdb_message_data_pull(uint8_t *buf, size_t buflen,
|
||||
|
||||
case CTDB_SRVID_RECD_UPDATE_IP:
|
||||
ret = ctdb_public_ip_pull(buf, buflen, mem_ctx,
|
||||
&mdata->pubip);
|
||||
&mdata->pubip, &np);
|
||||
break;
|
||||
|
||||
case CTDB_SRVID_VACUUM_FETCH:
|
||||
|
@ -231,10 +231,11 @@ void ctdb_uptime_push(struct ctdb_uptime *in, uint8_t *buf, size_t *npush);
|
||||
int ctdb_uptime_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
|
||||
struct ctdb_uptime **out, size_t *npull);
|
||||
|
||||
size_t ctdb_public_ip_len(struct ctdb_public_ip *public_ip);
|
||||
void ctdb_public_ip_push(struct ctdb_public_ip *public_ip, uint8_t *buf);
|
||||
size_t ctdb_public_ip_len(struct ctdb_public_ip *in);
|
||||
void ctdb_public_ip_push(struct ctdb_public_ip *in, uint8_t *buf,
|
||||
size_t *npush);
|
||||
int ctdb_public_ip_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
|
||||
struct ctdb_public_ip **out);
|
||||
struct ctdb_public_ip **out, size_t *npull);
|
||||
|
||||
size_t ctdb_public_ip_list_len(struct ctdb_public_ip_list *pubip_list);
|
||||
void ctdb_public_ip_list_push(struct ctdb_public_ip_list *pubip_list,
|
||||
|
@ -3387,46 +3387,70 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t ctdb_public_ip_len(struct ctdb_public_ip *pubip)
|
||||
size_t ctdb_public_ip_len(struct ctdb_public_ip *in)
|
||||
{
|
||||
return sizeof(struct ctdb_public_ip);
|
||||
return ctdb_uint32_len(&in->pnn) +
|
||||
ctdb_sock_addr_len(&in->addr);
|
||||
}
|
||||
|
||||
void ctdb_public_ip_push(struct ctdb_public_ip *pubip, uint8_t *buf)
|
||||
void ctdb_public_ip_push(struct ctdb_public_ip *in, uint8_t *buf,
|
||||
size_t *npush)
|
||||
{
|
||||
memcpy(buf, pubip, sizeof(struct ctdb_public_ip));
|
||||
size_t offset = 0, np;
|
||||
|
||||
ctdb_uint32_push(&in->pnn, buf+offset, &np);
|
||||
offset += np;
|
||||
|
||||
ctdb_sock_addr_push(&in->addr, buf+offset, &np);
|
||||
offset += np;
|
||||
|
||||
*npush = offset;
|
||||
}
|
||||
|
||||
static int ctdb_public_ip_pull_elems(uint8_t *buf, size_t buflen,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
struct ctdb_public_ip *out)
|
||||
struct ctdb_public_ip *out, size_t *npull)
|
||||
{
|
||||
if (buflen < sizeof(struct ctdb_public_ip)) {
|
||||
return EMSGSIZE;
|
||||
size_t offset = 0, np;
|
||||
int ret;
|
||||
|
||||
ret = ctdb_uint32_pull(buf+offset, buflen-offset, &out->pnn, &np);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
offset += np;
|
||||
|
||||
memcpy(out, buf, sizeof(struct ctdb_public_ip));
|
||||
ret = ctdb_sock_addr_pull_elems(buf+offset, buflen-offset, mem_ctx,
|
||||
&out->addr, &np);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
offset += np;
|
||||
|
||||
*npull = offset;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ctdb_public_ip_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
|
||||
struct ctdb_public_ip **out)
|
||||
struct ctdb_public_ip **out, size_t *npull)
|
||||
{
|
||||
struct ctdb_public_ip *pubip;
|
||||
struct ctdb_public_ip *val;
|
||||
size_t np;
|
||||
int ret;
|
||||
|
||||
pubip = talloc(mem_ctx, struct ctdb_public_ip);
|
||||
if (pubip == NULL) {
|
||||
val = talloc(mem_ctx, struct ctdb_public_ip);
|
||||
if (val == NULL) {
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
ret = ctdb_public_ip_pull_elems(buf, buflen, pubip, pubip);
|
||||
ret = ctdb_public_ip_pull_elems(buf, buflen, val, val, &np);
|
||||
if (ret != 0) {
|
||||
TALLOC_FREE(pubip);
|
||||
TALLOC_FREE(val);
|
||||
return ret;
|
||||
}
|
||||
|
||||
*out = pubip;
|
||||
*out = val;
|
||||
*npull = np;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -3452,15 +3476,15 @@ void ctdb_public_ip_list_push(struct ctdb_public_ip_list *pubip_list,
|
||||
{
|
||||
struct ctdb_public_ip_list_wire *wire =
|
||||
(struct ctdb_public_ip_list_wire *)buf;
|
||||
size_t offset;
|
||||
size_t offset, np;
|
||||
int i;
|
||||
|
||||
wire->num = pubip_list->num;
|
||||
|
||||
offset = offsetof(struct ctdb_public_ip_list_wire, ip);
|
||||
for (i=0; i<pubip_list->num; i++) {
|
||||
ctdb_public_ip_push(&pubip_list->ip[i], &buf[offset]);
|
||||
offset += ctdb_public_ip_len(&pubip_list->ip[i]);
|
||||
ctdb_public_ip_push(&pubip_list->ip[i], &buf[offset], &np);
|
||||
offset += np;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3470,7 +3494,7 @@ int ctdb_public_ip_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
|
||||
struct ctdb_public_ip_list *pubip_list;
|
||||
struct ctdb_public_ip_list_wire *wire =
|
||||
(struct ctdb_public_ip_list_wire *)buf;
|
||||
size_t offset;
|
||||
size_t offset, np;
|
||||
int i;
|
||||
bool ret;
|
||||
|
||||
@ -3511,12 +3535,12 @@ int ctdb_public_ip_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
|
||||
for (i=0; i<wire->num; i++) {
|
||||
ret = ctdb_public_ip_pull_elems(&buf[offset], buflen-offset,
|
||||
pubip_list->ip,
|
||||
&pubip_list->ip[i]);
|
||||
&pubip_list->ip[i], &np);
|
||||
if (ret != 0) {
|
||||
talloc_free(pubip_list);
|
||||
return ret;
|
||||
}
|
||||
offset += ctdb_public_ip_len(&pubip_list->ip[i]);
|
||||
offset += np;
|
||||
}
|
||||
|
||||
*out = pubip_list;
|
||||
|
@ -1166,6 +1166,51 @@ static int ctdb_uptime_pull_old(uint8_t *buf, size_t buflen,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t ctdb_public_ip_len_old(struct ctdb_public_ip *in)
|
||||
{
|
||||
return sizeof(struct ctdb_public_ip);
|
||||
}
|
||||
|
||||
static void ctdb_public_ip_push_old(struct ctdb_public_ip *in, uint8_t *buf)
|
||||
{
|
||||
memcpy(buf, in, sizeof(struct ctdb_public_ip));
|
||||
}
|
||||
|
||||
static int ctdb_public_ip_pull_elems_old(uint8_t *buf, size_t buflen,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
struct ctdb_public_ip *out)
|
||||
{
|
||||
if (buflen < sizeof(struct ctdb_public_ip)) {
|
||||
return EMSGSIZE;
|
||||
}
|
||||
|
||||
memcpy(out, buf, sizeof(struct ctdb_public_ip));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ctdb_public_ip_pull_old(uint8_t *buf, size_t buflen,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
struct ctdb_public_ip **out)
|
||||
{
|
||||
struct ctdb_public_ip *val;
|
||||
int ret;
|
||||
|
||||
val = talloc(mem_ctx, struct ctdb_public_ip);
|
||||
if (val == NULL) {
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
ret = ctdb_public_ip_pull_elems_old(buf, buflen, val, val);
|
||||
if (ret != 0) {
|
||||
TALLOC_FREE(val);
|
||||
return ret;
|
||||
}
|
||||
|
||||
*out = val;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
COMPAT_TYPE3_TEST(struct ctdb_statistics, ctdb_statistics);
|
||||
COMPAT_TYPE3_TEST(struct ctdb_vnn_map, ctdb_vnn_map);
|
||||
@ -1191,6 +1236,7 @@ COMPAT_TYPE3_TEST(struct ctdb_tickle_list, ctdb_tickle_list);
|
||||
COMPAT_TYPE3_TEST(struct ctdb_addr_info, ctdb_addr_info);
|
||||
COMPAT_TYPE3_TEST(struct ctdb_transdb, ctdb_transdb);
|
||||
COMPAT_TYPE3_TEST(struct ctdb_uptime, ctdb_uptime);
|
||||
COMPAT_TYPE3_TEST(struct ctdb_public_ip, ctdb_public_ip);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@ -1221,6 +1267,7 @@ int main(int argc, char *argv[])
|
||||
COMPAT_TEST_FUNC(ctdb_addr_info)();
|
||||
COMPAT_TEST_FUNC(ctdb_transdb)();
|
||||
COMPAT_TEST_FUNC(ctdb_uptime)();
|
||||
COMPAT_TEST_FUNC(ctdb_public_ip)();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ PROTOCOL_TYPE3_TEST(struct ctdb_tickle_list, ctdb_tickle_list);
|
||||
PROTOCOL_TYPE3_TEST(struct ctdb_addr_info, ctdb_addr_info);
|
||||
PROTOCOL_TYPE3_TEST(struct ctdb_transdb, ctdb_transdb);
|
||||
PROTOCOL_TYPE3_TEST(struct ctdb_uptime, ctdb_uptime);
|
||||
DEFINE_TEST(struct ctdb_public_ip, ctdb_public_ip);
|
||||
PROTOCOL_TYPE3_TEST(struct ctdb_public_ip, ctdb_public_ip);
|
||||
DEFINE_TEST(struct ctdb_public_ip_list, ctdb_public_ip_list);
|
||||
DEFINE_TEST(struct ctdb_node_and_flags, ctdb_node_and_flags);
|
||||
DEFINE_TEST(struct ctdb_node_map, ctdb_node_map);
|
||||
|
Loading…
Reference in New Issue
Block a user