]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:ctdbd_conn: add ctdbd_conn_{get,set}_cluster_level() helper functions
authorStefan Metzmacher <metze@samba.org>
Wed, 15 Jul 2026 13:30:11 +0000 (15:30 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 4 Aug 2026 09:51:32 +0000 (09:51 +0000)
These will be used in the next steps...

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/include/ctdbd_conn.h
source3/lib/ctdbd_conn.c

index 23f4a4ec23f14a14e4e301cdb0c5971f5d81fd8b..c3b049ec14c23f77df045dc21199dec8ec4cb5a9 100644 (file)
@@ -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);
index 26777fdd2d3ae0773b8d2aef8e9fad2a2a87ca94..049453ea21d2ed049a00f52b50226635cf0d4794 100644 (file)
@@ -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;