From: Stefan Metzmacher Date: Wed, 15 Jul 2026 13:30:11 +0000 (+0200) Subject: s3:ctdbd_conn: add ctdbd_conn_{get,set}_cluster_level() helper functions X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ea502b37e6777bbfcef84ab4ced7f816d6f97cde;p=thirdparty%2Fsamba.git s3:ctdbd_conn: add ctdbd_conn_{get,set}_cluster_level() helper functions These will be used in the next steps... Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h index 23f4a4ec23f..c3b049ec14c 100644 --- a/source3/include/ctdbd_conn.h +++ b/source3/include/ctdbd_conn.h @@ -30,6 +30,7 @@ struct ctdbd_connection; struct messaging_context; struct messaging_rec; +struct cluster_level_active; int ctdbd_init_connection(TALLOC_CTX *mem_ctx, const char *sockname, int timeout, @@ -41,6 +42,10 @@ int ctdbd_init_async_connection( struct ctdbd_connection **pconn); int ctdbd_generation(struct ctdbd_connection *conn, uint32_t *generation); +const struct cluster_level_active *ctdbd_conn_get_cluster_level( + struct ctdbd_connection *conn); +void ctdbd_conn_set_cluster_level(struct ctdbd_connection *conn, + const struct cluster_level_active *level); uint32_t ctdbd_vnn(const struct ctdbd_connection *conn); pid_t ctdbd_pid(const struct ctdbd_connection *conn); struct timeval ctdbd_start_time(const struct ctdbd_connection *conn); diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index 26777fdd2d3..049453ea21d 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -40,6 +40,8 @@ #include "lib/async_req/async_sock.h" #include "lib/dbwrap/dbwrap.h" #include "lib/dbwrap/dbwrap_rbt.h" +#include "librpc/gen_ndr/ndr_cluster_level.h" +#include "cluster_support.h" /* paths to these include files come from --with-ctdb= in configure */ @@ -58,6 +60,7 @@ struct ctdbd_connection { pid_t pid; struct timeval start_time; } local_ctdbd; + struct cluster_level_active active_level; uint32_t reqid; uint32_t our_vnn; uint64_t rand_srvid; @@ -442,6 +445,31 @@ fail: return ok; } +/* + * Get the cluster-wide active functional level. + */ +const struct cluster_level_active *ctdbd_conn_get_cluster_level( + struct ctdbd_connection *conn) +{ + return &conn->active_level; +} + +/* + * Set the cluster-wide active functional level + * on the ctdbd_connection, for the cases of the + * initial creation of the global version. + */ +void ctdbd_conn_set_cluster_level(struct ctdbd_connection *conn, + const struct cluster_level_active *level) +{ + /* + * only upgrades are possible + */ + SMB_ASSERT(cluster_level_is_valid(level)); + SMB_ASSERT(cluster_level_is_valid_update(&conn->active_level, level)); + conn->active_level = *level; +} + uint32_t ctdbd_vnn(const struct ctdbd_connection *conn) { return conn->our_vnn;