From: Stefan Metzmacher Date: Thu, 23 Nov 2023 14:04:09 +0000 (+0100) Subject: ctdb: send a CTDB_SRVID_IPREALLOCATED message after CTDB_EVENT_IPREALLOCATED X-Git-Tag: talloc-2.4.2~165 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b1d0d5d51422f377c2e989ea6dacb2aa5794082b;p=thirdparty%2Fsamba.git ctdb: send a CTDB_SRVID_IPREALLOCATED message after CTDB_EVENT_IPREALLOCATED Event scripts run the "ipreallocated" hook in order to notice that some ip addresses in the cluster potentially changed. CTDB_SRVID_IPREALLOCATED gives C code a chance to get notified as well once the event scripts are finished. Signed-off-by: Stefan Metzmacher Reviewed-by: Martin Schwenke --- diff --git a/ctdb/protocol/protocol.h b/ctdb/protocol/protocol.h index 3b66c403ab8..009a0df06af 100644 --- a/ctdb/protocol/protocol.h +++ b/ctdb/protocol/protocol.h @@ -140,6 +140,9 @@ struct ctdb_call { /* SRVID to inform clients that an IP address has been taken over */ #define CTDB_SRVID_TAKE_IP 0xF301000000000000LL +/* SRVID to inform clients that CTDB_EVENT_IPREALLOCATED finished */ +#define CTDB_SRVID_IPREALLOCATED 0xF302000000000000LL + /* SRVID to inform recovery daemon of the node flags - OBSOLETE */ #define CTDB_SRVID_SET_NODE_FLAGS 0xF400000000000000LL diff --git a/ctdb/protocol/protocol_debug.c b/ctdb/protocol/protocol_debug.c index ae091b04d32..f1e1fc070d9 100644 --- a/ctdb/protocol/protocol_debug.c +++ b/ctdb/protocol/protocol_debug.c @@ -301,6 +301,8 @@ static void ctdb_srvid_print(uint64_t srvid, FILE *fp) fprintf(fp, "RELEASE_IP"); } else if (srvid == CTDB_SRVID_TAKE_IP) { fprintf(fp, "TAKE_IP"); + } else if (srvid == CTDB_SRVID_IPREALLOCATED) { + fprintf(fp, "IPREALLOCATED"); } else if (srvid == CTDB_SRVID_SET_NODE_FLAGS) { fprintf(fp, "SET_NODE_FLAGS"); } else if (srvid == CTDB_SRVID_RECD_UPDATE_IP) { diff --git a/ctdb/protocol/protocol_message.c b/ctdb/protocol/protocol_message.c index e2202bb78d5..8d323227914 100644 --- a/ctdb/protocol/protocol_message.c +++ b/ctdb/protocol/protocol_message.c @@ -57,6 +57,9 @@ static size_t ctdb_message_data_len(union ctdb_message_data *mdata, len = ctdb_string_len(&mdata->ipaddr); break; + case CTDB_SRVID_IPREALLOCATED: + break; + case CTDB_SRVID_SET_NODE_FLAGS: len = ctdb_node_flag_change_len(mdata->flag_change); break; @@ -148,6 +151,9 @@ static void ctdb_message_data_push(union ctdb_message_data *mdata, ctdb_string_push(&mdata->ipaddr, buf, &np); break; + case CTDB_SRVID_IPREALLOCATED: + break; + case CTDB_SRVID_SET_NODE_FLAGS: ctdb_node_flag_change_push(mdata->flag_change, buf, &np); break; @@ -244,6 +250,9 @@ static int ctdb_message_data_pull(uint8_t *buf, size_t buflen, &np); break; + case CTDB_SRVID_IPREALLOCATED: + break; + case CTDB_SRVID_SET_NODE_FLAGS: ret = ctdb_node_flag_change_pull(buf, buflen, mem_ctx, &mdata->flag_change, &np); diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index e333105e633..b622fafd95f 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -2399,6 +2399,7 @@ static void ctdb_ipreallocated_callback(struct ctdb_context *ctdb, { struct ipreallocated_callback_state *state = talloc_get_type(p, struct ipreallocated_callback_state); + TDB_DATA data = { .dsize = 0, }; if (status != 0) { DEBUG(DEBUG_ERR, @@ -2409,6 +2410,9 @@ static void ctdb_ipreallocated_callback(struct ctdb_context *ctdb, } } + D_INFO("Sending IPREALLOCATED message\n"); + ctdb_daemon_send_message(ctdb, ctdb->pnn, CTDB_SRVID_IPREALLOCATED, data); + ctdb_request_control_reply(ctdb, state->c, NULL, status, NULL); talloc_free(state); }