r20709: pass a repsFromTo1 struct down as it contains all needed info for the source dsa
authorStefan Metzmacher <metze@samba.org>
Fri, 12 Jan 2007 16:02:10 +0000 (16:02 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:40:29 +0000 (14:40 -0500)
and the highwater mark vector

metze
(This used to be commit a31e017e5388e5abd6ed9d09adcf26d2527954a6)

source4/dsdb/repl/replicated_objects.c
source4/dsdb/samdb/ldb_modules/repl_meta_data.c
source4/dsdb/samdb/samdb.h
source4/torture/libnet/libnet_BecomeDC.c

index da3f6d0461ee485bfe8a2d3e2078c00121ab56a2..1e032b4c80490694361cafdc847bee31b142b900 100644 (file)
@@ -183,8 +183,7 @@ WERROR dsdb_extended_replicated_objects_commit(struct ldb_context *ldb,
                                               const struct drsuapi_DsReplicaObjectListItemEx *first_object,
                                               uint32_t linked_attributes_count,
                                               const struct drsuapi_DsReplicaLinkedAttribute *linked_attributes,
-                                              const struct GUID *source_dsa_invocation_id,
-                                              const struct drsuapi_DsReplicaHighWaterMark *new_highwatermark,
+                                              const struct repsFromTo1 *source_dsa,
                                               const struct drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector,
                                               TALLOC_CTX *mem_ctx,
                                               struct dsdb_extended_replicated_objects **_out)
@@ -205,9 +204,8 @@ WERROR dsdb_extended_replicated_objects_commit(struct ldb_context *ldb,
        out->partition_dn = ldb_dn_new(out, ldb, partition_dn);
        W_ERROR_HAVE_NO_MEMORY(out->partition_dn);
 
-       out->source_dsa_invocation_id   = source_dsa_invocation_id;
-       out->new_highwatermark          = new_highwatermark;
-       out->uptodateness_vector        = uptodateness_vector;
+       out->source_dsa         = source_dsa;
+       out->uptodateness_vector= uptodateness_vector;
 
        out->num_objects        = object_count;
        out->objects            = talloc_array(out,
index 7998d5466c4cac15ea4d9bb5d9bbe0349bb81363..a1fe2e7eb554744575dc9cba370eaffb872f03b0 100644 (file)
@@ -677,6 +677,9 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a
                return replmd_replicated_request_error(ar, ret);
        }
 
+       /*
+        * first create the new replUpToDateVector
+        */
        ouv_value = ldb_msg_find_ldb_val(ar->sub.search_msg, "replUpToDateVector");
        if (ouv_value) {
                nt_status = ndr_pull_struct_blob(ouv_value, ar->sub.mem_ctx, &ouv,
@@ -743,7 +746,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a
         */
        found = false;
        for (j=0; j < ni; j++) {
-               if (!GUID_equal(ar->objs->source_dsa_invocation_id,
+               if (!GUID_equal(&ar->objs->source_dsa->source_dsa_invocation_id,
                                &nuv.ctr.ctr2.cursors[j].source_dsa_invocation_id)) {
                        continue;
                }
@@ -757,7 +760,7 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a
                 * and use the tmp_highest_usn because this is what we have just applied
                 * to our ldb
                 */
-               nuv.ctr.ctr2.cursors[j].highest_usn             = ar->objs->new_highwatermark->tmp_highest_usn;
+               nuv.ctr.ctr2.cursors[j].highest_usn             = ar->objs->source_dsa->highwatermark.tmp_highest_usn;
                nuv.ctr.ctr2.cursors[j].last_sync_success       = now;
                break;
        }
@@ -769,8 +772,8 @@ static int replmd_replicated_uptodate_modify(struct replmd_replicated_request *a
                 * and use the tmp_highest_usn because this is what we have just applied
                 * to our ldb
                 */
-               nuv.ctr.ctr2.cursors[ni].source_dsa_invocation_id= *ar->objs->source_dsa_invocation_id;
-               nuv.ctr.ctr2.cursors[ni].highest_usn            = ar->objs->new_highwatermark->tmp_highest_usn;
+               nuv.ctr.ctr2.cursors[ni].source_dsa_invocation_id= ar->objs->source_dsa->source_dsa_invocation_id;
+               nuv.ctr.ctr2.cursors[ni].highest_usn            = ar->objs->source_dsa->highwatermark.tmp_highest_usn;
                nuv.ctr.ctr2.cursors[ni].last_sync_success      = now;
                ni++;
        }
index 73e40183aab03175a3456c78a8f1e7699b6167fe..0a4804dfb34cdbe1ba7bd67ae514b0532869f548 100644 (file)
@@ -50,8 +50,7 @@ struct dsdb_extended_replicated_object {
 struct dsdb_extended_replicated_objects {
        struct ldb_dn *partition_dn;
 
-       const struct GUID *source_dsa_invocation_id;
-       const struct drsuapi_DsReplicaHighWaterMark *new_highwatermark;
+       const struct repsFromTo1 *source_dsa;
        const struct drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector;
 
        uint32_t num_objects;
index d6fd89b7f367eb550bfb1bf874304996480a5a23..1af840891e3a374013741bbf1565c037d99cc015 100644 (file)
@@ -259,39 +259,57 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s,
        struct drsuapi_DsReplicaObjectListItemEx *cur;
        uint32_t linked_attributes_count;
        struct drsuapi_DsReplicaLinkedAttribute *linked_attributes;
-       const struct GUID *source_dsa_invocation_id;
-       const struct drsuapi_DsReplicaHighWaterMark *new_highwatermark;
        const struct drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector;
        struct dsdb_extended_replicated_objects *objs;
+       struct repsFromTo1 *s_dsa;
+       char *tmp_dns_name;
        uint32_t i;
 
+       s_dsa                   = talloc_zero(s, struct repsFromTo1);
+       NT_STATUS_HAVE_NO_MEMORY(s_dsa);
+       s_dsa->other_info       = talloc(s_dsa, struct repsFromTo1OtherInfo);
+       NT_STATUS_HAVE_NO_MEMORY(s_dsa->other_info);
+
        switch (c->ctr_level) {
        case 1:
-               mapping_ctr             = &c->ctr1->mapping_ctr;
-               total_object_count      = c->ctr1->total_object_count;
-               object_count            = s->schema_part.object_count;
-               first_object            = s->schema_part.first_object;
-               linked_attributes_count = 0;
-               linked_attributes       = NULL;
-               source_dsa_invocation_id= &c->ctr1->source_dsa_invocation_id;
-               new_highwatermark       = &c->ctr1->new_highwatermark;
-               uptodateness_vector     = NULL; /* TODO: map it */
+               mapping_ctr                     = &c->ctr1->mapping_ctr;
+               total_object_count              = c->ctr1->total_object_count;
+               object_count                    = s->schema_part.object_count;
+               first_object                    = s->schema_part.first_object;
+               linked_attributes_count         = 0;
+               linked_attributes               = NULL;
+               s_dsa->highwatermark            = c->ctr1->new_highwatermark;
+               s_dsa->source_dsa_obj_guid      = c->ctr1->source_dsa_guid;
+               s_dsa->source_dsa_invocation_id = c->ctr1->source_dsa_invocation_id;
+               uptodateness_vector             = NULL; /* TODO: map it */
                break;
        case 6:
-               mapping_ctr             = &c->ctr6->mapping_ctr;
-               total_object_count      = c->ctr6->total_object_count;
-               object_count            = s->schema_part.object_count;
-               first_object            = s->schema_part.first_object;
-               linked_attributes_count = 0; /* TODO: ! */
-               linked_attributes       = NULL; /* TODO: ! */;
-               source_dsa_invocation_id= &c->ctr6->source_dsa_invocation_id;
-               new_highwatermark       = &c->ctr6->new_highwatermark;
-               uptodateness_vector     = c->ctr6->uptodateness_vector;
+               mapping_ctr                     = &c->ctr6->mapping_ctr;
+               total_object_count              = c->ctr6->total_object_count;
+               object_count                    = s->schema_part.object_count;
+               first_object                    = s->schema_part.first_object;
+               linked_attributes_count         = 0; /* TODO: ! */
+               linked_attributes               = NULL; /* TODO: ! */;
+               s_dsa->highwatermark            = c->ctr6->new_highwatermark;
+               s_dsa->source_dsa_obj_guid      = c->ctr6->source_dsa_guid;
+               s_dsa->source_dsa_invocation_id = c->ctr6->source_dsa_invocation_id;
+               uptodateness_vector             = c->ctr6->uptodateness_vector;
                break;
        default:
                return NT_STATUS_INVALID_PARAMETER;
        }
 
+       s_dsa->replica_flags            = DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE
+                                       | DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP
+                                       | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS;
+       memset(s_dsa->schedule, 0x11, sizeof(s_dsa->schedule));
+
+       tmp_dns_name    = GUID_string(s_dsa->other_info, &s_dsa->source_dsa_obj_guid);
+       NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name);
+       tmp_dns_name    = talloc_asprintf_append(tmp_dns_name, "._msdcs.%s", c->forest->dns_name);
+       NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name);
+       s_dsa->other_info->dns_name = tmp_dns_name;
+
        for (cur = first_object; cur; cur = cur->next_object) {
                bool is_attr = false;
                bool is_class = false;
@@ -368,8 +386,7 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s,
                                                         first_object,
                                                         linked_attributes_count,
                                                         linked_attributes,
-                                                        source_dsa_invocation_id,
-                                                        new_highwatermark,
+                                                        s_dsa,
                                                         uptodateness_vector,
                                                         s, &objs);
        if (!W_ERROR_IS_OK(status)) {
@@ -388,6 +405,7 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s,
                }
        }
 
+       talloc_free(s_dsa);
        talloc_free(objs);
        return NT_STATUS_OK;
 }
@@ -472,39 +490,57 @@ static NTSTATUS test_become_dc_store_chunk(void *private_data,
        struct drsuapi_DsReplicaObjectListItemEx *first_object;
        uint32_t linked_attributes_count;
        struct drsuapi_DsReplicaLinkedAttribute *linked_attributes;
-       const struct GUID *source_dsa_invocation_id;
-       const struct drsuapi_DsReplicaHighWaterMark *new_highwatermark;
        const struct drsuapi_DsReplicaCursor2CtrEx *uptodateness_vector;
        struct dsdb_extended_replicated_objects *objs;
+       struct repsFromTo1 *s_dsa;
+       char *tmp_dns_name;
        uint32_t i;
 
+       s_dsa                   = talloc_zero(s, struct repsFromTo1);
+       NT_STATUS_HAVE_NO_MEMORY(s_dsa);
+       s_dsa->other_info       = talloc(s_dsa, struct repsFromTo1OtherInfo);
+       NT_STATUS_HAVE_NO_MEMORY(s_dsa->other_info);
+
        switch (c->ctr_level) {
        case 1:
-               mapping_ctr             = &c->ctr1->mapping_ctr;
-               total_object_count      = c->ctr1->total_object_count;
-               object_count            = c->ctr1->object_count;
-               first_object            = c->ctr1->first_object;
-               linked_attributes_count = 0;
-               linked_attributes       = NULL;
-               source_dsa_invocation_id= &c->ctr1->source_dsa_invocation_id;
-               new_highwatermark       = &c->ctr1->new_highwatermark;
-               uptodateness_vector     = NULL; /* TODO: map it */
+               mapping_ctr                     = &c->ctr1->mapping_ctr;
+               total_object_count              = c->ctr1->total_object_count;
+               object_count                    = c->ctr1->object_count;
+               first_object                    = c->ctr1->first_object;
+               linked_attributes_count         = 0;
+               linked_attributes               = NULL;
+               s_dsa->highwatermark            = c->ctr1->new_highwatermark;
+               s_dsa->source_dsa_obj_guid      = c->ctr1->source_dsa_guid;
+               s_dsa->source_dsa_invocation_id = c->ctr1->source_dsa_invocation_id;
+               uptodateness_vector             = NULL; /* TODO: map it */
                break;
        case 6:
-               mapping_ctr             = &c->ctr6->mapping_ctr;
-               total_object_count      = c->ctr6->total_object_count;
-               object_count            = c->ctr6->object_count;
-               first_object            = c->ctr6->first_object;
-               linked_attributes_count = c->ctr6->linked_attributes_count;
-               linked_attributes       = c->ctr6->linked_attributes;
-               source_dsa_invocation_id= &c->ctr6->source_dsa_invocation_id;
-               new_highwatermark       = &c->ctr6->new_highwatermark;
-               uptodateness_vector     = c->ctr6->uptodateness_vector;
+               mapping_ctr                     = &c->ctr6->mapping_ctr;
+               total_object_count              = c->ctr6->total_object_count;
+               object_count                    = c->ctr6->object_count;
+               first_object                    = c->ctr6->first_object;
+               linked_attributes_count         = c->ctr6->linked_attributes_count;
+               linked_attributes               = c->ctr6->linked_attributes;
+               s_dsa->highwatermark            = c->ctr6->new_highwatermark;
+               s_dsa->source_dsa_obj_guid      = c->ctr6->source_dsa_guid;
+               s_dsa->source_dsa_invocation_id = c->ctr6->source_dsa_invocation_id;
+               uptodateness_vector             = c->ctr6->uptodateness_vector;
                break;
        default:
                return NT_STATUS_INVALID_PARAMETER;
        }
 
+       s_dsa->replica_flags            = DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE
+                                       | DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP
+                                       | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS;
+       memset(s_dsa->schedule, 0x11, sizeof(s_dsa->schedule));
+
+       tmp_dns_name    = GUID_string(s_dsa->other_info, &s_dsa->source_dsa_obj_guid);
+       NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name);
+       tmp_dns_name    = talloc_asprintf_append(tmp_dns_name, "._msdcs.%s", c->forest->dns_name);
+       NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name);
+       s_dsa->other_info->dns_name = tmp_dns_name;
+
        if (total_object_count) {
                DEBUG(0,("Partition[%s] objects[%u/%u]\n",
                        c->partition->nc.dn, object_count, total_object_count));
@@ -521,8 +557,7 @@ static NTSTATUS test_become_dc_store_chunk(void *private_data,
                                                         first_object,
                                                         linked_attributes_count,
                                                         linked_attributes,
-                                                        source_dsa_invocation_id,
-                                                        new_highwatermark,
+                                                        s_dsa,
                                                         uptodateness_vector,
                                                         s, &objs);
        if (!W_ERROR_IS_OK(status)) {
@@ -540,6 +575,7 @@ static NTSTATUS test_become_dc_store_chunk(void *private_data,
                        NDR_PRINT_DEBUG(replPropertyMetaDataBlob, objs->objects[i].meta_data);
                }
        }
+       talloc_free(s_dsa);
        talloc_free(objs);
 
        for (i=0; i < linked_attributes_count; i++) {