]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:cluster_support: prepare support for multiple ranges with major level 0
authorStefan Metzmacher <metze@samba.org>
Fri, 7 Aug 2026 10:58:39 +0000 (12:58 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 7 Aug 2026 15:26:30 +0000 (15:26 +0000)
When we want to add support for upgrading from Samba versions before
4.25 we likely need to support multiple ranges with major level 0.

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

index 5664dc0af55ab6000d849ee1630a99cd36d6762e..ea6b36cf6edd68bf4204b6c618d0c79bfdc26bb5 100644 (file)
@@ -66,18 +66,18 @@ bool cluster_support_available(void)
        BUILD_ASSERT( \
                CLUSTER_LEVEL_MAJOR_ ## __major  ## _MINOR_ ## __minor_min \
                == (__minor_min)); \
-       BUILD_ASSERT( \
+       BUILD_ASSERT((__major) == 0 || \
                CLUSTER_LEVEL_MAJOR_ ## __major  ## _MINOR_MIN \
                == (__minor_min)); \
        BUILD_ASSERT( \
                CLUSTER_LEVEL_MAJOR_ ## __major  ## _MINOR_ ## __minor_max \
                == (__minor_max)); \
-       BUILD_ASSERT( \
+       BUILD_ASSERT((__major) == 0 || \
                CLUSTER_LEVEL_MAJOR_ ## __major  ## _MINOR_MAX \
                == (__minor_max)); \
        BUILD_ASSERT((__minor_min)  <= __minor_max); \
        BUILD_ASSERT((__major)     < UINT8_MAX); \
-       BUILD_ASSERT((__minor_max) < UINT8_MAX); \
+       BUILD_ASSERT((__major) == 0 || (__minor_max) < UINT8_MAX); \
        BUILD_ASSERT((__major) != 0 || (__minor_max) != 0);
        CFL_ALL_RANGES
 #undef CFL_RANGE
@@ -238,9 +238,9 @@ static const struct cluster_level_range supported_ranges[] = {
                .major = \
                CLUSTER_LEVEL_MAJOR_ ## __major, \
                .minor_min = \
-               CLUSTER_LEVEL_MAJOR_ ## __major  ## _MINOR_MIN, \
+               CLUSTER_LEVEL_MAJOR_ ## __major  ## _MINOR_ ## __minor_min, \
                .minor_max = \
-               CLUSTER_LEVEL_MAJOR_ ## __major  ## _MINOR_MAX, \
+               CLUSTER_LEVEL_MAJOR_ ## __major  ## _MINOR_ ## __minor_max, \
        },
        CFL_ALL_RANGES
 #undef CFL_RANGE
@@ -286,6 +286,17 @@ static void cluster_level_range_asserts(void)
        SMB_ASSERT(supported_ranges[0].minor_max ==
                   CLUSTER_LEVEL_MAJOR_LATEST_MINOR_MAX);
        for (i = 1; i < ARRAY_SIZE(supported_ranges); i++) {
+               if (supported_ranges[i-1].major == 0) {
+                       /*
+                        * For legacy upgrades we use allow
+                        * multiple ranges with major level 0.
+                        */
+                       SMB_ASSERT(supported_ranges[i].major == 0);
+                       SMB_ASSERT(supported_ranges[i-1].minor_min >
+                                  supported_ranges[i].minor_max);
+                       continue;
+               }
+
                SMB_ASSERT(supported_ranges[i-1].major >
                           supported_ranges[i].major);
        }