r13035: active,special group replicas are overwritten by tombstone,special group...
[abartlet/samba.git/.git] / source4 / torture / nbt / winsreplication.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    WINS replication testing
5
6    Copyright (C) Andrew Tridgell        2005
7    Copyright (C) Stefan Metzmacher      2005
8    
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 2 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24 #include "includes.h"
25 #include "libcli/wrepl/winsrepl.h"
26 #include "lib/events/events.h"
27 #include "lib/socket/socket.h"
28
29 #define CHECK_STATUS(status, correct) do { \
30         if (!NT_STATUS_EQUAL(status, correct)) { \
31                 printf("(%s) Incorrect status %s - should be %s\n", \
32                        __location__, nt_errstr(status), nt_errstr(correct)); \
33                 ret = False; \
34                 goto done; \
35         }} while (0)
36
37 #define CHECK_VALUE(v, correct) do { \
38         if ((v) != (correct)) { \
39                 printf("(%s) Incorrect value %s=%d - should be %d\n", \
40                        __location__, #v, v, correct); \
41                 ret = False; \
42                 goto done; \
43         }} while (0)
44
45 #define CHECK_VALUE_UINT64(v, correct) do { \
46         if ((v) != (correct)) { \
47                 printf("(%s) Incorrect value %s=%llu - should be %llu\n", \
48                        __location__, #v, (long long)v, (long long)correct); \
49                 ret = False; \
50                 goto done; \
51         }} while (0)
52
53 #define CHECK_VALUE_STRING(v, correct) do { \
54         if ( ((!v) && (correct)) || \
55              ((v) && (!correct)) || \
56              ((v) && (correct) && strcmp(v,correct) != 0)) { \
57                 printf("(%s) Incorrect value %s='%s' - should be '%s'\n", \
58                        __location__, #v, v, correct); \
59                 ret = False; \
60                 goto done; \
61         }} while (0)
62
63 #define _NBT_NAME(n,t,s) {\
64         .name   = n,\
65         .type   = t,\
66         .scope  = s\
67 }
68
69 static const char *wrepl_name_type_string(enum wrepl_name_type type)
70 {
71         switch (type) {
72         case WREPL_TYPE_UNIQUE: return "UNIQUE";
73         case WREPL_TYPE_GROUP: return "GROUP";
74         case WREPL_TYPE_SGROUP: return "SGROUP";
75         case WREPL_TYPE_MHOMED: return "MHOMED";
76         }
77         return "UNKNOWN_TYPE";
78 }
79
80 static const char *wrepl_name_state_string(enum wrepl_name_state state)
81 {
82         switch (state) {
83         case WREPL_STATE_ACTIVE: return "ACTIVE";
84         case WREPL_STATE_RELEASED: return "RELEASED";
85         case WREPL_STATE_TOMBSTONE: return "TOMBSTONE";
86         case WREPL_STATE_RESERVED: return "RESERVED";
87         }
88         return "UNKNOWN_STATE";
89 }
90
91 /*
92   test how assoc_ctx's are only usable on the connection
93   they are created on.
94 */
95 static BOOL test_assoc_ctx1(TALLOC_CTX *mem_ctx, const char *address)
96 {
97         BOOL ret = True;
98         struct wrepl_request *req;
99         struct wrepl_socket *wrepl_socket1;
100         struct wrepl_associate associate1;
101         struct wrepl_socket *wrepl_socket2;
102         struct wrepl_associate associate2;
103         struct wrepl_pull_table pull_table;
104         struct wrepl_packet packet;
105         struct wrepl_send_ctrl ctrl;
106         struct wrepl_packet *rep_packet;
107         struct wrepl_associate_stop assoc_stop;
108         NTSTATUS status;
109
110         if (!lp_parm_bool(-1, "torture", "dangerous", False)) {
111                 printf("winsrepl: cross connection assoc_ctx usage disabled - enable dangerous tests to use\n");
112                 return True;
113         }
114
115         printf("Test if assoc_ctx is only valid on the conection it was created on\n");
116
117         wrepl_socket1 = wrepl_socket_init(mem_ctx, NULL);
118         wrepl_socket2 = wrepl_socket_init(mem_ctx, NULL);
119
120         printf("Setup 2 wrepl connections\n");
121         status = wrepl_connect(wrepl_socket1, NULL, address);
122         CHECK_STATUS(status, NT_STATUS_OK);
123
124         status = wrepl_connect(wrepl_socket2, NULL, address);
125         CHECK_STATUS(status, NT_STATUS_OK);
126
127         printf("Send a start association request (conn1)\n");
128         status = wrepl_associate(wrepl_socket1, &associate1);
129         CHECK_STATUS(status, NT_STATUS_OK);
130
131         printf("association context (conn1): 0x%x\n", associate1.out.assoc_ctx);
132
133         printf("Send a start association request (conn2)\n");
134         status = wrepl_associate(wrepl_socket2, &associate2);
135         CHECK_STATUS(status, NT_STATUS_OK);
136
137         printf("association context (conn2): 0x%x\n", associate2.out.assoc_ctx);
138
139         printf("Send a replication table query, with assoc 1 (conn2), the anwser should be on conn1\n");
140         ZERO_STRUCT(packet);
141         packet.opcode                      = WREPL_OPCODE_BITS;
142         packet.assoc_ctx                   = associate1.out.assoc_ctx;
143         packet.mess_type                   = WREPL_REPLICATION;
144         packet.message.replication.command = WREPL_REPL_TABLE_QUERY;
145         ZERO_STRUCT(ctrl);
146         ctrl.send_only = True;
147         req = wrepl_request_send(wrepl_socket2, &packet, &ctrl);
148         status = wrepl_request_recv(req, mem_ctx, &rep_packet);
149         CHECK_STATUS(status, NT_STATUS_OK);
150
151         printf("Send a association request (conn2), to make sure the last request was ignored\n");
152         status = wrepl_associate(wrepl_socket2, &associate2);
153         CHECK_STATUS(status, NT_STATUS_OK);
154
155         printf("Send a replication table query, with invalid assoc (conn1), receive answer from conn2\n");
156         pull_table.in.assoc_ctx = 0;
157         req = wrepl_pull_table_send(wrepl_socket1, &pull_table);
158         status = wrepl_request_recv(req, mem_ctx, &rep_packet);
159         CHECK_STATUS(status, NT_STATUS_OK);
160
161         printf("Send a association request (conn1), to make sure the last request was handled correct\n");
162         status = wrepl_associate(wrepl_socket1, &associate2);
163         CHECK_STATUS(status, NT_STATUS_OK);
164
165         assoc_stop.in.assoc_ctx = associate1.out.assoc_ctx;
166         assoc_stop.in.reason    = 4;
167         printf("Send a association stop request (conn1), reson: %u\n", assoc_stop.in.reason);
168         status = wrepl_associate_stop(wrepl_socket1, &assoc_stop);
169         CHECK_STATUS(status, NT_STATUS_END_OF_FILE);
170
171         assoc_stop.in.assoc_ctx = associate2.out.assoc_ctx;
172         assoc_stop.in.reason    = 0;
173         printf("Send a association stop request (conn2), reson: %u\n", assoc_stop.in.reason);
174         status = wrepl_associate_stop(wrepl_socket2, &assoc_stop);
175         CHECK_STATUS(status, NT_STATUS_OK);
176
177 done:
178         printf("Close 2 wrepl connections\n");
179         talloc_free(wrepl_socket1);
180         talloc_free(wrepl_socket2);
181         return ret;
182 }
183
184 /*
185   test if we always get back the same assoc_ctx
186 */
187 static BOOL test_assoc_ctx2(TALLOC_CTX *mem_ctx, const char *address)
188 {
189         BOOL ret = True;
190         struct wrepl_socket *wrepl_socket;
191         struct wrepl_associate associate;
192         uint32_t assoc_ctx1;
193         NTSTATUS status;
194
195         printf("Test if we always get back the same assoc_ctx\n");
196
197         wrepl_socket = wrepl_socket_init(mem_ctx, NULL);
198         
199         printf("Setup wrepl connections\n");
200         status = wrepl_connect(wrepl_socket, NULL, address);
201         CHECK_STATUS(status, NT_STATUS_OK);
202
203
204         printf("Send 1st start association request\n");
205         status = wrepl_associate(wrepl_socket, &associate);
206         CHECK_STATUS(status, NT_STATUS_OK);
207         assoc_ctx1 = associate.out.assoc_ctx;
208         printf("1st association context: 0x%x\n", associate.out.assoc_ctx);
209
210         printf("Send 2nd start association request\n");
211         status = wrepl_associate(wrepl_socket, &associate);
212         CHECK_VALUE(associate.out.assoc_ctx, assoc_ctx1);
213         CHECK_STATUS(status, NT_STATUS_OK);
214         printf("2nd association context: 0x%x\n", associate.out.assoc_ctx);
215
216         printf("Send 3rd start association request\n");
217         status = wrepl_associate(wrepl_socket, &associate);
218         CHECK_VALUE(associate.out.assoc_ctx, assoc_ctx1);
219         CHECK_STATUS(status, NT_STATUS_OK);
220         printf("3rd association context: 0x%x\n", associate.out.assoc_ctx);
221
222 done:
223         printf("Close wrepl connections\n");
224         talloc_free(wrepl_socket);
225         return ret;
226 }
227
228
229 /*
230   display a replication entry
231 */
232 static void display_entry(TALLOC_CTX *mem_ctx, struct wrepl_name *name)
233 {
234         int i;
235
236         printf("%s\n", nbt_name_string(mem_ctx, &name->name));
237         printf("\tTYPE:%u STATE:%u NODE:%u STATIC:%u VERSION_ID: %llu\n",
238                 name->type, name->state, name->node, name->is_static, (long long)name->version_id);
239         printf("\tRAW_FLAGS: 0x%08X OWNER: %-15s\n",
240                 name->raw_flags, name->owner);
241         for (i=0;i<name->num_addresses;i++) {
242                 printf("\tADDR: %-15s OWNER: %-15s\n", 
243                         name->addresses[i].address, name->addresses[i].owner);
244         }
245 }
246
247 /*
248   test a full replication dump from a WINS server
249 */
250 static BOOL test_wins_replication(TALLOC_CTX *mem_ctx, const char *address)
251 {
252         BOOL ret = True;
253         struct wrepl_socket *wrepl_socket;
254         NTSTATUS status;
255         int i, j;
256         struct wrepl_associate associate;
257         struct wrepl_pull_table pull_table;
258         struct wrepl_pull_names pull_names;
259
260         printf("Test one pull replication cycle\n");
261
262         wrepl_socket = wrepl_socket_init(mem_ctx, NULL);
263         
264         printf("Setup wrepl connections\n");
265         status = wrepl_connect(wrepl_socket, NULL, address);
266         CHECK_STATUS(status, NT_STATUS_OK);
267
268         printf("Send a start association request\n");
269
270         status = wrepl_associate(wrepl_socket, &associate);
271         CHECK_STATUS(status, NT_STATUS_OK);
272
273         printf("association context: 0x%x\n", associate.out.assoc_ctx);
274
275         printf("Send a replication table query\n");
276         pull_table.in.assoc_ctx = associate.out.assoc_ctx;
277
278         status = wrepl_pull_table(wrepl_socket, mem_ctx, &pull_table);
279         if (NT_STATUS_EQUAL(NT_STATUS_NETWORK_ACCESS_DENIED,status)) {
280                 struct wrepl_packet packet;
281                 struct wrepl_request *req;
282
283                 ZERO_STRUCT(packet);
284                 packet.opcode                      = WREPL_OPCODE_BITS;
285                 packet.assoc_ctx                   = associate.out.assoc_ctx;
286                 packet.mess_type                   = WREPL_STOP_ASSOCIATION;
287                 packet.message.stop.reason         = 0;
288
289                 req = wrepl_request_send(wrepl_socket, &packet, NULL);
290                 talloc_free(req);
291
292                 printf("failed - We are not a valid pull partner for the server\n");
293                 ret = False;
294                 goto done;
295         }
296         CHECK_STATUS(status, NT_STATUS_OK);
297
298         printf("Found %d replication partners\n", pull_table.out.num_partners);
299
300         for (i=0;i<pull_table.out.num_partners;i++) {
301                 struct wrepl_wins_owner *partner = &pull_table.out.partners[i];
302                 printf("%s   max_version=%6llu   min_version=%6llu type=%d\n",
303                        partner->address, 
304                        (long long)partner->max_version, 
305                        (long long)partner->min_version, 
306                        partner->type);
307
308                 pull_names.in.assoc_ctx = associate.out.assoc_ctx;
309                 pull_names.in.partner = *partner;
310                 
311                 status = wrepl_pull_names(wrepl_socket, mem_ctx, &pull_names);
312                 CHECK_STATUS(status, NT_STATUS_OK);
313
314                 printf("Received %d names\n", pull_names.out.num_names);
315
316                 for (j=0;j<pull_names.out.num_names;j++) {
317                         display_entry(mem_ctx, &pull_names.out.names[j]);
318                 }
319         }
320
321 done:
322         printf("Close wrepl connections\n");
323         talloc_free(wrepl_socket);
324         return ret;
325 }
326
327 struct test_wrepl_conflict_conn {
328         const char *address;
329         struct wrepl_socket *pull;
330         uint32_t pull_assoc;
331
332 #define TEST_OWNER_A_ADDRESS "127.65.65.1"
333 #define TEST_ADDRESS_A_PREFIX "127.0.65"
334 #define TEST_OWNER_B_ADDRESS "127.66.66.1"
335 #define TEST_ADDRESS_B_PREFIX "127.0.66"
336 #define TEST_OWNER_X_ADDRESS "127.88.88.1"
337 #define TEST_ADDRESS_X_PREFIX "127.0.88"
338
339         struct wrepl_wins_owner a, b, c, x;
340
341         struct socket_address *myaddr;
342         struct socket_address *myaddr2;
343         struct nbt_name_socket *nbtsock;
344         struct nbt_name_socket *nbtsock2;
345
346         struct nbt_name_socket *nbtsock_srv;
347         struct nbt_name_socket *nbtsock_srv2;
348
349         uint32_t addresses_best_num;
350         struct wrepl_ip *addresses_best;
351
352         uint32_t addresses_best2_num;
353         struct wrepl_ip *addresses_best2;
354
355         uint32_t addresses_all_num;
356         struct wrepl_ip *addresses_all;
357
358         uint32_t addresses_mhomed_num;
359         struct wrepl_ip *addresses_mhomed;
360 };
361
362 static const struct wrepl_ip addresses_A_1[] = {
363         {
364         .owner  = TEST_OWNER_A_ADDRESS,
365         .ip     = TEST_ADDRESS_A_PREFIX".1"
366         }
367 };
368 static const struct wrepl_ip addresses_A_2[] = {
369         {
370         .owner  = TEST_OWNER_A_ADDRESS,
371         .ip     = TEST_ADDRESS_A_PREFIX".2"
372         }
373 };
374 static const struct wrepl_ip addresses_A_3_4[] = {
375         {
376         .owner  = TEST_OWNER_A_ADDRESS,
377         .ip     = TEST_ADDRESS_A_PREFIX".3"
378         },
379         {
380         .owner  = TEST_OWNER_A_ADDRESS,
381         .ip     = TEST_ADDRESS_A_PREFIX".4"
382         }
383 };
384 static const struct wrepl_ip addresses_A_3_4_X_3_4[] = {
385         {
386         .owner  = TEST_OWNER_A_ADDRESS,
387         .ip     = TEST_ADDRESS_A_PREFIX".3"
388         },
389         {
390         .owner  = TEST_OWNER_A_ADDRESS,
391         .ip     = TEST_ADDRESS_A_PREFIX".4"
392         },
393         {
394         .owner  = TEST_OWNER_X_ADDRESS,
395         .ip     = TEST_ADDRESS_X_PREFIX".3"
396         },
397         {
398         .owner  = TEST_OWNER_X_ADDRESS,
399         .ip     = TEST_ADDRESS_X_PREFIX".4"
400         }
401 };
402 static const struct wrepl_ip addresses_A_3_4_B_3_4[] = {
403         {
404         .owner  = TEST_OWNER_A_ADDRESS,
405         .ip     = TEST_ADDRESS_A_PREFIX".3"
406         },
407         {
408         .owner  = TEST_OWNER_A_ADDRESS,
409         .ip     = TEST_ADDRESS_A_PREFIX".4"
410         },
411         {
412         .owner  = TEST_OWNER_B_ADDRESS,
413         .ip     = TEST_ADDRESS_B_PREFIX".3"
414         },
415         {
416         .owner  = TEST_OWNER_B_ADDRESS,
417         .ip     = TEST_ADDRESS_B_PREFIX".4"
418         }
419 };
420 static const struct wrepl_ip addresses_A_3_4_OWNER_B[] = {
421         {
422         .owner  = TEST_OWNER_B_ADDRESS,
423         .ip     = TEST_ADDRESS_A_PREFIX".3"
424         },
425         {
426         .owner  = TEST_OWNER_B_ADDRESS,
427         .ip     = TEST_ADDRESS_A_PREFIX".4"
428         }
429 };
430 static const struct wrepl_ip addresses_A_3_4_X_3_4_OWNER_B[] = {
431         {
432         .owner  = TEST_OWNER_B_ADDRESS,
433         .ip     = TEST_ADDRESS_A_PREFIX".3"
434         },
435         {
436         .owner  = TEST_OWNER_B_ADDRESS,
437         .ip     = TEST_ADDRESS_A_PREFIX".4"
438         },
439         {
440         .owner  = TEST_OWNER_B_ADDRESS,
441         .ip     = TEST_ADDRESS_X_PREFIX".3"
442         },
443         {
444         .owner  = TEST_OWNER_B_ADDRESS,
445         .ip     = TEST_ADDRESS_X_PREFIX".4"
446         }
447 };
448
449 static const struct wrepl_ip addresses_A_3_4_X_1_2[] = {
450         {
451         .owner  = TEST_OWNER_A_ADDRESS,
452         .ip     = TEST_ADDRESS_A_PREFIX".3"
453         },
454         {
455         .owner  = TEST_OWNER_A_ADDRESS,
456         .ip     = TEST_ADDRESS_A_PREFIX".4"
457         },
458         {
459         .owner  = TEST_OWNER_X_ADDRESS,
460         .ip     = TEST_ADDRESS_X_PREFIX".1"
461         },
462         {
463         .owner  = TEST_OWNER_X_ADDRESS,
464         .ip     = TEST_ADDRESS_X_PREFIX".2"
465         }
466 };
467
468 static const struct wrepl_ip addresses_B_1[] = {
469         {
470         .owner  = TEST_OWNER_B_ADDRESS,
471         .ip     = TEST_ADDRESS_B_PREFIX".1"
472         }
473 };
474 static const struct wrepl_ip addresses_B_2[] = {
475         {
476         .owner  = TEST_OWNER_B_ADDRESS,
477         .ip     = TEST_ADDRESS_B_PREFIX".2"
478         }
479 };
480 static const struct wrepl_ip addresses_B_3_4[] = {
481         {
482         .owner  = TEST_OWNER_B_ADDRESS,
483         .ip     = TEST_ADDRESS_B_PREFIX".3"
484         },
485         {
486         .owner  = TEST_OWNER_B_ADDRESS,
487         .ip     = TEST_ADDRESS_B_PREFIX".4"
488         }
489 };
490 static const struct wrepl_ip addresses_B_3_4_X_3_4[] = {
491         {
492         .owner  = TEST_OWNER_B_ADDRESS,
493         .ip     = TEST_ADDRESS_B_PREFIX".3"
494         },
495         {
496         .owner  = TEST_OWNER_B_ADDRESS,
497         .ip     = TEST_ADDRESS_B_PREFIX".4"
498         },
499         {
500         .owner  = TEST_OWNER_X_ADDRESS,
501         .ip     = TEST_ADDRESS_X_PREFIX".3"
502         },
503         {
504         .owner  = TEST_OWNER_X_ADDRESS,
505         .ip     = TEST_ADDRESS_X_PREFIX".4"
506         }
507 };
508 static const struct wrepl_ip addresses_B_3_4_X_1_2[] = {
509         {
510         .owner  = TEST_OWNER_B_ADDRESS,
511         .ip     = TEST_ADDRESS_B_PREFIX".3"
512         },
513         {
514         .owner  = TEST_OWNER_B_ADDRESS,
515         .ip     = TEST_ADDRESS_B_PREFIX".4"
516         },
517         {
518         .owner  = TEST_OWNER_X_ADDRESS,
519         .ip     = TEST_ADDRESS_X_PREFIX".1"
520         },
521         {
522         .owner  = TEST_OWNER_X_ADDRESS,
523         .ip     = TEST_ADDRESS_X_PREFIX".2"
524         }
525 };
526
527 static const struct wrepl_ip addresses_X_1_2[] = {
528         {
529         .owner  = TEST_OWNER_X_ADDRESS,
530         .ip     = TEST_ADDRESS_X_PREFIX".1"
531         },
532         {
533         .owner  = TEST_OWNER_X_ADDRESS,
534         .ip     = TEST_ADDRESS_X_PREFIX".2"
535         }
536 };
537 static const struct wrepl_ip addresses_X_3_4[] = {
538         {
539         .owner  = TEST_OWNER_X_ADDRESS,
540         .ip     = TEST_ADDRESS_X_PREFIX".3"
541         },
542         {
543         .owner  = TEST_OWNER_X_ADDRESS,
544         .ip     = TEST_ADDRESS_X_PREFIX".4"
545         }
546 };
547
548 static struct test_wrepl_conflict_conn *test_create_conflict_ctx(TALLOC_CTX *mem_ctx,
549                                                                  const char *address)
550 {
551         struct test_wrepl_conflict_conn *ctx;
552         struct wrepl_associate associate;
553         struct wrepl_pull_table pull_table;
554         struct socket_address *nbt_srv_addr;
555         NTSTATUS status;
556         uint32_t i;
557
558         ctx = talloc_zero(mem_ctx, struct test_wrepl_conflict_conn);
559         if (!ctx) return NULL;
560
561         ctx->address    = address;
562         ctx->pull       = wrepl_socket_init(ctx, NULL);
563         if (!ctx->pull) return NULL;
564
565         printf("Setup wrepl conflict pull connection\n");
566         status = wrepl_connect(ctx->pull, NULL, ctx->address);
567         if (!NT_STATUS_IS_OK(status)) return NULL;
568
569         status = wrepl_associate(ctx->pull, &associate);
570         if (!NT_STATUS_IS_OK(status)) return NULL;
571
572         ctx->pull_assoc = associate.out.assoc_ctx;
573
574         ctx->a.address          = TEST_OWNER_A_ADDRESS;
575         ctx->a.max_version      = 0;
576         ctx->a.min_version      = 0;
577         ctx->a.type             = 1;
578
579         ctx->b.address          = TEST_OWNER_B_ADDRESS;
580         ctx->b.max_version      = 0;
581         ctx->b.min_version      = 0;
582         ctx->b.type             = 1;
583
584         ctx->x.address          = TEST_OWNER_X_ADDRESS;
585         ctx->x.max_version      = 0;
586         ctx->x.min_version      = 0;
587         ctx->x.type             = 1;
588
589         ctx->c.address          = address;
590         ctx->c.max_version      = 0;
591         ctx->c.min_version      = 0;
592         ctx->c.type             = 1;
593
594         pull_table.in.assoc_ctx = ctx->pull_assoc;
595         status = wrepl_pull_table(ctx->pull, ctx->pull, &pull_table);
596         if (!NT_STATUS_IS_OK(status)) return NULL;
597
598         for (i=0; i < pull_table.out.num_partners; i++) {
599                 if (strcmp(TEST_OWNER_A_ADDRESS,pull_table.out.partners[i].address)==0) {
600                         ctx->a.max_version      = pull_table.out.partners[i].max_version;
601                         ctx->a.min_version      = pull_table.out.partners[i].min_version;
602                 }
603                 if (strcmp(TEST_OWNER_B_ADDRESS,pull_table.out.partners[i].address)==0) {
604                         ctx->b.max_version      = pull_table.out.partners[i].max_version;
605                         ctx->b.min_version      = pull_table.out.partners[i].min_version;
606                 }
607                 if (strcmp(TEST_OWNER_X_ADDRESS,pull_table.out.partners[i].address)==0) {
608                         ctx->x.max_version      = pull_table.out.partners[i].max_version;
609                         ctx->x.min_version      = pull_table.out.partners[i].min_version;
610                 }
611                 if (strcmp(address,pull_table.out.partners[i].address)==0) {
612                         ctx->c.max_version      = pull_table.out.partners[i].max_version;
613                         ctx->c.min_version      = pull_table.out.partners[i].min_version;
614                 }
615         }
616
617         talloc_free(pull_table.out.partners);
618
619         ctx->nbtsock = nbt_name_socket_init(ctx, NULL);
620         if (!ctx->nbtsock) return NULL;
621
622         ctx->myaddr = socket_address_from_strings(mem_ctx, ctx->nbtsock->sock->backend_name, iface_best_ip(address), 0);
623         if (!ctx->myaddr) return NULL;
624
625         for (i = 0; i < iface_count(); i++) {
626                 if (strcmp(ctx->myaddr->addr, iface_n_ip(i)) == 0) continue;
627                 ctx->myaddr2 = socket_address_from_strings(mem_ctx, ctx->nbtsock->sock->backend_name, iface_n_ip(i), 0);
628                 if (!ctx->myaddr2) return NULL;
629                 break;
630         }
631
632         status = socket_listen(ctx->nbtsock->sock, ctx->myaddr, 0, 0);
633         if (!NT_STATUS_IS_OK(status)) return NULL;
634
635         ctx->nbtsock_srv = nbt_name_socket_init(ctx, NULL);
636         if (!ctx->nbtsock_srv) return NULL;
637
638         /* Make a port 137 version of ctx->myaddr */
639         nbt_srv_addr = socket_address_from_strings(mem_ctx, ctx->nbtsock_srv->sock->backend_name, ctx->myaddr->addr, lp_nbt_port());
640         if (!nbt_srv_addr) return NULL;
641
642         /* And if possible, bind to it.  This won't work unless we are root or in sockewrapper */
643         status = socket_listen(ctx->nbtsock_srv->sock, nbt_srv_addr, 0, 0);
644         talloc_free(nbt_srv_addr);
645         if (!NT_STATUS_IS_OK(status)) {
646                 /* this isn't fatal */
647                 talloc_free(ctx->nbtsock_srv);
648                 ctx->nbtsock_srv = NULL;
649         }
650
651         if (ctx->myaddr2 && ctx->nbtsock_srv) {
652                 ctx->nbtsock2 = nbt_name_socket_init(ctx, NULL);
653                 if (!ctx->nbtsock2) return NULL;
654
655                 status = socket_listen(ctx->nbtsock2->sock, ctx->myaddr2, 0, 0);
656                 if (!NT_STATUS_IS_OK(status)) return NULL;
657
658                 ctx->nbtsock_srv2 = nbt_name_socket_init(ctx, ctx->nbtsock_srv->event_ctx);
659                 if (!ctx->nbtsock_srv2) return NULL;
660
661                 /* Make a port 137 version of ctx->myaddr2 */
662                 nbt_srv_addr = socket_address_from_strings(mem_ctx, 
663                                                            ctx->nbtsock_srv->sock->backend_name, 
664                                                            ctx->myaddr2->addr, lp_nbt_port());
665                 if (!nbt_srv_addr) return NULL;
666
667                 /* And if possible, bind to it.  This won't work unless we are root or in sockewrapper */
668                 status = socket_listen(ctx->nbtsock_srv2->sock, ctx->myaddr2, 0, 0);
669                 talloc_free(nbt_srv_addr);
670                 if (!NT_STATUS_IS_OK(status)) {
671                         /* this isn't fatal */
672                         talloc_free(ctx->nbtsock_srv2);
673                         ctx->nbtsock_srv2 = NULL;
674                 }
675         }
676
677         ctx->addresses_best_num = 1;
678         ctx->addresses_best = talloc_array(ctx, struct wrepl_ip, ctx->addresses_best_num);
679         if (!ctx->addresses_best) return NULL;
680         ctx->addresses_best[0].owner    = ctx->b.address;
681         ctx->addresses_best[0].ip       = ctx->myaddr->addr;
682
683         ctx->addresses_all_num = iface_count();
684         ctx->addresses_all = talloc_array(ctx, struct wrepl_ip, ctx->addresses_all_num);
685         if (!ctx->addresses_all) return NULL;
686         for (i=0; i < ctx->addresses_all_num; i++) {
687                 ctx->addresses_all[i].owner     = ctx->b.address;
688                 ctx->addresses_all[i].ip        = talloc_strdup(ctx->addresses_all, iface_n_ip(i));
689                 if (!ctx->addresses_all[i].ip) return NULL;
690         }
691
692         if (ctx->nbtsock_srv2) {
693                 ctx->addresses_best2_num = 1;
694                 ctx->addresses_best2 = talloc_array(ctx, struct wrepl_ip, ctx->addresses_best2_num);
695                 if (!ctx->addresses_best2) return NULL;
696                 ctx->addresses_best2[0].owner   = ctx->b.address;
697                 ctx->addresses_best2[0].ip      = ctx->myaddr2->addr;
698
699                 ctx->addresses_mhomed_num = 2;
700                 ctx->addresses_mhomed = talloc_array(ctx, struct wrepl_ip, ctx->addresses_mhomed_num);
701                 if (!ctx->addresses_mhomed) return NULL;
702                 ctx->addresses_mhomed[0].owner  = ctx->b.address;
703                 ctx->addresses_mhomed[0].ip     = ctx->myaddr->addr;
704                 ctx->addresses_mhomed[1].owner  = ctx->b.address;
705                 ctx->addresses_mhomed[1].ip     = ctx->myaddr2->addr;
706         }
707
708         return ctx;
709 }
710
711 static BOOL test_wrepl_update_one(struct test_wrepl_conflict_conn *ctx,
712                                   const struct wrepl_wins_owner *owner,
713                                   const struct wrepl_wins_name *name)
714 {
715         BOOL ret = True;
716         struct wrepl_socket *wrepl_socket;
717         struct wrepl_associate associate;
718         struct wrepl_packet update_packet, repl_send;
719         struct wrepl_table *update;
720         struct wrepl_wins_owner wrepl_wins_owners[1];
721         struct wrepl_packet *repl_recv;
722         struct wrepl_wins_owner *send_request;
723         struct wrepl_send_reply *send_reply;
724         struct wrepl_wins_name wrepl_wins_names[1];
725         uint32_t assoc_ctx;
726         NTSTATUS status;
727
728         wrepl_socket = wrepl_socket_init(ctx, NULL);
729
730         status = wrepl_connect(wrepl_socket, NULL, ctx->address);
731         CHECK_STATUS(status, NT_STATUS_OK);
732
733         status = wrepl_associate(wrepl_socket, &associate);
734         CHECK_STATUS(status, NT_STATUS_OK);
735         assoc_ctx = associate.out.assoc_ctx;
736
737         /* now send a WREPL_REPL_UPDATE message */
738         ZERO_STRUCT(update_packet);
739         update_packet.opcode                    = WREPL_OPCODE_BITS;
740         update_packet.assoc_ctx                 = assoc_ctx;
741         update_packet.mess_type                 = WREPL_REPLICATION;
742         update_packet.message.replication.command       = WREPL_REPL_UPDATE;
743         update  = &update_packet.message.replication.info.table;
744
745         update->partner_count   = ARRAY_SIZE(wrepl_wins_owners);
746         update->partners        = wrepl_wins_owners;
747         update->initiator       = "0.0.0.0";
748
749         wrepl_wins_owners[0]    = *owner;
750
751         status = wrepl_request(wrepl_socket, wrepl_socket,
752                                &update_packet, &repl_recv);
753         CHECK_STATUS(status, NT_STATUS_OK);
754         CHECK_VALUE(repl_recv->mess_type, WREPL_REPLICATION);
755         CHECK_VALUE(repl_recv->message.replication.command, WREPL_REPL_SEND_REQUEST);
756         send_request = &repl_recv->message.replication.info.owner;
757
758         ZERO_STRUCT(repl_send);
759         repl_send.opcode                        = WREPL_OPCODE_BITS;
760         repl_send.assoc_ctx                     = assoc_ctx;
761         repl_send.mess_type                     = WREPL_REPLICATION;
762         repl_send.message.replication.command   = WREPL_REPL_SEND_REPLY;
763         send_reply = &repl_send.message.replication.info.reply;
764
765         send_reply->num_names   = ARRAY_SIZE(wrepl_wins_names);
766         send_reply->names       = wrepl_wins_names;
767
768         wrepl_wins_names[0]     = *name;
769
770         status = wrepl_request(wrepl_socket, wrepl_socket,
771                                &repl_send, &repl_recv);
772         CHECK_STATUS(status, NT_STATUS_OK);
773         CHECK_VALUE(repl_recv->mess_type, WREPL_STOP_ASSOCIATION);
774         CHECK_VALUE(repl_recv->message.stop.reason, 0);
775
776 done:
777         talloc_free(wrepl_socket);
778         return ret;
779 }
780
781 static BOOL test_wrepl_is_applied(struct test_wrepl_conflict_conn *ctx,
782                                   const struct wrepl_wins_owner *owner,
783                                   const struct wrepl_wins_name *name,
784                                   BOOL expected)
785 {
786         BOOL ret = True;
787         NTSTATUS status;
788         struct wrepl_pull_names pull_names;
789         struct wrepl_name *names;
790
791         pull_names.in.assoc_ctx = ctx->pull_assoc;
792         pull_names.in.partner   = *owner;
793         pull_names.in.partner.min_version = pull_names.in.partner.max_version;
794                 
795         status = wrepl_pull_names(ctx->pull, ctx->pull, &pull_names);
796         CHECK_STATUS(status, NT_STATUS_OK);
797         CHECK_VALUE(pull_names.out.num_names, (expected?1:0));
798
799         names = pull_names.out.names;
800
801         if (expected) {
802                 uint32_t flags = WREPL_NAME_FLAGS(names[0].type,
803                                                   names[0].state,
804                                                   names[0].node,
805                                                   names[0].is_static);
806                 CHECK_VALUE(names[0].name.type, name->name->type);
807                 CHECK_VALUE_STRING(names[0].name.name, name->name->name);
808                 CHECK_VALUE_STRING(names[0].name.scope, name->name->scope);
809                 CHECK_VALUE(flags, name->flags);
810                 CHECK_VALUE_UINT64(names[0].version_id, name->id);
811
812                 if (flags & 2) {
813                         CHECK_VALUE(names[0].num_addresses,
814                                     name->addresses.addresses.num_ips);
815                 } else {
816                         CHECK_VALUE(names[0].num_addresses, 1);
817                         CHECK_VALUE_STRING(names[0].addresses[0].address,
818                                            name->addresses.ip);
819                 }
820         }
821 done:
822         talloc_free(pull_names.out.names);
823         return ret;
824 }
825
826 static BOOL test_wrepl_mhomed_merged(struct test_wrepl_conflict_conn *ctx,
827                                      const struct wrepl_wins_owner *owner1,
828                                      uint32_t num_ips1, const struct wrepl_ip *ips1,
829                                      const struct wrepl_wins_owner *owner2,
830                                      uint32_t num_ips2, const struct wrepl_ip *ips2,
831                                      const struct wrepl_wins_name *name2)
832 {
833         BOOL ret = True;
834         NTSTATUS status;
835         struct wrepl_pull_names pull_names;
836         struct wrepl_name *names;
837         uint32_t flags;
838         uint32_t i, j;
839         uint32_t num_ips = num_ips1 + num_ips2;
840
841         for (i = 0; i < num_ips2; i++) {
842                 for (j = 0; j < num_ips1; j++) {
843                         if (strcmp(ips2[i].ip,ips1[j].ip) == 0) {
844                                 num_ips--;
845                                 break;
846                         }
847                 } 
848         }
849
850         pull_names.in.assoc_ctx = ctx->pull_assoc;
851         pull_names.in.partner   = *owner2;
852         pull_names.in.partner.min_version = pull_names.in.partner.max_version;
853
854         status = wrepl_pull_names(ctx->pull, ctx->pull, &pull_names);
855         CHECK_STATUS(status, NT_STATUS_OK);
856         CHECK_VALUE(pull_names.out.num_names, 1);
857
858         names = pull_names.out.names;
859
860         flags = WREPL_NAME_FLAGS(names[0].type,
861                                  names[0].state,
862                                  names[0].node,
863                                  names[0].is_static);
864         CHECK_VALUE(names[0].name.type, name2->name->type);
865         CHECK_VALUE_STRING(names[0].name.name, name2->name->name);
866         CHECK_VALUE_STRING(names[0].name.scope, name2->name->scope);
867         CHECK_VALUE(flags, name2->flags | WREPL_TYPE_MHOMED);
868         CHECK_VALUE_UINT64(names[0].version_id, name2->id);
869
870         CHECK_VALUE(names[0].num_addresses, num_ips);
871
872         for (i = 0; i < names[0].num_addresses; i++) {
873                 const char *addr = names[0].addresses[i].address; 
874                 const char *owner = names[0].addresses[i].owner;
875                 BOOL found = False;
876
877                 for (j = 0; j < num_ips2; j++) {
878                         if (strcmp(addr, ips2[j].ip) == 0) {
879                                 found = True;
880                                 CHECK_VALUE_STRING(owner, owner2->address);
881                                 break;
882                         }
883                 }
884
885                 if (found) continue;
886
887                 for (j = 0; j < num_ips1; j++) {
888                         if (strcmp(addr, ips1[j].ip) == 0) {
889                                 found = True;
890                                 CHECK_VALUE_STRING(owner, owner1->address);
891                                 break;
892                         }
893                 }
894
895                 if (found) continue;
896
897                 CHECK_VALUE_STRING(addr, "not found in address list");
898         }
899 done:
900         talloc_free(pull_names.out.names);
901         return ret;
902 }
903
904 static BOOL test_wrepl_sgroup_merged(struct test_wrepl_conflict_conn *ctx,
905                                      struct wrepl_wins_owner *merge_owner,
906                                      struct wrepl_wins_owner *owner1,
907                                      uint32_t num_ips1, const struct wrepl_ip *ips1,
908                                      struct wrepl_wins_owner *owner2,
909                                      uint32_t num_ips2, const struct wrepl_ip *ips2,
910                                      const struct wrepl_wins_name *name2)
911 {
912         BOOL ret = True;
913         NTSTATUS status;
914         struct wrepl_pull_names pull_names;
915         struct wrepl_name *names;
916         struct wrepl_name *name = NULL;
917         uint32_t flags;
918         uint32_t i, j;
919         uint32_t num_ips = num_ips1 + num_ips2;
920
921         if (!merge_owner) {
922                 merge_owner = &ctx->c;
923         }
924
925         for (i = 0; i < num_ips1; i++) {
926                 if (owner1 != &ctx->c && strcmp(ips1[i].owner,owner2->address) == 0) {
927                         num_ips--;
928                         continue;
929                 }
930                 for (j = 0; j < num_ips2; j++) {
931                         if (strcmp(ips1[i].ip,ips2[j].ip) == 0) {
932                                 num_ips--;
933                                 break;
934                         }
935                 }
936         }
937
938
939         pull_names.in.assoc_ctx = ctx->pull_assoc;
940         pull_names.in.partner   = *merge_owner;
941         pull_names.in.partner.min_version = pull_names.in.partner.max_version;
942         pull_names.in.partner.max_version = 0;
943
944         status = wrepl_pull_names(ctx->pull, ctx->pull, &pull_names);
945         CHECK_STATUS(status, NT_STATUS_OK);
946
947         names = pull_names.out.names;
948         
949         for (i = 0; i < pull_names.out.num_names; i++) {
950                 if (names[i].name.type != name2->name->type)    continue;
951                 if (!names[i].name.name) continue;
952                 if (strcmp(names[i].name.name, name2->name->name) != 0) continue;
953                 if (names[i].name.scope) continue;
954
955                 name = &names[i];
956         }
957
958         if (pull_names.out.num_names > 0) {
959                 merge_owner->max_version        = names[pull_names.out.num_names-1].version_id;
960         }
961
962         if (!name) {
963                 printf("%s: Name '%s' not found\n", __location__, nbt_name_string(ctx, name2->name));
964                 return False;
965         }
966
967         flags = WREPL_NAME_FLAGS(name->type,
968                                  name->state,
969                                  name->node,
970                                  name->is_static);
971         CHECK_VALUE(name->name.type, name2->name->type);
972         CHECK_VALUE_STRING(name->name.name, name2->name->name);
973         CHECK_VALUE_STRING(name->name.scope, name2->name->scope);
974         CHECK_VALUE(flags, name2->flags);
975
976         CHECK_VALUE(name->num_addresses, num_ips);
977
978         for (i = 0; i < name->num_addresses; i++) {
979                 const char *addr = name->addresses[i].address; 
980                 const char *owner = name->addresses[i].owner;
981                 BOOL found = False;
982
983                 for (j = 0; j < num_ips2; j++) {
984                         if (strcmp(addr, ips2[j].ip) == 0) {
985                                 found = True;
986                                 CHECK_VALUE_STRING(owner, ips2[j].owner);
987                                 break;
988                         }
989                 }
990
991                 if (found) continue;
992
993                 for (j = 0; j < num_ips1; j++) {
994                         if (strcmp(addr, ips1[j].ip) == 0) {
995                                 found = True;
996                                 if (owner1 == &ctx->c) {
997                                         CHECK_VALUE_STRING(owner, owner1->address);
998                                 } else {
999                                         CHECK_VALUE_STRING(owner, ips1[j].owner);
1000                                 }
1001                                 break;
1002                         }
1003                 }
1004
1005                 if (found) continue;
1006
1007                 CHECK_VALUE_STRING(addr, "not found in address list");
1008         }
1009 done:
1010         talloc_free(pull_names.out.names);
1011         return ret;
1012 }
1013
1014 static BOOL test_conflict_same_owner(struct test_wrepl_conflict_conn *ctx)
1015 {
1016         BOOL ret = True;
1017         struct nbt_name name;
1018         struct wrepl_wins_name wins_name1;
1019         struct wrepl_wins_name wins_name2;
1020         struct wrepl_wins_name *wins_name_tmp;
1021         struct wrepl_wins_name *wins_name_last;
1022         struct wrepl_wins_name *wins_name_cur;
1023         uint32_t i,j;
1024         uint8_t types[] = { 0x00, 0x1C };
1025         struct {
1026                 enum wrepl_name_type type;
1027                 enum wrepl_name_state state;
1028                 enum wrepl_name_node node;
1029                 BOOL is_static;
1030                 uint32_t num_ips;
1031                 const struct wrepl_ip *ips;
1032         } records[] = {
1033                 {
1034                 .type           = WREPL_TYPE_GROUP,
1035                 .state          = WREPL_STATE_ACTIVE,
1036                 .node           = WREPL_NODE_B,
1037                 .is_static      = False,
1038                 .num_ips        = ARRAY_SIZE(addresses_A_1),
1039                 .ips            = addresses_A_1,
1040                 },{
1041                 .type           = WREPL_TYPE_UNIQUE,
1042                 .state          = WREPL_STATE_ACTIVE,
1043                 .node           = WREPL_NODE_B,
1044                 .is_static      = False,
1045                 .num_ips        = ARRAY_SIZE(addresses_A_1),
1046                 .ips            = addresses_A_1,
1047                 },{
1048                 .type           = WREPL_TYPE_UNIQUE,
1049                 .state          = WREPL_STATE_ACTIVE,
1050                 .node           = WREPL_NODE_B,
1051                 .is_static      = False,
1052                 .num_ips        = ARRAY_SIZE(addresses_A_2),
1053                 .ips            = addresses_A_2,
1054                 },{
1055                 .type           = WREPL_TYPE_UNIQUE,
1056                 .state          = WREPL_STATE_ACTIVE,
1057                 .node           = WREPL_NODE_B,
1058                 .is_static      = True,
1059                 .num_ips        = ARRAY_SIZE(addresses_A_1),
1060                 .ips            = addresses_A_1,
1061                 },{
1062                 .type           = WREPL_TYPE_UNIQUE,
1063                 .state          = WREPL_STATE_ACTIVE,
1064                 .node           = WREPL_NODE_B,
1065                 .is_static      = False,
1066                 .num_ips        = ARRAY_SIZE(addresses_A_2),
1067                 .ips            = addresses_A_2,
1068                 },{
1069                 .type           = WREPL_TYPE_SGROUP,
1070                 .state          = WREPL_STATE_TOMBSTONE,
1071                 .node           = WREPL_NODE_B,
1072                 .is_static      = False,
1073                 .num_ips        = ARRAY_SIZE(addresses_A_2),
1074                 .ips            = addresses_A_2,
1075                 },{
1076                 .type           = WREPL_TYPE_MHOMED,
1077                 .state          = WREPL_STATE_TOMBSTONE,
1078                 .node           = WREPL_NODE_B,
1079                 .is_static      = False,
1080                 .num_ips        = ARRAY_SIZE(addresses_A_1),
1081                 .ips            = addresses_A_1,
1082                 },{
1083                 .type           = WREPL_TYPE_MHOMED,
1084                 .state          = WREPL_STATE_RELEASED,
1085                 .node           = WREPL_NODE_B,
1086                 .is_static      = False,
1087                 .num_ips        = ARRAY_SIZE(addresses_A_2),
1088                 .ips            = addresses_A_2,
1089                 },{
1090                 .type           = WREPL_TYPE_SGROUP,
1091                 .state          = WREPL_STATE_ACTIVE,
1092                 .node           = WREPL_NODE_B,
1093                 .is_static      = False,
1094                 .num_ips        = ARRAY_SIZE(addresses_A_1),
1095                 .ips            = addresses_A_1,
1096                 },{
1097                 .type           = WREPL_TYPE_SGROUP,
1098                 .state          = WREPL_STATE_ACTIVE,
1099                 .node           = WREPL_NODE_B,
1100                 .is_static      = False,
1101                 .num_ips        = ARRAY_SIZE(addresses_A_3_4),
1102                 .ips            = addresses_A_3_4,
1103                 },{
1104                 .type           = WREPL_TYPE_SGROUP,
1105                 .state          = WREPL_STATE_TOMBSTONE,
1106                 .node           = WREPL_NODE_B,
1107                 .is_static      = False,
1108                 .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1109                 .ips            = addresses_B_3_4,
1110                 },{
1111                 /* the last one should always be a unique,tomstone record! */
1112                 .type           = WREPL_TYPE_UNIQUE,
1113                 .state          = WREPL_STATE_TOMBSTONE,
1114                 .node           = WREPL_NODE_B,
1115                 .is_static      = False,
1116                 .num_ips        = ARRAY_SIZE(addresses_A_1),
1117                 .ips            = addresses_A_1,
1118                 }
1119         };
1120
1121         name.name       = "_SAME_OWNER_A";
1122         name.type       = 0;
1123         name.scope      = NULL;
1124
1125         wins_name_tmp   = NULL;
1126         wins_name_last  = &wins_name2;
1127         wins_name_cur   = &wins_name1;
1128
1129         for (j=0; ret && j < ARRAY_SIZE(types); j++) {
1130                 name.type = types[j];
1131                 printf("Test Replica Conflicts with same owner[%s] for %s\n",
1132                         nbt_name_string(ctx, &name), ctx->a.address);
1133
1134                 for(i=0; ret && i < ARRAY_SIZE(records); i++) {
1135                         wins_name_tmp   = wins_name_last;
1136                         wins_name_last  = wins_name_cur;
1137                         wins_name_cur   = wins_name_tmp;
1138
1139                         if (i > 0) {
1140                                 printf("%s,%s%s vs. %s,%s%s with %s ip(s) => %s\n",
1141                                         wrepl_name_type_string(records[i-1].type),
1142                                         wrepl_name_state_string(records[i-1].state),
1143                                         (records[i-1].is_static?",static":""),
1144                                         wrepl_name_type_string(records[i].type),
1145                                         wrepl_name_state_string(records[i].state),
1146                                         (records[i].is_static?",static":""),
1147                                         (records[i-1].ips==records[i].ips?"same":"different"),
1148                                         "REPLACE");
1149                         }
1150
1151                         wins_name_cur->name     = &name;
1152                         wins_name_cur->flags    = WREPL_NAME_FLAGS(records[i].type,
1153                                                                    records[i].state,
1154                                                                    records[i].node,
1155                                                                    records[i].is_static);
1156                         wins_name_cur->id       = ++ctx->a.max_version;
1157                         if (wins_name_cur->flags & 2) {
1158                                 wins_name_cur->addresses.addresses.num_ips = records[i].num_ips;
1159                                 wins_name_cur->addresses.addresses.ips     = discard_const(records[i].ips);
1160                         } else {
1161                                 wins_name_cur->addresses.ip = records[i].ips[0].ip;
1162                         }
1163                         wins_name_cur->unknown  = "255.255.255.255";
1164
1165                         ret &= test_wrepl_update_one(ctx, &ctx->a,wins_name_cur);
1166                         if (records[i].state == WREPL_STATE_RELEASED) {
1167                                 ret &= test_wrepl_is_applied(ctx, &ctx->a, wins_name_last, False);
1168                                 ret &= test_wrepl_is_applied(ctx, &ctx->a, wins_name_cur, False);
1169                         } else {
1170                                 ret &= test_wrepl_is_applied(ctx, &ctx->a, wins_name_cur, True);
1171                         }
1172
1173                         /* the first one is a cleanup run */
1174                         if (!ret && i == 0) ret = True;
1175
1176                         if (!ret) {
1177                                 printf("conflict handled wrong or record[%u]: %s\n", i, __location__);
1178                                 return ret;
1179                         }
1180                 }
1181         }
1182         return ret;
1183 }
1184
1185 static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx)
1186 {
1187         BOOL ret = True;
1188         struct wrepl_wins_name wins_name1;
1189         struct wrepl_wins_name wins_name2;
1190         struct wrepl_wins_name *wins_name_r1;
1191         struct wrepl_wins_name *wins_name_r2;
1192         uint32_t i;
1193         struct {
1194                 const char *line; /* just better debugging */
1195                 struct nbt_name name;
1196                 const char *comment;
1197                 BOOL extra; /* not the worst case, this is an extra test */
1198                 BOOL cleanup;
1199                 struct {
1200                         struct wrepl_wins_owner *owner;
1201                         enum wrepl_name_type type;
1202                         enum wrepl_name_state state;
1203                         enum wrepl_name_node node;
1204                         BOOL is_static;
1205                         uint32_t num_ips;
1206                         const struct wrepl_ip *ips;
1207                         BOOL apply_expected;
1208                         BOOL sgroup_merge;
1209                         struct wrepl_wins_owner *merge_owner;
1210                         BOOL sgroup_cleanup;
1211                 } r1, r2;
1212         } records[] = {
1213         /* 
1214          * NOTE: the first record and the last applied one
1215          *       needs to be from the same owner,
1216          *       to not conflict in the next smbtorture run!!!
1217          */
1218         {
1219                 .line   = __location__,
1220                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1221                 .cleanup= True,
1222                 .r1     = {
1223                         .owner          = &ctx->b,
1224                         .type           = WREPL_TYPE_UNIQUE,
1225                         .state          = WREPL_STATE_TOMBSTONE,
1226                         .node           = WREPL_NODE_B,
1227                         .is_static      = False,
1228                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1229                         .ips            = addresses_B_1,
1230                         .apply_expected = True /* ignored */
1231                 },
1232                 .r2     = {
1233                         .owner          = &ctx->a,
1234                         .type           = WREPL_TYPE_UNIQUE,
1235                         .state          = WREPL_STATE_TOMBSTONE,
1236                         .node           = WREPL_NODE_B,
1237                         .is_static      = False,
1238                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1239                         .ips            = addresses_A_1,
1240                         .apply_expected = True /* ignored */
1241                 }
1242         },
1243
1244 /*
1245  * unique vs unique section
1246  */
1247         /* 
1248          * unique,active vs. unique,active
1249          * => should be replaced
1250          */
1251         {
1252                 .line   = __location__,
1253                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1254                 .r1     = {
1255                         .owner          = &ctx->a,
1256                         .type           = WREPL_TYPE_UNIQUE,
1257                         .state          = WREPL_STATE_ACTIVE,
1258                         .node           = WREPL_NODE_B,
1259                         .is_static      = False,
1260                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1261                         .ips            = addresses_A_1,
1262                         .apply_expected = True
1263                 },
1264                 .r2     = {
1265                         .owner          = &ctx->b,
1266                         .type           = WREPL_TYPE_UNIQUE,
1267                         .state          = WREPL_STATE_ACTIVE,
1268                         .node           = WREPL_NODE_B,
1269                         .is_static      = False,
1270                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1271                         .ips            = addresses_B_1,
1272                         .apply_expected = True
1273                 }
1274         },
1275
1276         /* 
1277          * unique,active vs. unique,tombstone
1278          * => should NOT be replaced
1279          */
1280         {
1281                 .line   = __location__,
1282                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1283                 .r1     = {
1284                         .owner          = &ctx->b,
1285                         .type           = WREPL_TYPE_UNIQUE,
1286                         .state          = WREPL_STATE_ACTIVE,
1287                         .node           = WREPL_NODE_B,
1288                         .is_static      = False,
1289                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1290                         .ips            = addresses_B_1,
1291                         .apply_expected = True
1292                 },
1293                 .r2     = {
1294                         .owner          = &ctx->a,
1295                         .type           = WREPL_TYPE_UNIQUE,
1296                         .state          = WREPL_STATE_TOMBSTONE,
1297                         .node           = WREPL_NODE_B,
1298                         .is_static      = False,
1299                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1300                         .ips            = addresses_B_1,
1301                         .apply_expected = False
1302                 }
1303         },
1304
1305         /* 
1306          * unique,released vs. unique,active
1307          * => should be replaced
1308          */
1309         {
1310                 .line   = __location__,
1311                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1312                 .r1     = {
1313                         .owner          = &ctx->b,
1314                         .type           = WREPL_TYPE_UNIQUE,
1315                         .state          = WREPL_STATE_RELEASED,
1316                         .node           = WREPL_NODE_B,
1317                         .is_static      = False,
1318                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1319                         .ips            = addresses_B_1,
1320                         .apply_expected = False
1321                 },
1322                 .r2     = {
1323                         .owner          = &ctx->a,
1324                         .type           = WREPL_TYPE_UNIQUE,
1325                         .state          = WREPL_STATE_ACTIVE,
1326                         .node           = WREPL_NODE_B,
1327                         .is_static      = False,
1328                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1329                         .ips            = addresses_A_1,
1330                         .apply_expected = True
1331                 }
1332         },
1333
1334         /* 
1335          * unique,released vs. unique,tombstone
1336          * => should be replaced
1337          */
1338         {
1339                 .line   = __location__,
1340                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1341                 .r1     = {
1342                         .owner          = &ctx->a,
1343                         .type           = WREPL_TYPE_UNIQUE,
1344                         .state          = WREPL_STATE_RELEASED,
1345                         .node           = WREPL_NODE_B,
1346                         .is_static      = False,
1347                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1348                         .ips            = addresses_A_1,
1349                         .apply_expected = False
1350                 },
1351                 .r2     = {
1352                         .owner          = &ctx->b,
1353                         .type           = WREPL_TYPE_UNIQUE,
1354                         .state          = WREPL_STATE_TOMBSTONE,
1355                         .node           = WREPL_NODE_B,
1356                         .is_static      = False,
1357                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1358                         .ips            = addresses_B_1,
1359                         .apply_expected = True
1360                 }
1361         },
1362
1363         /* 
1364          * unique,tombstone vs. unique,active
1365          * => should be replaced
1366          */
1367         {
1368                 .line   = __location__,
1369                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1370                 .r1     = {
1371                         .owner          = &ctx->b,
1372                         .type           = WREPL_TYPE_UNIQUE,
1373                         .state          = WREPL_STATE_TOMBSTONE,
1374                         .node           = WREPL_NODE_B,
1375                         .is_static      = False,
1376                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1377                         .ips            = addresses_B_1,
1378                         .apply_expected = True
1379                 },
1380                 .r2     = {
1381                         .owner          = &ctx->a,
1382                         .type           = WREPL_TYPE_UNIQUE,
1383                         .state          = WREPL_STATE_ACTIVE,
1384                         .node           = WREPL_NODE_B,
1385                         .is_static      = False,
1386                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1387                         .ips            = addresses_A_1,
1388                         .apply_expected = True
1389                 }
1390         },
1391
1392         /* 
1393          * unique,tombstone vs. unique,tombstone
1394          * => should be replaced
1395          */
1396         {
1397                 .line   = __location__,
1398                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1399                 .r1     = {
1400                         .owner          = &ctx->a,
1401                         .type           = WREPL_TYPE_UNIQUE,
1402                         .state          = WREPL_STATE_TOMBSTONE,
1403                         .node           = WREPL_NODE_B,
1404                         .is_static      = False,
1405                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1406                         .ips            = addresses_A_1,
1407                         .apply_expected = True
1408                 },
1409                 .r2     = {
1410                         .owner          = &ctx->b,
1411                         .type           = WREPL_TYPE_UNIQUE,
1412                         .state          = WREPL_STATE_TOMBSTONE,
1413                         .node           = WREPL_NODE_B,
1414                         .is_static      = False,
1415                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1416                         .ips            = addresses_B_1,
1417                         .apply_expected = True
1418                 }
1419         },
1420
1421
1422 /*
1423  * unique vs normal groups section,
1424  */
1425         /* 
1426          * unique,active vs. group,active
1427          * => should be replaced
1428          */
1429         {
1430                 .line   = __location__,
1431                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1432                 .r1     = {
1433                         .owner          = &ctx->b,
1434                         .type           = WREPL_TYPE_UNIQUE,
1435                         .state          = WREPL_STATE_ACTIVE,
1436                         .node           = WREPL_NODE_B,
1437                         .is_static      = False,
1438                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1439                         .ips            = addresses_B_1,
1440                         .apply_expected = True
1441                 },
1442                 .r2     = {
1443                         .owner          = &ctx->a,
1444                         .type           = WREPL_TYPE_GROUP,
1445                         .state          = WREPL_STATE_ACTIVE,
1446                         .node           = WREPL_NODE_B,
1447                         .is_static      = False,
1448                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1449                         .ips            = addresses_A_1,
1450                         .apply_expected = True
1451                 }
1452         },
1453
1454         /* 
1455          * unique,active vs. group,tombstone
1456          * => should NOT be replaced
1457          */
1458         {
1459                 .line   = __location__,
1460                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1461                 .r1     = {
1462                         .owner          = &ctx->a,
1463                         .type           = WREPL_TYPE_UNIQUE,
1464                         .state          = WREPL_STATE_ACTIVE,
1465                         .node           = WREPL_NODE_B,
1466                         .is_static      = False,
1467                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1468                         .ips            = addresses_A_1,
1469                         .apply_expected = True
1470                 },
1471                 .r2     = {
1472                         .owner          = &ctx->b,
1473                         .type           = WREPL_TYPE_GROUP,
1474                         .state          = WREPL_STATE_TOMBSTONE,
1475                         .node           = WREPL_NODE_B,
1476                         .is_static      = False,
1477                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1478                         .ips            = addresses_A_1,
1479                         .apply_expected = False
1480                 }
1481         },
1482
1483         /* 
1484          * unique,released vs. group,active
1485          * => should be replaced
1486          */
1487         {
1488                 .line   = __location__,
1489                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1490                 .r1     = {
1491                         .owner          = &ctx->a,
1492                         .type           = WREPL_TYPE_UNIQUE,
1493                         .state          = WREPL_STATE_RELEASED,
1494                         .node           = WREPL_NODE_B,
1495                         .is_static      = False,
1496                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1497                         .ips            = addresses_A_1,
1498                         .apply_expected = False
1499                 },
1500                 .r2     = {
1501                         .owner          = &ctx->b,
1502                         .type           = WREPL_TYPE_GROUP,
1503                         .state          = WREPL_STATE_ACTIVE,
1504                         .node           = WREPL_NODE_B,
1505                         .is_static      = False,
1506                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1507                         .ips            = addresses_B_1,
1508                         .apply_expected = True
1509                 }
1510         },
1511
1512         /* 
1513          * unique,released vs. group,tombstone
1514          * => should be replaced
1515          */
1516         {
1517                 .line   = __location__,
1518                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1519                 .r1     = {
1520                         .owner          = &ctx->b,
1521                         .type           = WREPL_TYPE_UNIQUE,
1522                         .state          = WREPL_STATE_RELEASED,
1523                         .node           = WREPL_NODE_B,
1524                         .is_static      = False,
1525                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1526                         .ips            = addresses_B_1,
1527                         .apply_expected = False
1528                 },
1529                 .r2     = {
1530                         .owner          = &ctx->a,
1531                         .type           = WREPL_TYPE_GROUP,
1532                         .state          = WREPL_STATE_TOMBSTONE,
1533                         .node           = WREPL_NODE_B,
1534                         .is_static      = False,
1535                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1536                         .ips            = addresses_A_1,
1537                         .apply_expected = True
1538                 }
1539         },
1540
1541         /* 
1542          * unique,tombstone vs. group,active
1543          * => should be replaced
1544          */
1545         {
1546                 .line   = __location__,
1547                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1548                 .r1     = {
1549                         .owner          = &ctx->a,
1550                         .type           = WREPL_TYPE_UNIQUE,
1551                         .state          = WREPL_STATE_TOMBSTONE,
1552                         .node           = WREPL_NODE_B,
1553                         .is_static      = False,
1554                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1555                         .ips            = addresses_A_1,
1556                         .apply_expected = True
1557                 },
1558                 .r2     = {
1559                         .owner          = &ctx->b,
1560                         .type           = WREPL_TYPE_GROUP,
1561                         .state          = WREPL_STATE_ACTIVE,
1562                         .node           = WREPL_NODE_B,
1563                         .is_static      = False,
1564                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1565                         .ips            = addresses_B_1,
1566                         .apply_expected = True
1567                 }
1568         },
1569
1570         /* 
1571          * unique,tombstone vs. group,tombstone
1572          * => should be replaced
1573          */
1574         {
1575                 .line   = __location__,
1576                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1577                 .r1     = {
1578                         .owner          = &ctx->b,
1579                         .type           = WREPL_TYPE_UNIQUE,
1580                         .state          = WREPL_STATE_TOMBSTONE,
1581                         .node           = WREPL_NODE_B,
1582                         .is_static      = False,
1583                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1584                         .ips            = addresses_B_1,
1585                         .apply_expected = True
1586                 },
1587                 .r2     = {
1588                         .owner          = &ctx->a,
1589                         .type           = WREPL_TYPE_GROUP,
1590                         .state          = WREPL_STATE_TOMBSTONE,
1591                         .node           = WREPL_NODE_B,
1592                         .is_static      = False,
1593                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1594                         .ips            = addresses_A_1,
1595                         .apply_expected = True
1596                 }
1597         },
1598
1599 /*
1600  * unique vs special groups section,
1601  */
1602         /* 
1603          * unique,active vs. sgroup,active
1604          * => should NOT be replaced
1605          */
1606         {
1607                 .line   = __location__,
1608                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1609                 .r1     = {
1610                         .owner          = &ctx->a,
1611                         .type           = WREPL_TYPE_UNIQUE,
1612                         .state          = WREPL_STATE_ACTIVE,
1613                         .node           = WREPL_NODE_B,
1614                         .is_static      = False,
1615                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1616                         .ips            = addresses_A_1,
1617                         .apply_expected = True
1618                 },
1619                 .r2     = {
1620                         .owner          = &ctx->b,
1621                         .type           = WREPL_TYPE_SGROUP,
1622                         .state          = WREPL_STATE_ACTIVE,
1623                         .node           = WREPL_NODE_B,
1624                         .is_static      = False,
1625                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1626                         .ips            = addresses_A_1,
1627                         .apply_expected = False
1628                 }
1629         },
1630
1631         /* 
1632          * unique,active vs. sgroup,tombstone
1633          * => should NOT be replaced
1634          */
1635         {
1636                 .line   = __location__,
1637                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1638                 .r1     = {
1639                         .owner          = &ctx->a,
1640                         .type           = WREPL_TYPE_UNIQUE,
1641                         .state          = WREPL_STATE_ACTIVE,
1642                         .node           = WREPL_NODE_B,
1643                         .is_static      = False,
1644                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1645                         .ips            = addresses_A_1,
1646                         .apply_expected = True
1647                 },
1648                 .r2     = {
1649                         .owner          = &ctx->b,
1650                         .type           = WREPL_TYPE_SGROUP,
1651                         .state          = WREPL_STATE_TOMBSTONE,
1652                         .node           = WREPL_NODE_B,
1653                         .is_static      = False,
1654                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1655                         .ips            = addresses_A_1,
1656                         .apply_expected = False
1657                 }
1658         },
1659
1660         /* 
1661          * unique,released vs. sgroup,active
1662          * => should be replaced
1663          */
1664         {
1665                 .line   = __location__,
1666                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1667                 .r1     = {
1668                         .owner          = &ctx->a,
1669                         .type           = WREPL_TYPE_UNIQUE,
1670                         .state          = WREPL_STATE_RELEASED,
1671                         .node           = WREPL_NODE_B,
1672                         .is_static      = False,
1673                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1674                         .ips            = addresses_A_1,
1675                         .apply_expected = False
1676                 },
1677                 .r2     = {
1678                         .owner          = &ctx->b,
1679                         .type           = WREPL_TYPE_SGROUP,
1680                         .state          = WREPL_STATE_ACTIVE,
1681                         .node           = WREPL_NODE_B,
1682                         .is_static      = False,
1683                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1684                         .ips            = addresses_B_3_4,
1685                         .apply_expected = True
1686                 }
1687         },
1688
1689         /* 
1690          * unique,released vs. sgroup,tombstone
1691          * => should be replaced
1692          */
1693         {
1694                 .line   = __location__,
1695                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1696                 .r1     = {
1697                         .owner          = &ctx->b,
1698                         .type           = WREPL_TYPE_UNIQUE,
1699                         .state          = WREPL_STATE_RELEASED,
1700                         .node           = WREPL_NODE_B,
1701                         .is_static      = False,
1702                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1703                         .ips            = addresses_B_1,
1704                         .apply_expected = False
1705                 },
1706                 .r2     = {
1707                         .owner          = &ctx->a,
1708                         .type           = WREPL_TYPE_SGROUP,
1709                         .state          = WREPL_STATE_TOMBSTONE,
1710                         .node           = WREPL_NODE_B,
1711                         .is_static      = False,
1712                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
1713                         .ips            = addresses_A_3_4,
1714                         .apply_expected = True
1715                 }
1716         },
1717
1718         /* 
1719          * unique,tombstone vs. sgroup,active
1720          * => should be replaced
1721          */
1722         {
1723                 .line   = __location__,
1724                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1725                 .r1     = {
1726                         .owner          = &ctx->a,
1727                         .type           = WREPL_TYPE_UNIQUE,
1728                         .state          = WREPL_STATE_TOMBSTONE,
1729                         .node           = WREPL_NODE_B,
1730                         .is_static      = False,
1731                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1732                         .ips            = addresses_A_1,
1733                         .apply_expected = True
1734                 },
1735                 .r2     = {
1736                         .owner          = &ctx->b,
1737                         .type           = WREPL_TYPE_SGROUP,
1738                         .state          = WREPL_STATE_ACTIVE,
1739                         .node           = WREPL_NODE_B,
1740                         .is_static      = False,
1741                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1742                         .ips            = addresses_B_3_4,
1743                         .apply_expected = True
1744                 }
1745         },
1746
1747         /* 
1748          * unique,tombstone vs. sgroup,tombstone
1749          * => should be replaced
1750          */
1751         {
1752                 .line   = __location__,
1753                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1754                 .r1     = {
1755                         .owner          = &ctx->b,
1756                         .type           = WREPL_TYPE_UNIQUE,
1757                         .state          = WREPL_STATE_TOMBSTONE,
1758                         .node           = WREPL_NODE_B,
1759                         .is_static      = False,
1760                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1761                         .ips            = addresses_B_1,
1762                         .apply_expected = True
1763                 },
1764                 .r2     = {
1765                         .owner          = &ctx->a,
1766                         .type           = WREPL_TYPE_SGROUP,
1767                         .state          = WREPL_STATE_TOMBSTONE,
1768                         .node           = WREPL_NODE_B,
1769                         .is_static      = False,
1770                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
1771                         .ips            = addresses_A_3_4,
1772                         .apply_expected = True
1773                 }
1774         },
1775
1776 /*
1777  * unique vs multi homed section,
1778  */
1779         /* 
1780          * unique,active vs. mhomed,active
1781          * => should be replaced
1782          */
1783         {
1784                 .line   = __location__,
1785                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1786                 .r1     = {
1787                         .owner          = &ctx->a,
1788                         .type           = WREPL_TYPE_UNIQUE,
1789                         .state          = WREPL_STATE_ACTIVE,
1790                         .node           = WREPL_NODE_B,
1791                         .is_static      = False,
1792                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1793                         .ips            = addresses_A_1,
1794                         .apply_expected = True
1795                 },
1796                 .r2     = {
1797                         .owner          = &ctx->b,
1798                         .type           = WREPL_TYPE_MHOMED,
1799                         .state          = WREPL_STATE_ACTIVE,
1800                         .node           = WREPL_NODE_B,
1801                         .is_static      = False,
1802                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1803                         .ips            = addresses_B_3_4,
1804                         .apply_expected = True
1805                 }
1806         },
1807
1808         /* 
1809          * unique,active vs. mhomed,tombstone
1810          * => should NOT be replaced
1811          */
1812         {
1813                 .line   = __location__,
1814                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1815                 .r1     = {
1816                         .owner          = &ctx->b,
1817                         .type           = WREPL_TYPE_UNIQUE,
1818                         .state          = WREPL_STATE_ACTIVE,
1819                         .node           = WREPL_NODE_B,
1820                         .is_static      = False,
1821                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1822                         .ips            = addresses_B_3_4,
1823                         .apply_expected = True
1824                 },
1825                 .r2     = {
1826                         .owner          = &ctx->a,
1827                         .type           = WREPL_TYPE_MHOMED,
1828                         .state          = WREPL_STATE_TOMBSTONE,
1829                         .node           = WREPL_NODE_B,
1830                         .is_static      = False,
1831                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1832                         .ips            = addresses_B_3_4,
1833                         .apply_expected = False
1834                 }
1835         },
1836
1837         /* 
1838          * unique,released vs. mhomed,active
1839          * => should be replaced
1840          */
1841         {
1842                 .line   = __location__,
1843                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1844                 .r1     = {
1845                         .owner          = &ctx->b,
1846                         .type           = WREPL_TYPE_UNIQUE,
1847                         .state          = WREPL_STATE_RELEASED,
1848                         .node           = WREPL_NODE_B,
1849                         .is_static      = False,
1850                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1851                         .ips            = addresses_B_1,
1852                         .apply_expected = False
1853                 },
1854                 .r2     = {
1855                         .owner          = &ctx->a,
1856                         .type           = WREPL_TYPE_MHOMED,
1857                         .state          = WREPL_STATE_ACTIVE,
1858                         .node           = WREPL_NODE_B,
1859                         .is_static      = False,
1860                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
1861                         .ips            = addresses_A_3_4,
1862                         .apply_expected = True
1863                 }
1864         },
1865
1866         /* 
1867          * unique,released vs. mhomed,tombstone
1868          * => should be replaced
1869          */
1870         {
1871                 .line   = __location__,
1872                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1873                 .r1     = {
1874                         .owner          = &ctx->a,
1875                         .type           = WREPL_TYPE_UNIQUE,
1876                         .state          = WREPL_STATE_RELEASED,
1877                         .node           = WREPL_NODE_B,
1878                         .is_static      = False,
1879                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1880                         .ips            = addresses_A_1,
1881                         .apply_expected = False
1882                 },
1883                 .r2     = {
1884                         .owner          = &ctx->b,
1885                         .type           = WREPL_TYPE_MHOMED,
1886                         .state          = WREPL_STATE_TOMBSTONE,
1887                         .node           = WREPL_NODE_B,
1888                         .is_static      = False,
1889                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1890                         .ips            = addresses_B_3_4,
1891                         .apply_expected = True
1892                 }
1893         },
1894
1895         /* 
1896          * unique,tombstone vs. mhomed,active
1897          * => should be replaced
1898          */
1899         {
1900                 .line   = __location__,
1901                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1902                 .r1     = {
1903                         .owner          = &ctx->b,
1904                         .type           = WREPL_TYPE_UNIQUE,
1905                         .state          = WREPL_STATE_TOMBSTONE,
1906                         .node           = WREPL_NODE_B,
1907                         .is_static      = False,
1908                         .num_ips        = ARRAY_SIZE(addresses_B_1),
1909                         .ips            = addresses_B_1,
1910                         .apply_expected = True
1911                 },
1912                 .r2     = {
1913                         .owner          = &ctx->a,
1914                         .type           = WREPL_TYPE_MHOMED,
1915                         .state          = WREPL_STATE_ACTIVE,
1916                         .node           = WREPL_NODE_B,
1917                         .is_static      = False,
1918                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
1919                         .ips            = addresses_A_3_4,
1920                         .apply_expected = True
1921                 }
1922         },
1923
1924         /* 
1925          * unique,tombstone vs. mhomed,tombstone
1926          * => should be replaced
1927          */
1928         {
1929                 .line   = __location__,
1930                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1931                 .r1     = {
1932                         .owner          = &ctx->a,
1933                         .type           = WREPL_TYPE_UNIQUE,
1934                         .state          = WREPL_STATE_TOMBSTONE,
1935                         .node           = WREPL_NODE_B,
1936                         .is_static      = False,
1937                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1938                         .ips            = addresses_A_1,
1939                         .apply_expected = True
1940                 },
1941                 .r2     = {
1942                         .owner          = &ctx->b,
1943                         .type           = WREPL_TYPE_MHOMED,
1944                         .state          = WREPL_STATE_TOMBSTONE,
1945                         .node           = WREPL_NODE_B,
1946                         .is_static      = False,
1947                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
1948                         .ips            = addresses_B_3_4,
1949                         .apply_expected = True
1950                 }
1951         },
1952
1953 /*
1954  * normal groups vs unique section,
1955  */
1956         /* 
1957          * group,active vs. unique,active
1958          * => should NOT be replaced
1959          */
1960         {
1961                 .line   = __location__,
1962                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1963                 .r1     = {
1964                         .owner          = &ctx->a,
1965                         .type           = WREPL_TYPE_GROUP,
1966                         .state          = WREPL_STATE_ACTIVE,
1967                         .node           = WREPL_NODE_B,
1968                         .is_static      = False,
1969                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1970                         .ips            = addresses_A_1,
1971                         .apply_expected = True
1972                 },
1973                 .r2     = {
1974                         .owner          = &ctx->b,
1975                         .type           = WREPL_TYPE_UNIQUE,
1976                         .state          = WREPL_STATE_ACTIVE,
1977                         .node           = WREPL_NODE_B,
1978                         .is_static      = False,
1979                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1980                         .ips            = addresses_A_1,
1981                         .apply_expected = False
1982                 }
1983         },
1984
1985         /* 
1986          * group,active vs. unique,tombstone
1987          * => should NOT be replaced
1988          */
1989         {
1990                 .line   = __location__,
1991                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
1992                 .r1     = {
1993                         .owner          = &ctx->a,
1994                         .type           = WREPL_TYPE_GROUP,
1995                         .state          = WREPL_STATE_ACTIVE,
1996                         .node           = WREPL_NODE_B,
1997                         .is_static      = False,
1998                         .num_ips        = ARRAY_SIZE(addresses_A_1),
1999                         .ips            = addresses_A_1,
2000                         .apply_expected = True
2001                 },
2002                 .r2     = {
2003                         .owner          = &ctx->b,
2004                         .type           = WREPL_TYPE_UNIQUE,
2005                         .state          = WREPL_STATE_TOMBSTONE,
2006                         .node           = WREPL_NODE_B,
2007                         .is_static      = False,
2008                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2009                         .ips            = addresses_A_1,
2010                         .apply_expected = False
2011                 }
2012         },
2013
2014         /* 
2015          * group,released vs. unique,active
2016          * => should NOT be replaced
2017          */
2018         {
2019                 .line   = __location__,
2020                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2021                 .r1     = {
2022                         .owner          = &ctx->a,
2023                         .type           = WREPL_TYPE_GROUP,
2024                         .state          = WREPL_STATE_RELEASED,
2025                         .node           = WREPL_NODE_B,
2026                         .is_static      = False,
2027                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2028                         .ips            = addresses_A_1,
2029                         .apply_expected = False
2030                 },
2031                 .r2     = {
2032                         .owner          = &ctx->b,
2033                         .type           = WREPL_TYPE_UNIQUE,
2034                         .state          = WREPL_STATE_ACTIVE,
2035                         .node           = WREPL_NODE_B,
2036                         .is_static      = False,
2037                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2038                         .ips            = addresses_A_1,
2039                         .apply_expected = False
2040                 }
2041         },
2042
2043         /* 
2044          * group,released vs. unique,tombstone
2045          * => should NOT be replaced
2046          */
2047         {
2048                 .line   = __location__,
2049                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2050                 .r1     = {
2051                         .owner          = &ctx->a,
2052                         .type           = WREPL_TYPE_GROUP,
2053                         .state          = WREPL_STATE_RELEASED,
2054                         .node           = WREPL_NODE_B,
2055                         .is_static      = False,
2056                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2057                         .ips            = addresses_A_1,
2058                         .apply_expected = False
2059                 },
2060                 .r2     = {
2061                         .owner          = &ctx->b,
2062                         .type           = WREPL_TYPE_UNIQUE,
2063                         .state          = WREPL_STATE_TOMBSTONE,
2064                         .node           = WREPL_NODE_B,
2065                         .is_static      = False,
2066                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2067                         .ips            = addresses_A_1,
2068                         .apply_expected = False
2069                 }
2070         },
2071
2072         /* 
2073          * group,tombstone vs. unique,active
2074          * => should NOT be replaced
2075          */
2076         {
2077                 .line   = __location__,
2078                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2079                 .r1     = {
2080                         .owner          = &ctx->a,
2081                         .type           = WREPL_TYPE_GROUP,
2082                         .state          = WREPL_STATE_TOMBSTONE,
2083                         .node           = WREPL_NODE_B,
2084                         .is_static      = False,
2085                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2086                         .ips            = addresses_A_1,
2087                         .apply_expected = True
2088                 },
2089                 .r2     = {
2090                         .owner          = &ctx->b,
2091                         .type           = WREPL_TYPE_UNIQUE,
2092                         .state          = WREPL_STATE_ACTIVE,
2093                         .node           = WREPL_NODE_B,
2094                         .is_static      = False,
2095                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2096                         .ips            = addresses_A_1,
2097                         .apply_expected = False
2098                 }
2099         },
2100
2101         /* 
2102          * group,tombstone vs. unique,tombstone
2103          * => should NOT be replaced
2104          */
2105         {
2106                 .line   = __location__,
2107                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2108                 .r1     = {
2109                         .owner          = &ctx->a,
2110                         .type           = WREPL_TYPE_GROUP,
2111                         .state          = WREPL_STATE_TOMBSTONE,
2112                         .node           = WREPL_NODE_B,
2113                         .is_static      = False,
2114                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2115                         .ips            = addresses_A_1,
2116                         .apply_expected = True
2117                 },
2118                 .r2     = {
2119                         .owner          = &ctx->b,
2120                         .type           = WREPL_TYPE_UNIQUE,
2121                         .state          = WREPL_STATE_TOMBSTONE,
2122                         .node           = WREPL_NODE_B,
2123                         .is_static      = False,
2124                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2125                         .ips            = addresses_A_1,
2126                         .apply_expected = False
2127                 }
2128         },
2129
2130 /*
2131  * normal groups vs normal groups section,
2132  */
2133         /* 
2134          * group,active vs. group,active
2135          * => should NOT be replaced
2136          */
2137         {
2138                 .line   = __location__,
2139                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2140                 .r1     = {
2141                         .owner          = &ctx->a,
2142                         .type           = WREPL_TYPE_GROUP,
2143                         .state          = WREPL_STATE_ACTIVE,
2144                         .node           = WREPL_NODE_B,
2145                         .is_static      = False,
2146                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2147                         .ips            = addresses_A_1,
2148                         .apply_expected = True
2149                 },
2150                 .r2     = {
2151                         .owner          = &ctx->b,
2152                         .type           = WREPL_TYPE_GROUP,
2153                         .state          = WREPL_STATE_ACTIVE,
2154                         .node           = WREPL_NODE_B,
2155                         .is_static      = False,
2156                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2157                         .ips            = addresses_A_1,
2158                         .apply_expected = False
2159                 }
2160         },
2161
2162         /* 
2163          * group,active vs. group,tombstone
2164          * => should NOT be replaced
2165          */
2166         {
2167                 .line   = __location__,
2168                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2169                 .r1     = {
2170                         .owner          = &ctx->a,
2171                         .type           = WREPL_TYPE_GROUP,
2172                         .state          = WREPL_STATE_ACTIVE,
2173                         .node           = WREPL_NODE_B,
2174                         .is_static      = False,
2175                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2176                         .ips            = addresses_A_1,
2177                         .apply_expected = True
2178                 },
2179                 .r2     = {
2180                         .owner          = &ctx->b,
2181                         .type           = WREPL_TYPE_GROUP,
2182                         .state          = WREPL_STATE_TOMBSTONE,
2183                         .node           = WREPL_NODE_B,
2184                         .is_static      = False,
2185                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2186                         .ips            = addresses_A_1,
2187                         .apply_expected = False
2188                 }
2189         },
2190
2191         /* 
2192          * group,released vs. group,active
2193          * => should be replaced
2194          */
2195         {
2196                 .line   = __location__,
2197                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2198                 .r1     = {
2199                         .owner          = &ctx->a,
2200                         .type           = WREPL_TYPE_GROUP,
2201                         .state          = WREPL_STATE_RELEASED,
2202                         .node           = WREPL_NODE_B,
2203                         .is_static      = False,
2204                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2205                         .ips            = addresses_A_1,
2206                         .apply_expected = False
2207                 },
2208                 .r2     = {
2209                         .owner          = &ctx->b,
2210                         .type           = WREPL_TYPE_GROUP,
2211                         .state          = WREPL_STATE_ACTIVE,
2212                         .node           = WREPL_NODE_B,
2213                         .is_static      = False,
2214                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2215                         .ips            = addresses_B_1,
2216                         .apply_expected = True
2217                 }
2218         },
2219
2220         /* 
2221          * group,released vs. group,tombstone
2222          * => should be replaced
2223          */
2224         {
2225                 .line   = __location__,
2226                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2227                 .r1     = {
2228                         .owner          = &ctx->a,
2229                         .type           = WREPL_TYPE_GROUP,
2230                         .state          = WREPL_STATE_RELEASED,
2231                         .node           = WREPL_NODE_B,
2232                         .is_static      = False,
2233                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2234                         .ips            = addresses_A_1,
2235                         .apply_expected = False
2236                 },
2237                 .r2     = {
2238                         .owner          = &ctx->b,
2239                         .type           = WREPL_TYPE_GROUP,
2240                         .state          = WREPL_STATE_TOMBSTONE,
2241                         .node           = WREPL_NODE_B,
2242                         .is_static      = False,
2243                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2244                         .ips            = addresses_B_1,
2245                         .apply_expected = True
2246                 }
2247         },
2248
2249         /* 
2250          * group,tombstone vs. group,active
2251          * => should be replaced
2252          */
2253         {
2254                 .line   = __location__,
2255                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2256                 .r1     = {
2257                         .owner          = &ctx->b,
2258                         .type           = WREPL_TYPE_GROUP,
2259                         .state          = WREPL_STATE_TOMBSTONE,
2260                         .node           = WREPL_NODE_B,
2261                         .is_static      = False,
2262                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2263                         .ips            = addresses_B_1,
2264                         .apply_expected = True
2265                 },
2266                 .r2     = {
2267                         .owner          = &ctx->a,
2268                         .type           = WREPL_TYPE_GROUP,
2269                         .state          = WREPL_STATE_ACTIVE,
2270                         .node           = WREPL_NODE_B,
2271                         .is_static      = False,
2272                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2273                         .ips            = addresses_A_1,
2274                         .apply_expected = True
2275                 }
2276         },
2277
2278         /* 
2279          * group,tombstone vs. group,tombstone
2280          * => should be replaced
2281          */
2282         {
2283                 .line   = __location__,
2284                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2285                 .r1     = {
2286                         .owner          = &ctx->a,
2287                         .type           = WREPL_TYPE_GROUP,
2288                         .state          = WREPL_STATE_TOMBSTONE,
2289                         .node           = WREPL_NODE_B,
2290                         .is_static      = False,
2291                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2292                         .ips            = addresses_A_1,
2293                         .apply_expected = True
2294                 },
2295                 .r2     = {
2296                         .owner          = &ctx->b,
2297                         .type           = WREPL_TYPE_GROUP,
2298                         .state          = WREPL_STATE_TOMBSTONE,
2299                         .node           = WREPL_NODE_B,
2300                         .is_static      = False,
2301                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2302                         .ips            = addresses_B_1,
2303                         .apply_expected = True
2304                 }
2305         },
2306
2307 /*
2308  * normal groups vs special groups section,
2309  */
2310         /* 
2311          * group,active vs. sgroup,active
2312          * => should NOT be replaced
2313          */
2314         {
2315                 .line   = __location__,
2316                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2317                 .r1     = {
2318                         .owner          = &ctx->b,
2319                         .type           = WREPL_TYPE_GROUP,
2320                         .state          = WREPL_STATE_ACTIVE,
2321                         .node           = WREPL_NODE_B,
2322                         .is_static      = False,
2323                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2324                         .ips            = addresses_B_1,
2325                         .apply_expected = True
2326                 },
2327                 .r2     = {
2328                         .owner          = &ctx->a,
2329                         .type           = WREPL_TYPE_SGROUP,
2330                         .state          = WREPL_STATE_ACTIVE,
2331                         .node           = WREPL_NODE_B,
2332                         .is_static      = False,
2333                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2334                         .ips            = addresses_B_1,
2335                         .apply_expected = False
2336                 }
2337         },
2338
2339         /* 
2340          * group,active vs. sgroup,tombstone
2341          * => should NOT be replaced
2342          */
2343         {
2344                 .line   = __location__,
2345                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2346                 .r1     = {
2347                         .owner          = &ctx->b,
2348                         .type           = WREPL_TYPE_GROUP,
2349                         .state          = WREPL_STATE_ACTIVE,
2350                         .node           = WREPL_NODE_B,
2351                         .is_static      = False,
2352                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2353                         .ips            = addresses_B_1,
2354                         .apply_expected = True
2355                 },
2356                 .r2     = {
2357                         .owner          = &ctx->a,
2358                         .type           = WREPL_TYPE_SGROUP,
2359                         .state          = WREPL_STATE_TOMBSTONE,
2360                         .node           = WREPL_NODE_B,
2361                         .is_static      = False,
2362                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2363                         .ips            = addresses_B_1,
2364                         .apply_expected = False
2365                 }
2366         },
2367
2368         /* 
2369          * group,released vs. sgroup,active
2370          * => should be replaced
2371          */
2372         {
2373                 .line   = __location__,
2374                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2375                 .r1     = {
2376                         .owner          = &ctx->a,
2377                         .type           = WREPL_TYPE_GROUP,
2378                         .state          = WREPL_STATE_RELEASED,
2379                         .node           = WREPL_NODE_B,
2380                         .is_static      = False,
2381                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2382                         .ips            = addresses_A_1,
2383                         .apply_expected = False
2384                 },
2385                 .r2     = {
2386                         .owner          = &ctx->b,
2387                         .type           = WREPL_TYPE_SGROUP,
2388                         .state          = WREPL_STATE_ACTIVE,
2389                         .node           = WREPL_NODE_B,
2390                         .is_static      = False,
2391                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2392                         .ips            = addresses_B_1,
2393                         .apply_expected = True
2394                 }
2395         },
2396
2397         /* 
2398          * group,released vs. sgroup,tombstone
2399          * => should NOT be replaced
2400          */
2401         {
2402                 .line   = __location__,
2403                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2404                 .r1     = {
2405                         .owner          = &ctx->b,
2406                         .type           = WREPL_TYPE_GROUP,
2407                         .state          = WREPL_STATE_RELEASED,
2408                         .node           = WREPL_NODE_B,
2409                         .is_static      = False,
2410                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2411                         .ips            = addresses_B_1,
2412                         .apply_expected = False
2413                 },
2414                 .r2     = {
2415                         .owner          = &ctx->a,
2416                         .type           = WREPL_TYPE_SGROUP,
2417                         .state          = WREPL_STATE_TOMBSTONE,
2418                         .node           = WREPL_NODE_B,
2419                         .is_static      = False,
2420                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2421                         .ips            = addresses_B_1,
2422                         .apply_expected = False
2423                 }
2424         },
2425
2426         /* 
2427          * group,tombstone vs. sgroup,active
2428          * => should be replaced
2429          */
2430         {
2431                 .line   = __location__,
2432                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2433                 .r1     = {
2434                         .owner          = &ctx->b,
2435                         .type           = WREPL_TYPE_GROUP,
2436                         .state          = WREPL_STATE_TOMBSTONE,
2437                         .node           = WREPL_NODE_B,
2438                         .is_static      = False,
2439                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2440                         .ips            = addresses_B_1,
2441                         .apply_expected = True
2442                 },
2443                 .r2     = {
2444                         .owner          = &ctx->a,
2445                         .type           = WREPL_TYPE_SGROUP,
2446                         .state          = WREPL_STATE_ACTIVE,
2447                         .node           = WREPL_NODE_B,
2448                         .is_static      = False,
2449                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2450                         .ips            = addresses_A_1,
2451                         .apply_expected = True
2452                 }
2453         },
2454
2455         /* 
2456          * group,tombstone vs. sgroup,tombstone
2457          * => should be replaced
2458          */
2459         {
2460                 .line   = __location__,
2461                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2462                 .r1     = {
2463                         .owner          = &ctx->a,
2464                         .type           = WREPL_TYPE_GROUP,
2465                         .state          = WREPL_STATE_TOMBSTONE,
2466                         .node           = WREPL_NODE_B,
2467                         .is_static      = False,
2468                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2469                         .ips            = addresses_A_1,
2470                         .apply_expected = True
2471                 },
2472                 .r2     = {
2473                         .owner          = &ctx->b,
2474                         .type           = WREPL_TYPE_SGROUP,
2475                         .state          = WREPL_STATE_TOMBSTONE,
2476                         .node           = WREPL_NODE_B,
2477                         .is_static      = False,
2478                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2479                         .ips            = addresses_B_1,
2480                         .apply_expected = True
2481                 }
2482         },
2483
2484 /*
2485  * normal groups vs multi homed section,
2486  */
2487         /* 
2488          * group,active vs. mhomed,active
2489          * => should NOT be replaced
2490          */
2491         {
2492                 .line   = __location__,
2493                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2494                 .r1     = {
2495                         .owner          = &ctx->b,
2496                         .type           = WREPL_TYPE_GROUP,
2497                         .state          = WREPL_STATE_ACTIVE,
2498                         .node           = WREPL_NODE_B,
2499                         .is_static      = False,
2500                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2501                         .ips            = addresses_B_1,
2502                         .apply_expected = True
2503                 },
2504                 .r2     = {
2505                         .owner          = &ctx->a,
2506                         .type           = WREPL_TYPE_MHOMED,
2507                         .state          = WREPL_STATE_ACTIVE,
2508                         .node           = WREPL_NODE_B,
2509                         .is_static      = False,
2510                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2511                         .ips            = addresses_B_1,
2512                         .apply_expected = False
2513                 }
2514         },
2515
2516         /* 
2517          * group,active vs. mhomed,tombstone
2518          * => should NOT be replaced
2519          */
2520         {
2521                 .line   = __location__,
2522                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2523                 .r1     = {
2524                         .owner          = &ctx->b,
2525                         .type           = WREPL_TYPE_GROUP,
2526                         .state          = WREPL_STATE_ACTIVE,
2527                         .node           = WREPL_NODE_B,
2528                         .is_static      = False,
2529                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2530                         .ips            = addresses_B_1,
2531                         .apply_expected = True
2532                 },
2533                 .r2     = {
2534                         .owner          = &ctx->a,
2535                         .type           = WREPL_TYPE_MHOMED,
2536                         .state          = WREPL_STATE_TOMBSTONE,
2537                         .node           = WREPL_NODE_B,
2538                         .is_static      = False,
2539                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2540                         .ips            = addresses_B_1,
2541                         .apply_expected = False
2542                 }
2543         },
2544
2545         /* 
2546          * group,released vs. mhomed,active
2547          * => should NOT be replaced
2548          */
2549         {
2550                 .line   = __location__,
2551                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2552                 .r1     = {
2553                         .owner          = &ctx->b,
2554                         .type           = WREPL_TYPE_GROUP,
2555                         .state          = WREPL_STATE_RELEASED,
2556                         .node           = WREPL_NODE_B,
2557                         .is_static      = False,
2558                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2559                         .ips            = addresses_B_1,
2560                         .apply_expected = False
2561                 },
2562                 .r2     = {
2563                         .owner          = &ctx->a,
2564                         .type           = WREPL_TYPE_MHOMED,
2565                         .state          = WREPL_STATE_ACTIVE,
2566                         .node           = WREPL_NODE_B,
2567                         .is_static      = False,
2568                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2569                         .ips            = addresses_B_1,
2570                         .apply_expected = False
2571                 }
2572         },
2573
2574         /* 
2575          * group,released vs. mhomed,tombstone
2576          * => should NOT be replaced
2577          */
2578         {
2579                 .line   = __location__,
2580                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2581                 .r1     = {
2582                         .owner          = &ctx->b,
2583                         .type           = WREPL_TYPE_GROUP,
2584                         .state          = WREPL_STATE_RELEASED,
2585                         .node           = WREPL_NODE_B,
2586                         .is_static      = False,
2587                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2588                         .ips            = addresses_B_1,
2589                         .apply_expected = False
2590                 },
2591                 .r2     = {
2592                         .owner          = &ctx->a,
2593                         .type           = WREPL_TYPE_MHOMED,
2594                         .state          = WREPL_STATE_TOMBSTONE,
2595                         .node           = WREPL_NODE_B,
2596                         .is_static      = False,
2597                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2598                         .ips            = addresses_B_1,
2599                         .apply_expected = False
2600                 }
2601         },
2602
2603         /* 
2604          * group,tombstone vs. mhomed,active
2605          * => should be replaced
2606          */
2607         {
2608                 .line   = __location__,
2609                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2610                 .r1     = {
2611                         .owner          = &ctx->b,
2612                         .type           = WREPL_TYPE_GROUP,
2613                         .state          = WREPL_STATE_TOMBSTONE,
2614                         .node           = WREPL_NODE_B,
2615                         .is_static      = False,
2616                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2617                         .ips            = addresses_B_1,
2618                         .apply_expected = True
2619                 },
2620                 .r2     = {
2621                         .owner          = &ctx->a,
2622                         .type           = WREPL_TYPE_MHOMED,
2623                         .state          = WREPL_STATE_ACTIVE,
2624                         .node           = WREPL_NODE_B,
2625                         .is_static      = False,
2626                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2627                         .ips            = addresses_A_1,
2628                         .apply_expected = True
2629                 }
2630         },
2631
2632         /* 
2633          * group,tombstone vs. mhomed,tombstone
2634          * => should be replaced
2635          */
2636         {
2637                 .line   = __location__,
2638                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2639                 .r1     = {
2640                         .owner          = &ctx->a,
2641                         .type           = WREPL_TYPE_GROUP,
2642                         .state          = WREPL_STATE_TOMBSTONE,
2643                         .node           = WREPL_NODE_B,
2644                         .is_static      = False,
2645                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2646                         .ips            = addresses_A_1,
2647                         .apply_expected = True
2648                 },
2649                 .r2     = {
2650                         .owner          = &ctx->b,
2651                         .type           = WREPL_TYPE_MHOMED,
2652                         .state          = WREPL_STATE_TOMBSTONE,
2653                         .node           = WREPL_NODE_B,
2654                         .is_static      = False,
2655                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2656                         .ips            = addresses_B_1,
2657                         .apply_expected = True
2658                 }
2659         },
2660
2661 /*
2662  * special groups vs unique section,
2663  */
2664         /* 
2665          * sgroup,active vs. unique,active
2666          * => should NOT be replaced
2667          */
2668         {
2669                 .line   = __location__,
2670                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2671                 .r1     = {
2672                         .owner          = &ctx->b,
2673                         .type           = WREPL_TYPE_SGROUP,
2674                         .state          = WREPL_STATE_ACTIVE,
2675                         .node           = WREPL_NODE_B,
2676                         .is_static      = False,
2677                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2678                         .ips            = addresses_B_1,
2679                         .apply_expected = True
2680                 },
2681                 .r2     = {
2682                         .owner          = &ctx->a,
2683                         .type           = WREPL_TYPE_UNIQUE,
2684                         .state          = WREPL_STATE_ACTIVE,
2685                         .node           = WREPL_NODE_B,
2686                         .is_static      = False,
2687                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2688                         .ips            = addresses_B_1,
2689                         .apply_expected = False
2690                 }
2691         },
2692
2693         /* 
2694          * sgroup,active vs. unique,tombstone
2695          * => should NOT be replaced
2696          */
2697         {
2698                 .line   = __location__,
2699                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2700                 .r1     = {
2701                         .owner          = &ctx->b,
2702                         .type           = WREPL_TYPE_SGROUP,
2703                         .state          = WREPL_STATE_ACTIVE,
2704                         .node           = WREPL_NODE_B,
2705                         .is_static      = False,
2706                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2707                         .ips            = addresses_B_1,
2708                         .apply_expected = True
2709                 },
2710                 .r2     = {
2711                         .owner          = &ctx->a,
2712                         .type           = WREPL_TYPE_UNIQUE,
2713                         .state          = WREPL_STATE_TOMBSTONE,
2714                         .node           = WREPL_NODE_B,
2715                         .is_static      = False,
2716                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2717                         .ips            = addresses_B_1,
2718                         .apply_expected = False
2719                 }
2720         },
2721
2722         /* 
2723          * sgroup,released vs. unique,active
2724          * => should be replaced
2725          */
2726         {
2727                 .line   = __location__,
2728                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2729                 .r1     = {
2730                         .owner          = &ctx->b,
2731                         .type           = WREPL_TYPE_SGROUP,
2732                         .state          = WREPL_STATE_RELEASED,
2733                         .node           = WREPL_NODE_B,
2734                         .is_static      = False,
2735                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2736                         .ips            = addresses_B_1,
2737                         .apply_expected = False
2738                 },
2739                 .r2     = {
2740                         .owner          = &ctx->a,
2741                         .type           = WREPL_TYPE_UNIQUE,
2742                         .state          = WREPL_STATE_ACTIVE,
2743                         .node           = WREPL_NODE_B,
2744                         .is_static      = False,
2745                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2746                         .ips            = addresses_A_1,
2747                         .apply_expected = True
2748                 }
2749         },
2750
2751         /* 
2752          * sgroup,released vs. unique,tombstone
2753          * => should be replaced
2754          */
2755         {
2756                 .line   = __location__,
2757                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2758                 .r1     = {
2759                         .owner          = &ctx->a,
2760                         .type           = WREPL_TYPE_SGROUP,
2761                         .state          = WREPL_STATE_RELEASED,
2762                         .node           = WREPL_NODE_B,
2763                         .is_static      = False,
2764                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2765                         .ips            = addresses_A_1,
2766                         .apply_expected = False
2767                 },
2768                 .r2     = {
2769                         .owner          = &ctx->b,
2770                         .type           = WREPL_TYPE_UNIQUE,
2771                         .state          = WREPL_STATE_TOMBSTONE,
2772                         .node           = WREPL_NODE_B,
2773                         .is_static      = False,
2774                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2775                         .ips            = addresses_B_1,
2776                         .apply_expected = True
2777                 }
2778         },
2779
2780         /* 
2781          * sgroup,tombstone vs. unique,active
2782          * => should be replaced
2783          */
2784         {
2785                 .line   = __location__,
2786                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2787                 .r1     = {
2788                         .owner          = &ctx->a,
2789                         .type           = WREPL_TYPE_SGROUP,
2790                         .state          = WREPL_STATE_TOMBSTONE,
2791                         .node           = WREPL_NODE_B,
2792                         .is_static      = False,
2793                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2794                         .ips            = addresses_A_1,
2795                         .apply_expected = True
2796                 },
2797                 .r2     = {
2798                         .owner          = &ctx->b,
2799                         .type           = WREPL_TYPE_UNIQUE,
2800                         .state          = WREPL_STATE_ACTIVE,
2801                         .node           = WREPL_NODE_B,
2802                         .is_static      = False,
2803                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2804                         .ips            = addresses_B_1,
2805                         .apply_expected = True
2806                 }
2807         },
2808
2809         /* 
2810          * sgroup,tombstone vs. unique,tombstone
2811          * => should be replaced
2812          */
2813         {
2814                 .line   = __location__,
2815                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2816                 .r1     = {
2817                         .owner          = &ctx->b,
2818                         .type           = WREPL_TYPE_SGROUP,
2819                         .state          = WREPL_STATE_TOMBSTONE,
2820                         .node           = WREPL_NODE_B,
2821                         .is_static      = False,
2822                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2823                         .ips            = addresses_B_1,
2824                         .apply_expected = True
2825                 },
2826                 .r2     = {
2827                         .owner          = &ctx->a,
2828                         .type           = WREPL_TYPE_UNIQUE,
2829                         .state          = WREPL_STATE_TOMBSTONE,
2830                         .node           = WREPL_NODE_B,
2831                         .is_static      = False,
2832                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2833                         .ips            = addresses_A_1,
2834                         .apply_expected = True
2835                 }
2836         },
2837
2838 /*
2839  * special groups vs normal group section,
2840  */
2841         /* 
2842          * sgroup,active vs. group,active
2843          * => should NOT be replaced
2844          */
2845         {
2846                 .line   = __location__,
2847                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2848                 .r1     = {
2849                         .owner          = &ctx->a,
2850                         .type           = WREPL_TYPE_SGROUP,
2851                         .state          = WREPL_STATE_ACTIVE,
2852                         .node           = WREPL_NODE_B,
2853                         .is_static      = False,
2854                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2855                         .ips            = addresses_A_1,
2856                         .apply_expected = True
2857                 },
2858                 .r2     = {
2859                         .owner          = &ctx->b,
2860                         .type           = WREPL_TYPE_GROUP,
2861                         .state          = WREPL_STATE_ACTIVE,
2862                         .node           = WREPL_NODE_B,
2863                         .is_static      = False,
2864                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2865                         .ips            = addresses_A_1,
2866                         .apply_expected = False
2867                 }
2868         },
2869
2870         /* 
2871          * sgroup,active vs. group,tombstone
2872          * => should NOT be replaced
2873          */
2874         {
2875                 .line   = __location__,
2876                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2877                 .r1     = {
2878                         .owner          = &ctx->a,
2879                         .type           = WREPL_TYPE_SGROUP,
2880                         .state          = WREPL_STATE_ACTIVE,
2881                         .node           = WREPL_NODE_B,
2882                         .is_static      = False,
2883                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2884                         .ips            = addresses_A_1,
2885                         .apply_expected = True
2886                 },
2887                 .r2     = {
2888                         .owner          = &ctx->b,
2889                         .type           = WREPL_TYPE_GROUP,
2890                         .state          = WREPL_STATE_TOMBSTONE,
2891                         .node           = WREPL_NODE_B,
2892                         .is_static      = False,
2893                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2894                         .ips            = addresses_A_1,
2895                         .apply_expected = False
2896                 }
2897         },
2898
2899         /* 
2900          * sgroup,released vs. group,active
2901          * => should be replaced
2902          */
2903         {
2904                 .line   = __location__,
2905                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2906                 .r1     = {
2907                         .owner          = &ctx->a,
2908                         .type           = WREPL_TYPE_SGROUP,
2909                         .state          = WREPL_STATE_RELEASED,
2910                         .node           = WREPL_NODE_B,
2911                         .is_static      = False,
2912                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2913                         .ips            = addresses_A_1,
2914                         .apply_expected = False
2915                 },
2916                 .r2     = {
2917                         .owner          = &ctx->b,
2918                         .type           = WREPL_TYPE_GROUP,
2919                         .state          = WREPL_STATE_ACTIVE,
2920                         .node           = WREPL_NODE_B,
2921                         .is_static      = False,
2922                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2923                         .ips            = addresses_B_1,
2924                         .apply_expected = True
2925                 }
2926         },
2927
2928         /* 
2929          * sgroup,released vs. group,tombstone
2930          * => should be replaced
2931          */
2932         {
2933                 .line   = __location__,
2934                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2935                 .r1     = {
2936                         .owner          = &ctx->b,
2937                         .type           = WREPL_TYPE_SGROUP,
2938                         .state          = WREPL_STATE_RELEASED,
2939                         .node           = WREPL_NODE_B,
2940                         .is_static      = False,
2941                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2942                         .ips            = addresses_B_1,
2943                         .apply_expected = False
2944                 },
2945                 .r2     = {
2946                         .owner          = &ctx->a,
2947                         .type           = WREPL_TYPE_GROUP,
2948                         .state          = WREPL_STATE_TOMBSTONE,
2949                         .node           = WREPL_NODE_B,
2950                         .is_static      = False,
2951                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2952                         .ips            = addresses_A_1,
2953                         .apply_expected = True
2954                 }
2955         },
2956
2957         /* 
2958          * sgroup,tombstone vs. group,active
2959          * => should NOT be replaced
2960          */
2961         {
2962                 .line   = __location__,
2963                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2964                 .r1     = {
2965                         .owner          = &ctx->a,
2966                         .type           = WREPL_TYPE_SGROUP,
2967                         .state          = WREPL_STATE_TOMBSTONE,
2968                         .node           = WREPL_NODE_B,
2969                         .is_static      = False,
2970                         .num_ips        = ARRAY_SIZE(addresses_A_1),
2971                         .ips            = addresses_A_1,
2972                         .apply_expected = True
2973                 },
2974                 .r2     = {
2975                         .owner          = &ctx->b,
2976                         .type           = WREPL_TYPE_GROUP,
2977                         .state          = WREPL_STATE_ACTIVE,
2978                         .node           = WREPL_NODE_B,
2979                         .is_static      = False,
2980                         .num_ips        = ARRAY_SIZE(addresses_B_1),
2981                         .ips            = addresses_B_1,
2982                         .apply_expected = True
2983                 }
2984         },
2985
2986         /* 
2987          * sgroup,tombstone vs. group,tombstone
2988          * => should NOT be replaced
2989          */
2990         {
2991                 .line   = __location__,
2992                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
2993                 .r1     = {
2994                         .owner          = &ctx->b,
2995                         .type           = WREPL_TYPE_SGROUP,
2996                         .state          = WREPL_STATE_TOMBSTONE,
2997                         .node           = WREPL_NODE_B,
2998                         .is_static      = False,
2999                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3000                         .ips            = addresses_B_1,
3001                         .apply_expected = True
3002                 },
3003                 .r2     = {
3004                         .owner          = &ctx->a,
3005                         .type           = WREPL_TYPE_GROUP,
3006                         .state          = WREPL_STATE_TOMBSTONE,
3007                         .node           = WREPL_NODE_B,
3008                         .is_static      = False,
3009                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3010                         .ips            = addresses_A_1,
3011                         .apply_expected = True
3012                 }
3013         },
3014
3015 /*
3016  * special groups (not active) vs special group section,
3017  */
3018         /* 
3019          * sgroup,released vs. sgroup,active
3020          * => should be replaced
3021          */
3022         {
3023                 .line   = __location__,
3024                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3025                 .r1     = {
3026                         .owner          = &ctx->a,
3027                         .type           = WREPL_TYPE_SGROUP,
3028                         .state          = WREPL_STATE_RELEASED,
3029                         .node           = WREPL_NODE_B,
3030                         .is_static      = False,
3031                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3032                         .ips            = addresses_A_1,
3033                         .apply_expected = False
3034                 },
3035                 .r2     = {
3036                         .owner          = &ctx->b,
3037                         .type           = WREPL_TYPE_SGROUP,
3038                         .state          = WREPL_STATE_ACTIVE,
3039                         .node           = WREPL_NODE_B,
3040                         .is_static      = False,
3041                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3042                         .ips            = addresses_B_1,
3043                         .apply_expected = True
3044                 }
3045         },
3046
3047         /* 
3048          * sgroup,released vs. sgroup,tombstone
3049          * => should be replaced
3050          */
3051         {
3052                 .line   = __location__,
3053                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3054                 .r1     = {
3055                         .owner          = &ctx->b,
3056                         .type           = WREPL_TYPE_SGROUP,
3057                         .state          = WREPL_STATE_RELEASED,
3058                         .node           = WREPL_NODE_B,
3059                         .is_static      = False,
3060                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3061                         .ips            = addresses_B_1,
3062                         .apply_expected = False
3063                 },
3064                 .r2     = {
3065                         .owner          = &ctx->a,
3066                         .type           = WREPL_TYPE_SGROUP,
3067                         .state          = WREPL_STATE_TOMBSTONE,
3068                         .node           = WREPL_NODE_B,
3069                         .is_static      = False,
3070                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3071                         .ips            = addresses_A_1,
3072                         .apply_expected = True
3073                 }
3074         },
3075
3076         /* 
3077          * sgroup,tombstone vs. sgroup,active
3078          * => should NOT be replaced
3079          */
3080         {
3081                 .line   = __location__,
3082                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3083                 .r1     = {
3084                         .owner          = &ctx->a,
3085                         .type           = WREPL_TYPE_SGROUP,
3086                         .state          = WREPL_STATE_TOMBSTONE,
3087                         .node           = WREPL_NODE_B,
3088                         .is_static      = False,
3089                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3090                         .ips            = addresses_A_1,
3091                         .apply_expected = True
3092                 },
3093                 .r2     = {
3094                         .owner          = &ctx->b,
3095                         .type           = WREPL_TYPE_SGROUP,
3096                         .state          = WREPL_STATE_ACTIVE,
3097                         .node           = WREPL_NODE_B,
3098                         .is_static      = False,
3099                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3100                         .ips            = addresses_B_1,
3101                         .apply_expected = True
3102                 }
3103         },
3104
3105         /* 
3106          * sgroup,tombstone vs. sgroup,tombstone
3107          * => should NOT be replaced
3108          */
3109         {
3110                 .line   = __location__,
3111                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3112                 .r1     = {
3113                         .owner          = &ctx->b,
3114                         .type           = WREPL_TYPE_SGROUP,
3115                         .state          = WREPL_STATE_TOMBSTONE,
3116                         .node           = WREPL_NODE_B,
3117                         .is_static      = False,
3118                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3119                         .ips            = addresses_B_1,
3120                         .apply_expected = True
3121                 },
3122                 .r2     = {
3123                         .owner          = &ctx->a,
3124                         .type           = WREPL_TYPE_SGROUP,
3125                         .state          = WREPL_STATE_TOMBSTONE,
3126                         .node           = WREPL_NODE_B,
3127                         .is_static      = False,
3128                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3129                         .ips            = addresses_A_1,
3130                         .apply_expected = True
3131                 }
3132         },
3133
3134 /*
3135  * special groups vs multi homed section,
3136  */
3137         /* 
3138          * sgroup,active vs. mhomed,active
3139          * => should NOT be replaced
3140          */
3141         {
3142                 .line   = __location__,
3143                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3144                 .r1     = {
3145                         .owner          = &ctx->a,
3146                         .type           = WREPL_TYPE_SGROUP,
3147                         .state          = WREPL_STATE_ACTIVE,
3148                         .node           = WREPL_NODE_B,
3149                         .is_static      = False,
3150                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3151                         .ips            = addresses_A_1,
3152                         .apply_expected = True
3153                 },
3154                 .r2     = {
3155                         .owner          = &ctx->b,
3156                         .type           = WREPL_TYPE_MHOMED,
3157                         .state          = WREPL_STATE_ACTIVE,
3158                         .node           = WREPL_NODE_B,
3159                         .is_static      = False,
3160                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3161                         .ips            = addresses_A_1,
3162                         .apply_expected = False
3163                 }
3164         },
3165
3166         /* 
3167          * sgroup,active vs. mhomed,tombstone
3168          * => should NOT be replaced
3169          */
3170         {
3171                 .line   = __location__,
3172                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3173                 .r1     = {
3174                         .owner          = &ctx->a,
3175                         .type           = WREPL_TYPE_SGROUP,
3176                         .state          = WREPL_STATE_ACTIVE,
3177                         .node           = WREPL_NODE_B,
3178                         .is_static      = False,
3179                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3180                         .ips            = addresses_A_1,
3181                         .apply_expected = True
3182                 },
3183                 .r2     = {
3184                         .owner          = &ctx->b,
3185                         .type           = WREPL_TYPE_MHOMED,
3186                         .state          = WREPL_STATE_TOMBSTONE,
3187                         .node           = WREPL_NODE_B,
3188                         .is_static      = False,
3189                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3190                         .ips            = addresses_A_1,
3191                         .apply_expected = False
3192                 }
3193         },
3194
3195         /* 
3196          * sgroup,released vs. mhomed,active
3197          * => should be replaced
3198          */
3199         {
3200                 .line   = __location__,
3201                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3202                 .r1     = {
3203                         .owner          = &ctx->a,
3204                         .type           = WREPL_TYPE_SGROUP,
3205                         .state          = WREPL_STATE_RELEASED,
3206                         .node           = WREPL_NODE_B,
3207                         .is_static      = False,
3208                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3209                         .ips            = addresses_A_1,
3210                         .apply_expected = False
3211                 },
3212                 .r2     = {
3213                         .owner          = &ctx->b,
3214                         .type           = WREPL_TYPE_MHOMED,
3215                         .state          = WREPL_STATE_ACTIVE,
3216                         .node           = WREPL_NODE_B,
3217                         .is_static      = False,
3218                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3219                         .ips            = addresses_B_1,
3220                         .apply_expected = True
3221                 }
3222         },
3223
3224         /* 
3225          * sgroup,released vs. mhomed,tombstone
3226          * => should be replaced
3227          */
3228         {
3229                 .line   = __location__,
3230                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3231                 .r1     = {
3232                         .owner          = &ctx->b,
3233                         .type           = WREPL_TYPE_SGROUP,
3234                         .state          = WREPL_STATE_RELEASED,
3235                         .node           = WREPL_NODE_B,
3236                         .is_static      = False,
3237                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3238                         .ips            = addresses_B_1,
3239                         .apply_expected = False
3240                 },
3241                 .r2     = {
3242                         .owner          = &ctx->a,
3243                         .type           = WREPL_TYPE_MHOMED,
3244                         .state          = WREPL_STATE_TOMBSTONE,
3245                         .node           = WREPL_NODE_B,
3246                         .is_static      = False,
3247                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3248                         .ips            = addresses_A_1,
3249                         .apply_expected = True
3250                 }
3251         },
3252
3253         /* 
3254          * sgroup,tombstone vs. mhomed,active
3255          * => should be replaced
3256          */
3257         {
3258                 .line   = __location__,
3259                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3260                 .r1     = {
3261                         .owner          = &ctx->a,
3262                         .type           = WREPL_TYPE_SGROUP,
3263                         .state          = WREPL_STATE_TOMBSTONE,
3264                         .node           = WREPL_NODE_B,
3265                         .is_static      = False,
3266                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3267                         .ips            = addresses_A_1,
3268                         .apply_expected = True
3269                 },
3270                 .r2     = {
3271                         .owner          = &ctx->b,
3272                         .type           = WREPL_TYPE_MHOMED,
3273                         .state          = WREPL_STATE_ACTIVE,
3274                         .node           = WREPL_NODE_B,
3275                         .is_static      = False,
3276                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3277                         .ips            = addresses_B_1,
3278                         .apply_expected = True
3279                 }
3280         },
3281
3282         /* 
3283          * sgroup,tombstone vs. mhomed,tombstone
3284          * => should be replaced
3285          */
3286         {
3287                 .line   = __location__,
3288                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3289                 .r1     = {
3290                         .owner          = &ctx->b,
3291                         .type           = WREPL_TYPE_SGROUP,
3292                         .state          = WREPL_STATE_TOMBSTONE,
3293                         .node           = WREPL_NODE_B,
3294                         .is_static      = False,
3295                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3296                         .ips            = addresses_B_1,
3297                         .apply_expected = True
3298                 },
3299                 .r2     = {
3300                         .owner          = &ctx->a,
3301                         .type           = WREPL_TYPE_MHOMED,
3302                         .state          = WREPL_STATE_TOMBSTONE,
3303                         .node           = WREPL_NODE_B,
3304                         .is_static      = False,
3305                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3306                         .ips            = addresses_A_1,
3307                         .apply_expected = True
3308                 }
3309         },
3310
3311 /*
3312  * multi homed vs. unique section,
3313  */
3314         /* 
3315          * mhomed,active vs. unique,active
3316          * => should be replaced
3317          */
3318         {
3319                 .line   = __location__,
3320                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3321                 .r1     = {
3322                         .owner          = &ctx->a,
3323                         .type           = WREPL_TYPE_MHOMED,
3324                         .state          = WREPL_STATE_ACTIVE,
3325                         .node           = WREPL_NODE_B,
3326                         .is_static      = False,
3327                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3328                         .ips            = addresses_A_3_4,
3329                         .apply_expected = True
3330                 },
3331                 .r2     = {
3332                         .owner          = &ctx->b,
3333                         .type           = WREPL_TYPE_UNIQUE,
3334                         .state          = WREPL_STATE_ACTIVE,
3335                         .node           = WREPL_NODE_B,
3336                         .is_static      = False,
3337                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3338                         .ips            = addresses_B_1,
3339                         .apply_expected = True
3340                 }
3341         },
3342
3343         /* 
3344          * mhomed,active vs. unique,tombstone
3345          * => should NOT be replaced
3346          */
3347         {
3348                 .line   = __location__,
3349                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3350                 .r1     = {
3351                         .owner          = &ctx->b,
3352                         .type           = WREPL_TYPE_MHOMED,
3353                         .state          = WREPL_STATE_ACTIVE,
3354                         .node           = WREPL_NODE_B,
3355                         .is_static      = False,
3356                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3357                         .ips            = addresses_B_1,
3358                         .apply_expected = True
3359                 },
3360                 .r2     = {
3361                         .owner          = &ctx->a,
3362                         .type           = WREPL_TYPE_UNIQUE,
3363                         .state          = WREPL_STATE_TOMBSTONE,
3364                         .node           = WREPL_NODE_B,
3365                         .is_static      = False,
3366                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3367                         .ips            = addresses_B_1,
3368                         .apply_expected = False
3369                 }
3370         },
3371
3372         /* 
3373          * mhomed,released vs. unique,active
3374          * => should be replaced
3375          */
3376         {
3377                 .line   = __location__,
3378                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3379                 .r1     = {
3380                         .owner          = &ctx->a,
3381                         .type           = WREPL_TYPE_MHOMED,
3382                         .state          = WREPL_STATE_RELEASED,
3383                         .node           = WREPL_NODE_B,
3384                         .is_static      = False,
3385                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3386                         .ips            = addresses_A_1,
3387                         .apply_expected = False
3388                 },
3389                 .r2     = {
3390                         .owner          = &ctx->b,
3391                         .type           = WREPL_TYPE_UNIQUE,
3392                         .state          = WREPL_STATE_ACTIVE,
3393                         .node           = WREPL_NODE_B,
3394                         .is_static      = False,
3395                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3396                         .ips            = addresses_B_1,
3397                         .apply_expected = True
3398                 }
3399         },
3400
3401         /* 
3402          * mhomed,released vs. uinique,tombstone
3403          * => should be replaced
3404          */
3405         {
3406                 .line   = __location__,
3407                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3408                 .r1     = {
3409                         .owner          = &ctx->b,
3410                         .type           = WREPL_TYPE_MHOMED,
3411                         .state          = WREPL_STATE_RELEASED,
3412                         .node           = WREPL_NODE_B,
3413                         .is_static      = False,
3414                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3415                         .ips            = addresses_B_1,
3416                         .apply_expected = False
3417                 },
3418                 .r2     = {
3419                         .owner          = &ctx->a,
3420                         .type           = WREPL_TYPE_UNIQUE,
3421                         .state          = WREPL_STATE_TOMBSTONE,
3422                         .node           = WREPL_NODE_B,
3423                         .is_static      = False,
3424                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3425                         .ips            = addresses_A_1,
3426                         .apply_expected = True
3427                 }
3428         },
3429
3430         /* 
3431          * mhomed,tombstone vs. unique,active
3432          * => should be replaced
3433          */
3434         {
3435                 .line   = __location__,
3436                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3437                 .r1     = {
3438                         .owner          = &ctx->a,
3439                         .type           = WREPL_TYPE_MHOMED,
3440                         .state          = WREPL_STATE_TOMBSTONE,
3441                         .node           = WREPL_NODE_B,
3442                         .is_static      = False,
3443                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3444                         .ips            = addresses_A_1,
3445                         .apply_expected = True
3446                 },
3447                 .r2     = {
3448                         .owner          = &ctx->b,
3449                         .type           = WREPL_TYPE_UNIQUE,
3450                         .state          = WREPL_STATE_ACTIVE,
3451                         .node           = WREPL_NODE_B,
3452                         .is_static      = False,
3453                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3454                         .ips            = addresses_B_1,
3455                         .apply_expected = True
3456                 }
3457         },
3458
3459         /* 
3460          * mhomed,tombstone vs. uinique,tombstone
3461          * => should be replaced
3462          */
3463         {
3464                 .line   = __location__,
3465                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3466                 .r1     = {
3467                         .owner          = &ctx->b,
3468                         .type           = WREPL_TYPE_MHOMED,
3469                         .state          = WREPL_STATE_TOMBSTONE,
3470                         .node           = WREPL_NODE_B,
3471                         .is_static      = False,
3472                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3473                         .ips            = addresses_B_1,
3474                         .apply_expected = True
3475                 },
3476                 .r2     = {
3477                         .owner          = &ctx->a,
3478                         .type           = WREPL_TYPE_UNIQUE,
3479                         .state          = WREPL_STATE_TOMBSTONE,
3480                         .node           = WREPL_NODE_B,
3481                         .is_static      = False,
3482                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3483                         .ips            = addresses_A_1,
3484                         .apply_expected = True
3485                 }
3486         },
3487
3488 /*
3489  * multi homed vs. normal group section,
3490  */
3491         /* 
3492          * mhomed,active vs. group,active
3493          * => should be replaced
3494          */
3495         {
3496                 .line   = __location__,
3497                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3498                 .r1     = {
3499                         .owner          = &ctx->a,
3500                         .type           = WREPL_TYPE_MHOMED,
3501                         .state          = WREPL_STATE_ACTIVE,
3502                         .node           = WREPL_NODE_B,
3503                         .is_static      = False,
3504                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3505                         .ips            = addresses_A_1,
3506                         .apply_expected = True
3507                 },
3508                 .r2     = {
3509                         .owner          = &ctx->b,
3510                         .type           = WREPL_TYPE_GROUP,
3511                         .state          = WREPL_STATE_ACTIVE,
3512                         .node           = WREPL_NODE_B,
3513                         .is_static      = False,
3514                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3515                         .ips            = addresses_B_1,
3516                         .apply_expected = True
3517                 }
3518         },
3519
3520         /* 
3521          * mhomed,active vs. group,tombstone
3522          * => should NOT be replaced
3523          */
3524         {
3525                 .line   = __location__,
3526                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3527                 .r1     = {
3528                         .owner          = &ctx->b,
3529                         .type           = WREPL_TYPE_MHOMED,
3530                         .state          = WREPL_STATE_ACTIVE,
3531                         .node           = WREPL_NODE_B,
3532                         .is_static      = False,
3533                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3534                         .ips            = addresses_B_1,
3535                         .apply_expected = True
3536                 },
3537                 .r2     = {
3538                         .owner          = &ctx->a,
3539                         .type           = WREPL_TYPE_GROUP,
3540                         .state          = WREPL_STATE_TOMBSTONE,
3541                         .node           = WREPL_NODE_B,
3542                         .is_static      = False,
3543                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3544                         .ips            = addresses_B_1,
3545                         .apply_expected = False
3546                 }
3547         },
3548
3549         /* 
3550          * mhomed,released vs. group,active
3551          * => should be replaced
3552          */
3553         {
3554                 .line   = __location__,
3555                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3556                 .r1     = {
3557                         .owner          = &ctx->b,
3558                         .type           = WREPL_TYPE_MHOMED,
3559                         .state          = WREPL_STATE_RELEASED,
3560                         .node           = WREPL_NODE_B,
3561                         .is_static      = False,
3562                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3563                         .ips            = addresses_B_1,
3564                         .apply_expected = False
3565                 },
3566                 .r2     = {
3567                         .owner          = &ctx->a,
3568                         .type           = WREPL_TYPE_GROUP,
3569                         .state          = WREPL_STATE_ACTIVE,
3570                         .node           = WREPL_NODE_B,
3571                         .is_static      = False,
3572                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3573                         .ips            = addresses_A_1,
3574                         .apply_expected = True
3575                 }
3576         },
3577
3578         /* 
3579          * mhomed,released vs. group,tombstone
3580          * => should be replaced
3581          */
3582         {
3583                 .line   = __location__,
3584                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3585                 .r1     = {
3586                         .owner          = &ctx->a,
3587                         .type           = WREPL_TYPE_MHOMED,
3588                         .state          = WREPL_STATE_RELEASED,
3589                         .node           = WREPL_NODE_B,
3590                         .is_static      = False,
3591                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3592                         .ips            = addresses_A_1,
3593                         .apply_expected = False
3594                 },
3595                 .r2     = {
3596                         .owner          = &ctx->b,
3597                         .type           = WREPL_TYPE_GROUP,
3598                         .state          = WREPL_STATE_TOMBSTONE,
3599                         .node           = WREPL_NODE_B,
3600                         .is_static      = False,
3601                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3602                         .ips            = addresses_B_1,
3603                         .apply_expected = True
3604                 }
3605         },
3606
3607         /* 
3608          * mhomed,tombstone vs. group,active
3609          * => should be replaced
3610          */
3611         {
3612                 .line   = __location__,
3613                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3614                 .r1     = {
3615                         .owner          = &ctx->b,
3616                         .type           = WREPL_TYPE_MHOMED,
3617                         .state          = WREPL_STATE_TOMBSTONE,
3618                         .node           = WREPL_NODE_B,
3619                         .is_static      = False,
3620                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3621                         .ips            = addresses_B_1,
3622                         .apply_expected = True
3623                 },
3624                 .r2     = {
3625                         .owner          = &ctx->a,
3626                         .type           = WREPL_TYPE_GROUP,
3627                         .state          = WREPL_STATE_ACTIVE,
3628                         .node           = WREPL_NODE_B,
3629                         .is_static      = False,
3630                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3631                         .ips            = addresses_A_1,
3632                         .apply_expected = True
3633                 }
3634         },
3635
3636         /* 
3637          * mhomed,tombstone vs. group,tombstone
3638          * => should be replaced
3639          */
3640         {
3641                 .line   = __location__,
3642                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3643                 .r1     = {
3644                         .owner          = &ctx->a,
3645                         .type           = WREPL_TYPE_MHOMED,
3646                         .state          = WREPL_STATE_TOMBSTONE,
3647                         .node           = WREPL_NODE_B,
3648                         .is_static      = False,
3649                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3650                         .ips            = addresses_A_1,
3651                         .apply_expected = True
3652                 },
3653                 .r2     = {
3654                         .owner          = &ctx->b,
3655                         .type           = WREPL_TYPE_GROUP,
3656                         .state          = WREPL_STATE_TOMBSTONE,
3657                         .node           = WREPL_NODE_B,
3658                         .is_static      = False,
3659                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3660                         .ips            = addresses_B_1,
3661                         .apply_expected = True
3662                 }
3663         },
3664
3665 /*
3666  * multi homed vs. special group section,
3667  */
3668         /* 
3669          * mhomed,active vs. sgroup,active
3670          * => should NOT be replaced
3671          */
3672         {
3673                 .line   = __location__,
3674                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3675                 .r1     = {
3676                         .owner          = &ctx->a,
3677                         .type           = WREPL_TYPE_MHOMED,
3678                         .state          = WREPL_STATE_ACTIVE,
3679                         .node           = WREPL_NODE_B,
3680                         .is_static      = False,
3681                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3682                         .ips            = addresses_A_1,
3683                         .apply_expected = True
3684                 },
3685                 .r2     = {
3686                         .owner          = &ctx->b,
3687                         .type           = WREPL_TYPE_SGROUP,
3688                         .state          = WREPL_STATE_ACTIVE,
3689                         .node           = WREPL_NODE_B,
3690                         .is_static      = False,
3691                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3692                         .ips            = addresses_A_1,
3693                         .apply_expected = False
3694                 }
3695         },
3696
3697         /* 
3698          * mhomed,active vs. sgroup,tombstone
3699          * => should NOT be replaced
3700          */
3701         {
3702                 .line   = __location__,
3703                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3704                 .r1     = {
3705                         .owner          = &ctx->a,
3706                         .type           = WREPL_TYPE_MHOMED,
3707                         .state          = WREPL_STATE_ACTIVE,
3708                         .node           = WREPL_NODE_B,
3709                         .is_static      = False,
3710                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3711                         .ips            = addresses_A_1,
3712                         .apply_expected = True
3713                 },
3714                 .r2     = {
3715                         .owner          = &ctx->b,
3716                         .type           = WREPL_TYPE_SGROUP,
3717                         .state          = WREPL_STATE_TOMBSTONE,
3718                         .node           = WREPL_NODE_B,
3719                         .is_static      = False,
3720                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3721                         .ips            = addresses_A_1,
3722                         .apply_expected = False
3723                 }
3724         },
3725
3726         /* 
3727          * mhomed,released vs. sgroup,active
3728          * => should be replaced
3729          */
3730         {
3731                 .line   = __location__,
3732                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3733                 .r1     = {
3734                         .owner          = &ctx->a,
3735                         .type           = WREPL_TYPE_MHOMED,
3736                         .state          = WREPL_STATE_RELEASED,
3737                         .node           = WREPL_NODE_B,
3738                         .is_static      = False,
3739                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3740                         .ips            = addresses_A_1,
3741                         .apply_expected = False
3742                 },
3743                 .r2     = {
3744                         .owner          = &ctx->b,
3745                         .type           = WREPL_TYPE_SGROUP,
3746                         .state          = WREPL_STATE_ACTIVE,
3747                         .node           = WREPL_NODE_B,
3748                         .is_static      = False,
3749                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3750                         .ips            = addresses_B_1,
3751                         .apply_expected = True
3752                 }
3753         },
3754
3755         /* 
3756          * mhomed,released vs. sgroup,tombstone
3757          * => should be replaced
3758          */
3759         {
3760                 .line   = __location__,
3761                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3762                 .r1     = {
3763                         .owner          = &ctx->b,
3764                         .type           = WREPL_TYPE_MHOMED,
3765                         .state          = WREPL_STATE_RELEASED,
3766                         .node           = WREPL_NODE_B,
3767                         .is_static      = False,
3768                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3769                         .ips            = addresses_B_1,
3770                         .apply_expected = False
3771                 },
3772                 .r2     = {
3773                         .owner          = &ctx->a,
3774                         .type           = WREPL_TYPE_SGROUP,
3775                         .state          = WREPL_STATE_TOMBSTONE,
3776                         .node           = WREPL_NODE_B,
3777                         .is_static      = False,
3778                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3779                         .ips            = addresses_A_1,
3780                         .apply_expected = True
3781                 }
3782         },
3783
3784         /* 
3785          * mhomed,tombstone vs. sgroup,active
3786          * => should be replaced
3787          */
3788         {
3789                 .line   = __location__,
3790                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3791                 .r1     = {
3792                         .owner          = &ctx->a,
3793                         .type           = WREPL_TYPE_MHOMED,
3794                         .state          = WREPL_STATE_TOMBSTONE,
3795                         .node           = WREPL_NODE_B,
3796                         .is_static      = False,
3797                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3798                         .ips            = addresses_A_1,
3799                         .apply_expected = True
3800                 },
3801                 .r2     = {
3802                         .owner          = &ctx->b,
3803                         .type           = WREPL_TYPE_SGROUP,
3804                         .state          = WREPL_STATE_ACTIVE,
3805                         .node           = WREPL_NODE_B,
3806                         .is_static      = False,
3807                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3808                         .ips            = addresses_B_1,
3809                         .apply_expected = True
3810                 }
3811         },
3812
3813         /* 
3814          * mhomed,tombstone vs. sgroup,tombstone
3815          * => should be replaced
3816          */
3817         {
3818                 .line   = __location__,
3819                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3820                 .r1     = {
3821                         .owner          = &ctx->b,
3822                         .type           = WREPL_TYPE_MHOMED,
3823                         .state          = WREPL_STATE_TOMBSTONE,
3824                         .node           = WREPL_NODE_B,
3825                         .is_static      = False,
3826                         .num_ips        = ARRAY_SIZE(addresses_B_1),
3827                         .ips            = addresses_B_1,
3828                         .apply_expected = True
3829                 },
3830                 .r2     = {
3831                         .owner          = &ctx->a,
3832                         .type           = WREPL_TYPE_SGROUP,
3833                         .state          = WREPL_STATE_TOMBSTONE,
3834                         .node           = WREPL_NODE_B,
3835                         .is_static      = False,
3836                         .num_ips        = ARRAY_SIZE(addresses_A_1),
3837                         .ips            = addresses_A_1,
3838                         .apply_expected = True
3839                 }
3840         },
3841
3842 /*
3843  * multi homed vs. mlti homed section,
3844  */
3845         /* 
3846          * mhomed,active vs. mhomed,active
3847          * => should be replaced
3848          */
3849         {
3850                 .line   = __location__,
3851                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3852                 .r1     = {
3853                         .owner          = &ctx->a,
3854                         .type           = WREPL_TYPE_MHOMED,
3855                         .state          = WREPL_STATE_ACTIVE,
3856                         .node           = WREPL_NODE_B,
3857                         .is_static      = False,
3858                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3859                         .ips            = addresses_A_3_4,
3860                         .apply_expected = True
3861                 },
3862                 .r2     = {
3863                         .owner          = &ctx->b,
3864                         .type           = WREPL_TYPE_MHOMED,
3865                         .state          = WREPL_STATE_ACTIVE,
3866                         .node           = WREPL_NODE_B,
3867                         .is_static      = False,
3868                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3869                         .ips            = addresses_B_3_4,
3870                         .apply_expected = True
3871                 }
3872         },
3873
3874         /* 
3875          * mhomed,active vs. mhomed,tombstone
3876          * => should NOT be replaced
3877          */
3878         {
3879                 .line   = __location__,
3880                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3881                 .r1     = {
3882                         .owner          = &ctx->b,
3883                         .type           = WREPL_TYPE_MHOMED,
3884                         .state          = WREPL_STATE_ACTIVE,
3885                         .node           = WREPL_NODE_B,
3886                         .is_static      = False,
3887                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3888                         .ips            = addresses_B_3_4,
3889                         .apply_expected = True
3890                 },
3891                 .r2     = {
3892                         .owner          = &ctx->a,
3893                         .type           = WREPL_TYPE_MHOMED,
3894                         .state          = WREPL_STATE_TOMBSTONE,
3895                         .node           = WREPL_NODE_B,
3896                         .is_static      = False,
3897                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3898                         .ips            = addresses_B_3_4,
3899                         .apply_expected = False
3900                 }
3901         },
3902
3903         /* 
3904          * mhomed,released vs. mhomed,active
3905          * => should be replaced
3906          */
3907         {
3908                 .line   = __location__,
3909                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3910                 .r1     = {
3911                         .owner          = &ctx->b,
3912                         .type           = WREPL_TYPE_MHOMED,
3913                         .state          = WREPL_STATE_RELEASED,
3914                         .node           = WREPL_NODE_B,
3915                         .is_static      = False,
3916                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3917                         .ips            = addresses_B_3_4,
3918                         .apply_expected = False
3919                 },
3920                 .r2     = {
3921                         .owner          = &ctx->a,
3922                         .type           = WREPL_TYPE_MHOMED,
3923                         .state          = WREPL_STATE_ACTIVE,
3924                         .node           = WREPL_NODE_B,
3925                         .is_static      = False,
3926                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3927                         .ips            = addresses_A_3_4,
3928                         .apply_expected = True
3929                 }
3930         },
3931
3932         /* 
3933          * mhomed,released vs. mhomed,tombstone
3934          * => should be replaced
3935          */
3936         {
3937                 .line   = __location__,
3938                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3939                 .r1     = {
3940                         .owner          = &ctx->a,
3941                         .type           = WREPL_TYPE_MHOMED,
3942                         .state          = WREPL_STATE_RELEASED,
3943                         .node           = WREPL_NODE_B,
3944                         .is_static      = False,
3945                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3946                         .ips            = addresses_A_3_4,
3947                         .apply_expected = False
3948                 },
3949                 .r2     = {
3950                         .owner          = &ctx->b,
3951                         .type           = WREPL_TYPE_MHOMED,
3952                         .state          = WREPL_STATE_TOMBSTONE,
3953                         .node           = WREPL_NODE_B,
3954                         .is_static      = False,
3955                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3956                         .ips            = addresses_B_3_4,
3957                         .apply_expected = True
3958                 }
3959         },
3960
3961         /* 
3962          * mhomed,tombstone vs. mhomed,active
3963          * => should be replaced
3964          */
3965         {
3966                 .line   = __location__,
3967                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3968                 .r1     = {
3969                         .owner          = &ctx->b,
3970                         .type           = WREPL_TYPE_MHOMED,
3971                         .state          = WREPL_STATE_TOMBSTONE,
3972                         .node           = WREPL_NODE_B,
3973                         .is_static      = False,
3974                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
3975                         .ips            = addresses_B_3_4,
3976                         .apply_expected = True
3977                 },
3978                 .r2     = {
3979                         .owner          = &ctx->a,
3980                         .type           = WREPL_TYPE_MHOMED,
3981                         .state          = WREPL_STATE_ACTIVE,
3982                         .node           = WREPL_NODE_B,
3983                         .is_static      = False,
3984                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
3985                         .ips            = addresses_A_3_4,
3986                         .apply_expected = True
3987                 }
3988         },
3989
3990         /* 
3991          * mhomed,tombstone vs. mhomed,tombstone
3992          * => should be replaced
3993          */
3994         {
3995                 .line   = __location__,
3996                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
3997                 .r1     = {
3998                         .owner          = &ctx->a,
3999                         .type           = WREPL_TYPE_MHOMED,
4000                         .state          = WREPL_STATE_TOMBSTONE,
4001                         .node           = WREPL_NODE_B,
4002                         .is_static      = False,
4003                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4004                         .ips            = addresses_A_3_4,
4005                         .apply_expected = True
4006                 },
4007                 .r2     = {
4008                         .owner          = &ctx->b,
4009                         .type           = WREPL_TYPE_MHOMED,
4010                         .state          = WREPL_STATE_TOMBSTONE,
4011                         .node           = WREPL_NODE_B,
4012                         .is_static      = False,
4013                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
4014                         .ips            = addresses_B_3_4,
4015                         .apply_expected = True
4016                 }
4017         },
4018         {
4019                 .line   = __location__,
4020                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4021                 .cleanup= True,
4022                 .r1     = {
4023                         .owner          = &ctx->b,
4024                         .type           = WREPL_TYPE_UNIQUE,
4025                         .state          = WREPL_STATE_TOMBSTONE,
4026                         .node           = WREPL_NODE_B,
4027                         .is_static      = False,
4028                         .num_ips        = ARRAY_SIZE(addresses_B_1),
4029                         .ips            = addresses_B_1,
4030                         .apply_expected = True,
4031                 },
4032                 .r2     = {
4033                         .owner          = &ctx->a,
4034                         .type           = WREPL_TYPE_UNIQUE,
4035                         .state          = WREPL_STATE_TOMBSTONE,
4036                         .node           = WREPL_NODE_B,
4037                         .is_static      = False,
4038                         .num_ips        = ARRAY_SIZE(addresses_A_1),
4039                         .ips            = addresses_A_1,
4040                         .apply_expected = True,
4041                 }
4042         },
4043 /*
4044  * special group vs special group section,
4045  */
4046         /* 
4047          * sgroup,active vs. sgroup,active same addresses
4048          * => should be NOT replaced
4049          */
4050         {
4051                 .line   = __location__,
4052                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4053                 .comment= "A:A_3_4 vs. B:A_3_4",
4054                 .extra  = True,
4055                 .r1     = {
4056                         .owner          = &ctx->a,
4057                         .type           = WREPL_TYPE_SGROUP,
4058                         .state          = WREPL_STATE_ACTIVE,
4059                         .node           = WREPL_NODE_B,
4060                         .is_static      = False,
4061                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4062                         .ips            = addresses_A_3_4,
4063                         .apply_expected = True
4064                 },
4065                 .r2     = {
4066                         .owner          = &ctx->b,
4067                         .type           = WREPL_TYPE_SGROUP,
4068                         .state          = WREPL_STATE_ACTIVE,
4069                         .node           = WREPL_NODE_B,
4070                         .is_static      = False,
4071                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4072                         .ips            = addresses_A_3_4,
4073                         .apply_expected = False,
4074                         .sgroup_cleanup = True
4075                 }
4076         },
4077         /* 
4078          * sgroup,active vs. sgroup,active same addresses
4079          * => should be NOT replaced
4080          */
4081         {
4082                 .line   = __location__,
4083                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4084                 .comment= "A:A_3_4 vs. B:NULL",
4085                 .extra  = True,
4086                 .r1     = {
4087                         .owner          = &ctx->a,
4088                         .type           = WREPL_TYPE_SGROUP,
4089                         .state          = WREPL_STATE_ACTIVE,
4090                         .node           = WREPL_NODE_B,
4091                         .is_static      = False,
4092                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4093                         .ips            = addresses_A_3_4,
4094                         .apply_expected = True
4095                 },
4096                 .r2     = {
4097                         .owner          = &ctx->b,
4098                         .type           = WREPL_TYPE_SGROUP,
4099                         .state          = WREPL_STATE_ACTIVE,
4100                         .node           = WREPL_NODE_B,
4101                         .is_static      = False,
4102                         .num_ips        = 0,
4103                         .ips            = NULL,
4104                         .apply_expected = False,
4105                         .sgroup_cleanup = True
4106                 }
4107         },
4108         /* 
4109          * sgroup,active vs. sgroup,active subset addresses, special case...
4110          * => should NOT be replaced
4111          */
4112         {
4113                 .line   = __location__,
4114                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4115                 .comment= "A:A_3_4_X_3_4 vs. B:A_3_4",
4116                 .extra  = True,
4117                 .r1     = {
4118                         .owner          = &ctx->a,
4119                         .type           = WREPL_TYPE_SGROUP,
4120                         .state          = WREPL_STATE_ACTIVE,
4121                         .node           = WREPL_NODE_B,
4122                         .is_static      = False,
4123                         .num_ips        = ARRAY_SIZE(addresses_A_3_4_X_3_4),
4124                         .ips            = addresses_A_3_4_X_3_4,
4125                         .apply_expected = True,
4126                 },
4127                 .r2     = {
4128                         .owner          = &ctx->b,
4129                         .type           = WREPL_TYPE_SGROUP,
4130                         .state          = WREPL_STATE_ACTIVE,
4131                         .node           = WREPL_NODE_B,
4132                         .is_static      = False,
4133                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4134                         .ips            = addresses_A_3_4,
4135                         .apply_expected = False,
4136                 }
4137         },
4138         {
4139                 .line   = __location__,
4140                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4141                 .cleanup= True,
4142                 .r1     = {
4143                         .owner          = &ctx->a,
4144                         .type           = WREPL_TYPE_SGROUP,
4145                         .state          = WREPL_STATE_ACTIVE,
4146                         .node           = WREPL_NODE_B,
4147                         .is_static      = False,
4148                         .num_ips        = 0,
4149                         .ips            = NULL,
4150                         .apply_expected = False,
4151                 },
4152                 .r2     = {
4153                         .owner          = &ctx->x,
4154                         .type           = WREPL_TYPE_SGROUP,
4155                         .state          = WREPL_STATE_ACTIVE,
4156                         .node           = WREPL_NODE_B,
4157                         .is_static      = False,
4158                         .num_ips        = 0,
4159                         .ips            = NULL,
4160                         .apply_expected = False,
4161                 }
4162         },
4163         /* 
4164          * sgroup,active vs. sgroup,active different addresses, but owner changed
4165          * => should be replaced
4166          */
4167         {
4168                 .line   = __location__,
4169                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4170                 .comment= "A:B_3_4 vs. B:A_3_4",
4171                 .extra  = True,
4172                 .r1     = {
4173                         .owner          = &ctx->a,
4174                         .type           = WREPL_TYPE_SGROUP,
4175                         .state          = WREPL_STATE_ACTIVE,
4176                         .node           = WREPL_NODE_B,
4177                         .is_static      = False,
4178                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
4179                         .ips            = addresses_B_3_4,
4180                         .apply_expected = True,
4181                 },
4182                 .r2     = {
4183                         .owner          = &ctx->b,
4184                         .type           = WREPL_TYPE_SGROUP,
4185                         .state          = WREPL_STATE_ACTIVE,
4186                         .node           = WREPL_NODE_B,
4187                         .is_static      = False,
4188                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4189                         .ips            = addresses_A_3_4,
4190                         .apply_expected = True,
4191                         .sgroup_cleanup = True
4192                 }
4193         },
4194         /* 
4195          * sgroup,active vs. sgroup,active different addresses, but owner changed
4196          * => should be replaced
4197          */
4198         {
4199                 .line   = __location__,
4200                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4201                 .comment= "A:A_3_4 vs. B:A_3_4_OWNER_B",
4202                 .extra  = True,
4203                 .r1     = {
4204                         .owner          = &ctx->a,
4205                         .type           = WREPL_TYPE_SGROUP,
4206                         .state          = WREPL_STATE_ACTIVE,
4207                         .node           = WREPL_NODE_B,
4208                         .is_static      = False,
4209                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4210                         .ips            = addresses_A_3_4,
4211                         .apply_expected = True,
4212                 },
4213                 .r2     = {
4214                         .owner          = &ctx->b,
4215                         .type           = WREPL_TYPE_SGROUP,
4216                         .state          = WREPL_STATE_ACTIVE,
4217                         .node           = WREPL_NODE_B,
4218                         .is_static      = False,
4219                         .num_ips        = ARRAY_SIZE(addresses_A_3_4_OWNER_B),
4220                         .ips            = addresses_A_3_4_OWNER_B,
4221                         .apply_expected = True,
4222                         .sgroup_cleanup = True
4223                 }
4224         },
4225         /* 
4226          * sgroup,active vs. sgroup,active different addresses, but owner changed
4227          * => should be replaced
4228          */
4229         {
4230                 .line   = __location__,
4231                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4232                 .comment= "A:A_3_4_OWNER_B vs. B:A_3_4",
4233                 .extra  = True,
4234                 .r1     = {
4235                         .owner          = &ctx->a,
4236                         .type           = WREPL_TYPE_SGROUP,
4237                         .state          = WREPL_STATE_ACTIVE,
4238                         .node           = WREPL_NODE_B,
4239                         .is_static      = False,
4240                         .num_ips        = ARRAY_SIZE(addresses_A_3_4_OWNER_B),
4241                         .ips            = addresses_A_3_4_OWNER_B,
4242                         .apply_expected = True,
4243                 },
4244                 .r2     = {
4245                         .owner          = &ctx->b,
4246                         .type           = WREPL_TYPE_SGROUP,
4247                         .state          = WREPL_STATE_ACTIVE,
4248                         .node           = WREPL_NODE_B,
4249                         .is_static      = False,
4250                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4251                         .ips            = addresses_A_3_4,
4252                         .apply_expected = True,
4253                         .sgroup_cleanup = True
4254                 }
4255         },
4256         /* 
4257          * sgroup,active vs. sgroup,active different addresses
4258          * => should be merged
4259          */
4260         {
4261                 .line   = __location__,
4262                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4263                 .comment= "A:A_3_4 vs. B:B_3_4 => C:A_3_4_B_3_4",
4264                 .extra  = True,
4265                 .r1     = {
4266                         .owner          = &ctx->a,
4267                         .type           = WREPL_TYPE_SGROUP,
4268                         .state          = WREPL_STATE_ACTIVE,
4269                         .node           = WREPL_NODE_B,
4270                         .is_static      = False,
4271                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4272                         .ips            = addresses_A_3_4,
4273                         .apply_expected = True,
4274                 },
4275                 .r2     = {
4276                         .owner          = &ctx->b,
4277                         .type           = WREPL_TYPE_SGROUP,
4278                         .state          = WREPL_STATE_ACTIVE,
4279                         .node           = WREPL_NODE_B,
4280                         .is_static      = False,
4281                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
4282                         .ips            = addresses_B_3_4,
4283                         .sgroup_merge   = True,
4284                         .sgroup_cleanup = True,
4285                 }
4286         },
4287         /* 
4288          * sgroup,active vs. sgroup,active different addresses, special case...
4289          * => should be merged
4290          */
4291         {
4292                 .line   = __location__,
4293                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4294                 .comment= "A:B_3_4_X_3_4 vs. B:A_3_4 => B:A_3_4_X_3_4",
4295                 .extra  = True,
4296                 .r1     = {
4297                         .owner          = &ctx->a,
4298                         .type           = WREPL_TYPE_SGROUP,
4299                         .state          = WREPL_STATE_ACTIVE,
4300                         .node           = WREPL_NODE_B,
4301                         .is_static      = False,
4302                         .num_ips        = ARRAY_SIZE(addresses_B_3_4_X_3_4),
4303                         .ips            = addresses_B_3_4_X_3_4,
4304                         .apply_expected = True,
4305                 },
4306                 .r2     = {
4307                         .owner          = &ctx->b,
4308                         .type           = WREPL_TYPE_SGROUP,
4309                         .state          = WREPL_STATE_ACTIVE,
4310                         .node           = WREPL_NODE_B,
4311                         .is_static      = False,
4312                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4313                         .ips            = addresses_A_3_4,
4314                         .sgroup_merge   = True,
4315                         .merge_owner    = &ctx->b,
4316                         .sgroup_cleanup = False
4317                 }
4318         },
4319         {
4320                 .line   = __location__,
4321                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4322                 .cleanup= True,
4323                 .r1     = {
4324                         .owner          = &ctx->b,
4325                         .type           = WREPL_TYPE_SGROUP,
4326                         .state          = WREPL_STATE_ACTIVE,
4327                         .node           = WREPL_NODE_B,
4328                         .is_static      = False,
4329                         .num_ips        = ARRAY_SIZE(addresses_A_3_4_X_3_4_OWNER_B),
4330                         .ips            = addresses_A_3_4_X_3_4_OWNER_B,
4331                         .apply_expected = True,
4332                 },
4333                 .r2     = {
4334                         .owner          = &ctx->b,
4335                         .type           = WREPL_TYPE_SGROUP,
4336                         .state          = WREPL_STATE_ACTIVE,
4337                         .node           = WREPL_NODE_B,
4338                         .is_static      = False,
4339                         .num_ips        = 0,
4340                         .ips            = NULL,
4341                         .apply_expected = False,
4342                 }
4343         },
4344         /* 
4345          * sgroup,active vs. sgroup,active different addresses, special case...
4346          * => should be merged
4347          */
4348         {
4349                 .line   = __location__,
4350                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4351                 .comment= "A:X_3_4 vs. B:A_3_4 => C:A_3_4_X_3_4",
4352                 .extra  = True,
4353                 .r1     = {
4354                         .owner          = &ctx->a,
4355                         .type           = WREPL_TYPE_SGROUP,
4356                         .state          = WREPL_STATE_ACTIVE,
4357                         .node           = WREPL_NODE_B,
4358                         .is_static      = False,
4359                         .num_ips        = ARRAY_SIZE(addresses_X_3_4),
4360                         .ips            = addresses_X_3_4,
4361                         .apply_expected = True,
4362                 },
4363                 .r2     = {
4364                         .owner          = &ctx->b,
4365                         .type           = WREPL_TYPE_SGROUP,
4366                         .state          = WREPL_STATE_ACTIVE,
4367                         .node           = WREPL_NODE_B,
4368                         .is_static      = False,
4369                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4370                         .ips            = addresses_A_3_4,
4371                         .sgroup_merge   = True,
4372                         .sgroup_cleanup = False
4373                 }
4374         },
4375         {
4376                 .line   = __location__,
4377                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4378                 .cleanup= True,
4379                 .r1     = {
4380                         .owner          = &ctx->a,
4381                         .type           = WREPL_TYPE_SGROUP,
4382                         .state          = WREPL_STATE_ACTIVE,
4383                         .node           = WREPL_NODE_B,
4384                         .is_static      = False,
4385                         .num_ips        = 0,
4386                         .ips            = NULL,
4387                         .apply_expected = False,
4388                 },
4389                 .r2     = {
4390                         .owner          = &ctx->x,
4391                         .type           = WREPL_TYPE_SGROUP,
4392                         .state          = WREPL_STATE_ACTIVE,
4393                         .node           = WREPL_NODE_B,
4394                         .is_static      = False,
4395                         .num_ips        = 0,
4396                         .ips            = NULL,
4397                         .apply_expected = False,
4398                 }
4399         },
4400         /* 
4401          * sgroup,active vs. sgroup,active different addresses, special case...
4402          * => should be merged
4403          */
4404         {
4405                 .line   = __location__,
4406                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4407                 .comment= "A:A_3_4_X_3_4 vs. B:A_3_4_OWNER_B => B:A_3_4_OWNER_B_X_3_4",
4408                 .extra  = True,
4409                 .r1     = {
4410                         .owner          = &ctx->a,
4411                         .type           = WREPL_TYPE_SGROUP,
4412                         .state          = WREPL_STATE_ACTIVE,
4413                         .node           = WREPL_NODE_B,
4414                         .is_static      = False,
4415                         .num_ips        = ARRAY_SIZE(addresses_A_3_4_X_3_4),
4416                         .ips            = addresses_A_3_4_X_3_4,
4417                         .apply_expected = True,
4418                 },
4419                 .r2     = {
4420                         .owner          = &ctx->b,
4421                         .type           = WREPL_TYPE_SGROUP,
4422                         .state          = WREPL_STATE_ACTIVE,
4423                         .node           = WREPL_NODE_B,
4424                         .is_static      = False,
4425                         .num_ips        = ARRAY_SIZE(addresses_A_3_4_OWNER_B),
4426                         .ips            = addresses_A_3_4_OWNER_B,
4427                         .sgroup_merge   = True,
4428                         .merge_owner    = &ctx->b,
4429                 }
4430         },
4431         {
4432                 .line   = __location__,
4433                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4434                 .cleanup= True,
4435                 .r1     = {
4436                         .owner          = &ctx->b,
4437                         .type           = WREPL_TYPE_SGROUP,
4438                         .state          = WREPL_STATE_ACTIVE,
4439                         .node           = WREPL_NODE_B,
4440                         .is_static      = False,
4441                         .num_ips        = 0,
4442                         .ips            = NULL,
4443                         .apply_expected = False,
4444                 },
4445                 .r2     = {
4446                         .owner          = &ctx->x,
4447                         .type           = WREPL_TYPE_SGROUP,
4448                         .state          = WREPL_STATE_ACTIVE,
4449                         .node           = WREPL_NODE_B,
4450                         .is_static      = False,
4451                         .num_ips        = 0,
4452                         .ips            = NULL,
4453                         .apply_expected = False,
4454                 }
4455         },
4456         /* 
4457          * sgroup,active vs. sgroup,active partly different addresses, special case...
4458          * => should be merged
4459          */
4460         {
4461                 .line   = __location__,
4462                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4463                 .comment= "A:B_3_4_X_3_4 vs. B:B_3_4_X_1_2 => C:B_3_4_X_1_2_3_4",
4464                 .extra  = True,
4465                 .r1     = {
4466                         .owner          = &ctx->a,
4467                         .type           = WREPL_TYPE_SGROUP,
4468                         .state          = WREPL_STATE_ACTIVE,
4469                         .node           = WREPL_NODE_B,
4470                         .is_static      = False,
4471                         .num_ips        = ARRAY_SIZE(addresses_B_3_4_X_3_4),
4472                         .ips            = addresses_B_3_4_X_3_4,
4473                         .apply_expected = True,
4474                 },
4475                 .r2     = {
4476                         .owner          = &ctx->b,
4477                         .type           = WREPL_TYPE_SGROUP,
4478                         .state          = WREPL_STATE_ACTIVE,
4479                         .node           = WREPL_NODE_B,
4480                         .is_static      = False,
4481                         .num_ips        = ARRAY_SIZE(addresses_B_3_4_X_1_2),
4482                         .ips            = addresses_B_3_4_X_1_2,
4483                         .sgroup_merge   = True,
4484                         .sgroup_cleanup = False
4485                 }
4486         },
4487         {
4488                 .line   = __location__,
4489                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4490                 .cleanup= True,
4491                 .r1     = {
4492                         .owner          = &ctx->b,
4493                         .type           = WREPL_TYPE_SGROUP,
4494                         .state          = WREPL_STATE_ACTIVE,
4495                         .node           = WREPL_NODE_B,
4496                         .is_static      = False,
4497                         .num_ips        = 0,
4498                         .ips            = NULL,
4499                         .apply_expected = False,
4500                 },
4501                 .r2     = {
4502                         .owner          = &ctx->x,
4503                         .type           = WREPL_TYPE_SGROUP,
4504                         .state          = WREPL_STATE_ACTIVE,
4505                         .node           = WREPL_NODE_B,
4506                         .is_static      = False,
4507                         .num_ips        = 0,
4508                         .ips            = NULL,
4509                         .apply_expected = False,
4510                 }
4511         },
4512         /* 
4513          * sgroup,active vs. sgroup,active different addresses, special case...
4514          * => should be merged
4515          */
4516         {
4517                 .line   = __location__,
4518                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4519                 .comment= "A:A_3_4_B_3_4 vs. B:NULL => B:A_3_4",
4520                 .extra  = True,
4521                 .r1     = {
4522                         .owner          = &ctx->a,
4523                         .type           = WREPL_TYPE_SGROUP,
4524                         .state          = WREPL_STATE_ACTIVE,
4525                         .node           = WREPL_NODE_B,
4526                         .is_static      = False,
4527                         .num_ips        = ARRAY_SIZE(addresses_A_3_4_B_3_4),
4528                         .ips            = addresses_A_3_4_B_3_4,
4529                         .apply_expected = True,
4530                 },
4531                 .r2     = {
4532                         .owner          = &ctx->b,
4533                         .type           = WREPL_TYPE_SGROUP,
4534                         .state          = WREPL_STATE_ACTIVE,
4535                         .node           = WREPL_NODE_B,
4536                         .is_static      = False,
4537                         .num_ips        = 0,
4538                         .ips            = NULL,
4539                         .sgroup_merge   = True,
4540                         .merge_owner    = &ctx->b,
4541                         .sgroup_cleanup = True
4542                 }
4543         },
4544         {
4545                 .line   = __location__,
4546                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4547                 .cleanup= True,
4548                 .r1     = {
4549                         .owner          = &ctx->a,
4550                         .type           = WREPL_TYPE_SGROUP,
4551                         .state          = WREPL_STATE_ACTIVE,
4552                         .node           = WREPL_NODE_B,
4553                         .is_static      = False,
4554                         .num_ips        = 0,
4555                         .ips            = NULL,
4556                         .apply_expected = False,
4557                 },
4558                 .r2     = {
4559                         .owner          = &ctx->a,
4560                         .type           = WREPL_TYPE_UNIQUE,
4561                         .state          = WREPL_STATE_TOMBSTONE,
4562                         .node           = WREPL_NODE_B,
4563                         .is_static      = False,
4564                         .num_ips        = ARRAY_SIZE(addresses_A_1),
4565                         .ips            = addresses_A_1,
4566                         .apply_expected = True,
4567                 }
4568         },
4569         /* 
4570          * sgroup,active vs. sgroup,active different addresses, special case...
4571          * => should be merged
4572          */
4573         {
4574                 .line   = __location__,
4575                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4576                 .comment= "A:B_3_4_X_3_4 vs. B:NULL => B:X_3_4",
4577                 .extra  = True,
4578                 .r1     = {
4579                         .owner          = &ctx->a,
4580                         .type           = WREPL_TYPE_SGROUP,
4581                         .state          = WREPL_STATE_ACTIVE,
4582                         .node           = WREPL_NODE_B,
4583                         .is_static      = False,
4584                         .num_ips        = ARRAY_SIZE(addresses_B_3_4_X_3_4),
4585                         .ips            = addresses_B_3_4_X_3_4,
4586                         .apply_expected = True,
4587                 },
4588                 .r2     = {
4589                         .owner          = &ctx->b,
4590                         .type           = WREPL_TYPE_SGROUP,
4591                         .state          = WREPL_STATE_ACTIVE,
4592                         .node           = WREPL_NODE_B,
4593                         .is_static      = False,
4594                         .num_ips        = 0,
4595                         .ips            = NULL,
4596                         .sgroup_merge   = True,
4597                         .merge_owner    = &ctx->b,
4598                         .sgroup_cleanup = True
4599                 }
4600         },
4601         {
4602                 .line   = __location__,
4603                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4604                 .cleanup= True,
4605                 .r1     = {
4606                         .owner          = &ctx->x,
4607                         .type           = WREPL_TYPE_SGROUP,
4608                         .state          = WREPL_STATE_ACTIVE,
4609                         .node           = WREPL_NODE_B,
4610                         .is_static      = False,
4611                         .num_ips        = 0,
4612                         .ips            = NULL,
4613                         .apply_expected = False,
4614                 },
4615                 .r2     = {
4616                         .owner          = &ctx->x,
4617                         .type           = WREPL_TYPE_UNIQUE,
4618                         .state          = WREPL_STATE_TOMBSTONE,
4619                         .node           = WREPL_NODE_B,
4620                         .is_static      = False,
4621                         .num_ips        = ARRAY_SIZE(addresses_A_1),
4622                         .ips            = addresses_A_1,
4623                         .apply_expected = True,
4624                 }
4625         },
4626
4627         /* 
4628          * sgroup,active vs. sgroup,tombstone different no addresses, special
4629          * => should be replaced
4630          */
4631         {
4632                 .line   = __location__,
4633                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4634                 .comment= "A:B_3_4_X_3_4 vs. B:NULL => B:NULL",
4635                 .extra  = True,
4636                 .r1     = {
4637                         .owner          = &ctx->a,
4638                         .type           = WREPL_TYPE_SGROUP,
4639                         .state          = WREPL_STATE_ACTIVE,
4640                         .node           = WREPL_NODE_B,
4641                         .is_static      = False,
4642                         .num_ips        = ARRAY_SIZE(addresses_B_3_4_X_3_4),
4643                         .ips            = addresses_B_3_4_X_3_4,
4644                         .apply_expected = True,
4645                 },
4646                 .r2     = {
4647                         .owner          = &ctx->b,
4648                         .type           = WREPL_TYPE_SGROUP,
4649                         .state          = WREPL_STATE_TOMBSTONE,
4650                         .node           = WREPL_NODE_B,
4651                         .is_static      = False,
4652                         .num_ips        = 0,
4653                         .ips            = NULL,
4654                         .apply_expected = True,
4655                 }
4656         },
4657         /* 
4658          * sgroup,active vs. sgroup,tombstone different addresses
4659          * => should be replaced
4660          */
4661         {
4662                 .line   = __location__,
4663                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4664                 .comment= "A:B_3_4_X_3_4 vs. B:A_3_4 => B:A_3_4",
4665                 .extra  = True,
4666                 .r1     = {
4667                         .owner          = &ctx->a,
4668                         .type           = WREPL_TYPE_SGROUP,
4669                         .state          = WREPL_STATE_ACTIVE,
4670                         .node           = WREPL_NODE_B,
4671                         .is_static      = False,
4672                         .num_ips        = ARRAY_SIZE(addresses_B_3_4_X_3_4),
4673                         .ips            = addresses_B_3_4_X_3_4,
4674                         .apply_expected = True,
4675                 },
4676                 .r2     = {
4677                         .owner          = &ctx->b,
4678                         .type           = WREPL_TYPE_SGROUP,
4679                         .state          = WREPL_STATE_TOMBSTONE,
4680                         .node           = WREPL_NODE_B,
4681                         .is_static      = False,
4682                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
4683                         .ips            = addresses_A_3_4,
4684                         .apply_expected = True,
4685                 }
4686         },
4687         /* 
4688          * sgroup,active vs. sgroup,tombstone subset addresses
4689          * => should be replaced
4690          */
4691         {
4692                 .line   = __location__,
4693                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4694                 .comment= "A:B_3_4_X_3_4 vs. B:B_3_4 => B:B_3_4",
4695                 .extra  = True,
4696                 .r1     = {
4697                         .owner          = &ctx->a,
4698                         .type           = WREPL_TYPE_SGROUP,
4699                         .state          = WREPL_STATE_ACTIVE,
4700                         .node           = WREPL_NODE_B,
4701                         .is_static      = False,
4702                         .num_ips        = ARRAY_SIZE(addresses_B_3_4_X_3_4),
4703                         .ips            = addresses_B_3_4_X_3_4,
4704                         .apply_expected = True,
4705                 },
4706                 .r2     = {
4707                         .owner          = &ctx->b,
4708                         .type           = WREPL_TYPE_SGROUP,
4709                         .state          = WREPL_STATE_TOMBSTONE,
4710                         .node           = WREPL_NODE_B,
4711                         .is_static      = False,
4712                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
4713                         .ips            = addresses_B_3_4,
4714                         .apply_expected = True,
4715                 }
4716         },
4717         /* 
4718          * sgroup,active vs. sgroup,active same addresses
4719          * => should be replaced
4720          */
4721         {
4722                 .line   = __location__,
4723                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4724                 .comment= "A:B_3_4_X_3_4 vs. B:B_3_4_X_3_4 => B:B_3_4_X_3_4",
4725                 .extra  = True,
4726                 .r1     = {
4727                         .owner          = &ctx->a,
4728                         .type           = WREPL_TYPE_SGROUP,
4729                         .state          = WREPL_STATE_ACTIVE,
4730                         .node           = WREPL_NODE_B,
4731                         .is_static      = False,
4732                         .num_ips        = ARRAY_SIZE(addresses_B_3_4_X_3_4),
4733                         .ips            = addresses_B_3_4_X_3_4,
4734                         .apply_expected = True,
4735                 },
4736                 .r2     = {
4737                         .owner          = &ctx->b,
4738                         .type           = WREPL_TYPE_SGROUP,
4739                         .state          = WREPL_STATE_TOMBSTONE,
4740                         .node           = WREPL_NODE_B,
4741                         .is_static      = False,
4742                         .num_ips        = ARRAY_SIZE(addresses_B_3_4_X_3_4),
4743                         .ips            = addresses_B_3_4_X_3_4,
4744                         .apply_expected = True,
4745                 }
4746         },
4747
4748         /* 
4749          * This should be the last record in this array,
4750          * we need to make sure the we leave a tombstoned unique entry
4751          * owned by OWNER_A
4752          */
4753         {
4754                 .line   = __location__,
4755                 .name   = _NBT_NAME("_DIFF_OWNER", 0x00, NULL),
4756                 .cleanup= True,
4757                 .r1     = {
4758                         .owner          = &ctx->a,
4759                         .type           = WREPL_TYPE_UNIQUE,
4760                         .state          = WREPL_STATE_TOMBSTONE,
4761                         .node           = WREPL_NODE_B,
4762                         .is_static      = False,
4763                         .num_ips        = ARRAY_SIZE(addresses_A_1),
4764                         .ips            = addresses_A_1,
4765                         .apply_expected = True
4766                 },
4767                 .r2     = {
4768                         .owner          = &ctx->a,
4769                         .type           = WREPL_TYPE_UNIQUE,
4770                         .state          = WREPL_STATE_TOMBSTONE,
4771                         .node           = WREPL_NODE_B,
4772                         .is_static      = False,
4773                         .num_ips        = ARRAY_SIZE(addresses_A_1),
4774                         .ips            = addresses_A_1,
4775                         .apply_expected = True
4776                 }
4777         }}; /* do not add entries here, this should be the last record! */
4778
4779         wins_name_r1    = &wins_name1;
4780         wins_name_r2    = &wins_name2;
4781
4782         printf("Test Replica Conflicts with different owners\n");
4783
4784         for(i=0; ret && i < ARRAY_SIZE(records); i++) {
4785
4786                 if (!records[i].extra && !records[i].cleanup) {
4787                         /* we should test the worst cases */
4788                         if (records[i].r2.apply_expected && records[i].r1.ips==records[i].r2.ips) {
4789                                 printf("(%s) Programmer error, invalid record[%u]: %s\n",
4790                                         __location__, i, records[i].line);
4791                                 return False;
4792                         } else if (!records[i].r2.apply_expected && records[i].r1.ips!=records[i].r2.ips) {
4793                                 printf("(%s) Programmer error, invalid record[%u]: %s\n",
4794                                         __location__, i, records[i].line);
4795                                 return False;
4796                         }
4797                 }
4798
4799                 if (!records[i].cleanup) {
4800                         const char *expected;
4801                         const char *ips;
4802
4803                         if (records[i].r2.sgroup_merge) {
4804                                 expected = "SGROUP_MERGE";
4805                         } else if (records[i].r2.apply_expected) {
4806                                 expected = "REPLACE";
4807                         } else {
4808                                 expected = "NOT REPLACE";
4809                         }
4810
4811                         if (!records[i].r1.ips && !records[i].r2.ips) {
4812                                 ips = "with no ip(s)";
4813                         } else if (records[i].r1.ips==records[i].r2.ips) {
4814                                 ips = "with same ip(s)";
4815                         } else {
4816                                 ips = "with different ip(s)";
4817                         }
4818
4819                         printf("%s,%s%s vs. %s,%s%s %s => %s\n",
4820                                 wrepl_name_type_string(records[i].r1.type),
4821                                 wrepl_name_state_string(records[i].r1.state),
4822                                 (records[i].r1.is_static?",static":""),
4823                                 wrepl_name_type_string(records[i].r2.type),
4824                                 wrepl_name_state_string(records[i].r2.state),
4825                                 (records[i].r2.is_static?",static":""),
4826                                 (records[i].comment?records[i].comment:ips),
4827                                 expected);
4828                 }
4829
4830                 /*
4831                  * Setup R1
4832                  */
4833                 wins_name_r1->name      = &records[i].name;
4834                 wins_name_r1->flags     = WREPL_NAME_FLAGS(records[i].r1.type,
4835                                                            records[i].r1.state,
4836                                                            records[i].r1.node,
4837                                                            records[i].r1.is_static);
4838                 wins_name_r1->id        = ++records[i].r1.owner->max_version;
4839                 if (wins_name_r1->flags & 2) {
4840                         wins_name_r1->addresses.addresses.num_ips = records[i].r1.num_ips;
4841                         wins_name_r1->addresses.addresses.ips     = discard_const(records[i].r1.ips);
4842                 } else {
4843                         wins_name_r1->addresses.ip = records[i].r1.ips[0].ip;
4844                 }
4845                 wins_name_r1->unknown   = "255.255.255.255";
4846
4847                 /* now apply R1 */
4848                 ret &= test_wrepl_update_one(ctx, records[i].r1.owner, wins_name_r1);
4849                 ret &= test_wrepl_is_applied(ctx, records[i].r1.owner,
4850                                              wins_name_r1, records[i].r1.apply_expected);
4851
4852                 /*
4853                  * Setup R2
4854                  */
4855                 wins_name_r2->name      = &records[i].name;
4856                 wins_name_r2->flags     = WREPL_NAME_FLAGS(records[i].r2.type,
4857                                                            records[i].r2.state,
4858                                                            records[i].r2.node,
4859                                                            records[i].r2.is_static);
4860                 wins_name_r2->id        = ++records[i].r2.owner->max_version;
4861                 if (wins_name_r2->flags & 2) {
4862                         wins_name_r2->addresses.addresses.num_ips = records[i].r2.num_ips;
4863                         wins_name_r2->addresses.addresses.ips     = discard_const(records[i].r2.ips);
4864                 } else {
4865                         wins_name_r2->addresses.ip = records[i].r2.ips[0].ip;
4866                 }
4867                 wins_name_r2->unknown   = "255.255.255.255";
4868
4869                 /* now apply R2 */
4870                 ret &= test_wrepl_update_one(ctx, records[i].r2.owner, wins_name_r2);
4871                 if (records[i].r1.state == WREPL_STATE_RELEASED) {
4872                         ret &= test_wrepl_is_applied(ctx, records[i].r1.owner,
4873                                                      wins_name_r1, False);
4874                 } else if (records[i].r2.sgroup_merge) {
4875                         ret &= test_wrepl_sgroup_merged(ctx, records[i].r2.merge_owner,
4876                                                         records[i].r1.owner,
4877                                                         records[i].r1.num_ips, records[i].r1.ips,
4878                                                         records[i].r2.owner,
4879                                                         records[i].r2.num_ips, records[i].r2.ips,
4880                                                         wins_name_r2);
4881                 } else if (records[i].r1.owner != records[i].r2.owner) {
4882                         BOOL _expected;
4883                         _expected = (records[i].r1.apply_expected && !records[i].r2.apply_expected);
4884                         ret &= test_wrepl_is_applied(ctx, records[i].r1.owner,
4885                                                      wins_name_r1, _expected);
4886                 }
4887                 if (records[i].r2.state == WREPL_STATE_RELEASED) {
4888                         ret &= test_wrepl_is_applied(ctx, records[i].r2.owner,
4889                                                      wins_name_r2, False);
4890                 } else if (!records[i].r2.sgroup_merge) {
4891                         ret &= test_wrepl_is_applied(ctx, records[i].r2.owner,
4892                                                      wins_name_r2, records[i].r2.apply_expected);
4893                 }
4894
4895                 if (records[i].r2.sgroup_cleanup) {
4896                         if (!ret) {
4897                                 printf("failed before sgroup_cleanup record[%u]: %s\n", i, records[i].line);
4898                                 return ret;
4899                         }
4900
4901                         /* clean up the SGROUP record */
4902                         wins_name_r1->name      = &records[i].name;
4903                         wins_name_r1->flags     = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP,
4904                                                                    WREPL_STATE_ACTIVE,
4905                                                                    WREPL_NODE_B, False);
4906                         wins_name_r1->id        = ++records[i].r1.owner->max_version;
4907                         wins_name_r1->addresses.addresses.num_ips = 0;
4908                         wins_name_r1->addresses.addresses.ips     = NULL;
4909                         wins_name_r1->unknown   = "255.255.255.255";
4910                         ret &= test_wrepl_update_one(ctx, records[i].r1.owner, wins_name_r1);
4911
4912                         /* here we test how names from an owner are deleted */
4913                         if (records[i].r2.sgroup_merge && records[i].r2.num_ips) {
4914                                 ret &= test_wrepl_sgroup_merged(ctx, NULL,
4915                                                                 records[i].r2.owner,
4916                                                                 records[i].r2.num_ips, records[i].r2.ips,
4917                                                                 records[i].r1.owner,
4918                                                                 0, NULL,
4919                                                                 wins_name_r2);
4920                         }
4921
4922                         /* clean up the SGROUP record */
4923                         wins_name_r2->name      = &records[i].name;
4924                         wins_name_r2->flags     = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP,
4925                                                                    WREPL_STATE_ACTIVE,
4926                                                                    WREPL_NODE_B, False);
4927                         wins_name_r2->id        = ++records[i].r2.owner->max_version;
4928                         wins_name_r2->addresses.addresses.num_ips = 0;
4929                         wins_name_r2->addresses.addresses.ips     = NULL;
4930                         wins_name_r2->unknown   = "255.255.255.255";
4931                         ret &= test_wrepl_update_one(ctx, records[i].r2.owner, wins_name_r2);
4932
4933                         /* take ownership of the SGROUP record */
4934                         wins_name_r2->name      = &records[i].name;
4935                         wins_name_r2->flags     = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP,
4936                                                                    WREPL_STATE_ACTIVE,
4937                                                                    WREPL_NODE_B, False);
4938                         wins_name_r2->id        = ++records[i].r2.owner->max_version;
4939                         wins_name_r2->addresses.addresses.num_ips = ARRAY_SIZE(addresses_B_1);
4940                         wins_name_r2->addresses.addresses.ips     = discard_const(addresses_B_1);
4941                         wins_name_r2->unknown   = "255.255.255.255";
4942                         ret &= test_wrepl_update_one(ctx, records[i].r2.owner, wins_name_r2);
4943                         ret &= test_wrepl_is_applied(ctx, records[i].r2.owner, wins_name_r2, True);
4944
4945                         /* overwrite the SGROUP record with unique,tombstone */
4946                         wins_name_r2->name      = &records[i].name;
4947                         wins_name_r2->flags     = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP,
4948                                                                    WREPL_STATE_TOMBSTONE,
4949                                                                    WREPL_NODE_B, False);
4950                         wins_name_r2->id        = ++records[i].r2.owner->max_version;
4951                         wins_name_r2->addresses.addresses.num_ips = ARRAY_SIZE(addresses_B_1);
4952                         wins_name_r2->addresses.addresses.ips     = discard_const(addresses_B_1);
4953                         wins_name_r2->unknown   = "255.255.255.255";
4954                         ret &= test_wrepl_update_one(ctx, records[i].r2.owner, wins_name_r2);
4955                         ret &= test_wrepl_is_applied(ctx, records[i].r2.owner, wins_name_r2, True);
4956
4957                         if (!ret) {
4958                                 printf("failed in sgroup_cleanup record[%u]: %s\n", i, records[i].line);
4959                                 return ret;
4960                         }
4961                 }
4962
4963                 /* the first one is a cleanup run */
4964                 if (!ret && i == 0) ret = True;
4965
4966                 if (!ret) {
4967                         printf("conflict handled wrong or record[%u]: %s\n", i, records[i].line);
4968                         return ret;
4969                 }
4970         }
4971
4972         return ret;
4973 }
4974
4975 static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_conn *ctx)
4976 {
4977         BOOL ret = True;
4978         NTSTATUS status;
4979         struct wrepl_wins_name wins_name_;
4980         struct wrepl_wins_name *wins_name = &wins_name_;
4981         struct nbt_name_register name_register_;
4982         struct nbt_name_register *name_register = &name_register_;
4983         struct nbt_name_release release_;
4984         struct nbt_name_release *release = &release_;
4985         uint32_t i;
4986         struct {
4987                 const char *line; /* just better debugging */
4988                 struct nbt_name name;
4989                 struct {
4990                         uint32_t nb_flags;
4991                         BOOL mhomed;
4992                         uint32_t num_ips;
4993                         const struct wrepl_ip *ips;
4994                         BOOL apply_expected;
4995                 } wins;
4996                 struct {
4997                         enum wrepl_name_type type;
4998                         enum wrepl_name_state state;
4999                         enum wrepl_name_node node;
5000                         BOOL is_static;
5001                         uint32_t num_ips;
5002                         const struct wrepl_ip *ips;
5003                         BOOL apply_expected;
5004                 } replica;
5005         } records[] = {
5006 /* 
5007  * unique vs. unique section
5008  */
5009         /*
5010          * unique,released vs. unique,active with same ip(s)
5011          */
5012         {
5013                 .line   = __location__,
5014                 .name   = _NBT_NAME("_UR_UA_SI", 0x00, NULL),
5015                 .wins   = {
5016                         .nb_flags       = 0,
5017                         .mhomed         = False,
5018                         .num_ips        = ctx->addresses_best_num,
5019                         .ips            = ctx->addresses_best,
5020                         .apply_expected = True
5021                 },
5022                 .replica= {
5023                         .type           = WREPL_TYPE_UNIQUE,
5024                         .state          = WREPL_STATE_ACTIVE,
5025                         .node           = WREPL_NODE_B,
5026                         .is_static      = False,
5027                         .num_ips        = ctx->addresses_best_num,
5028                         .ips            = ctx->addresses_best,
5029                         .apply_expected = True
5030                 },
5031         },
5032         /*
5033          * unique,released vs. unique,active with different ip(s)
5034          */
5035         {
5036                 .line   = __location__,
5037                 .name   = _NBT_NAME("_UR_UA_DI", 0x00, NULL),
5038                 .wins   = {
5039                         .nb_flags       = 0,
5040                         .mhomed         = False,
5041                         .num_ips        = ctx->addresses_best_num,
5042                         .ips            = ctx->addresses_best,
5043                         .apply_expected = True
5044                 },
5045                 .replica= {
5046                         .type           = WREPL_TYPE_UNIQUE,
5047                         .state          = WREPL_STATE_ACTIVE,
5048                         .node           = WREPL_NODE_B,
5049                         .is_static      = False,
5050                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5051                         .ips            = addresses_B_1,
5052                         .apply_expected = True
5053                 },
5054         },
5055         /*
5056          * unique,released vs. unique,tombstone with same ip(s)
5057          */
5058         {
5059                 .line   = __location__,
5060                 .name   = _NBT_NAME("_UR_UT_SI", 0x00, NULL),
5061                 .wins   = {
5062                         .nb_flags       = 0,
5063                         .mhomed         = False,
5064                         .num_ips        = ctx->addresses_best_num,
5065                         .ips            = ctx->addresses_best,
5066                         .apply_expected = True
5067                 },
5068                 .replica= {
5069                         .type           = WREPL_TYPE_UNIQUE,
5070                         .state          = WREPL_STATE_TOMBSTONE,
5071                         .node           = WREPL_NODE_B,
5072                         .is_static      = False,
5073                         .num_ips        = ctx->addresses_best_num,
5074                         .ips            = ctx->addresses_best,
5075                         .apply_expected = True
5076                 },
5077         },
5078         /*
5079          * unique,released vs. unique,tombstone with different ip(s)
5080          */
5081         {
5082                 .line   = __location__,
5083                 .name   = _NBT_NAME("_UR_UT_DI", 0x00, NULL),
5084                 .wins   = {
5085                         .nb_flags       = 0,
5086                         .mhomed         = False,
5087                         .num_ips        = ctx->addresses_best_num,
5088                         .ips            = ctx->addresses_best,
5089                         .apply_expected = True
5090                 },
5091                 .replica= {
5092                         .type           = WREPL_TYPE_UNIQUE,
5093                         .state          = WREPL_STATE_TOMBSTONE,
5094                         .node           = WREPL_NODE_B,
5095                         .is_static      = False,
5096                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5097                         .ips            = addresses_B_1,
5098                         .apply_expected = True
5099                 },
5100         },
5101 /* 
5102  * unique vs. group section
5103  */
5104         /*
5105          * unique,released vs. group,active with same ip(s)
5106          */
5107         {
5108                 .line   = __location__,
5109                 .name   = _NBT_NAME("_UR_GA_SI", 0x00, NULL),
5110                 .wins   = {
5111                         .nb_flags       = 0,
5112                         .mhomed         = False,
5113                         .num_ips        = ctx->addresses_best_num,
5114                         .ips            = ctx->addresses_best,
5115                         .apply_expected = True
5116                 },
5117                 .replica= {
5118                         .type           = WREPL_TYPE_GROUP,
5119                         .state          = WREPL_STATE_ACTIVE,
5120                         .node           = WREPL_NODE_B,
5121                         .is_static      = False,
5122                         .num_ips        = ctx->addresses_best_num,
5123                         .ips            = ctx->addresses_best,
5124                         .apply_expected = True
5125                 },
5126         },
5127         /*
5128          * unique,released vs. group,active with different ip(s)
5129          */
5130         {
5131                 .line   = __location__,
5132                 .name   = _NBT_NAME("_UR_GA_DI", 0x00, NULL),
5133                 .wins   = {
5134                         .nb_flags       = 0,
5135                         .mhomed         = False,
5136                         .num_ips        = ctx->addresses_best_num,
5137                         .ips            = ctx->addresses_best,
5138                         .apply_expected = True
5139                 },
5140                 .replica= {
5141                         .type           = WREPL_TYPE_GROUP,
5142                         .state          = WREPL_STATE_ACTIVE,
5143                         .node           = WREPL_NODE_B,
5144                         .is_static      = False,
5145                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5146                         .ips            = addresses_B_1,
5147                         .apply_expected = True
5148                 },
5149         },
5150         /*
5151          * unique,released vs. group,tombstone with same ip(s)
5152          */
5153         {
5154                 .line   = __location__,
5155                 .name   = _NBT_NAME("_UR_GT_SI", 0x00, NULL),
5156                 .wins   = {
5157                         .nb_flags       = 0,
5158                         .mhomed         = False,
5159                         .num_ips        = ctx->addresses_best_num,
5160                         .ips            = ctx->addresses_best,
5161                         .apply_expected = True
5162                 },
5163                 .replica= {
5164                         .type           = WREPL_TYPE_GROUP,
5165                         .state          = WREPL_STATE_TOMBSTONE,
5166                         .node           = WREPL_NODE_B,
5167                         .is_static      = False,
5168                         .num_ips        = ctx->addresses_best_num,
5169                         .ips            = ctx->addresses_best,
5170                         .apply_expected = True
5171                 },
5172         },
5173         /*
5174          * unique,released vs. group,tombstone with different ip(s)
5175          */
5176         {
5177                 .line   = __location__,
5178                 .name   = _NBT_NAME("_UR_GT_DI", 0x00, NULL),
5179                 .wins   = {
5180                         .nb_flags       = 0,
5181                         .mhomed         = False,
5182                         .num_ips        = ctx->addresses_best_num,
5183                         .ips            = ctx->addresses_best,
5184                         .apply_expected = True
5185                 },
5186                 .replica= {
5187                         .type           = WREPL_TYPE_GROUP,
5188                         .state          = WREPL_STATE_TOMBSTONE,
5189                         .node           = WREPL_NODE_B,
5190                         .is_static      = False,
5191                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5192                         .ips            = addresses_B_1,
5193                         .apply_expected = True
5194                 },
5195         },
5196 /* 
5197  * unique vs. special group section
5198  */
5199         /*
5200          * unique,released vs. sgroup,active with same ip(s)
5201          */
5202         {
5203                 .line   = __location__,
5204                 .name   = _NBT_NAME("_UR_SA_SI", 0x00, NULL),
5205                 .wins   = {
5206                         .nb_flags       = 0,
5207                         .mhomed         = False,
5208                         .num_ips        = ctx->addresses_best_num,
5209                         .ips            = ctx->addresses_best,
5210                         .apply_expected = True
5211                 },
5212                 .replica= {
5213                         .type           = WREPL_TYPE_SGROUP,
5214                         .state          = WREPL_STATE_ACTIVE,
5215                         .node           = WREPL_NODE_B,
5216                         .is_static      = False,
5217                         .num_ips        = ctx->addresses_best_num,
5218                         .ips            = ctx->addresses_best,
5219                         .apply_expected = True
5220                 },
5221         },
5222         /*
5223          * unique,released vs. sgroup,active with different ip(s)
5224          */
5225         {
5226                 .line   = __location__,
5227                 .name   = _NBT_NAME("_UR_SA_DI", 0x00, NULL),
5228                 .wins   = {
5229                         .nb_flags       = 0,
5230                         .mhomed         = False,
5231                         .num_ips        = ctx->addresses_best_num,
5232                         .ips            = ctx->addresses_best,
5233                         .apply_expected = True
5234                 },
5235                 .replica= {
5236                         .type           = WREPL_TYPE_SGROUP,
5237                         .state          = WREPL_STATE_ACTIVE,
5238                         .node           = WREPL_NODE_B,
5239                         .is_static      = False,
5240                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5241                         .ips            = addresses_B_1,
5242                         .apply_expected = True
5243                 },
5244         },
5245         /*
5246          * unique,released vs. sgroup,tombstone with same ip(s)
5247          */
5248         {
5249                 .line   = __location__,
5250                 .name   = _NBT_NAME("_UR_ST_SI", 0x00, NULL),
5251                 .wins   = {
5252                         .nb_flags       = 0,
5253                         .mhomed         = False,
5254                         .num_ips        = ctx->addresses_best_num,
5255                         .ips            = ctx->addresses_best,
5256                         .apply_expected = True
5257                 },
5258                 .replica= {
5259                         .type           = WREPL_TYPE_SGROUP,
5260                         .state          = WREPL_STATE_TOMBSTONE,
5261                         .node           = WREPL_NODE_B,
5262                         .is_static      = False,
5263                         .num_ips        = ctx->addresses_best_num,
5264                         .ips            = ctx->addresses_best,
5265                         .apply_expected = True
5266                 },
5267         },
5268         /*
5269          * unique,released vs. sgroup,tombstone with different ip(s)
5270          */
5271         {
5272                 .line   = __location__,
5273                 .name   = _NBT_NAME("_UR_ST_DI", 0x00, NULL),
5274                 .wins   = {
5275                         .nb_flags       = 0,
5276                         .mhomed         = False,
5277                         .num_ips        = ctx->addresses_best_num,
5278                         .ips            = ctx->addresses_best,
5279                         .apply_expected = True
5280                 },
5281                 .replica= {
5282                         .type           = WREPL_TYPE_SGROUP,
5283                         .state          = WREPL_STATE_TOMBSTONE,
5284                         .node           = WREPL_NODE_B,
5285                         .is_static      = False,
5286                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5287                         .ips            = addresses_B_1,
5288                         .apply_expected = True
5289                 },
5290         },
5291 /* 
5292  * unique vs. multi homed section
5293  */
5294         /*
5295          * unique,released vs. mhomed,active with same ip(s)
5296          */
5297         {
5298                 .line   = __location__,
5299                 .name   = _NBT_NAME("_UR_MA_SI", 0x00, NULL),
5300                 .wins   = {
5301                         .nb_flags       = 0,
5302                         .mhomed         = False,
5303                         .num_ips        = ctx->addresses_best_num,
5304                         .ips            = ctx->addresses_best,
5305                         .apply_expected = True
5306                 },
5307                 .replica= {
5308                         .type           = WREPL_TYPE_MHOMED,
5309                         .state          = WREPL_STATE_ACTIVE,
5310                         .node           = WREPL_NODE_B,
5311                         .is_static      = False,
5312                         .num_ips        = ctx->addresses_best_num,
5313                         .ips            = ctx->addresses_best,
5314                         .apply_expected = True
5315                 },
5316         },
5317         /*
5318          * unique,released vs. mhomed,active with different ip(s)
5319          */
5320         {
5321                 .line   = __location__,
5322                 .name   = _NBT_NAME("_UR_MA_DI", 0x00, NULL),
5323                 .wins   = {
5324                         .nb_flags       = 0,
5325                         .mhomed         = False,
5326                         .num_ips        = ctx->addresses_best_num,
5327                         .ips            = ctx->addresses_best,
5328                         .apply_expected = True
5329                 },
5330                 .replica= {
5331                         .type           = WREPL_TYPE_MHOMED,
5332                         .state          = WREPL_STATE_ACTIVE,
5333                         .node           = WREPL_NODE_B,
5334                         .is_static      = False,
5335                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5336                         .ips            = addresses_B_1,
5337                         .apply_expected = True
5338                 },
5339         },
5340         /*
5341          * unique,released vs. mhomed,tombstone with same ip(s)
5342          */
5343         {
5344                 .line   = __location__,
5345                 .name   = _NBT_NAME("_UR_MT_SI", 0x00, NULL),
5346                 .wins   = {
5347                         .nb_flags       = 0,
5348                         .mhomed         = False,
5349                         .num_ips        = ctx->addresses_best_num,
5350                         .ips            = ctx->addresses_best,
5351                         .apply_expected = True
5352                 },
5353                 .replica= {
5354                         .type           = WREPL_TYPE_MHOMED,
5355                         .state          = WREPL_STATE_TOMBSTONE,
5356                         .node           = WREPL_NODE_B,
5357                         .is_static      = False,
5358                         .num_ips        = ctx->addresses_best_num,
5359                         .ips            = ctx->addresses_best,
5360                         .apply_expected = True
5361                 },
5362         },
5363         /*
5364          * unique,released vs. mhomed,tombstone with different ip(s)
5365          */
5366         {
5367                 .line   = __location__,
5368                 .name   = _NBT_NAME("_UR_MT_DI", 0x00, NULL),
5369                 .wins   = {
5370                         .nb_flags       = 0,
5371                         .mhomed         = False,
5372                         .num_ips        = ctx->addresses_best_num,
5373                         .ips            = ctx->addresses_best,
5374                         .apply_expected = True
5375                 },
5376                 .replica= {
5377                         .type           = WREPL_TYPE_MHOMED,
5378                         .state          = WREPL_STATE_TOMBSTONE,
5379                         .node           = WREPL_NODE_B,
5380                         .is_static      = False,
5381                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5382                         .ips            = addresses_B_1,
5383                         .apply_expected = True
5384                 },
5385         },
5386 /* 
5387  * group vs. unique section
5388  */
5389         /*
5390          * group,released vs. unique,active with same ip(s)
5391          */
5392         {
5393                 .line   = __location__,
5394                 .name   = _NBT_NAME("_GR_UA_SI", 0x00, NULL),
5395                 .wins   = {
5396                         .nb_flags       = NBT_NM_GROUP,
5397                         .mhomed         = False,
5398                         .num_ips        = ctx->addresses_best_num,
5399                         .ips            = ctx->addresses_best,
5400                         .apply_expected = True
5401                 },
5402                 .replica= {
5403                         .type           = WREPL_TYPE_UNIQUE,
5404                         .state          = WREPL_STATE_ACTIVE,
5405                         .node           = WREPL_NODE_B,
5406                         .is_static      = False,
5407                         .num_ips        = ctx->addresses_best_num,
5408                         .ips            = ctx->addresses_best,
5409                         .apply_expected = False
5410                 },
5411         },
5412         /*
5413          * group,released vs. unique,active with different ip(s)
5414          */
5415         {
5416                 .line   = __location__,
5417                 .name   = _NBT_NAME("_GR_UA_DI", 0x00, NULL),
5418                 .wins   = {
5419                         .nb_flags       = NBT_NM_GROUP,
5420                         .mhomed         = False,
5421                         .num_ips        = ctx->addresses_best_num,
5422                         .ips            = ctx->addresses_best,
5423                         .apply_expected = True
5424                 },
5425                 .replica= {
5426                         .type           = WREPL_TYPE_UNIQUE,
5427                         .state          = WREPL_STATE_ACTIVE,
5428                         .node           = WREPL_NODE_B,
5429                         .is_static      = False,
5430                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5431                         .ips            = addresses_B_1,
5432                         .apply_expected = False
5433                 },
5434         },
5435         /*
5436          * group,released vs. unique,tombstone with same ip(s)
5437          */
5438         {
5439                 .line   = __location__,
5440                 .name   = _NBT_NAME("_GR_UT_SI", 0x00, NULL),
5441                 .wins   = {
5442                         .nb_flags       = NBT_NM_GROUP,
5443                         .mhomed         = False,
5444                         .num_ips        = ctx->addresses_best_num,
5445                         .ips            = ctx->addresses_best,
5446                         .apply_expected = True
5447                 },
5448                 .replica= {
5449                         .type           = WREPL_TYPE_UNIQUE,
5450                         .state          = WREPL_STATE_TOMBSTONE,
5451                         .node           = WREPL_NODE_B,
5452                         .is_static      = False,
5453                         .num_ips        = ctx->addresses_best_num,
5454                         .ips            = ctx->addresses_best,
5455                         .apply_expected = False
5456                 },
5457         },
5458         /*
5459          * group,released vs. unique,tombstone with different ip(s)
5460          */
5461         {
5462                 .line   = __location__,
5463                 .name   = _NBT_NAME("_GR_UT_DI", 0x00, NULL),
5464                 .wins   = {
5465                         .nb_flags       = NBT_NM_GROUP,
5466                         .mhomed         = False,
5467                         .num_ips        = ctx->addresses_best_num,
5468                         .ips            = ctx->addresses_best,
5469                         .apply_expected = True
5470                 },
5471                 .replica= {
5472                         .type           = WREPL_TYPE_UNIQUE,
5473                         .state          = WREPL_STATE_TOMBSTONE,
5474                         .node           = WREPL_NODE_B,
5475                         .is_static      = False,
5476                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5477                         .ips            = addresses_B_1,
5478                         .apply_expected = False
5479                 },
5480         },
5481 /* 
5482  * group vs. group section
5483  */
5484         /*
5485          * group,released vs. group,active with same ip(s)
5486          */
5487         {
5488                 .line   = __location__,
5489                 .name   = _NBT_NAME("_GR_GA_SI", 0x00, NULL),
5490                 .wins   = {
5491                         .nb_flags       = NBT_NM_GROUP,
5492                         .mhomed         = False,
5493                         .num_ips        = ctx->addresses_best_num,
5494                         .ips            = ctx->addresses_best,
5495                         .apply_expected = True
5496                 },
5497                 .replica= {
5498                         .type           = WREPL_TYPE_GROUP,
5499                         .state          = WREPL_STATE_ACTIVE,
5500                         .node           = WREPL_NODE_B,
5501                         .is_static      = False,
5502                         .num_ips        = ctx->addresses_best_num,
5503                         .ips            = ctx->addresses_best,
5504                         .apply_expected = True
5505                 },
5506         },
5507         /*
5508          * group,released vs. group,active with different ip(s)
5509          */
5510         {
5511                 .line   = __location__,
5512                 .name   = _NBT_NAME("_GR_GA_DI", 0x00, NULL),
5513                 .wins   = {
5514                         .nb_flags       = NBT_NM_GROUP,
5515                         .mhomed         = False,
5516                         .num_ips        = ctx->addresses_best_num,
5517                         .ips            = ctx->addresses_best,
5518                         .apply_expected = True
5519                 },
5520                 .replica= {
5521                         .type           = WREPL_TYPE_GROUP,
5522                         .state          = WREPL_STATE_ACTIVE,
5523                         .node           = WREPL_NODE_B,
5524                         .is_static      = False,
5525                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5526                         .ips            = addresses_B_1,
5527                         .apply_expected = True
5528                 },
5529         },
5530         /*
5531          * group,released vs. group,tombstone with same ip(s)
5532          */
5533         {
5534                 .line   = __location__,
5535                 .name   = _NBT_NAME("_GR_GT_SI", 0x00, NULL),
5536                 .wins   = {
5537                         .nb_flags       = NBT_NM_GROUP,
5538                         .mhomed         = False,
5539                         .num_ips        = ctx->addresses_best_num,
5540                         .ips            = ctx->addresses_best,
5541                         .apply_expected = True
5542                 },
5543                 .replica= {
5544                         .type           = WREPL_TYPE_GROUP,
5545                         .state          = WREPL_STATE_TOMBSTONE,
5546                         .node           = WREPL_NODE_B,
5547                         .is_static      = False,
5548                         .num_ips        = ctx->addresses_best_num,
5549                         .ips            = ctx->addresses_best,
5550                         .apply_expected = True
5551                 },
5552         },
5553         /*
5554          * group,released vs. group,tombstone with different ip(s)
5555          */
5556         {
5557                 .line   = __location__,
5558                 .name   = _NBT_NAME("_GR_GT_DI", 0x00, NULL),
5559                 .wins   = {
5560                         .nb_flags       = NBT_NM_GROUP,
5561                         .mhomed         = False,
5562                         .num_ips        = ctx->addresses_best_num,
5563                         .ips            = ctx->addresses_best,
5564                         .apply_expected = True
5565                 },
5566                 .replica= {
5567                         .type           = WREPL_TYPE_GROUP,
5568                         .state          = WREPL_STATE_TOMBSTONE,
5569                         .node           = WREPL_NODE_B,
5570                         .is_static      = False,
5571                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5572                         .ips            = addresses_B_1,
5573                         .apply_expected = True
5574                 },
5575         },
5576 /* 
5577  * group vs. special group section
5578  */
5579         /*
5580          * group,released vs. sgroup,active with same ip(s)
5581          */
5582         {
5583                 .line   = __location__,
5584                 .name   = _NBT_NAME("_GR_SA_SI", 0x00, NULL),
5585                 .wins   = {
5586                         .nb_flags       = NBT_NM_GROUP,
5587                         .mhomed         = False,
5588                         .num_ips        = ctx->addresses_best_num,
5589                         .ips            = ctx->addresses_best,
5590                         .apply_expected = True
5591                 },
5592                 .replica= {
5593                         .type           = WREPL_TYPE_SGROUP,
5594                         .state          = WREPL_STATE_ACTIVE,
5595                         .node           = WREPL_NODE_B,
5596                         .is_static      = False,
5597                         .num_ips        = ctx->addresses_best_num,
5598                         .ips            = ctx->addresses_best,
5599                         .apply_expected = False
5600                 },
5601         },
5602         /*
5603          * group,released vs. sgroup,active with different ip(s)
5604          */
5605         {
5606                 .line   = __location__,
5607                 .name   = _NBT_NAME("_GR_SA_DI", 0x00, NULL),
5608                 .wins   = {
5609                         .nb_flags       = NBT_NM_GROUP,
5610                         .mhomed         = False,
5611                         .num_ips        = ctx->addresses_best_num,
5612                         .ips            = ctx->addresses_best,
5613                         .apply_expected = True
5614                 },
5615                 .replica= {
5616                         .type           = WREPL_TYPE_SGROUP,
5617                         .state          = WREPL_STATE_ACTIVE,
5618                         .node           = WREPL_NODE_B,
5619                         .is_static      = False,
5620                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5621                         .ips            = addresses_B_1,
5622                         .apply_expected = False
5623                 },
5624         },
5625         /*
5626          * group,released vs. sgroup,tombstone with same ip(s)
5627          */
5628         {
5629                 .line   = __location__,
5630                 .name   = _NBT_NAME("_GR_ST_SI", 0x00, NULL),
5631                 .wins   = {
5632                         .nb_flags       = NBT_NM_GROUP,
5633                         .mhomed         = False,
5634                         .num_ips        = ctx->addresses_best_num,
5635                         .ips            = ctx->addresses_best,
5636                         .apply_expected = True
5637                 },
5638                 .replica= {
5639                         .type           = WREPL_TYPE_SGROUP,
5640                         .state          = WREPL_STATE_TOMBSTONE,
5641                         .node           = WREPL_NODE_B,
5642                         .is_static      = False,
5643                         .num_ips        = ctx->addresses_best_num,
5644                         .ips            = ctx->addresses_best,
5645                         .apply_expected = False
5646                 },
5647         },
5648         /*
5649          * group,released vs. sgroup,tombstone with different ip(s)
5650          */
5651         {
5652                 .line   = __location__,
5653                 .name   = _NBT_NAME("_GR_ST_DI", 0x00, NULL),
5654                 .wins   = {
5655                         .nb_flags       = NBT_NM_GROUP,
5656                         .mhomed         = False,
5657                         .num_ips        = ctx->addresses_best_num,
5658                         .ips            = ctx->addresses_best,
5659                         .apply_expected = True
5660                 },
5661                 .replica= {
5662                         .type           = WREPL_TYPE_SGROUP,
5663                         .state          = WREPL_STATE_TOMBSTONE,
5664                         .node           = WREPL_NODE_B,
5665                         .is_static      = False,
5666                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5667                         .ips            = addresses_B_1,
5668                         .apply_expected = False
5669                 },
5670         },
5671 /* 
5672  * group vs. multi homed section
5673  */
5674         /*
5675          * group,released vs. mhomed,active with same ip(s)
5676          */
5677         {
5678                 .line   = __location__,
5679                 .name   = _NBT_NAME("_GR_MA_SI", 0x00, NULL),
5680                 .wins   = {
5681                         .nb_flags       = NBT_NM_GROUP,
5682                         .mhomed         = False,
5683                         .num_ips        = ctx->addresses_best_num,
5684                         .ips            = ctx->addresses_best,
5685                         .apply_expected = True
5686                 },
5687                 .replica= {
5688                         .type           = WREPL_TYPE_MHOMED,
5689                         .state          = WREPL_STATE_ACTIVE,
5690                         .node           = WREPL_NODE_B,
5691                         .is_static      = False,
5692                         .num_ips        = ctx->addresses_best_num,
5693                         .ips            = ctx->addresses_best,
5694                         .apply_expected = False
5695                 },
5696         },
5697         /*
5698          * group,released vs. mhomed,active with different ip(s)
5699          */
5700         {
5701                 .line   = __location__,
5702                 .name   = _NBT_NAME("_GR_MA_DI", 0x00, NULL),
5703                 .wins   = {
5704                         .nb_flags       = NBT_NM_GROUP,
5705                         .mhomed         = False,
5706                         .num_ips        = ctx->addresses_best_num,
5707                         .ips            = ctx->addresses_best,
5708                         .apply_expected = True
5709                 },
5710                 .replica= {
5711                         .type           = WREPL_TYPE_MHOMED,
5712                         .state          = WREPL_STATE_ACTIVE,
5713                         .node           = WREPL_NODE_B,
5714                         .is_static      = False,
5715                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5716                         .ips            = addresses_B_1,
5717                         .apply_expected = False
5718                 },
5719         },
5720         /*
5721          * group,released vs. mhomed,tombstone with same ip(s)
5722          */
5723         {
5724                 .line   = __location__,
5725                 .name   = _NBT_NAME("_GR_MT_SI", 0x00, NULL),
5726                 .wins   = {
5727                         .nb_flags       = NBT_NM_GROUP,
5728                         .mhomed         = False,
5729                         .num_ips        = ctx->addresses_best_num,
5730                         .ips            = ctx->addresses_best,
5731                         .apply_expected = True
5732                 },
5733                 .replica= {
5734                         .type           = WREPL_TYPE_MHOMED,
5735                         .state          = WREPL_STATE_TOMBSTONE,
5736                         .node           = WREPL_NODE_B,
5737                         .is_static      = False,
5738                         .num_ips        = ctx->addresses_best_num,
5739                         .ips            = ctx->addresses_best,
5740                         .apply_expected = False
5741                 },
5742         },
5743         /*
5744          * group,released vs. mhomed,tombstone with different ip(s)
5745          */
5746         {
5747                 .line   = __location__,
5748                 .name   = _NBT_NAME("_GR_MT_DI", 0x00, NULL),
5749                 .wins   = {
5750                         .nb_flags       = NBT_NM_GROUP,
5751                         .mhomed         = False,
5752                         .num_ips        = ctx->addresses_best_num,
5753                         .ips            = ctx->addresses_best,
5754                         .apply_expected = True
5755                 },
5756                 .replica= {
5757                         .type           = WREPL_TYPE_MHOMED,
5758                         .state          = WREPL_STATE_TOMBSTONE,
5759                         .node           = WREPL_NODE_B,
5760                         .is_static      = False,
5761                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5762                         .ips            = addresses_B_1,
5763                         .apply_expected = False
5764                 },
5765         },
5766 /* 
5767  * special group vs. unique section
5768  */
5769         /*
5770          * sgroup,released vs. unique,active with same ip(s)
5771          */
5772         {
5773                 .line   = __location__,
5774                 .name   = _NBT_NAME("_SR_UA_SI", 0x1C, NULL),
5775                 .wins   = {
5776                         .nb_flags       = NBT_NM_GROUP,
5777                         .mhomed         = False,
5778                         .num_ips        = ctx->addresses_best_num,
5779                         .ips            = ctx->addresses_best,
5780                         .apply_expected = True
5781                 },
5782                 .replica= {
5783                         .type           = WREPL_TYPE_UNIQUE,
5784                         .state          = WREPL_STATE_ACTIVE,
5785                         .node           = WREPL_NODE_B,
5786                         .is_static      = False,
5787                         .num_ips        = ctx->addresses_best_num,
5788                         .ips            = ctx->addresses_best,
5789                         .apply_expected = True
5790                 },
5791         },
5792         /*
5793          * sgroup,released vs. unique,active with different ip(s)
5794          */
5795         {
5796                 .line   = __location__,
5797                 .name   = _NBT_NAME("_SR_UA_DI", 0x1C, NULL),
5798                 .wins   = {
5799                         .nb_flags       = NBT_NM_GROUP,
5800                         .mhomed         = False,
5801                         .num_ips        = ctx->addresses_best_num,
5802                         .ips            = ctx->addresses_best,
5803                         .apply_expected = True
5804                 },
5805                 .replica= {
5806                         .type           = WREPL_TYPE_UNIQUE,
5807                         .state          = WREPL_STATE_ACTIVE,
5808                         .node           = WREPL_NODE_B,
5809                         .is_static      = False,
5810                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5811                         .ips            = addresses_B_1,
5812                         .apply_expected = True
5813                 },
5814         },
5815         /*
5816          * sgroup,released vs. unique,tombstone with same ip(s)
5817          */
5818         {
5819                 .line   = __location__,
5820                 .name   = _NBT_NAME("_SR_UT_SI", 0x1C, NULL),
5821                 .wins   = {
5822                         .nb_flags       = NBT_NM_GROUP,
5823                         .mhomed         = False,
5824                         .num_ips        = ctx->addresses_best_num,
5825                         .ips            = ctx->addresses_best,
5826                         .apply_expected = True
5827                 },
5828                 .replica= {
5829                         .type           = WREPL_TYPE_UNIQUE,
5830                         .state          = WREPL_STATE_TOMBSTONE,
5831                         .node           = WREPL_NODE_B,
5832                         .is_static      = False,
5833                         .num_ips        = ctx->addresses_best_num,
5834                         .ips            = ctx->addresses_best,
5835                         .apply_expected = True
5836                 },
5837         },
5838         /*
5839          * sgroup,released vs. unique,tombstone with different ip(s)
5840          */
5841         {
5842                 .line   = __location__,
5843                 .name   = _NBT_NAME("_SR_UT_DI", 0x1C, NULL),
5844                 .wins   = {
5845                         .nb_flags       = NBT_NM_GROUP,
5846                         .mhomed         = False,
5847                         .num_ips        = ctx->addresses_best_num,
5848                         .ips            = ctx->addresses_best,
5849                         .apply_expected = True
5850                 },
5851                 .replica= {
5852                         .type           = WREPL_TYPE_UNIQUE,
5853                         .state          = WREPL_STATE_TOMBSTONE,
5854                         .node           = WREPL_NODE_B,
5855                         .is_static      = False,
5856                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5857                         .ips            = addresses_B_1,
5858                         .apply_expected = True
5859                 },
5860         },
5861 /* 
5862  * special group vs. group section
5863  */
5864         /*
5865          * sgroup,released vs. group,active with same ip(s)
5866          */
5867         {
5868                 .line   = __location__,
5869                 .name   = _NBT_NAME("_SR_GA_SI", 0x1C, NULL),
5870                 .wins   = {
5871                         .nb_flags       = NBT_NM_GROUP,
5872                         .mhomed         = False,
5873                         .num_ips        = ctx->addresses_best_num,
5874                         .ips            = ctx->addresses_best,
5875                         .apply_expected = True
5876                 },
5877                 .replica= {
5878                         .type           = WREPL_TYPE_GROUP,
5879                         .state          = WREPL_STATE_ACTIVE,
5880                         .node           = WREPL_NODE_B,
5881                         .is_static      = False,
5882                         .num_ips        = ctx->addresses_best_num,
5883                         .ips            = ctx->addresses_best,
5884                         .apply_expected = True
5885                 },
5886         },
5887         /*
5888          * sgroup,released vs. group,active with different ip(s)
5889          */
5890         {
5891                 .line   = __location__,
5892                 .name   = _NBT_NAME("_SR_GA_DI", 0x1C, NULL),
5893                 .wins   = {
5894                         .nb_flags       = NBT_NM_GROUP,
5895                         .mhomed         = False,
5896                         .num_ips        = ctx->addresses_best_num,
5897                         .ips            = ctx->addresses_best,
5898                         .apply_expected = True
5899                 },
5900                 .replica= {
5901                         .type           = WREPL_TYPE_GROUP,
5902                         .state          = WREPL_STATE_ACTIVE,
5903                         .node           = WREPL_NODE_B,
5904                         .is_static      = False,
5905                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5906                         .ips            = addresses_B_1,
5907                         .apply_expected = True
5908                 },
5909         },
5910         /*
5911          * sgroup,released vs. group,tombstone with same ip(s)
5912          */
5913         {
5914                 .line   = __location__,
5915                 .name   = _NBT_NAME("_SR_GT_SI", 0x1C, NULL),
5916                 .wins   = {
5917                         .nb_flags       = NBT_NM_GROUP,
5918                         .mhomed         = False,
5919                         .num_ips        = ctx->addresses_best_num,
5920                         .ips            = ctx->addresses_best,
5921                         .apply_expected = True
5922                 },
5923                 .replica= {
5924                         .type           = WREPL_TYPE_GROUP,
5925                         .state          = WREPL_STATE_TOMBSTONE,
5926                         .node           = WREPL_NODE_B,
5927                         .is_static      = False,
5928                         .num_ips        = ctx->addresses_best_num,
5929                         .ips            = ctx->addresses_best,
5930                         .apply_expected = True
5931                 },
5932         },
5933         /*
5934          * sgroup,released vs. group,tombstone with different ip(s)
5935          */
5936         {
5937                 .line   = __location__,
5938                 .name   = _NBT_NAME("_SR_GT_DI", 0x1C, NULL),
5939                 .wins   = {
5940                         .nb_flags       = NBT_NM_GROUP,
5941                         .mhomed         = False,
5942                         .num_ips        = ctx->addresses_best_num,
5943                         .ips            = ctx->addresses_best,
5944                         .apply_expected = True
5945                 },
5946                 .replica= {
5947                         .type           = WREPL_TYPE_GROUP,
5948                         .state          = WREPL_STATE_TOMBSTONE,
5949                         .node           = WREPL_NODE_B,
5950                         .is_static      = False,
5951                         .num_ips        = ARRAY_SIZE(addresses_B_1),
5952                         .ips            = addresses_B_1,
5953                         .apply_expected = True
5954                 },
5955         },
5956 /* 
5957  * special group vs. special group section
5958  */
5959         /*
5960          * sgroup,released vs. sgroup,active with same ip(s)
5961          */
5962         {
5963                 .line   = __location__,
5964                 .name   = _NBT_NAME("_SR_SA_SI", 0x1C, NULL),
5965                 .wins   = {
5966                         .nb_flags       = NBT_NM_GROUP,
5967                         .mhomed         = False,
5968                         .num_ips        = ctx->addresses_best_num,
5969                         .ips            = ctx->addresses_best,
5970                         .apply_expected = True
5971                 },
5972                 .replica= {
5973                         .type           = WREPL_TYPE_SGROUP,
5974                         .state          = WREPL_STATE_ACTIVE,
5975                         .node           = WREPL_NODE_B,
5976                         .is_static      = False,
5977                         .num_ips        = ctx->addresses_best_num,
5978                         .ips            = ctx->addresses_best,
5979                         .apply_expected = True
5980                 },
5981         },
5982         /*
5983          * sgroup,released vs. sgroup,active with different ip(s)
5984          */
5985         {
5986                 .line   = __location__,
5987                 .name   = _NBT_NAME("_SR_SA_DI", 0x1C, NULL),
5988                 .wins   = {
5989                         .nb_flags       = NBT_NM_GROUP,
5990                         .mhomed         = False,
5991                         .num_ips        = ctx->addresses_best_num,
5992                         .ips            = ctx->addresses_best,
5993                         .apply_expected = True
5994                 },
5995                 .replica= {
5996                         .type           = WREPL_TYPE_SGROUP,
5997                         .state          = WREPL_STATE_ACTIVE,
5998                         .node           = WREPL_NODE_B,
5999                         .is_static      = False,
6000                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6001                         .ips            = addresses_B_1,
6002                         .apply_expected = True
6003                 },
6004         },
6005         /*
6006          * sgroup,released vs. sgroup,tombstone with same ip(s)
6007          */
6008         {
6009                 .line   = __location__,
6010                 .name   = _NBT_NAME("_SR_ST_SI", 0x1C, NULL),
6011                 .wins   = {
6012                         .nb_flags       = NBT_NM_GROUP,
6013                         .mhomed         = False,
6014                         .num_ips        = ctx->addresses_best_num,
6015                         .ips            = ctx->addresses_best,
6016                         .apply_expected = True
6017                 },
6018                 .replica= {
6019                         .type           = WREPL_TYPE_SGROUP,
6020                         .state          = WREPL_STATE_TOMBSTONE,
6021                         .node           = WREPL_NODE_B,
6022                         .is_static      = False,
6023                         .num_ips        = ctx->addresses_best_num,
6024                         .ips            = ctx->addresses_best,
6025                         .apply_expected = True
6026                 },
6027         },
6028         /*
6029          * sgroup,released vs. sgroup,tombstone with different ip(s)
6030          */
6031         {
6032                 .line   = __location__,
6033                 .name   = _NBT_NAME("_SR_ST_DI", 0x1C, NULL),
6034                 .wins   = {
6035                         .nb_flags       = NBT_NM_GROUP,
6036                         .mhomed         = False,
6037                         .num_ips        = ctx->addresses_best_num,
6038                         .ips            = ctx->addresses_best,
6039                         .apply_expected = True
6040                 },
6041                 .replica= {
6042                         .type           = WREPL_TYPE_SGROUP,
6043                         .state          = WREPL_STATE_TOMBSTONE,
6044                         .node           = WREPL_NODE_B,
6045                         .is_static      = False,
6046                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6047                         .ips            = addresses_B_1,
6048                         .apply_expected = True
6049                 },
6050         },
6051 /* 
6052  * special group vs. multi homed section
6053  */
6054         /*
6055          * sgroup,released vs. mhomed,active with same ip(s)
6056          */
6057         {
6058                 .line   = __location__,
6059                 .name   = _NBT_NAME("_SR_MA_SI", 0x1C, NULL),
6060                 .wins   = {
6061                         .nb_flags       = NBT_NM_GROUP,
6062                         .mhomed         = False,
6063                         .num_ips        = ctx->addresses_best_num,
6064                         .ips            = ctx->addresses_best,
6065                         .apply_expected = True
6066                 },
6067                 .replica= {
6068                         .type           = WREPL_TYPE_MHOMED,
6069                         .state          = WREPL_STATE_ACTIVE,
6070                         .node           = WREPL_NODE_B,
6071                         .is_static      = False,
6072                         .num_ips        = ctx->addresses_best_num,
6073                         .ips            = ctx->addresses_best,
6074                         .apply_expected = True
6075                 },
6076         },
6077         /*
6078          * sgroup,released vs. mhomed,active with different ip(s)
6079          */
6080         {
6081                 .line   = __location__,
6082                 .name   = _NBT_NAME("_SR_MA_DI", 0x1C, NULL),
6083                 .wins   = {
6084                         .nb_flags       = NBT_NM_GROUP,
6085                         .mhomed         = False,
6086                         .num_ips        = ctx->addresses_best_num,
6087                         .ips            = ctx->addresses_best,
6088                         .apply_expected = True
6089                 },
6090                 .replica= {
6091                         .type           = WREPL_TYPE_MHOMED,
6092                         .state          = WREPL_STATE_ACTIVE,
6093                         .node           = WREPL_NODE_B,
6094                         .is_static      = False,
6095                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6096                         .ips            = addresses_B_1,
6097                         .apply_expected = True
6098                 },
6099         },
6100         /*
6101          * sgroup,released vs. mhomed,tombstone with same ip(s)
6102          */
6103         {
6104                 .line   = __location__,
6105                 .name   = _NBT_NAME("_SR_MT_SI", 0x1C, NULL),
6106                 .wins   = {
6107                         .nb_flags       = NBT_NM_GROUP,
6108                         .mhomed         = False,
6109                         .num_ips        = ctx->addresses_best_num,
6110                         .ips            = ctx->addresses_best,
6111                         .apply_expected = True
6112                 },
6113                 .replica= {
6114                         .type           = WREPL_TYPE_MHOMED,
6115                         .state          = WREPL_STATE_TOMBSTONE,
6116                         .node           = WREPL_NODE_B,
6117                         .is_static      = False,
6118                         .num_ips        = ctx->addresses_best_num,
6119                         .ips            = ctx->addresses_best,
6120                         .apply_expected = True
6121                 },
6122         },
6123         /*
6124          * sgroup,released vs. mhomed,tombstone with different ip(s)
6125          */
6126         {
6127                 .line   = __location__,
6128                 .name   = _NBT_NAME("_SR_MT_DI", 0x1C, NULL),
6129                 .wins   = {
6130                         .nb_flags       = NBT_NM_GROUP,
6131                         .mhomed         = False,
6132                         .num_ips        = ctx->addresses_best_num,
6133                         .ips            = ctx->addresses_best,
6134                         .apply_expected = True
6135                 },
6136                 .replica= {
6137                         .type           = WREPL_TYPE_MHOMED,
6138                         .state          = WREPL_STATE_TOMBSTONE,
6139                         .node           = WREPL_NODE_B,
6140                         .is_static      = False,
6141                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6142                         .ips            = addresses_B_1,
6143                         .apply_expected = True
6144                 },
6145         },
6146 /* 
6147  * multi homed vs. unique section
6148  */
6149         /*
6150          * mhomed,released vs. unique,active with same ip(s)
6151          */
6152         {
6153                 .line   = __location__,
6154                 .name   = _NBT_NAME("_MR_UA_SI", 0x00, NULL),
6155                 .wins   = {
6156                         .nb_flags       = 0,
6157                         .mhomed         = True,
6158                         .num_ips        = ctx->addresses_best_num,
6159                         .ips            = ctx->addresses_best,
6160                         .apply_expected = True
6161                 },
6162                 .replica= {
6163                         .type           = WREPL_TYPE_UNIQUE,
6164                         .state          = WREPL_STATE_ACTIVE,
6165                         .node           = WREPL_NODE_B,
6166                         .is_static      = False,
6167                         .num_ips        = ctx->addresses_best_num,
6168                         .ips            = ctx->addresses_best,
6169                         .apply_expected = True
6170                 },
6171         },
6172         /*
6173          * mhomed,released vs. unique,active with different ip(s)
6174          */
6175         {
6176                 .line   = __location__,
6177                 .name   = _NBT_NAME("_MR_UA_DI", 0x00, NULL),
6178                 .wins   = {
6179                         .nb_flags       = 0,
6180                         .mhomed         = True,
6181                         .num_ips        = ctx->addresses_best_num,
6182                         .ips            = ctx->addresses_best,
6183                         .apply_expected = True
6184                 },
6185                 .replica= {
6186                         .type           = WREPL_TYPE_UNIQUE,
6187                         .state          = WREPL_STATE_ACTIVE,
6188                         .node           = WREPL_NODE_B,
6189                         .is_static      = False,
6190                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6191                         .ips            = addresses_B_1,
6192                         .apply_expected = True
6193                 },
6194         },
6195         /*
6196          * mhomed,released vs. unique,tombstone with same ip(s)
6197          */
6198         {
6199                 .line   = __location__,
6200                 .name   = _NBT_NAME("_MR_UT_SI", 0x00, NULL),
6201                 .wins   = {
6202                         .nb_flags       = 0,
6203                         .mhomed         = True,
6204                         .num_ips        = ctx->addresses_best_num,
6205                         .ips            = ctx->addresses_best,
6206                         .apply_expected = True
6207                 },
6208                 .replica= {
6209                         .type           = WREPL_TYPE_UNIQUE,
6210                         .state          = WREPL_STATE_TOMBSTONE,
6211                         .node           = WREPL_NODE_B,
6212                         .is_static      = False,
6213                         .num_ips        = ctx->addresses_best_num,
6214                         .ips            = ctx->addresses_best,
6215                         .apply_expected = True
6216                 },
6217         },
6218         /*
6219          * mhomed,released vs. unique,tombstone with different ip(s)
6220          */
6221         {
6222                 .line   = __location__,
6223                 .name   = _NBT_NAME("_MR_UT_DI", 0x00, NULL),
6224                 .wins   = {
6225                         .nb_flags       = 0,
6226                         .mhomed         = True,
6227                         .num_ips        = ctx->addresses_best_num,
6228                         .ips            = ctx->addresses_best,
6229                         .apply_expected = True
6230                 },
6231                 .replica= {
6232                         .type           = WREPL_TYPE_UNIQUE,
6233                         .state          = WREPL_STATE_TOMBSTONE,
6234                         .node           = WREPL_NODE_B,
6235                         .is_static      = False,
6236                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6237                         .ips            = addresses_B_1,
6238                         .apply_expected = True
6239                 },
6240         },
6241 /* 
6242  * multi homed vs. group section
6243  */
6244         /*
6245          * mhomed,released vs. group,active with same ip(s)
6246          */
6247         {
6248                 .line   = __location__,
6249                 .name   = _NBT_NAME("_MR_GA_SI", 0x00, NULL),
6250                 .wins   = {
6251                         .nb_flags       = 0,
6252                         .mhomed         = True,
6253                         .num_ips        = ctx->addresses_best_num,
6254                         .ips            = ctx->addresses_best,
6255                         .apply_expected = True
6256                 },
6257                 .replica= {
6258                         .type           = WREPL_TYPE_GROUP,
6259                         .state          = WREPL_STATE_ACTIVE,
6260                         .node           = WREPL_NODE_B,
6261                         .is_static      = False,
6262                         .num_ips        = ctx->addresses_best_num,
6263                         .ips            = ctx->addresses_best,
6264                         .apply_expected = True
6265                 },
6266         },
6267         /*
6268          * mhomed,released vs. group,active with different ip(s)
6269          */
6270         {
6271                 .line   = __location__,
6272                 .name   = _NBT_NAME("_MR_GA_DI", 0x00, NULL),
6273                 .wins   = {
6274                         .nb_flags       = 0,
6275                         .mhomed         = True,
6276                         .num_ips        = ctx->addresses_best_num,
6277                         .ips            = ctx->addresses_best,
6278                         .apply_expected = True
6279                 },
6280                 .replica= {
6281                         .type           = WREPL_TYPE_GROUP,
6282                         .state          = WREPL_STATE_ACTIVE,
6283                         .node           = WREPL_NODE_B,
6284                         .is_static      = False,
6285                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6286                         .ips            = addresses_B_1,
6287                         .apply_expected = True
6288                 },
6289         },
6290         /*
6291          * mhomed,released vs. group,tombstone with same ip(s)
6292          */
6293         {
6294                 .line   = __location__,
6295                 .name   = _NBT_NAME("_MR_GT_SI", 0x00, NULL),
6296                 .wins   = {
6297                         .nb_flags       = 0,
6298                         .mhomed         = True,
6299                         .num_ips        = ctx->addresses_best_num,
6300                         .ips            = ctx->addresses_best,
6301                         .apply_expected = True
6302                 },
6303                 .replica= {
6304                         .type           = WREPL_TYPE_GROUP,
6305                         .state          = WREPL_STATE_TOMBSTONE,
6306                         .node           = WREPL_NODE_B,
6307                         .is_static      = False,
6308                         .num_ips        = ctx->addresses_best_num,
6309                         .ips            = ctx->addresses_best,
6310                         .apply_expected = True
6311                 },
6312         },
6313         /*
6314          * mhomed,released vs. group,tombstone with different ip(s)
6315          */
6316         {
6317                 .line   = __location__,
6318                 .name   = _NBT_NAME("_MR_GT_DI", 0x00, NULL),
6319                 .wins   = {
6320                         .nb_flags       = 0,
6321                         .mhomed         = True,
6322                         .num_ips        = ctx->addresses_best_num,
6323                         .ips            = ctx->addresses_best,
6324                         .apply_expected = True
6325                 },
6326                 .replica= {
6327                         .type           = WREPL_TYPE_GROUP,
6328                         .state          = WREPL_STATE_TOMBSTONE,
6329                         .node           = WREPL_NODE_B,
6330                         .is_static      = False,
6331                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6332                         .ips            = addresses_B_1,
6333                         .apply_expected = True
6334                 },
6335         },
6336 /* 
6337  * multi homed vs. special group section
6338  */
6339         /*
6340          * mhomed,released vs. sgroup,active with same ip(s)
6341          */
6342         {
6343                 .line   = __location__,
6344                 .name   = _NBT_NAME("_MR_SA_SI", 0x00, NULL),
6345                 .wins   = {
6346                         .nb_flags       = 0,
6347                         .mhomed         = True,
6348                         .num_ips        = ctx->addresses_best_num,
6349                         .ips            = ctx->addresses_best,
6350                         .apply_expected = True
6351                 },
6352                 .replica= {
6353                         .type           = WREPL_TYPE_SGROUP,
6354                         .state          = WREPL_STATE_ACTIVE,
6355                         .node           = WREPL_NODE_B,
6356                         .is_static      = False,
6357                         .num_ips        = ctx->addresses_best_num,
6358                         .ips            = ctx->addresses_best,
6359                         .apply_expected = True
6360                 },
6361         },
6362         /*
6363          * mhomed,released vs. sgroup,active with different ip(s)
6364          */
6365         {
6366                 .line   = __location__,
6367                 .name   = _NBT_NAME("_MR_SA_DI", 0x00, NULL),
6368                 .wins   = {
6369                         .nb_flags       = 0,
6370                         .mhomed         = True,
6371                         .num_ips        = ctx->addresses_best_num,
6372                         .ips            = ctx->addresses_best,
6373                         .apply_expected = True
6374                 },
6375                 .replica= {
6376                         .type           = WREPL_TYPE_SGROUP,
6377                         .state          = WREPL_STATE_ACTIVE,
6378                         .node           = WREPL_NODE_B,
6379                         .is_static      = False,
6380                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6381                         .ips            = addresses_B_1,
6382                         .apply_expected = True
6383                 },
6384         },
6385         /*
6386          * mhomed,released vs. sgroup,tombstone with same ip(s)
6387          */
6388         {
6389                 .line   = __location__,
6390                 .name   = _NBT_NAME("_MR_ST_SI", 0x00, NULL),
6391                 .wins   = {
6392                         .nb_flags       = 0,
6393                         .mhomed         = True,
6394                         .num_ips        = ctx->addresses_best_num,
6395                         .ips            = ctx->addresses_best,
6396                         .apply_expected = True
6397                 },
6398                 .replica= {
6399                         .type           = WREPL_TYPE_SGROUP,
6400                         .state          = WREPL_STATE_TOMBSTONE,
6401                         .node           = WREPL_NODE_B,
6402                         .is_static      = False,
6403                         .num_ips        = ctx->addresses_best_num,
6404                         .ips            = ctx->addresses_best,
6405                         .apply_expected = True
6406                 },
6407         },
6408         /*
6409          * mhomed,released vs. sgroup,tombstone with different ip(s)
6410          */
6411         {
6412                 .line   = __location__,
6413                 .name   = _NBT_NAME("_MR_ST_DI", 0x00, NULL),
6414                 .wins   = {
6415                         .nb_flags       = 0,
6416                         .mhomed         = True,
6417                         .num_ips        = ctx->addresses_best_num,
6418                         .ips            = ctx->addresses_best,
6419                         .apply_expected = True
6420                 },
6421                 .replica= {
6422                         .type           = WREPL_TYPE_SGROUP,
6423                         .state          = WREPL_STATE_TOMBSTONE,
6424                         .node           = WREPL_NODE_B,
6425                         .is_static      = False,
6426                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6427                         .ips            = addresses_B_1,
6428                         .apply_expected = True
6429                 },
6430         },
6431 /* 
6432  * multi homed vs. multi homed section
6433  */
6434         /*
6435          * mhomed,released vs. mhomed,active with same ip(s)
6436          */
6437         {
6438                 .line   = __location__,
6439                 .name   = _NBT_NAME("_MR_MA_SI", 0x00, NULL),
6440                 .wins   = {
6441                         .nb_flags       = 0,
6442                         .mhomed         = True,
6443                         .num_ips        = ctx->addresses_best_num,
6444                         .ips            = ctx->addresses_best,
6445                         .apply_expected = True
6446                 },
6447                 .replica= {
6448                         .type           = WREPL_TYPE_MHOMED,
6449                         .state          = WREPL_STATE_ACTIVE,
6450                         .node           = WREPL_NODE_B,
6451                         .is_static      = False,
6452                         .num_ips        = ctx->addresses_best_num,
6453                         .ips            = ctx->addresses_best,
6454                         .apply_expected = True
6455                 },
6456         },
6457         /*
6458          * mhomed,released vs. mhomed,active with different ip(s)
6459          */
6460         {
6461                 .line   = __location__,
6462                 .name   = _NBT_NAME("_MR_MA_DI", 0x00, NULL),
6463                 .wins   = {
6464                         .nb_flags       = 0,
6465                         .mhomed         = True,
6466                         .num_ips        = ctx->addresses_best_num,
6467                         .ips            = ctx->addresses_best,
6468                         .apply_expected = True
6469                 },
6470                 .replica= {
6471                         .type           = WREPL_TYPE_MHOMED,
6472                         .state          = WREPL_STATE_ACTIVE,
6473                         .node           = WREPL_NODE_B,
6474                         .is_static      = False,
6475                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6476                         .ips            = addresses_B_1,
6477                         .apply_expected = True
6478                 },
6479         },
6480         /*
6481          * mhomed,released vs. mhomed,tombstone with same ip(s)
6482          */
6483         {
6484                 .line   = __location__,
6485                 .name   = _NBT_NAME("_MR_MT_SI", 0x00, NULL),
6486                 .wins   = {
6487                         .nb_flags       = 0,
6488                         .mhomed         = True,
6489                         .num_ips        = ctx->addresses_best_num,
6490                         .ips            = ctx->addresses_best,
6491                         .apply_expected = True
6492                 },
6493                 .replica= {
6494                         .type           = WREPL_TYPE_MHOMED,
6495                         .state          = WREPL_STATE_TOMBSTONE,
6496                         .node           = WREPL_NODE_B,
6497                         .is_static      = False,
6498                         .num_ips        = ctx->addresses_best_num,
6499                         .ips            = ctx->addresses_best,
6500                         .apply_expected = True
6501                 },
6502         },
6503         /*
6504          * mhomed,released vs. mhomed,tombstone with different ip(s)
6505          */
6506         {
6507                 .line   = __location__,
6508                 .name   = _NBT_NAME("_MR_MT_DI", 0x00, NULL),
6509                 .wins   = {
6510                         .nb_flags       = 0,
6511                         .mhomed         = True,
6512                         .num_ips        = ctx->addresses_best_num,
6513                         .ips            = ctx->addresses_best,
6514                         .apply_expected = True
6515                 },
6516                 .replica= {
6517                         .type           = WREPL_TYPE_MHOMED,
6518                         .state          = WREPL_STATE_TOMBSTONE,
6519                         .node           = WREPL_NODE_B,
6520                         .is_static      = False,
6521                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6522                         .ips            = addresses_B_1,
6523                         .apply_expected = True
6524                 },
6525         },
6526         };
6527
6528         printf("Test Replica records vs. owned released records\n");
6529
6530         for(i=0; ret && i < ARRAY_SIZE(records); i++) {
6531                 printf("%s => %s\n", nbt_name_string(ctx, &records[i].name),
6532                         (records[i].replica.apply_expected?"REPLACE":"NOT REPLACE"));
6533
6534                 /*
6535                  * Setup Register
6536                  */
6537                 name_register->in.name          = records[i].name;
6538                 name_register->in.dest_addr     = ctx->address;
6539                 name_register->in.address       = records[i].wins.ips[0].ip;
6540                 name_register->in.nb_flags      = records[i].wins.nb_flags;
6541                 name_register->in.register_demand= False;
6542                 name_register->in.broadcast     = False;
6543                 name_register->in.multi_homed   = records[i].wins.mhomed;
6544                 name_register->in.ttl           = 300000;
6545                 name_register->in.timeout       = 70;
6546                 name_register->in.retries       = 0;
6547
6548                 status = nbt_name_register(ctx->nbtsock, ctx, name_register);
6549                 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
6550                         printf("No response from %s for name register\n", ctx->address);
6551                         ret = False;
6552                 }
6553                 if (!NT_STATUS_IS_OK(status)) {
6554                         printf("Bad response from %s for name register - %s\n",
6555                                ctx->address, nt_errstr(status));
6556                         ret = False;
6557                 }
6558                 CHECK_VALUE(name_register->out.rcode, 0);
6559                 CHECK_VALUE_STRING(name_register->out.reply_from, ctx->address);
6560                 CHECK_VALUE(name_register->out.name.type, records[i].name.type);
6561                 CHECK_VALUE_STRING(name_register->out.name.name, records[i].name.name);
6562                 CHECK_VALUE_STRING(name_register->out.name.scope, records[i].name.scope);
6563                 CHECK_VALUE_STRING(name_register->out.reply_addr, records[i].wins.ips[0].ip);
6564
6565                 /* release the record */
6566                 release->in.name        = records[i].name;
6567                 release->in.dest_addr   = ctx->address;
6568                 release->in.address     = records[i].wins.ips[0].ip;
6569                 release->in.nb_flags    = records[i].wins.nb_flags;
6570                 release->in.broadcast   = False;
6571                 release->in.timeout     = 30;
6572                 release->in.retries     = 0;
6573
6574                 status = nbt_name_release(ctx->nbtsock, ctx, release);
6575                 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
6576                         printf("No response from %s for name release\n", ctx->address);
6577                         return False;
6578                 }
6579                 if (!NT_STATUS_IS_OK(status)) {
6580                         printf("Bad response from %s for name query - %s\n",
6581                                ctx->address, nt_errstr(status));
6582                         return False;
6583                 }
6584                 CHECK_VALUE(release->out.rcode, 0);
6585
6586                 /*
6587                  * Setup Replica
6588                  */
6589                 wins_name->name         = &records[i].name;
6590                 wins_name->flags        = WREPL_NAME_FLAGS(records[i].replica.type,
6591                                                            records[i].replica.state,
6592                                                            records[i].replica.node,
6593                                                            records[i].replica.is_static);
6594                 wins_name->id           = ++ctx->b.max_version;
6595                 if (wins_name->flags & 2) {
6596                         wins_name->addresses.addresses.num_ips = records[i].replica.num_ips;
6597                         wins_name->addresses.addresses.ips     = discard_const(records[i].replica.ips);
6598                 } else {
6599                         wins_name->addresses.ip = records[i].replica.ips[0].ip;
6600                 }
6601                 wins_name->unknown      = "255.255.255.255";
6602
6603                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
6604                 ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name,
6605                                              records[i].replica.apply_expected);
6606
6607                 if (records[i].replica.apply_expected) {
6608                         wins_name->name         = &records[i].name;
6609                         wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_UNIQUE,
6610                                                                    WREPL_STATE_TOMBSTONE,
6611                                                                    WREPL_NODE_B, False);
6612                         wins_name->id           = ++ctx->b.max_version;
6613                         wins_name->addresses.ip = addresses_B_1[0].ip;
6614                         wins_name->unknown      = "255.255.255.255";
6615
6616                         ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
6617                         ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True);
6618                 } else {
6619                         release->in.name        = records[i].name;
6620                         release->in.dest_addr   = ctx->address;
6621                         release->in.address     = records[i].wins.ips[0].ip;
6622                         release->in.nb_flags    = records[i].wins.nb_flags;
6623                         release->in.broadcast   = False;
6624                         release->in.timeout     = 30;
6625                         release->in.retries     = 0;
6626
6627                         status = nbt_name_release(ctx->nbtsock, ctx, release);
6628                         if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
6629                                 printf("No response from %s for name release\n", ctx->address);
6630                                 return False;
6631                         }
6632                         if (!NT_STATUS_IS_OK(status)) {
6633                                 printf("Bad response from %s for name query - %s\n",
6634                                        ctx->address, nt_errstr(status));
6635                                 return False;
6636                         }
6637                         CHECK_VALUE(release->out.rcode, 0);
6638                 }
6639 done:
6640                 if (!ret) {
6641                         printf("conflict handled wrong or record[%u]: %s\n", i, records[i].line);
6642                         return ret;
6643                 }
6644         }
6645
6646         return ret;
6647 }
6648
6649 struct test_conflict_owned_active_vs_replica_struct {
6650         const char *line; /* just better debugging */
6651         const char *section; /* just better debugging */
6652         struct nbt_name name;
6653         const char *comment;
6654         BOOL skip;
6655         struct {
6656                 uint32_t nb_flags;
6657                 BOOL mhomed;
6658                 uint32_t num_ips;
6659                 const struct wrepl_ip *ips;
6660                 BOOL apply_expected;
6661         } wins;
6662         struct {
6663                 uint32_t timeout;
6664                 BOOL positive;
6665                 BOOL expect_release;
6666                 BOOL late_release;
6667                 BOOL ret;
6668                 /* when num_ips == 0, then .wins.ips are used */
6669                 uint32_t num_ips;
6670                 const struct wrepl_ip *ips;
6671         } defend;
6672         struct {
6673                 enum wrepl_name_type type;
6674                 enum wrepl_name_state state;
6675                 enum wrepl_name_node node;
6676                 BOOL is_static;
6677                 uint32_t num_ips;
6678                 const struct wrepl_ip *ips;
6679                 BOOL apply_expected;
6680                 BOOL mhomed_merge;
6681                 BOOL sgroup_merge;
6682         } replica;
6683 };
6684
6685 static void test_conflict_owned_active_vs_replica_handler(struct nbt_name_socket *nbtsock, 
6686                                                           struct nbt_name_packet *req_packet, 
6687                                                           struct socket_address *src);
6688
6689 static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_conn *ctx)
6690 {
6691         BOOL ret = True;
6692         NTSTATUS status;
6693         struct wrepl_wins_name wins_name_;
6694         struct wrepl_wins_name *wins_name = &wins_name_;
6695         struct nbt_name_register name_register_;
6696         struct nbt_name_register *name_register = &name_register_;
6697         struct nbt_name_release release_;
6698         struct nbt_name_release *release = &release_;
6699         uint32_t i;
6700         struct test_conflict_owned_active_vs_replica_struct records[] = {
6701 /* 
6702  * unique vs. unique section
6703  */
6704         /*
6705          * unique,active vs. unique,active with same ip(s), unchecked
6706          */
6707         {
6708                 .line   = __location__,
6709                 .name   = _NBT_NAME("_UA_UA_SI_U", 0x00, NULL),
6710                 .wins   = {
6711                         .nb_flags       = 0,
6712                         .mhomed         = False,
6713                         .num_ips        = ctx->addresses_best_num,
6714                         .ips            = ctx->addresses_best,
6715                         .apply_expected = True
6716                 },
6717                 .defend = {
6718                         .timeout        = 0,
6719                 },
6720                 .replica= {
6721                         .type           = WREPL_TYPE_UNIQUE,
6722                         .state          = WREPL_STATE_ACTIVE,
6723                         .node           = WREPL_NODE_B,
6724                         .is_static      = False,
6725                         .num_ips        = ctx->addresses_best_num,
6726                         .ips            = ctx->addresses_best,
6727                         .apply_expected = True
6728                 },
6729         },
6730         /*
6731          * unique,active vs. unique,active with different ip(s), positive response
6732          */
6733         {
6734                 .line   = __location__,
6735                 .name   = _NBT_NAME("_UA_UA_DI_P", 0x00, NULL),
6736                 .wins   = {
6737                         .nb_flags       = 0,
6738                         .mhomed         = False,
6739                         .num_ips        = ctx->addresses_best_num,
6740                         .ips            = ctx->addresses_best,
6741                         .apply_expected = True
6742                 },
6743                 .defend = {
6744                         .timeout        = 10,
6745                         .positive       = True,
6746                 },
6747                 .replica= {
6748                         .type           = WREPL_TYPE_UNIQUE,
6749                         .state          = WREPL_STATE_ACTIVE,
6750                         .node           = WREPL_NODE_B,
6751                         .is_static      = False,
6752                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6753                         .ips            = addresses_B_1,
6754                         .apply_expected = False
6755                 },
6756         },
6757         /*
6758          * unique,active vs. unique,active with different ip(s), positive response other ips
6759          */
6760         {
6761                 .line   = __location__,
6762                 .name   = _NBT_NAME("_UA_UA_DI_O", 0x00, NULL),
6763                 .wins   = {
6764                         .nb_flags       = 0,
6765                         .mhomed         = False,
6766                         .num_ips        = ctx->addresses_best_num,
6767                         .ips            = ctx->addresses_best,
6768                         .apply_expected = True
6769                 },
6770                 .defend = {
6771                         .timeout        = 10,
6772                         .positive       = True,
6773                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
6774                         .ips            = addresses_A_3_4,
6775                 },
6776                 .replica= {
6777                         .type           = WREPL_TYPE_UNIQUE,
6778                         .state          = WREPL_STATE_ACTIVE,
6779                         .node           = WREPL_NODE_B,
6780                         .is_static      = False,
6781                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6782                         .ips            = addresses_B_1,
6783                         .apply_expected = False
6784                 },
6785         },
6786         /*
6787          * unique,active vs. unique,active with different ip(s), negative response
6788          */
6789         {
6790                 .line   = __location__,
6791                 .name   = _NBT_NAME("_UA_UA_DI_N", 0x00, NULL),
6792                 .wins   = {
6793                         .nb_flags       = 0,
6794                         .mhomed         = False,
6795                         .num_ips        = ctx->addresses_best_num,
6796                         .ips            = ctx->addresses_best,
6797                         .apply_expected = True
6798                 },
6799                 .defend = {
6800                         .timeout        = 10,
6801                         .positive       = False,
6802                 },
6803                 .replica= {
6804                         .type           = WREPL_TYPE_UNIQUE,
6805                         .state          = WREPL_STATE_ACTIVE,
6806                         .node           = WREPL_NODE_B,
6807                         .is_static      = False,
6808                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6809                         .ips            = addresses_B_1,
6810                         .apply_expected = True
6811                 },
6812         },
6813         /*
6814          * unique,active vs. unique,tombstone with same ip(s), unchecked
6815          */
6816         {
6817                 .line   = __location__,
6818                 .name   = _NBT_NAME("_UA_UT_SI_U", 0x00, NULL),
6819                 .wins   = {
6820                         .nb_flags       = 0,
6821                         .mhomed         = False,
6822                         .num_ips        = ctx->addresses_best_num,
6823                         .ips            = ctx->addresses_best,
6824                         .apply_expected = True
6825                 },
6826                 .defend = {
6827                         .timeout        = 0,
6828                 },
6829                 .replica= {
6830                         .type           = WREPL_TYPE_UNIQUE,
6831                         .state          = WREPL_STATE_TOMBSTONE,
6832                         .node           = WREPL_NODE_B,
6833                         .is_static      = False,
6834                         .num_ips        = ctx->addresses_best_num,
6835                         .ips            = ctx->addresses_best,
6836                         .apply_expected = False
6837                 },
6838         },
6839         /*
6840          * unique,active vs. unique,tombstone with different ip(s), unchecked
6841          */
6842         {
6843                 .line   = __location__,
6844                 .name   = _NBT_NAME("_UA_UT_DI_U", 0x00, NULL),
6845                 .wins   = {
6846                         .nb_flags       = 0,
6847                         .mhomed         = False,
6848                         .num_ips        = ctx->addresses_best_num,
6849                         .ips            = ctx->addresses_best,
6850                         .apply_expected = True
6851                 },
6852                 .defend = {
6853                         .timeout        = 0,
6854                 },
6855                 .replica= {
6856                         .type           = WREPL_TYPE_UNIQUE,
6857                         .state          = WREPL_STATE_TOMBSTONE,
6858                         .node           = WREPL_NODE_B,
6859                         .is_static      = False,
6860                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6861                         .ips            = addresses_B_1,
6862                         .apply_expected = False
6863                 },
6864         },
6865 /* 
6866  * unique vs. group section
6867  */
6868         /*
6869          * unique,active vs. group,active with same ip(s), release expected
6870          */
6871         {
6872                 .line   = __location__,
6873                 .name   = _NBT_NAME("_UA_GA_SI_R", 0x00, NULL),
6874                 .wins   = {
6875                         .nb_flags       = 0,
6876                         .mhomed         = False,
6877                         .num_ips        = ctx->addresses_best_num,
6878                         .ips            = ctx->addresses_best,
6879                         .apply_expected = True
6880                 },
6881                 .defend = {
6882                         .timeout        = 10,
6883                         .expect_release = True,
6884                 },
6885                 .replica= {
6886                         .type           = WREPL_TYPE_GROUP,
6887                         .state          = WREPL_STATE_ACTIVE,
6888                         .node           = WREPL_NODE_B,
6889                         .is_static      = False,
6890                         .num_ips        = ctx->addresses_best_num,
6891                         .ips            = ctx->addresses_best,
6892                         .apply_expected = True
6893                 },
6894         },
6895         /*
6896          * unique,active vs. group,active with different ip(s), release expected
6897          */
6898         {
6899                 .line   = __location__,
6900                 .name   = _NBT_NAME("_UA_GA_DI_R", 0x00, NULL),
6901                 .wins   = {
6902                         .nb_flags       = 0,
6903                         .mhomed         = False,
6904                         .num_ips        = ctx->addresses_best_num,
6905                         .ips            = ctx->addresses_best,
6906                         .apply_expected = True
6907                 },
6908                 .defend = {
6909                         .timeout        = 10,
6910                         .expect_release = True,
6911                 },
6912                 .replica= {
6913                         .type           = WREPL_TYPE_GROUP,
6914                         .state          = WREPL_STATE_ACTIVE,
6915                         .node           = WREPL_NODE_B,
6916                         .is_static      = False,
6917                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6918                         .ips            = addresses_B_1,
6919                         .apply_expected = True
6920                 },
6921         },
6922         /*
6923          * unique,active vs. group,tombstone with same ip(s), unchecked
6924          */
6925         {
6926                 .line   = __location__,
6927                 .name   = _NBT_NAME("_UA_GT_SI_U", 0x00, NULL),
6928                 .wins   = {
6929                         .nb_flags       = 0,
6930                         .mhomed         = False,
6931                         .num_ips        = ctx->addresses_best_num,
6932                         .ips            = ctx->addresses_best,
6933                         .apply_expected = True
6934                 },
6935                 .defend = {
6936                         .timeout        = 0,
6937                 },
6938                 .replica= {
6939                         .type           = WREPL_TYPE_GROUP,
6940                         .state          = WREPL_STATE_TOMBSTONE,
6941                         .node           = WREPL_NODE_B,
6942                         .is_static      = False,
6943                         .num_ips        = ctx->addresses_best_num,
6944                         .ips            = ctx->addresses_best,
6945                         .apply_expected = False
6946                 },
6947         },
6948         /*
6949          * unique,active vs. group,tombstone with different ip(s), unchecked
6950          */
6951         {
6952                 .line   = __location__,
6953                 .name   = _NBT_NAME("_UA_GT_DI_U", 0x00, NULL),
6954                 .wins   = {
6955                         .nb_flags       = 0,
6956                         .mhomed         = False,
6957                         .num_ips        = ctx->addresses_best_num,
6958                         .ips            = ctx->addresses_best,
6959                         .apply_expected = True
6960                 },
6961                 .defend = {
6962                         .timeout        = 0,
6963                 },
6964                 .replica= {
6965                         .type           = WREPL_TYPE_GROUP,
6966                         .state          = WREPL_STATE_TOMBSTONE,
6967                         .node           = WREPL_NODE_B,
6968                         .is_static      = False,
6969                         .num_ips        = ARRAY_SIZE(addresses_B_1),
6970                         .ips            = addresses_B_1,
6971                         .apply_expected = False
6972                 },
6973         },
6974 /* 
6975  * unique vs. special group section
6976  */
6977         /*
6978          * unique,active vs. sgroup,active with same ip(s), release expected
6979          */
6980         {
6981                 .line   = __location__,
6982                 .name   = _NBT_NAME("_UA_SA_SI_R", 0x00, NULL),
6983                 .wins   = {
6984                         .nb_flags       = 0,
6985                         .mhomed         = False,
6986                         .num_ips        = ctx->addresses_best_num,
6987                         .ips            = ctx->addresses_best,
6988                         .apply_expected = True
6989                 },
6990                 .defend = {
6991                         .timeout        = 10,
6992                         .expect_release = True,
6993                 },
6994                 .replica= {
6995                         .type           = WREPL_TYPE_SGROUP,
6996                         .state          = WREPL_STATE_ACTIVE,
6997                         .node           = WREPL_NODE_B,
6998                         .is_static      = False,
6999                         .num_ips        = ctx->addresses_best_num,
7000                         .ips            = ctx->addresses_best,
7001                         .apply_expected = True
7002                 },
7003         },
7004         /*
7005          * unique,active vs. group,active with different ip(s), release expected
7006          */
7007         {
7008                 .line   = __location__,
7009                 .name   = _NBT_NAME("_UA_SA_DI_R", 0x00, NULL),
7010                 .wins   = {
7011                         .nb_flags       = 0,
7012                         .mhomed         = False,
7013                         .num_ips        = ctx->addresses_best_num,
7014                         .ips            = ctx->addresses_best,
7015                         .apply_expected = True
7016                 },
7017                 .defend = {
7018                         .timeout        = 10,
7019                         .expect_release = True,
7020                 },
7021                 .replica= {
7022                         .type           = WREPL_TYPE_SGROUP,
7023                         .state          = WREPL_STATE_ACTIVE,
7024                         .node           = WREPL_NODE_B,
7025                         .is_static      = False,
7026                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7027                         .ips            = addresses_B_1,
7028                         .apply_expected = True
7029                 },
7030         },
7031         /*
7032          * unique,active vs. sgroup,tombstone with same ip(s), unchecked
7033          */
7034         {
7035                 .line   = __location__,
7036                 .name   = _NBT_NAME("_UA_ST_SI_U", 0x00, NULL),
7037                 .wins   = {
7038                         .nb_flags       = 0,
7039                         .mhomed         = False,
7040                         .num_ips        = ctx->addresses_best_num,
7041                         .ips            = ctx->addresses_best,
7042                         .apply_expected = True
7043                 },
7044                 .defend = {
7045                         .timeout        = 0,
7046                 },
7047                 .replica= {
7048                         .type           = WREPL_TYPE_SGROUP,
7049                         .state          = WREPL_STATE_TOMBSTONE,
7050                         .node           = WREPL_NODE_B,
7051                         .is_static      = False,
7052                         .num_ips        = ctx->addresses_best_num,
7053                         .ips            = ctx->addresses_best,
7054                         .apply_expected = False
7055                 },
7056         },
7057         /*
7058          * unique,active vs. sgroup,tombstone with different ip(s), unchecked
7059          */
7060         {
7061                 .line   = __location__,
7062                 .name   = _NBT_NAME("_UA_ST_DI_U", 0x00, NULL),
7063                 .wins   = {
7064                         .nb_flags       = 0,
7065                         .mhomed         = False,
7066                         .num_ips        = ctx->addresses_best_num,
7067                         .ips            = ctx->addresses_best,
7068                         .apply_expected = True
7069                 },
7070                 .defend = {
7071                         .timeout        = 0,
7072                 },
7073                 .replica= {
7074                         .type           = WREPL_TYPE_SGROUP,
7075                         .state          = WREPL_STATE_TOMBSTONE,
7076                         .node           = WREPL_NODE_B,
7077                         .is_static      = False,
7078                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7079                         .ips            = addresses_B_1,
7080                         .apply_expected = False
7081                 },
7082         },
7083 /* 
7084  * unique vs. multi homed section
7085  */
7086         /*
7087          * unique,active vs. mhomed,active with same ip(s), unchecked
7088          */
7089         {
7090                 .line   = __location__,
7091                 .name   = _NBT_NAME("_UA_MA_SI_U", 0x00, NULL),
7092                 .wins   = {
7093                         .nb_flags       = 0,
7094                         .mhomed         = False,
7095                         .num_ips        = ctx->addresses_best_num,
7096                         .ips            = ctx->addresses_best,
7097                         .apply_expected = True
7098                 },
7099                 .defend = {
7100                         .timeout        = 0,
7101                 },
7102                 .replica= {
7103                         .type           = WREPL_TYPE_MHOMED,
7104                         .state          = WREPL_STATE_ACTIVE,
7105                         .node           = WREPL_NODE_B,
7106                         .is_static      = False,
7107                         .num_ips        = ctx->addresses_best_num,
7108                         .ips            = ctx->addresses_best,
7109                         .apply_expected = True
7110                 },
7111         },
7112         /*
7113          * unique,active vs. mhomed,active with superset ip(s), unchecked
7114          */
7115         {
7116                 .line   = __location__,
7117                 .name   = _NBT_NAME("_UA_MA_SP_U", 0x00, NULL),
7118                 .wins   = {
7119                         .nb_flags       = 0,
7120                         .mhomed         = False,
7121                         .num_ips        = ctx->addresses_best_num,
7122                         .ips            = ctx->addresses_best,
7123                         .apply_expected = True
7124                 },
7125                 .defend = {
7126                         .timeout        = 0,
7127                 },
7128                 .replica= {
7129                         .type           = WREPL_TYPE_MHOMED,
7130                         .state          = WREPL_STATE_ACTIVE,
7131                         .node           = WREPL_NODE_B,
7132                         .is_static      = False,
7133                         .num_ips        = ctx->addresses_all_num,
7134                         .ips            = ctx->addresses_all,
7135                         .apply_expected = True
7136                 },
7137         },
7138         /*
7139          * unique,active vs. mhomed,active with different ip(s), positive response
7140          */
7141         {
7142                 .line   = __location__,
7143                 .name   = _NBT_NAME("_UA_MA_DI_P", 0x00, NULL),
7144                 .wins   = {
7145                         .nb_flags       = 0,
7146                         .mhomed         = False,
7147                         .num_ips        = ctx->addresses_best_num,
7148                         .ips            = ctx->addresses_best,
7149                         .apply_expected = True
7150                 },
7151                 .defend = {
7152                         .timeout        = 10,
7153                         .positive       = True,
7154                 },
7155                 .replica= {
7156                         .type           = WREPL_TYPE_MHOMED,
7157                         .state          = WREPL_STATE_ACTIVE,
7158                         .node           = WREPL_NODE_B,
7159                         .is_static      = False,
7160                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7161                         .ips            = addresses_B_3_4,
7162                         .apply_expected = False
7163                 },
7164         },
7165         /*
7166          * unique,active vs. mhomed,active with different ip(s), positive response other ips
7167          */
7168         {
7169                 .line   = __location__,
7170                 .name   = _NBT_NAME("_UA_MA_DI_O", 0x00, NULL),
7171                 .wins   = {
7172                         .nb_flags       = 0,
7173                         .mhomed         = False,
7174                         .num_ips        = ctx->addresses_best_num,
7175                         .ips            = ctx->addresses_best,
7176                         .apply_expected = True
7177                 },
7178                 .defend = {
7179                         .timeout        = 10,
7180                         .positive       = True,
7181                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
7182                         .ips            = addresses_A_3_4,
7183                 },
7184                 .replica= {
7185                         .type           = WREPL_TYPE_MHOMED,
7186                         .state          = WREPL_STATE_ACTIVE,
7187                         .node           = WREPL_NODE_B,
7188                         .is_static      = False,
7189                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7190                         .ips            = addresses_B_3_4,
7191                         .apply_expected = False
7192                 },
7193         },
7194         /*
7195          * unique,active vs. mhomed,active with different ip(s), negative response
7196          */
7197         {
7198                 .line   = __location__,
7199                 .name   = _NBT_NAME("_UA_MA_DI_N", 0x00, NULL),
7200                 .wins   = {
7201                         .nb_flags       = 0,
7202                         .mhomed         = False,
7203                         .num_ips        = ctx->addresses_best_num,
7204                         .ips            = ctx->addresses_best,
7205                         .apply_expected = True
7206                 },
7207                 .defend = {
7208                         .timeout        = 10,
7209                         .positive       = False,
7210                 },
7211                 .replica= {
7212                         .type           = WREPL_TYPE_MHOMED,
7213                         .state          = WREPL_STATE_ACTIVE,
7214                         .node           = WREPL_NODE_B,
7215                         .is_static      = False,
7216                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7217                         .ips            = addresses_B_3_4,
7218                         .apply_expected = True
7219                 },
7220         },
7221         /*
7222          * unique,active vs. mhomed,tombstone with same ip(s), unchecked
7223          */
7224         {
7225                 .line   = __location__,
7226                 .name   = _NBT_NAME("_UA_MT_SI_U", 0x00, NULL),
7227                 .wins   = {
7228                         .nb_flags       = 0,
7229                         .mhomed         = False,
7230                         .num_ips        = ctx->addresses_best_num,
7231                         .ips            = ctx->addresses_best,
7232                         .apply_expected = True
7233                 },
7234                 .defend = {
7235                         .timeout        = 0,
7236                 },
7237                 .replica= {
7238                         .type           = WREPL_TYPE_MHOMED,
7239                         .state          = WREPL_STATE_TOMBSTONE,
7240                         .node           = WREPL_NODE_B,
7241                         .is_static      = False,
7242                         .num_ips        = ctx->addresses_best_num,
7243                         .ips            = ctx->addresses_best,
7244                         .apply_expected = False
7245                 },
7246         },
7247         /*
7248          * unique,active vs. mhomed,tombstone with different ip(s), unchecked
7249          */
7250         {
7251                 .line   = __location__,
7252                 .name   = _NBT_NAME("_UA_MT_DI_U", 0x00, NULL),
7253                 .wins   = {
7254                         .nb_flags       = 0,
7255                         .mhomed         = False,
7256                         .num_ips        = ctx->addresses_best_num,
7257                         .ips            = ctx->addresses_best,
7258                         .apply_expected = True
7259                 },
7260                 .defend = {
7261                         .timeout        = 0,
7262                 },
7263                 .replica= {
7264                         .type           = WREPL_TYPE_MHOMED,
7265                         .state          = WREPL_STATE_TOMBSTONE,
7266                         .node           = WREPL_NODE_B,
7267                         .is_static      = False,
7268                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7269                         .ips            = addresses_B_3_4,
7270                         .apply_expected = False
7271                 },
7272         },
7273 /* 
7274  * normal group vs. unique section
7275  */
7276         /*
7277          * group,active vs. unique,active with same ip(s), unchecked
7278          */
7279         {
7280                 .line   = __location__,
7281                 .name   = _NBT_NAME("_GA_UA_SI_U", 0x00, NULL),
7282                 .wins   = {
7283                         .nb_flags       = NBT_NM_GROUP,
7284                         .mhomed         = False,
7285                         .num_ips        = ctx->addresses_best_num,
7286                         .ips            = ctx->addresses_best,
7287                         .apply_expected = True
7288                 },
7289                 .defend = {
7290                         .timeout        = 0,
7291                 },
7292                 .replica= {
7293                         .type           = WREPL_TYPE_UNIQUE,
7294                         .state          = WREPL_STATE_ACTIVE,
7295                         .node           = WREPL_NODE_B,
7296                         .is_static      = False,
7297                         .num_ips        = ctx->addresses_best_num,
7298                         .ips            = ctx->addresses_best,
7299                         .apply_expected = False
7300                 },
7301         },
7302         /*
7303          * group,active vs. unique,active with different ip(s), unchecked
7304          */
7305         {
7306                 .line   = __location__,
7307                 .name   = _NBT_NAME("_GA_UA_DI_U", 0x00, NULL),
7308                 .wins   = {
7309                         .nb_flags       = NBT_NM_GROUP,
7310                         .mhomed         = False,
7311                         .num_ips        = ctx->addresses_best_num,
7312                         .ips            = ctx->addresses_best,
7313                         .apply_expected = True
7314                 },
7315                 .defend = {
7316                         .timeout        = 0,
7317                 },
7318                 .replica= {
7319                         .type           = WREPL_TYPE_UNIQUE,
7320                         .state          = WREPL_STATE_ACTIVE,
7321                         .node           = WREPL_NODE_B,
7322                         .is_static      = False,
7323                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7324                         .ips            = addresses_B_1,
7325                         .apply_expected = False
7326                 },
7327         },
7328         /*
7329          * group,active vs. unique,tombstone with same ip(s), unchecked
7330          */
7331         {
7332                 .line   = __location__,
7333                 .name   = _NBT_NAME("_GA_UT_SI_U", 0x00, NULL),
7334                 .wins   = {
7335                         .nb_flags       = NBT_NM_GROUP,
7336                         .mhomed         = False,
7337                         .num_ips        = ctx->addresses_best_num,
7338                         .ips            = ctx->addresses_best,
7339                         .apply_expected = True
7340                 },
7341                 .defend = {
7342                         .timeout        = 0,
7343                 },
7344                 .replica= {
7345                         .type           = WREPL_TYPE_UNIQUE,
7346                         .state          = WREPL_STATE_TOMBSTONE,
7347                         .node           = WREPL_NODE_B,
7348                         .is_static      = False,
7349                         .num_ips        = ctx->addresses_best_num,
7350                         .ips            = ctx->addresses_best,
7351                         .apply_expected = False
7352                 },
7353         },
7354         /*
7355          * group,active vs. unique,tombstone with different ip(s), unchecked
7356          */
7357         {
7358                 .line   = __location__,
7359                 .name   = _NBT_NAME("_GA_UT_DI_U", 0x00, NULL),
7360                 .wins   = {
7361                         .nb_flags       = NBT_NM_GROUP,
7362                         .mhomed         = False,
7363                         .num_ips        = ctx->addresses_best_num,
7364                         .ips            = ctx->addresses_best,
7365                         .apply_expected = True
7366                 },
7367                 .defend = {
7368                         .timeout        = 0,
7369                 },
7370                 .replica= {
7371                         .type           = WREPL_TYPE_UNIQUE,
7372                         .state          = WREPL_STATE_TOMBSTONE,
7373                         .node           = WREPL_NODE_B,
7374                         .is_static      = False,
7375                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7376                         .ips            = addresses_B_1,
7377                         .apply_expected = False
7378                 },
7379         },
7380 /* 
7381  * normal group vs. normal group section
7382  */
7383         /*
7384          * group,active vs. group,active with same ip(s), unchecked
7385          */
7386         {
7387                 .line   = __location__,
7388                 .name   = _NBT_NAME("_GA_GA_SI_U", 0x00, NULL),
7389                 .wins   = {
7390                         .nb_flags       = NBT_NM_GROUP,
7391                         .mhomed         = False,
7392                         .num_ips        = ctx->addresses_best_num,
7393                         .ips            = ctx->addresses_best,
7394                         .apply_expected = True
7395                 },
7396                 .defend = {
7397                         .timeout        = 0,
7398                 },
7399                 .replica= {
7400                         .type           = WREPL_TYPE_GROUP,
7401                         .state          = WREPL_STATE_ACTIVE,
7402                         .node           = WREPL_NODE_B,
7403                         .is_static      = False,
7404                         .num_ips        = ctx->addresses_best_num,
7405                         .ips            = ctx->addresses_best,
7406                         .apply_expected = True
7407                 },
7408         },
7409         /*
7410          * group,active vs. group,active with different ip(s), unchecked
7411          */
7412         {
7413                 .line   = __location__,
7414                 .name   = _NBT_NAME("_GA_GA_DI_U", 0x00, NULL),
7415                 .wins   = {
7416                         .nb_flags       = NBT_NM_GROUP,
7417                         .mhomed         = False,
7418                         .num_ips        = ctx->addresses_best_num,
7419                         .ips            = ctx->addresses_best,
7420                         .apply_expected = True
7421                 },
7422                 .defend = {
7423                         .timeout        = 0,
7424                 },
7425                 .replica= {
7426                         .type           = WREPL_TYPE_GROUP,
7427                         .state          = WREPL_STATE_ACTIVE,
7428                         .node           = WREPL_NODE_B,
7429                         .is_static      = False,
7430                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7431                         .ips            = addresses_B_1,
7432                         .apply_expected = True
7433                 },
7434         },
7435         /*
7436          * group,active vs. group,tombstone with same ip(s), unchecked
7437          */
7438         {
7439                 .line   = __location__,
7440                 .name   = _NBT_NAME("_GA_GT_SI_U", 0x00, NULL),
7441                 .wins   = {
7442                         .nb_flags       = NBT_NM_GROUP,
7443                         .mhomed         = False,
7444                         .num_ips        = ctx->addresses_best_num,
7445                         .ips            = ctx->addresses_best,
7446                         .apply_expected = True
7447                 },
7448                 .defend = {
7449                         .timeout        = 0,
7450                 },
7451                 .replica= {
7452                         .type           = WREPL_TYPE_GROUP,
7453                         .state          = WREPL_STATE_TOMBSTONE,
7454                         .node           = WREPL_NODE_B,
7455                         .is_static      = False,
7456                         .num_ips        = ctx->addresses_best_num,
7457                         .ips            = ctx->addresses_best,
7458                         .apply_expected = False
7459                 },
7460         },
7461         /*
7462          * group,active vs. group,tombstone with different ip(s), unchecked
7463          */
7464         {
7465                 .line   = __location__,
7466                 .name   = _NBT_NAME("_GA_GT_DI_U", 0x00, NULL),
7467                 .wins   = {
7468                         .nb_flags       = NBT_NM_GROUP,
7469                         .mhomed         = False,
7470                         .num_ips        = ctx->addresses_best_num,
7471                         .ips            = ctx->addresses_best,
7472                         .apply_expected = True
7473                 },
7474                 .defend = {
7475                         .timeout        = 0,
7476                 },
7477                 .replica= {
7478                         .type           = WREPL_TYPE_GROUP,
7479                         .state          = WREPL_STATE_TOMBSTONE,
7480                         .node           = WREPL_NODE_B,
7481                         .is_static      = False,
7482                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7483                         .ips            = addresses_B_1,
7484                         .apply_expected = False
7485                 },
7486         },
7487 /* 
7488  * normal group vs. special group section
7489  */
7490         /*
7491          * group,active vs. sgroup,active with same ip(s), unchecked
7492          */
7493         {
7494                 .line   = __location__,
7495                 .name   = _NBT_NAME("_GA_SA_SI_U", 0x00, NULL),
7496                 .wins   = {
7497                         .nb_flags       = NBT_NM_GROUP,
7498                         .mhomed         = False,
7499                         .num_ips        = ctx->addresses_best_num,
7500                         .ips            = ctx->addresses_best,
7501                         .apply_expected = True
7502                 },
7503                 .defend = {
7504                         .timeout        = 0,
7505                 },
7506                 .replica= {
7507                         .type           = WREPL_TYPE_SGROUP,
7508                         .state          = WREPL_STATE_ACTIVE,
7509                         .node           = WREPL_NODE_B,
7510                         .is_static      = False,
7511                         .num_ips        = ctx->addresses_best_num,
7512                         .ips            = ctx->addresses_best,
7513                         .apply_expected = False
7514                 },
7515         },
7516         /*
7517          * group,active vs. sgroup,active with different ip(s), unchecked
7518          */
7519         {
7520                 .line   = __location__,
7521                 .name   = _NBT_NAME("_GA_SA_DI_U", 0x00, NULL),
7522                 .wins   = {
7523                         .nb_flags       = NBT_NM_GROUP,
7524                         .mhomed         = False,
7525                         .num_ips        = ctx->addresses_best_num,
7526                         .ips            = ctx->addresses_best,
7527                         .apply_expected = True
7528                 },
7529                 .defend = {
7530                         .timeout        = 0,
7531                 },
7532                 .replica= {
7533                         .type           = WREPL_TYPE_SGROUP,
7534                         .state          = WREPL_STATE_ACTIVE,
7535                         .node           = WREPL_NODE_B,
7536                         .is_static      = False,
7537                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7538                         .ips            = addresses_B_3_4,
7539                         .apply_expected = False
7540                 },
7541         },
7542         /*
7543          * group,active vs. sgroup,tombstone with same ip(s), unchecked
7544          */
7545         {
7546                 .line   = __location__,
7547                 .name   = _NBT_NAME("_GA_ST_SI_U", 0x00, NULL),
7548                 .wins   = {
7549                         .nb_flags       = NBT_NM_GROUP,
7550                         .mhomed         = False,
7551                         .num_ips        = ctx->addresses_best_num,
7552                         .ips            = ctx->addresses_best,
7553                         .apply_expected = True
7554                 },
7555                 .defend = {
7556                         .timeout        = 0,
7557                 },
7558                 .replica= {
7559                         .type           = WREPL_TYPE_SGROUP,
7560                         .state          = WREPL_STATE_TOMBSTONE,
7561                         .node           = WREPL_NODE_B,
7562                         .is_static      = False,
7563                         .num_ips        = ctx->addresses_best_num,
7564                         .ips            = ctx->addresses_best,
7565                         .apply_expected = False
7566                 },
7567         },
7568         /*
7569          * group,active vs. sgroup,tombstone with different ip(s), unchecked
7570          */
7571         {
7572                 .line   = __location__,
7573                 .name   = _NBT_NAME("_GA_ST_DI_U", 0x00, NULL),
7574                 .wins   = {
7575                         .nb_flags       = NBT_NM_GROUP,
7576                         .mhomed         = False,
7577                         .num_ips        = ctx->addresses_best_num,
7578                         .ips            = ctx->addresses_best,
7579                         .apply_expected = True
7580                 },
7581                 .defend = {
7582                         .timeout        = 0,
7583                 },
7584                 .replica= {
7585                         .type           = WREPL_TYPE_SGROUP,
7586                         .state          = WREPL_STATE_TOMBSTONE,
7587                         .node           = WREPL_NODE_B,
7588                         .is_static      = False,
7589                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7590                         .ips            = addresses_B_3_4,
7591                         .apply_expected = False
7592                 },
7593         },
7594 /* 
7595  * normal group vs. multi homed section
7596  */
7597         /*
7598          * group,active vs. mhomed,active with same ip(s), unchecked
7599          */
7600         {
7601                 .line   = __location__,
7602                 .name   = _NBT_NAME("_GA_MA_SI_U", 0x00, NULL),
7603                 .wins   = {
7604                         .nb_flags       = NBT_NM_GROUP,
7605                         .mhomed         = False,
7606                         .num_ips        = ctx->addresses_best_num,
7607                         .ips            = ctx->addresses_best,
7608                         .apply_expected = True
7609                 },
7610                 .defend = {
7611                         .timeout        = 0,
7612                 },
7613                 .replica= {
7614                         .type           = WREPL_TYPE_MHOMED,
7615                         .state          = WREPL_STATE_ACTIVE,
7616                         .node           = WREPL_NODE_B,
7617                         .is_static      = False,
7618                         .num_ips        = ctx->addresses_best_num,
7619                         .ips            = ctx->addresses_best,
7620                         .apply_expected = False
7621                 },
7622         },
7623         /*
7624          * group,active vs. mhomed,active with different ip(s), unchecked
7625          */
7626         {
7627                 .line   = __location__,
7628                 .name   = _NBT_NAME("_GA_MA_DI_U", 0x00, NULL),
7629                 .wins   = {
7630                         .nb_flags       = NBT_NM_GROUP,
7631                         .mhomed         = False,
7632                         .num_ips        = ctx->addresses_best_num,
7633                         .ips            = ctx->addresses_best,
7634                         .apply_expected = True
7635                 },
7636                 .defend = {
7637                         .timeout        = 0,
7638                 },
7639                 .replica= {
7640                         .type           = WREPL_TYPE_MHOMED,
7641                         .state          = WREPL_STATE_ACTIVE,
7642                         .node           = WREPL_NODE_B,
7643                         .is_static      = False,
7644                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7645                         .ips            = addresses_B_3_4,
7646                         .apply_expected = False
7647                 },
7648         },
7649         /*
7650          * group,active vs. mhomed,tombstone with same ip(s), unchecked
7651          */
7652         {
7653                 .line   = __location__,
7654                 .name   = _NBT_NAME("_GA_MT_SI_U", 0x00, NULL),
7655                 .wins   = {
7656                         .nb_flags       = NBT_NM_GROUP,
7657                         .mhomed         = False,
7658                         .num_ips        = ctx->addresses_best_num,
7659                         .ips            = ctx->addresses_best,
7660                         .apply_expected = True
7661                 },
7662                 .defend = {
7663                         .timeout        = 0,
7664                 },
7665                 .replica= {
7666                         .type           = WREPL_TYPE_MHOMED,
7667                         .state          = WREPL_STATE_TOMBSTONE,
7668                         .node           = WREPL_NODE_B,
7669                         .is_static      = False,
7670                         .num_ips        = ctx->addresses_best_num,
7671                         .ips            = ctx->addresses_best,
7672                         .apply_expected = False
7673                 },
7674         },
7675         /*
7676          * group,active vs. mhomed,tombstone with different ip(s), unchecked
7677          */
7678         {
7679                 .line   = __location__,
7680                 .name   = _NBT_NAME("_GA_MT_DI_U", 0x00, NULL),
7681                 .wins   = {
7682                         .nb_flags       = NBT_NM_GROUP,
7683                         .mhomed         = False,
7684                         .num_ips        = ctx->addresses_best_num,
7685                         .ips            = ctx->addresses_best,
7686                         .apply_expected = True
7687                 },
7688                 .defend = {
7689                         .timeout        = 0,
7690                 },
7691                 .replica= {
7692                         .type           = WREPL_TYPE_MHOMED,
7693                         .state          = WREPL_STATE_TOMBSTONE,
7694                         .node           = WREPL_NODE_B,
7695                         .is_static      = False,
7696                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
7697                         .ips            = addresses_B_3_4,
7698                         .apply_expected = False
7699                 },
7700         },
7701 /* 
7702  * special group vs. unique section
7703  */
7704         /*
7705          * sgroup,active vs. unique,active with same ip(s), unchecked
7706          */
7707         {
7708                 .line   = __location__,
7709                 .name   = _NBT_NAME("_SA_UA_SI_U", 0x1C, NULL),
7710                 .wins   = {
7711                         .nb_flags       = NBT_NM_GROUP,
7712                         .mhomed         = False,
7713                         .num_ips        = ctx->addresses_best_num,
7714                         .ips            = ctx->addresses_best,
7715                         .apply_expected = True
7716                 },
7717                 .defend = {
7718                         .timeout        = 0,
7719                 },
7720                 .replica= {
7721                         .type           = WREPL_TYPE_UNIQUE,
7722                         .state          = WREPL_STATE_ACTIVE,
7723                         .node           = WREPL_NODE_B,
7724                         .is_static      = False,
7725                         .num_ips        = ctx->addresses_best_num,
7726                         .ips            = ctx->addresses_best,
7727                         .apply_expected = False
7728                 },
7729         },
7730         /*
7731          * sgroup,active vs. unique,active with different ip(s), unchecked
7732          */
7733         {
7734                 .line   = __location__,
7735                 .name   = _NBT_NAME("_SA_UA_DI_U", 0x1C, NULL),
7736                 .wins   = {
7737                         .nb_flags       = NBT_NM_GROUP,
7738                         .mhomed         = False,
7739                         .num_ips        = ctx->addresses_best_num,
7740                         .ips            = ctx->addresses_best,
7741                         .apply_expected = True
7742                 },
7743                 .defend = {
7744                         .timeout        = 0,
7745                 },
7746                 .replica= {
7747                         .type           = WREPL_TYPE_UNIQUE,
7748                         .state          = WREPL_STATE_ACTIVE,
7749                         .node           = WREPL_NODE_B,
7750                         .is_static      = False,
7751                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7752                         .ips            = addresses_B_1,
7753                         .apply_expected = False
7754                 },
7755         },
7756         /*
7757          * sgroup,active vs. unique,tombstone with same ip(s), unchecked
7758          */
7759         {
7760                 .line   = __location__,
7761                 .name   = _NBT_NAME("_SA_UT_SI_U", 0x1C, NULL),
7762                 .wins   = {
7763                         .nb_flags       = NBT_NM_GROUP,
7764                         .mhomed         = False,
7765                         .num_ips        = ctx->addresses_best_num,
7766                         .ips            = ctx->addresses_best,
7767                         .apply_expected = True
7768                 },
7769                 .defend = {
7770                         .timeout        = 0,
7771                 },
7772                 .replica= {
7773                         .type           = WREPL_TYPE_UNIQUE,
7774                         .state          = WREPL_STATE_TOMBSTONE,
7775                         .node           = WREPL_NODE_B,
7776                         .is_static      = False,
7777                         .num_ips        = ctx->addresses_best_num,
7778                         .ips            = ctx->addresses_best,
7779                         .apply_expected = False
7780                 },
7781         },
7782         /*
7783          * sgroup,active vs. unique,tombstone with different ip(s), unchecked
7784          */
7785         {
7786                 .line   = __location__,
7787                 .name   = _NBT_NAME("_SA_UT_DI_U", 0x1C, NULL),
7788                 .wins   = {
7789                         .nb_flags       = NBT_NM_GROUP,
7790                         .mhomed         = False,
7791                         .num_ips        = ctx->addresses_best_num,
7792                         .ips            = ctx->addresses_best,
7793                         .apply_expected = True
7794                 },
7795                 .defend = {
7796                         .timeout        = 0,
7797                 },
7798                 .replica= {
7799                         .type           = WREPL_TYPE_UNIQUE,
7800                         .state          = WREPL_STATE_TOMBSTONE,
7801                         .node           = WREPL_NODE_B,
7802                         .is_static      = False,
7803                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7804                         .ips            = addresses_B_1,
7805                         .apply_expected = False
7806                 },
7807         },
7808 /* 
7809  * special group vs. normal group section
7810  */
7811         /*
7812          * sgroup,active vs. group,active with same ip(s), unchecked
7813          */
7814         {
7815                 .line   = __location__,
7816                 .name   = _NBT_NAME("_SA_GA_SI_U", 0x1C, NULL),
7817                 .wins   = {
7818                         .nb_flags       = NBT_NM_GROUP,
7819                         .mhomed         = False,
7820                         .num_ips        = ctx->addresses_best_num,
7821                         .ips            = ctx->addresses_best,
7822                         .apply_expected = True
7823                 },
7824                 .defend = {
7825                         .timeout        = 0,
7826                 },
7827                 .replica= {
7828                         .type           = WREPL_TYPE_GROUP,
7829                         .state          = WREPL_STATE_ACTIVE,
7830                         .node           = WREPL_NODE_B,
7831                         .is_static      = False,
7832                         .num_ips        = ctx->addresses_best_num,
7833                         .ips            = ctx->addresses_best,
7834                         .apply_expected = False
7835                 },
7836         },
7837         /*
7838          * sgroup,active vs. group,active with different ip(s), unchecked
7839          */
7840         {
7841                 .line   = __location__,
7842                 .name   = _NBT_NAME("_SA_GA_DI_U", 0x1C, NULL),
7843                 .wins   = {
7844                         .nb_flags       = NBT_NM_GROUP,
7845                         .mhomed         = False,
7846                         .num_ips        = ctx->addresses_best_num,
7847                         .ips            = ctx->addresses_best,
7848                         .apply_expected = True
7849                 },
7850                 .defend = {
7851                         .timeout        = 0,
7852                 },
7853                 .replica= {
7854                         .type           = WREPL_TYPE_GROUP,
7855                         .state          = WREPL_STATE_ACTIVE,
7856                         .node           = WREPL_NODE_B,
7857                         .is_static      = False,
7858                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7859                         .ips            = addresses_B_1,
7860                         .apply_expected = False
7861                 },
7862         },
7863         /*
7864          * sgroup,active vs. group,tombstone with same ip(s), unchecked
7865          */
7866         {
7867                 .line   = __location__,
7868                 .name   = _NBT_NAME("_SA_GT_SI_U", 0x1C, NULL),
7869                 .wins   = {
7870                         .nb_flags       = NBT_NM_GROUP,
7871                         .mhomed         = False,
7872                         .num_ips        = ctx->addresses_best_num,
7873                         .ips            = ctx->addresses_best,
7874                         .apply_expected = True
7875                 },
7876                 .defend = {
7877                         .timeout        = 0,
7878                 },
7879                 .replica= {
7880                         .type           = WREPL_TYPE_GROUP,
7881                         .state          = WREPL_STATE_TOMBSTONE,
7882                         .node           = WREPL_NODE_B,
7883                         .is_static      = False,
7884                         .num_ips        = ctx->addresses_best_num,
7885                         .ips            = ctx->addresses_best,
7886                         .apply_expected = False
7887                 },
7888         },
7889         /*
7890          * sgroup,active vs. group,tombstone with different ip(s), unchecked
7891          */
7892         {
7893                 .line   = __location__,
7894                 .name   = _NBT_NAME("_SA_GT_DI_U", 0x1C, NULL),
7895                 .wins   = {
7896                         .nb_flags       = NBT_NM_GROUP,
7897                         .mhomed         = False,
7898                         .num_ips        = ctx->addresses_best_num,
7899                         .ips            = ctx->addresses_best,
7900                         .apply_expected = True
7901                 },
7902                 .defend = {
7903                         .timeout        = 0,
7904                 },
7905                 .replica= {
7906                         .type           = WREPL_TYPE_GROUP,
7907                         .state          = WREPL_STATE_TOMBSTONE,
7908                         .node           = WREPL_NODE_B,
7909                         .is_static      = False,
7910                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7911                         .ips            = addresses_B_1,
7912                         .apply_expected = False
7913                 },
7914         },
7915 /* 
7916  * special group vs. multi homed section
7917  */
7918         /*
7919          * sgroup,active vs. mhomed,active with same ip(s), unchecked
7920          */
7921         {
7922                 .line   = __location__,
7923                 .name   = _NBT_NAME("_SA_MA_SI_U", 0x1C, NULL),
7924                 .wins   = {
7925                         .nb_flags       = NBT_NM_GROUP,
7926                         .mhomed         = False,
7927                         .num_ips        = ctx->addresses_best_num,
7928                         .ips            = ctx->addresses_best,
7929                         .apply_expected = True
7930                 },
7931                 .defend = {
7932                         .timeout        = 0,
7933                 },
7934                 .replica= {
7935                         .type           = WREPL_TYPE_MHOMED,
7936                         .state          = WREPL_STATE_ACTIVE,
7937                         .node           = WREPL_NODE_B,
7938                         .is_static      = False,
7939                         .num_ips        = ctx->addresses_best_num,
7940                         .ips            = ctx->addresses_best,
7941                         .apply_expected = False
7942                 },
7943         },
7944         /*
7945          * sgroup,active vs. mhomed,active with different ip(s), unchecked
7946          */
7947         {
7948                 .line   = __location__,
7949                 .name   = _NBT_NAME("_SA_MA_DI_U", 0x1C, NULL),
7950                 .wins   = {
7951                         .nb_flags       = NBT_NM_GROUP,
7952                         .mhomed         = False,
7953                         .num_ips        = ctx->addresses_best_num,
7954                         .ips            = ctx->addresses_best,
7955                         .apply_expected = True
7956                 },
7957                 .defend = {
7958                         .timeout        = 0,
7959                 },
7960                 .replica= {
7961                         .type           = WREPL_TYPE_MHOMED,
7962                         .state          = WREPL_STATE_ACTIVE,
7963                         .node           = WREPL_NODE_B,
7964                         .is_static      = False,
7965                         .num_ips        = ARRAY_SIZE(addresses_B_1),
7966                         .ips            = addresses_B_1,
7967                         .apply_expected = False
7968                 },
7969         },
7970         /*
7971          * sgroup,active vs. mhomed,tombstone with same ip(s), unchecked
7972          */
7973         {
7974                 .line   = __location__,
7975                 .name   = _NBT_NAME("_SA_MT_SI_U", 0x1C, NULL),
7976                 .wins   = {
7977                         .nb_flags       = NBT_NM_GROUP,
7978                         .mhomed         = False,
7979                         .num_ips        = ctx->addresses_best_num,
7980                         .ips            = ctx->addresses_best,
7981                         .apply_expected = True
7982                 },
7983                 .defend = {
7984                         .timeout        = 0,
7985                 },
7986                 .replica= {
7987                         .type           = WREPL_TYPE_MHOMED,
7988                         .state          = WREPL_STATE_TOMBSTONE,
7989                         .node           = WREPL_NODE_B,
7990                         .is_static      = False,
7991                         .num_ips        = ctx->addresses_best_num,
7992                         .ips            = ctx->addresses_best,
7993                         .apply_expected = False
7994                 },
7995         },
7996         /*
7997          * sgroup,active vs. mhomed,tombstone with different ip(s), unchecked
7998          */
7999         {
8000                 .line   = __location__,
8001                 .name   = _NBT_NAME("_SA_MT_DI_U", 0x1C, NULL),
8002                 .wins   = {
8003                         .nb_flags       = NBT_NM_GROUP,
8004                         .mhomed         = False,
8005                         .num_ips        = ctx->addresses_best_num,
8006                         .ips            = ctx->addresses_best,
8007                         .apply_expected = True
8008                 },
8009                 .defend = {
8010                         .timeout        = 0,
8011                 },
8012                 .replica= {
8013                         .type           = WREPL_TYPE_MHOMED,
8014                         .state          = WREPL_STATE_TOMBSTONE,
8015                         .node           = WREPL_NODE_B,
8016                         .is_static      = False,
8017                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8018                         .ips            = addresses_B_1,
8019                         .apply_expected = False
8020                 },
8021         },
8022 /* 
8023  * multi homed vs. unique section
8024  */
8025         /*
8026          * mhomed,active vs. unique,active with same ip(s), unchecked
8027          */
8028         {
8029                 .line   = __location__,
8030                 .name   = _NBT_NAME("_MA_UA_SI_U", 0x00, NULL),
8031                 .wins   = {
8032                         .nb_flags       = 0,
8033                         .mhomed         = True,
8034                         .num_ips        = ctx->addresses_best_num,
8035                         .ips            = ctx->addresses_best,
8036                         .apply_expected = True
8037                 },
8038                 .defend = {
8039                         .timeout        = 0,
8040                 },
8041                 .replica= {
8042                         .type           = WREPL_TYPE_UNIQUE,
8043                         .state          = WREPL_STATE_ACTIVE,
8044                         .node           = WREPL_NODE_B,
8045                         .is_static      = False,
8046                         .num_ips        = ctx->addresses_best_num,
8047                         .ips            = ctx->addresses_best,
8048                         .apply_expected = True
8049                 },
8050         },
8051         /*
8052          * mhomed,active vs. unique,active with different ip(s), positive response
8053          */
8054         {
8055                 .line   = __location__,
8056                 .name   = _NBT_NAME("_MA_UA_DI_P", 0x00, NULL),
8057                 .wins   = {
8058                         .nb_flags       = 0,
8059                         .mhomed         = True,
8060                         .num_ips        = ctx->addresses_best_num,
8061                         .ips            = ctx->addresses_best,
8062                         .apply_expected = True
8063                 },
8064                 .defend = {
8065                         .timeout        = 10,
8066                         .positive       = True,
8067                 },
8068                 .replica= {
8069                         .type           = WREPL_TYPE_UNIQUE,
8070                         .state          = WREPL_STATE_ACTIVE,
8071                         .node           = WREPL_NODE_B,
8072                         .is_static      = False,
8073                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8074                         .ips            = addresses_B_1,
8075                         .apply_expected = False
8076                 },
8077         },
8078         /*
8079          * mhomed,active vs. unique,active with different ip(s), positive response other ips
8080          */
8081         {
8082                 .line   = __location__,
8083                 .name   = _NBT_NAME("_MA_UA_DI_O", 0x00, NULL),
8084                 .wins   = {
8085                         .nb_flags       = 0,
8086                         .mhomed         = True,
8087                         .num_ips        = ctx->addresses_best_num,
8088                         .ips            = ctx->addresses_best,
8089                         .apply_expected = True
8090                 },
8091                 .defend = {
8092                         .timeout        = 10,
8093                         .positive       = True,
8094                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
8095                         .ips            = addresses_A_3_4,
8096                 },
8097                 .replica= {
8098                         .type           = WREPL_TYPE_UNIQUE,
8099                         .state          = WREPL_STATE_ACTIVE,
8100                         .node           = WREPL_NODE_B,
8101                         .is_static      = False,
8102                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8103                         .ips            = addresses_B_1,
8104                         .apply_expected = False
8105                 },
8106         },
8107         /*
8108          * mhomed,active vs. unique,active with different ip(s), negative response
8109          */
8110         {
8111                 .line   = __location__,
8112                 .name   = _NBT_NAME("_MA_UA_DI_N", 0x00, NULL),
8113                 .wins   = {
8114                         .nb_flags       = 0,
8115                         .mhomed         = True,
8116                         .num_ips        = ctx->addresses_best_num,
8117                         .ips            = ctx->addresses_best,
8118                         .apply_expected = True
8119                 },
8120                 .defend = {
8121                         .timeout        = 10,
8122                         .positive       = False,
8123                 },
8124                 .replica= {
8125                         .type           = WREPL_TYPE_UNIQUE,
8126                         .state          = WREPL_STATE_ACTIVE,
8127                         .node           = WREPL_NODE_B,
8128                         .is_static      = False,
8129                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8130                         .ips            = addresses_B_1,
8131                         .apply_expected = True
8132                 },
8133         },
8134         /*
8135          * mhomed,active vs. unique,tombstone with same ip(s), unchecked
8136          */
8137         {
8138                 .line   = __location__,
8139                 .name   = _NBT_NAME("_MA_UT_SI_U", 0x00, NULL),
8140                 .wins   = {
8141                         .nb_flags       = 0,
8142                         .mhomed         = True,
8143                         .num_ips        = ctx->addresses_best_num,
8144                         .ips            = ctx->addresses_best,
8145                         .apply_expected = True
8146                 },
8147                 .defend = {
8148                         .timeout        = 0,
8149                 },
8150                 .replica= {
8151                         .type           = WREPL_TYPE_UNIQUE,
8152                         .state          = WREPL_STATE_TOMBSTONE,
8153                         .node           = WREPL_NODE_B,
8154                         .is_static      = False,
8155                         .num_ips        = ctx->addresses_best_num,
8156                         .ips            = ctx->addresses_best,
8157                         .apply_expected = False
8158                 },
8159         },
8160         /*
8161          * mhomed,active vs. unique,tombstone with different ip(s), unchecked
8162          */
8163         {
8164                 .line   = __location__,
8165                 .name   = _NBT_NAME("_MA_UT_DI_U", 0x00, NULL),
8166                 .wins   = {
8167                         .nb_flags       = 0,
8168                         .mhomed         = True,
8169                         .num_ips        = ctx->addresses_best_num,
8170                         .ips            = ctx->addresses_best,
8171                         .apply_expected = True
8172                 },
8173                 .defend = {
8174                         .timeout        = 0,
8175                 },
8176                 .replica= {
8177                         .type           = WREPL_TYPE_UNIQUE,
8178                         .state          = WREPL_STATE_TOMBSTONE,
8179                         .node           = WREPL_NODE_B,
8180                         .is_static      = False,
8181                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8182                         .ips            = addresses_B_1,
8183                         .apply_expected = False
8184                 },
8185         },
8186 /* 
8187  * multi homed vs. normal group section
8188  */
8189         /*
8190          * mhomed,active vs. group,active with same ip(s), release expected
8191          */
8192         {
8193                 .line   = __location__,
8194                 .name   = _NBT_NAME("_MA_GA_SI_R", 0x00, NULL),
8195                 .wins   = {
8196                         .nb_flags       = 0,
8197                         .mhomed         = True,
8198                         .num_ips        = ctx->addresses_best_num,
8199                         .ips            = ctx->addresses_best,
8200                         .apply_expected = True
8201                 },
8202                 .defend = {
8203                         .timeout        = 10,
8204                         .expect_release = True,
8205                 },
8206                 .replica= {
8207                         .type           = WREPL_TYPE_GROUP,
8208                         .state          = WREPL_STATE_ACTIVE,
8209                         .node           = WREPL_NODE_B,
8210                         .is_static      = False,
8211                         .num_ips        = ctx->addresses_best_num,
8212                         .ips            = ctx->addresses_best,
8213                         .apply_expected = True
8214                 },
8215         },
8216         /*
8217          * mhomed,active vs. group,active with different ip(s), release expected
8218          */
8219         {
8220                 .line   = __location__,
8221                 .name   = _NBT_NAME("_MA_GA_DI_R", 0x00, NULL),
8222                 .wins   = {
8223                         .nb_flags       = 0,
8224                         .mhomed         = True,
8225                         .num_ips        = ctx->addresses_best_num,
8226                         .ips            = ctx->addresses_best,
8227                         .apply_expected = True
8228                 },
8229                 .defend = {
8230                         .timeout        = 10,
8231                         .expect_release = True,
8232                 },
8233                 .replica= {
8234                         .type           = WREPL_TYPE_GROUP,
8235                         .state          = WREPL_STATE_ACTIVE,
8236                         .node           = WREPL_NODE_B,
8237                         .is_static      = False,
8238                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8239                         .ips            = addresses_B_1,
8240                         .apply_expected = True
8241                 },
8242         },
8243         /*
8244          * mhomed,active vs. group,tombstone with same ip(s), unchecked
8245          */
8246         {
8247                 .line   = __location__,
8248                 .name   = _NBT_NAME("_MA_GT_SI_U", 0x00, NULL),
8249                 .wins   = {
8250                         .nb_flags       = 0,
8251                         .mhomed         = True,
8252                         .num_ips        = ctx->addresses_best_num,
8253                         .ips            = ctx->addresses_best,
8254                         .apply_expected = True
8255                 },
8256                 .defend = {
8257                         .timeout        = 0,
8258                 },
8259                 .replica= {
8260                         .type           = WREPL_TYPE_GROUP,
8261                         .state          = WREPL_STATE_TOMBSTONE,
8262                         .node           = WREPL_NODE_B,
8263                         .is_static      = False,
8264                         .num_ips        = ctx->addresses_best_num,
8265                         .ips            = ctx->addresses_best,
8266                         .apply_expected = False
8267                 },
8268         },
8269         /*
8270          * mhomed,active vs. group,tombstone with different ip(s), unchecked
8271          */
8272         {
8273                 .line   = __location__,
8274                 .name   = _NBT_NAME("_MA_GT_DI_U", 0x00, NULL),
8275                 .wins   = {
8276                         .nb_flags       = 0,
8277                         .mhomed         = True,
8278                         .num_ips        = ctx->addresses_best_num,
8279                         .ips            = ctx->addresses_best,
8280                         .apply_expected = True
8281                 },
8282                 .defend = {
8283                         .timeout        = 0,
8284                 },
8285                 .replica= {
8286                         .type           = WREPL_TYPE_GROUP,
8287                         .state          = WREPL_STATE_TOMBSTONE,
8288                         .node           = WREPL_NODE_B,
8289                         .is_static      = False,
8290                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8291                         .ips            = addresses_B_1,
8292                         .apply_expected = False
8293                 },
8294         },
8295 /* 
8296  * multi homed vs. special group section
8297  */
8298         /*
8299          * mhomed,active vs. sgroup,active with same ip(s), release expected
8300          */
8301         {
8302                 .line   = __location__,
8303                 .name   = _NBT_NAME("_MA_SA_SI_R", 0x00, NULL),
8304                 .wins   = {
8305                         .nb_flags       = 0,
8306                         .mhomed         = True,
8307                         .num_ips        = ctx->addresses_best_num,
8308                         .ips            = ctx->addresses_best,
8309                         .apply_expected = True
8310                 },
8311                 .defend = {
8312                         .timeout        = 10,
8313                         .expect_release = True,
8314                 },
8315                 .replica= {
8316                         .type           = WREPL_TYPE_SGROUP,
8317                         .state          = WREPL_STATE_ACTIVE,
8318                         .node           = WREPL_NODE_B,
8319                         .is_static      = False,
8320                         .num_ips        = ctx->addresses_best_num,
8321                         .ips            = ctx->addresses_best,
8322                         .apply_expected = True
8323                 },
8324         },
8325         /*
8326          * mhomed,active vs. group,active with different ip(s), release expected
8327          */
8328         {
8329                 .line   = __location__,
8330                 .name   = _NBT_NAME("_MA_SA_DI_R", 0x00, NULL),
8331                 .wins   = {
8332                         .nb_flags       = 0,
8333                         .mhomed         = True,
8334                         .num_ips        = ctx->addresses_best_num,
8335                         .ips            = ctx->addresses_best,
8336                         .apply_expected = True
8337                 },
8338                 .defend = {
8339                         .timeout        = 10,
8340                         .expect_release = True,
8341                 },
8342                 .replica= {
8343                         .type           = WREPL_TYPE_SGROUP,
8344                         .state          = WREPL_STATE_ACTIVE,
8345                         .node           = WREPL_NODE_B,
8346                         .is_static      = False,
8347                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8348                         .ips            = addresses_B_1,
8349                         .apply_expected = True
8350                 },
8351         },
8352         /*
8353          * mhomed,active vs. sgroup,tombstone with same ip(s), unchecked
8354          */
8355         {
8356                 .line   = __location__,
8357                 .name   = _NBT_NAME("_MA_ST_SI_U", 0x00, NULL),
8358                 .wins   = {
8359                         .nb_flags       = 0,
8360                         .mhomed         = True,
8361                         .num_ips        = ctx->addresses_best_num,
8362                         .ips            = ctx->addresses_best,
8363                         .apply_expected = True
8364                 },
8365                 .defend = {
8366                         .timeout        = 0,
8367                 },
8368                 .replica= {
8369                         .type           = WREPL_TYPE_SGROUP,
8370                         .state          = WREPL_STATE_TOMBSTONE,
8371                         .node           = WREPL_NODE_B,
8372                         .is_static      = False,
8373                         .num_ips        = ctx->addresses_best_num,
8374                         .ips            = ctx->addresses_best,
8375                         .apply_expected = False
8376                 },
8377         },
8378         /*
8379          * mhomed,active vs. sgroup,tombstone with different ip(s), unchecked
8380          */
8381         {
8382                 .line   = __location__,
8383                 .name   = _NBT_NAME("_MA_ST_DI_U", 0x00, NULL),
8384                 .wins   = {
8385                         .nb_flags       = 0,
8386                         .mhomed         = True,
8387                         .num_ips        = ctx->addresses_best_num,
8388                         .ips            = ctx->addresses_best,
8389                         .apply_expected = True
8390                 },
8391                 .defend = {
8392                         .timeout        = 0,
8393                 },
8394                 .replica= {
8395                         .type           = WREPL_TYPE_SGROUP,
8396                         .state          = WREPL_STATE_TOMBSTONE,
8397                         .node           = WREPL_NODE_B,
8398                         .is_static      = False,
8399                         .num_ips        = ARRAY_SIZE(addresses_B_1),
8400                         .ips            = addresses_B_1,
8401                         .apply_expected = False
8402                 },
8403         },
8404 /* 
8405  * multi homed vs. multi homed section
8406  */
8407         /*
8408          * mhomed,active vs. mhomed,active with same ip(s), unchecked
8409          */
8410         {
8411                 .line   = __location__,
8412                 .name   = _NBT_NAME("_MA_MA_SI_U", 0x00, NULL),
8413                 .wins   = {
8414                         .nb_flags       = 0,
8415                         .mhomed         = True,
8416                         .num_ips        = ctx->addresses_best_num,
8417                         .ips            = ctx->addresses_best,
8418                         .apply_expected = True
8419                 },
8420                 .defend = {
8421                         .timeout        = 0,
8422                 },
8423                 .replica= {
8424                         .type           = WREPL_TYPE_MHOMED,
8425                         .state          = WREPL_STATE_ACTIVE,
8426                         .node           = WREPL_NODE_B,
8427                         .is_static      = False,
8428                         .num_ips        = ctx->addresses_best_num,
8429                         .ips            = ctx->addresses_best,
8430                         .apply_expected = True
8431                 },
8432         },
8433         /*
8434          * mhomed,active vs. mhomed,active with superset ip(s), unchecked
8435          */
8436         {
8437                 .line   = __location__,
8438                 .name   = _NBT_NAME("_MA_MA_SP_U", 0x00, NULL),
8439                 .wins   = {
8440                         .nb_flags       = 0,
8441                         .mhomed         = True,
8442                         .num_ips        = ctx->addresses_best_num,
8443                         .ips            = ctx->addresses_best,
8444                         .apply_expected = True
8445                 },
8446                 .defend = {
8447                         .timeout        = 0,
8448                 },
8449                 .replica= {
8450                         .type           = WREPL_TYPE_MHOMED,
8451                         .state          = WREPL_STATE_ACTIVE,
8452                         .node           = WREPL_NODE_B,
8453                         .is_static      = False,
8454                         .num_ips        = ctx->addresses_all_num,
8455                         .ips            = ctx->addresses_all,
8456                         .apply_expected = True
8457                 },
8458         },
8459         /*
8460          * mhomed,active vs. mhomed,active with different ip(s), positive response
8461          */
8462         {
8463                 .line   = __location__,
8464                 .name   = _NBT_NAME("_MA_MA_DI_P", 0x00, NULL),
8465                 .wins   = {
8466                         .nb_flags       = 0,
8467                         .mhomed         = True,
8468                         .num_ips        = ctx->addresses_best_num,
8469                         .ips            = ctx->addresses_best,
8470                         .apply_expected = True
8471                 },
8472                 .defend = {
8473                         .timeout        = 10,
8474                         .positive       = True,
8475                 },
8476                 .replica= {
8477                         .type           = WREPL_TYPE_MHOMED,
8478                         .state          = WREPL_STATE_ACTIVE,
8479                         .node           = WREPL_NODE_B,
8480                         .is_static      = False,
8481                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8482                         .ips            = addresses_B_3_4,
8483                         .apply_expected = False
8484                 },
8485         },
8486         /*
8487          * mhomed,active vs. mhomed,active with different ip(s), positive response other ips
8488          */
8489         {
8490                 .line   = __location__,
8491                 .name   = _NBT_NAME("_MA_MA_DI_O", 0x00, NULL),
8492                 .wins   = {
8493                         .nb_flags       = 0,
8494                         .mhomed         = True,
8495                         .num_ips        = ctx->addresses_best_num,
8496                         .ips            = ctx->addresses_best,
8497                         .apply_expected = True
8498                 },
8499                 .defend = {
8500                         .timeout        = 10,
8501                         .positive       = True,
8502                         .num_ips        = ARRAY_SIZE(addresses_A_3_4),
8503                         .ips            = addresses_A_3_4,
8504                 },
8505                 .replica= {
8506                         .type           = WREPL_TYPE_MHOMED,
8507                         .state          = WREPL_STATE_ACTIVE,
8508                         .node           = WREPL_NODE_B,
8509                         .is_static      = False,
8510                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8511                         .ips            = addresses_B_3_4,
8512                         .apply_expected = False
8513                 },
8514         },
8515         /*
8516          * mhomed,active vs. mhomed,active with different ip(s), negative response
8517          */
8518         {
8519                 .line   = __location__,
8520                 .name   = _NBT_NAME("_MA_MA_DI_N", 0x00, NULL),
8521                 .wins   = {
8522                         .nb_flags       = 0,
8523                         .mhomed         = True,
8524                         .num_ips        = ctx->addresses_best_num,
8525                         .ips            = ctx->addresses_best,
8526                         .apply_expected = True
8527                 },
8528                 .defend = {
8529                         .timeout        = 10,
8530                         .positive       = False,
8531                 },
8532                 .replica= {
8533                         .type           = WREPL_TYPE_MHOMED,
8534                         .state          = WREPL_STATE_ACTIVE,
8535                         .node           = WREPL_NODE_B,
8536                         .is_static      = False,
8537                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8538                         .ips            = addresses_B_3_4,
8539                         .apply_expected = True
8540                 },
8541         },
8542         /*
8543          * mhomed,active vs. mhomed,tombstone with same ip(s), unchecked
8544          */
8545         {
8546                 .line   = __location__,
8547                 .name   = _NBT_NAME("_MA_MT_SI_U", 0x00, NULL),
8548                 .wins   = {
8549                         .nb_flags       = 0,
8550                         .mhomed         = True,
8551                         .num_ips        = ctx->addresses_best_num,
8552                         .ips            = ctx->addresses_best,
8553                         .apply_expected = True
8554                 },
8555                 .defend = {
8556                         .timeout        = 0,
8557                 },
8558                 .replica= {
8559                         .type           = WREPL_TYPE_MHOMED,
8560                         .state          = WREPL_STATE_TOMBSTONE,
8561                         .node           = WREPL_NODE_B,
8562                         .is_static      = False,
8563                         .num_ips        = ctx->addresses_best_num,
8564                         .ips            = ctx->addresses_best,
8565                         .apply_expected = False
8566                 },
8567         },
8568         /*
8569          * mhomed,active vs. mhomed,tombstone with different ip(s), unchecked
8570          */
8571         {
8572                 .line   = __location__,
8573                 .name   = _NBT_NAME("_MA_MT_DI_U", 0x00, NULL),
8574                 .wins   = {
8575                         .nb_flags       = 0,
8576                         .mhomed         = True,
8577                         .num_ips        = ctx->addresses_best_num,
8578                         .ips            = ctx->addresses_best,
8579                         .apply_expected = True
8580                 },
8581                 .defend = {
8582                         .timeout        = 0,
8583                 },
8584                 .replica= {
8585                         .type           = WREPL_TYPE_MHOMED,
8586                         .state          = WREPL_STATE_TOMBSTONE,
8587                         .node           = WREPL_NODE_B,
8588                         .is_static      = False,
8589                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8590                         .ips            = addresses_B_3_4,
8591                         .apply_expected = False
8592                 },
8593         },
8594 /*
8595  * some more multi homed test, including merging
8596  */
8597         /*
8598          * mhomed,active vs. mhomed,active with superset ip(s), unchecked
8599          */
8600         {
8601                 .line   = __location__,
8602                 .section= "Test Replica vs. owned active: some more MHOMED combinations",
8603                 .name   = _NBT_NAME("_MA_MA_SP_U", 0x00, NULL),
8604                 .comment= "C:MHOMED vs. B:ALL => B:ALL",
8605                 .skip   = (ctx->addresses_all_num < 3),
8606                 .wins   = {
8607                         .nb_flags       = 0,
8608                         .mhomed         = True,
8609                         .num_ips        = ctx->addresses_mhomed_num,
8610                         .ips            = ctx->addresses_mhomed,
8611                         .apply_expected = True
8612                 },
8613                 .defend = {
8614                         .timeout        = 0,
8615                 },
8616                 .replica= {
8617                         .type           = WREPL_TYPE_MHOMED,
8618                         .state          = WREPL_STATE_ACTIVE,
8619                         .node           = WREPL_NODE_B,
8620                         .is_static      = False,
8621                         .num_ips        = ctx->addresses_all_num,
8622                         .ips            = ctx->addresses_all,
8623                         .apply_expected = True
8624                 },
8625         },
8626         /*
8627          * mhomed,active vs. mhomed,active with same ips, unchecked
8628          */
8629         {
8630                 .line   = __location__,
8631                 .name   = _NBT_NAME("_MA_MA_SM_U", 0x00, NULL),
8632                 .comment= "C:MHOMED vs. B:MHOMED => B:MHOMED",
8633                 .skip   = (ctx->addresses_mhomed_num < 2),
8634                 .wins   = {
8635                         .nb_flags       = 0,
8636                         .mhomed         = True,
8637                         .num_ips        = ctx->addresses_mhomed_num,
8638                         .ips            = ctx->addresses_mhomed,
8639                         .apply_expected = True
8640                 },
8641                 .defend = {
8642                         .timeout        = 0,
8643                 },
8644                 .replica= {
8645                         .type           = WREPL_TYPE_MHOMED,
8646                         .state          = WREPL_STATE_ACTIVE,
8647                         .node           = WREPL_NODE_B,
8648                         .is_static      = False,
8649                         .num_ips        = ctx->addresses_mhomed_num,
8650                         .ips            = ctx->addresses_mhomed,
8651                         .apply_expected = True
8652                 },
8653         },
8654         /*
8655          * mhomed,active vs. mhomed,active with subset ip(s), positive response
8656          */
8657         {
8658                 .line   = __location__,
8659                 .name   = _NBT_NAME("_MA_MA_SB_P", 0x00, NULL),
8660                 .comment= "C:MHOMED vs. B:BEST (C:MHOMED) => B:MHOMED",
8661                 .skip   = (ctx->addresses_mhomed_num < 2),
8662                 .wins   = {
8663                         .nb_flags       = 0,
8664                         .mhomed         = True,
8665                         .num_ips        = ctx->addresses_mhomed_num,
8666                         .ips            = ctx->addresses_mhomed,
8667                         .apply_expected = True
8668                 },
8669                 .defend = {
8670                         .timeout        = 10,
8671                         .positive       = True
8672                 },
8673                 .replica= {
8674                         .type           = WREPL_TYPE_MHOMED,
8675                         .state          = WREPL_STATE_ACTIVE,
8676                         .node           = WREPL_NODE_B,
8677                         .is_static      = False,
8678                         .num_ips        = ctx->addresses_best_num,
8679                         .ips            = ctx->addresses_best,
8680                         .mhomed_merge   = True
8681                 },
8682         },
8683         /*
8684          * mhomed,active vs. mhomed,active with subset ip(s), positive response, with all addresses
8685          */
8686         {
8687                 .line   = __location__,
8688                 .name   = _NBT_NAME("_MA_MA_SB_A", 0x00, NULL),
8689                 .comment= "C:MHOMED vs. B:BEST (C:ALL) => B:MHOMED",
8690                 .skip   = (ctx->addresses_all_num < 3),
8691                 .wins   = {
8692                         .nb_flags       = 0,
8693                         .mhomed         = True,
8694                         .num_ips        = ctx->addresses_mhomed_num,
8695                         .ips            = ctx->addresses_mhomed,
8696                         .apply_expected = True
8697                 },
8698                 .defend = {
8699                         .timeout        = 10,
8700                         .positive       = True,
8701                         .num_ips        = ctx->addresses_all_num,
8702                         .ips            = ctx->addresses_all,
8703                 },
8704                 .replica= {
8705                         .type           = WREPL_TYPE_MHOMED,
8706                         .state          = WREPL_STATE_ACTIVE,
8707                         .node           = WREPL_NODE_B,
8708                         .is_static      = False,
8709                         .num_ips        = ctx->addresses_best_num,
8710                         .ips            = ctx->addresses_best,
8711                         .mhomed_merge   = True
8712                 },
8713         },
8714         /*
8715          * mhomed,active vs. mhomed,active with subset ip(s), positive response, with replicas addresses
8716          * TODO: check why the server sends a name release demand for one address?
8717          *       the release demand has no effect to the database record...
8718          */
8719         {
8720                 .line   = __location__,
8721                 .name   = _NBT_NAME("_MA_MA_SB_PRA", 0x00, NULL),
8722                 .comment= "C:MHOMED vs. B:BEST (C:BEST) => C:MHOMED",
8723                 .skip   = (ctx->addresses_all_num < 2),
8724                 .wins   = {
8725                         .nb_flags       = 0,
8726                         .mhomed         = True,
8727                         .num_ips        = ctx->addresses_mhomed_num,
8728                         .ips            = ctx->addresses_mhomed,
8729                         .apply_expected = True
8730                 },
8731                 .defend = {
8732                         .timeout        = 10,
8733                         .positive       = True,
8734                         .num_ips        = ctx->addresses_best_num,
8735                         .ips            = ctx->addresses_best,
8736                         .late_release   = True
8737                 },
8738                 .replica= {
8739                         .type           = WREPL_TYPE_MHOMED,
8740                         .state          = WREPL_STATE_ACTIVE,
8741                         .node           = WREPL_NODE_B,
8742                         .is_static      = False,
8743                         .num_ips        = ctx->addresses_best_num,
8744                         .ips            = ctx->addresses_best,
8745                         .apply_expected = False
8746                 },
8747         },
8748         /*
8749          * mhomed,active vs. mhomed,active with subset ip(s), positive response, with other addresses
8750          */
8751         {
8752                 .line   = __location__,
8753                 .name   = _NBT_NAME("_MA_MA_SB_O", 0x00, NULL),
8754                 .comment= "C:MHOMED vs. B:BEST (B:B_3_4) =>C:MHOMED",
8755                 .skip   = (ctx->addresses_all_num < 2),
8756                 .wins   = {
8757                         .nb_flags       = 0,
8758                         .mhomed         = True,
8759                         .num_ips        = ctx->addresses_mhomed_num,
8760                         .ips            = ctx->addresses_mhomed,
8761                         .apply_expected = True
8762                 },
8763                 .defend = {
8764                         .timeout        = 10,
8765                         .positive       = True,
8766                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8767                         .ips            = addresses_B_3_4,
8768                 },
8769                 .replica= {
8770                         .type           = WREPL_TYPE_MHOMED,
8771                         .state          = WREPL_STATE_ACTIVE,
8772                         .node           = WREPL_NODE_B,
8773                         .is_static      = False,
8774                         .num_ips        = ctx->addresses_best_num,
8775                         .ips            = ctx->addresses_best,
8776                         .apply_expected = False
8777                 },
8778         },
8779         /*
8780          * mhomed,active vs. mhomed,active with subset ip(s), negative response
8781          */
8782         {
8783                 .line   = __location__,
8784                 .name   = _NBT_NAME("_MA_MA_SB_N", 0x00, NULL),
8785                 .comment= "C:MHOMED vs. B:BEST (NEGATIVE) => B:BEST",
8786                 .skip   = (ctx->addresses_mhomed_num < 2),
8787                 .wins   = {
8788                         .nb_flags       = 0,
8789                         .mhomed         = True,
8790                         .num_ips        = ctx->addresses_mhomed_num,
8791                         .ips            = ctx->addresses_mhomed,
8792                         .apply_expected = True
8793                 },
8794                 .defend = {
8795                         .timeout        = 10,
8796                         .positive       = False
8797                 },
8798                 .replica= {
8799                         .type           = WREPL_TYPE_MHOMED,
8800                         .state          = WREPL_STATE_ACTIVE,
8801                         .node           = WREPL_NODE_B,
8802                         .is_static      = False,
8803                         .num_ips        = ctx->addresses_best_num,
8804                         .ips            = ctx->addresses_best,
8805                         .apply_expected = True
8806                 },
8807         },
8808 /*
8809  * some more multi homed and unique test, including merging
8810  */
8811         /*
8812          * mhomed,active vs. unique,active with subset ip(s), positive response
8813          */
8814         {
8815                 .line   = __location__,
8816                 .section= "Test Replica vs. owned active: some more UNIQUE,MHOMED combinations",
8817                 .name   = _NBT_NAME("_MA_UA_SB_P", 0x00, NULL),
8818                 .comment= "C:MHOMED vs. B:UNIQUE,BEST (C:MHOMED) => B:MHOMED",
8819                 .skip   = (ctx->addresses_all_num < 2),
8820                 .wins   = {
8821                         .nb_flags       = 0,
8822                         .mhomed         = True,
8823                         .num_ips        = ctx->addresses_mhomed_num,
8824                         .ips            = ctx->addresses_mhomed,
8825                         .apply_expected = True
8826                 },
8827                 .defend = {
8828                         .timeout        = 10,
8829                         .positive       = True,
8830                 },
8831                 .replica= {
8832                         .type           = WREPL_TYPE_UNIQUE,
8833                         .state          = WREPL_STATE_ACTIVE,
8834                         .node           = WREPL_NODE_B,
8835                         .is_static      = False,
8836                         .num_ips        = ctx->addresses_best_num,
8837                         .ips            = ctx->addresses_best,
8838                         .mhomed_merge   = True
8839                 },
8840         },
8841         /*
8842          * unique,active vs. unique,active with different ip(s), positive response, with replicas address
8843          * TODO: check why the server sends a name release demand for one address?
8844          *       the release demand has no effect to the database record...
8845          */
8846         {
8847                 .line   = __location__,
8848                 .name   = _NBT_NAME("_UA_UA_DI_PRA", 0x00, NULL),
8849                 .comment= "C:BEST vs. B:BEST2 (C:BEST2,LR:BEST2) => C:BEST",
8850                 .skip   = (ctx->addresses_all_num < 2),
8851                 .wins   = {
8852                         .nb_flags       = 0,
8853                         .mhomed         = False,
8854                         .num_ips        = ctx->addresses_best_num,
8855                         .ips            = ctx->addresses_best,
8856                         .apply_expected = True
8857                 },
8858                 .defend = {
8859                         .timeout        = 10,
8860                         .positive       = True,
8861                         .num_ips        = ctx->addresses_best2_num,
8862                         .ips            = ctx->addresses_best2,
8863                         .late_release   = True
8864                 },
8865                 .replica= {
8866                         .type           = WREPL_TYPE_UNIQUE,
8867                         .state          = WREPL_STATE_ACTIVE,
8868                         .node           = WREPL_NODE_B,
8869                         .is_static      = False,
8870                         .num_ips        = ctx->addresses_best2_num,
8871                         .ips            = ctx->addresses_best2,
8872                         .apply_expected = False,
8873                 },
8874         },
8875         /*
8876          * unique,active vs. unique,active with different ip(s), positive response, with all addresses
8877          */
8878         {
8879                 .line   = __location__,
8880                 .name   = _NBT_NAME("_UA_UA_DI_A", 0x00, NULL),
8881                 .comment= "C:BEST vs. B:BEST2 (C:ALL) => B:MHOMED",
8882                 .skip   = (ctx->addresses_all_num < 3),
8883                 .wins   = {
8884                         .nb_flags       = 0,
8885                         .mhomed         = False,
8886                         .num_ips        = ctx->addresses_best_num,
8887                         .ips            = ctx->addresses_best,
8888                         .apply_expected = True
8889                 },
8890                 .defend = {
8891                         .timeout        = 10,
8892                         .positive       = True,
8893                         .num_ips        = ctx->addresses_all_num,
8894                         .ips            = ctx->addresses_all,
8895                 },
8896                 .replica= {
8897                         .type           = WREPL_TYPE_UNIQUE,
8898                         .state          = WREPL_STATE_ACTIVE,
8899                         .node           = WREPL_NODE_B,
8900                         .is_static      = False,
8901                         .num_ips        = ctx->addresses_best2_num,
8902                         .ips            = ctx->addresses_best2,
8903                         .mhomed_merge   = True,
8904                 },
8905         },
8906         /*
8907          * unique,active vs. mhomed,active with different ip(s), positive response, with all addresses
8908          */
8909         {
8910                 .line   = __location__,
8911                 .name   = _NBT_NAME("_UA_MA_DI_A", 0x00, NULL),
8912                 .comment= "C:BEST vs. B:BEST2 (C:ALL) => B:MHOMED",
8913                 .skip   = (ctx->addresses_all_num < 3),
8914                 .wins   = {
8915                         .nb_flags       = 0,
8916                         .mhomed         = False,
8917                         .num_ips        = ctx->addresses_best_num,
8918                         .ips            = ctx->addresses_best,
8919                         .apply_expected = True
8920                 },
8921                 .defend = {
8922                         .timeout        = 10,
8923                         .positive       = True,
8924                         .num_ips        = ctx->addresses_all_num,
8925                         .ips            = ctx->addresses_all,
8926                 },
8927                 .replica= {
8928                         .type           = WREPL_TYPE_MHOMED,
8929                         .state          = WREPL_STATE_ACTIVE,
8930                         .node           = WREPL_NODE_B,
8931                         .is_static      = False,
8932                         .num_ips        = ctx->addresses_best2_num,
8933                         .ips            = ctx->addresses_best2,
8934                         .mhomed_merge   = True,
8935                 },
8936         },
8937 /*
8938  * special group vs. special group merging section
8939  */
8940         /*
8941          * sgroup,active vs. sgroup,active with different ip(s)
8942          */
8943         {
8944                 .line   = __location__,
8945                 .section= "Test Replica vs. owned active: SGROUP vs. SGROUP tests",
8946                 .name   = _NBT_NAME("_SA_SA_DI_U", 0x1C, NULL),
8947                 .skip   = (ctx->addresses_all_num < 3),
8948                 .wins   = {
8949                         .nb_flags       = NBT_NM_GROUP,
8950                         .mhomed         = False,
8951                         .num_ips        = ctx->addresses_mhomed_num,
8952                         .ips            = ctx->addresses_mhomed,
8953                         .apply_expected = True
8954                 },
8955                 .defend = {
8956                         .timeout        = 0,
8957                 },
8958                 .replica= {
8959                         .type           = WREPL_TYPE_SGROUP,
8960                         .state          = WREPL_STATE_ACTIVE,
8961                         .node           = WREPL_NODE_B,
8962                         .is_static      = False,
8963                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
8964                         .ips            = addresses_B_3_4,
8965                         .sgroup_merge   = True
8966                 },
8967         },
8968         /*
8969          * sgroup,active vs. sgroup,active with same ip(s)
8970          */
8971         {
8972                 .line   = __location__,
8973                 .name   = _NBT_NAME("_SA_SA_SI_U", 0x1C, NULL),
8974                 .skip   = (ctx->addresses_all_num < 3),
8975                 .wins   = {
8976                         .nb_flags       = NBT_NM_GROUP,
8977                         .mhomed         = False,
8978                         .num_ips        = ctx->addresses_mhomed_num,
8979                         .ips            = ctx->addresses_mhomed,
8980                         .apply_expected = True
8981                 },
8982                 .defend = {
8983                         .timeout        = 0,
8984                 },
8985                 .replica= {
8986                         .type           = WREPL_TYPE_SGROUP,
8987                         .state          = WREPL_STATE_ACTIVE,
8988                         .node           = WREPL_NODE_B,
8989                         .is_static      = False,
8990                         .num_ips        = ctx->addresses_mhomed_num,
8991                         .ips            = ctx->addresses_mhomed,
8992                         .sgroup_merge   = True
8993                 },
8994         },
8995         /*
8996          * sgroup,active vs. sgroup,active with superset ip(s)
8997          */
8998         {
8999                 .line   = __location__,
9000                 .name   = _NBT_NAME("_SA_SA_SP_U", 0x1C, NULL),
9001                 .skip   = (ctx->addresses_all_num < 3),
9002                 .wins   = {
9003                         .nb_flags       = NBT_NM_GROUP,
9004                         .mhomed         = False,
9005                         .num_ips        = ctx->addresses_mhomed_num,
9006                         .ips            = ctx->addresses_mhomed,
9007                         .apply_expected = True
9008                 },
9009                 .defend = {
9010                         .timeout        = 0,
9011                 },
9012                 .replica= {
9013                         .type           = WREPL_TYPE_SGROUP,
9014                         .state          = WREPL_STATE_ACTIVE,
9015                         .node           = WREPL_NODE_B,
9016                         .is_static      = False,
9017                         .num_ips        = ctx->addresses_all_num,
9018                         .ips            = ctx->addresses_all,
9019                         .sgroup_merge   = True
9020                 },
9021         },
9022         /*
9023          * sgroup,active vs. sgroup,active with subset ip(s)
9024          */
9025         {
9026                 .line   = __location__,
9027                 .name   = _NBT_NAME("_SA_SA_SB_U", 0x1C, NULL),
9028                 .skip   = (ctx->addresses_all_num < 3),
9029                 .wins   = {
9030                         .nb_flags       = NBT_NM_GROUP,
9031                         .mhomed         = False,
9032                         .num_ips        = ctx->addresses_mhomed_num,
9033                         .ips            = ctx->addresses_mhomed,
9034                         .apply_expected = True
9035                 },
9036                 .defend = {
9037                         .timeout        = 0,
9038                 },
9039                 .replica= {
9040                         .type           = WREPL_TYPE_SGROUP,
9041                         .state          = WREPL_STATE_ACTIVE,
9042                         .node           = WREPL_NODE_B,
9043                         .is_static      = False,
9044                         .num_ips        = ctx->addresses_best_num,
9045                         .ips            = ctx->addresses_best,
9046                         .sgroup_merge   = True
9047                 },
9048         },
9049         /*
9050          * sgroup,active vs. sgroup,tombstone with different ip(s)
9051          */
9052         {
9053                 .line   = __location__,
9054                 .name   = _NBT_NAME("_SA_ST_DI_U", 0x1C, NULL),
9055                 .skip   = (ctx->addresses_all_num < 3),
9056                 .wins   = {
9057                         .nb_flags       = NBT_NM_GROUP,
9058                         .mhomed         = False,
9059                         .num_ips        = ctx->addresses_mhomed_num,
9060                         .ips            = ctx->addresses_mhomed,
9061                         .apply_expected = True
9062                 },
9063                 .defend = {
9064                         .timeout        = 0,
9065                 },
9066                 .replica= {
9067                         .type           = WREPL_TYPE_SGROUP,
9068                         .state          = WREPL_STATE_TOMBSTONE,
9069                         .node           = WREPL_NODE_B,
9070                         .is_static      = False,
9071                         .num_ips        = ARRAY_SIZE(addresses_B_3_4),
9072                         .ips            = addresses_B_3_4,
9073                         .apply_expected = False
9074                 },
9075         },
9076         /*
9077          * sgroup,active vs. sgroup,tombstone with same ip(s)
9078          */
9079         {
9080                 .line   = __location__,
9081                 .name   = _NBT_NAME("_SA_ST_SI_U", 0x1C, NULL),
9082                 .skip   = (ctx->addresses_all_num < 3),
9083                 .wins   = {
9084                         .nb_flags       = NBT_NM_GROUP,
9085                         .mhomed         = False,
9086                         .num_ips        = ctx->addresses_mhomed_num,
9087                         .ips            = ctx->addresses_mhomed,
9088                         .apply_expected = True
9089                 },
9090                 .defend = {
9091                         .timeout        = 0,
9092                 },
9093                 .replica= {
9094                         .type           = WREPL_TYPE_SGROUP,
9095                         .state          = WREPL_STATE_TOMBSTONE,
9096                         .node           = WREPL_NODE_B,
9097                         .is_static      = False,
9098                         .num_ips        = ctx->addresses_mhomed_num,
9099                         .ips            = ctx->addresses_mhomed,
9100                         .apply_expected = False
9101                 },
9102         },
9103         /*
9104          * sgroup,active vs. sgroup,tombstone with superset ip(s)
9105          */
9106         {
9107                 .line   = __location__,
9108                 .name   = _NBT_NAME("_SA_ST_SP_U", 0x1C, NULL),
9109                 .skip   = (ctx->addresses_all_num < 3),
9110                 .wins   = {
9111                         .nb_flags       = NBT_NM_GROUP,
9112                         .mhomed         = False,
9113                         .num_ips        = ctx->addresses_mhomed_num,
9114                         .ips            = ctx->addresses_mhomed,
9115                         .apply_expected = True
9116                 },
9117                 .defend = {
9118                         .timeout        = 0,
9119                 },
9120                 .replica= {
9121                         .type           = WREPL_TYPE_SGROUP,
9122                         .state          = WREPL_STATE_TOMBSTONE,
9123                         .node           = WREPL_NODE_B,
9124                         .is_static      = False,
9125                         .num_ips        = ctx->addresses_all_num,
9126                         .ips            = ctx->addresses_all,
9127                         .apply_expected = False
9128                 },
9129         },
9130         /*
9131          * sgroup,active vs. sgroup,tombstone with subset ip(s)
9132          */
9133         {
9134                 .line   = __location__,
9135                 .name   = _NBT_NAME("_SA_ST_SB_U", 0x1C, NULL),
9136                 .skip   = (ctx->addresses_all_num < 3),
9137                 .wins   = {
9138                         .nb_flags       = NBT_NM_GROUP,
9139                         .mhomed         = False,
9140                         .num_ips        = ctx->addresses_mhomed_num,
9141                         .ips            = ctx->addresses_mhomed,
9142                         .apply_expected = True
9143                 },
9144                 .defend = {
9145                         .timeout        = 0,
9146                 },
9147                 .replica= {
9148                         .type           = WREPL_TYPE_SGROUP,
9149                         .state          = WREPL_STATE_TOMBSTONE,
9150                         .node           = WREPL_NODE_B,
9151                         .is_static      = False,
9152                         .num_ips        = ctx->addresses_best_num,
9153                         .ips            = ctx->addresses_best,
9154                         .apply_expected = False
9155                 },
9156         },
9157         };
9158
9159         if (!ctx->nbtsock_srv) {
9160                 printf("SKIP: Test Replica records vs. owned active records: not bound to port[%d]\n",
9161                         lp_nbt_port());
9162                 return True;
9163         }
9164
9165         printf("Test Replica records vs. owned active records\n");
9166
9167         for(i=0; ret && i < ARRAY_SIZE(records); i++) {
9168                 struct timeval end;
9169                 struct test_conflict_owned_active_vs_replica_struct record = records[i];
9170                 uint32_t j, count = 1;
9171                 const char *action;
9172
9173                 if (records[i].wins.mhomed || records[i].name.type == 0x1C) {
9174                         count = records[i].wins.num_ips;
9175                 }
9176
9177                 if (records[i].section) {
9178                         printf("%s\n", records[i].section);
9179                 }
9180
9181                 if (records[i].skip) {
9182                         printf("%s => SKIPPED\n", nbt_name_string(ctx, &records[i].name));
9183                         continue;
9184                 }
9185
9186                 if (records[i].replica.mhomed_merge) {
9187                         action = "MHOMED_MERGE";
9188                 } else if (records[i].replica.sgroup_merge) {
9189                         action = "SGROUP_MERGE";
9190                 } else if (records[i].replica.apply_expected) {
9191                         action = "REPLACE";
9192                 } else {
9193                         action = "NOT REPLACE";
9194                 }
9195
9196                 printf("%s%s%s => %s\n",
9197                         nbt_name_string(ctx, &records[i].name),
9198                         (records[i].comment?": ":""),
9199                         (records[i].comment?records[i].comment:""),
9200                         action);
9201
9202                 /* Prepare for multi homed registration */
9203                 ZERO_STRUCT(records[i].defend);
9204                 records[i].defend.timeout       = 10;
9205                 records[i].defend.positive      = True;
9206                 nbt_set_incoming_handler(ctx->nbtsock_srv,
9207                                          test_conflict_owned_active_vs_replica_handler,
9208                                          &records[i]);
9209                 if (ctx->nbtsock_srv2) {
9210                         nbt_set_incoming_handler(ctx->nbtsock_srv2,
9211                                                  test_conflict_owned_active_vs_replica_handler,
9212                                                  &records[i]);
9213                 }
9214
9215                 /*
9216                  * Setup Register
9217                  */
9218                 for (j=0; j < count; j++) {
9219                         struct nbt_name_request *req;
9220
9221                         name_register->in.name          = records[i].name;
9222                         name_register->in.dest_addr     = ctx->address;
9223                         name_register->in.address       = records[i].wins.ips[j].ip;
9224                         name_register->in.nb_flags      = records[i].wins.nb_flags;
9225                         name_register->in.register_demand= False;
9226                         name_register->in.broadcast     = False;
9227                         name_register->in.multi_homed   = records[i].wins.mhomed;
9228                         name_register->in.ttl           = 300000;
9229                         name_register->in.timeout       = 70;
9230                         name_register->in.retries       = 0;
9231
9232                         req = nbt_name_register_send(ctx->nbtsock, name_register);
9233
9234                         /* push the request on the wire */
9235                         event_loop_once(ctx->nbtsock->event_ctx);
9236
9237                         /*
9238                          * if we register multiple addresses,
9239                          * the server will do name queries to see if the old addresses
9240                          * are still alive
9241                          */
9242                         if (records[i].wins.mhomed && j > 0) {
9243                                 end = timeval_current_ofs(records[i].defend.timeout,0);
9244                                 records[i].defend.ret = True;
9245                                 while (records[i].defend.timeout > 0) {
9246                                         event_loop_once(ctx->nbtsock_srv->event_ctx);
9247                                         if (timeval_expired(&end)) break;
9248                                 }
9249                                 ret &= records[i].defend.ret;
9250                         }
9251
9252                         status = nbt_name_register_recv(req, ctx, name_register);
9253                         if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
9254                                 printf("No response from %s for name register\n", ctx->address);
9255                                 ret = False;
9256                         }
9257                         if (!NT_STATUS_IS_OK(status)) {
9258                                 printf("Bad response from %s for name register - %s\n",
9259                                        ctx->address, nt_errstr(status));
9260                                 ret = False;
9261                         }
9262                         CHECK_VALUE(name_register->out.rcode, 0);
9263                         CHECK_VALUE_STRING(name_register->out.reply_from, ctx->address);
9264                         CHECK_VALUE(name_register->out.name.type, records[i].name.type);
9265                         CHECK_VALUE_STRING(name_register->out.name.name, records[i].name.name);
9266                         CHECK_VALUE_STRING(name_register->out.name.scope, records[i].name.scope);
9267                         CHECK_VALUE_STRING(name_register->out.reply_addr, records[i].wins.ips[j].ip);
9268                 }
9269
9270                 /* Prepare for the current test */
9271                 records[i].defend = record.defend;
9272                 nbt_set_incoming_handler(ctx->nbtsock_srv,
9273                                          test_conflict_owned_active_vs_replica_handler,
9274                                          &records[i]);
9275                 if (ctx->nbtsock_srv2) {
9276                         nbt_set_incoming_handler(ctx->nbtsock_srv2,
9277                                                  test_conflict_owned_active_vs_replica_handler,
9278                                                  &records[i]);
9279                 }
9280
9281                 /*
9282                  * Setup Replica
9283                  */
9284                 wins_name->name         = &records[i].name;
9285                 wins_name->flags        = WREPL_NAME_FLAGS(records[i].replica.type,
9286                                                            records[i].replica.state,
9287                                                            records[i].replica.node,
9288                                                            records[i].replica.is_static);
9289                 wins_name->id           = ++ctx->b.max_version;
9290                 if (wins_name->flags & 2) {
9291                         wins_name->addresses.addresses.num_ips = records[i].replica.num_ips;
9292                         wins_name->addresses.addresses.ips     = discard_const(records[i].replica.ips);
9293                 } else {
9294                         wins_name->addresses.ip = records[i].replica.ips[0].ip;
9295                 }
9296                 wins_name->unknown      = "255.255.255.255";
9297
9298                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
9299
9300                 /*
9301                  * wait for the name query, which is handled in
9302                  * test_conflict_owned_active_vs_replica_handler()
9303                  */
9304                 end = timeval_current_ofs(records[i].defend.timeout,0);
9305                 records[i].defend.ret = True;
9306                 while (records[i].defend.timeout > 0) {
9307                         event_loop_once(ctx->nbtsock_srv->event_ctx);
9308                         if (timeval_expired(&end)) break;
9309                 }
9310                 ret &= records[i].defend.ret;
9311
9312                 if (records[i].defend.late_release) {
9313                         records[i].defend = record.defend;
9314                         records[i].defend.expect_release = True;
9315                         /*
9316                          * wait for the name release demand, which is handled in
9317                          * test_conflict_owned_active_vs_replica_handler()
9318                          */
9319                         end = timeval_current_ofs(records[i].defend.timeout,0);
9320                         records[i].defend.ret = True;
9321                         while (records[i].defend.timeout > 0) {
9322                                 event_loop_once(ctx->nbtsock_srv->event_ctx);
9323                                 if (timeval_expired(&end)) break;
9324                         }
9325                         ret &= records[i].defend.ret;
9326                 }
9327
9328                 if (records[i].replica.mhomed_merge) {
9329                         ret &= test_wrepl_mhomed_merged(ctx, &ctx->c,
9330                                                         records[i].wins.num_ips, records[i].wins.ips,
9331                                                         &ctx->b,
9332                                                         records[i].replica.num_ips, records[i].replica.ips,
9333                                                         wins_name);
9334                 } else if (records[i].replica.sgroup_merge) {
9335                         ret &= test_wrepl_sgroup_merged(ctx, NULL,
9336                                                         &ctx->c,
9337                                                         records[i].wins.num_ips, records[i].wins.ips,
9338                                                         &ctx->b,
9339                                                         records[i].replica.num_ips, records[i].replica.ips,
9340                                                         wins_name);
9341                 } else {
9342                         ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name,
9343                                                      records[i].replica.apply_expected);
9344                 }
9345
9346                 if (records[i].replica.apply_expected ||
9347                     records[i].replica.mhomed_merge) {
9348                         wins_name->name         = &records[i].name;
9349                         wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_UNIQUE,
9350                                                                    WREPL_STATE_TOMBSTONE,
9351                                                                    WREPL_NODE_B, False);
9352                         wins_name->id           = ++ctx->b.max_version;
9353                         wins_name->addresses.ip = addresses_B_1[0].ip;
9354                         wins_name->unknown      = "255.255.255.255";
9355
9356                         ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
9357                         ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True);
9358                 } else {
9359                         for (j=0; j < count; j++) {
9360                                 struct nbt_name_socket *nbtsock = ctx->nbtsock;
9361
9362                                 if (ctx->myaddr2 && strcmp(records[i].wins.ips[j].ip, ctx->myaddr2->addr) == 0) {
9363                                         nbtsock = ctx->nbtsock2;
9364                                 }
9365
9366                                 release->in.name        = records[i].name;
9367                                 release->in.dest_addr   = ctx->address;
9368                                 release->in.address     = records[i].wins.ips[j].ip;
9369                                 release->in.nb_flags    = records[i].wins.nb_flags;
9370                                 release->in.broadcast   = False;
9371                                 release->in.timeout     = 30;
9372                                 release->in.retries     = 0;
9373
9374                                 status = nbt_name_release(nbtsock, ctx, release);
9375                                 if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
9376                                         printf("No response from %s for name release\n", ctx->address);
9377                                         return False;
9378                                 }
9379                                 if (!NT_STATUS_IS_OK(status)) {
9380                                         printf("Bad response from %s for name query - %s\n",
9381                                                ctx->address, nt_errstr(status));
9382                                         return False;
9383                                 }
9384                                 CHECK_VALUE(release->out.rcode, 0);
9385                         }
9386
9387                         if (records[i].replica.sgroup_merge) {
9388                                 /* clean up the SGROUP record */
9389                                 wins_name->name         = &records[i].name;
9390                                 wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP,
9391                                                                            WREPL_STATE_ACTIVE,
9392                                                                            WREPL_NODE_B, False);
9393                                 wins_name->id           = ++ctx->b.max_version;
9394                                 wins_name->addresses.addresses.num_ips = 0;
9395                                 wins_name->addresses.addresses.ips     = NULL;
9396                                 wins_name->unknown      = "255.255.255.255";
9397                                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
9398
9399                                 /* take ownership of the SGROUP record */
9400                                 wins_name->name         = &records[i].name;
9401                                 wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP,
9402                                                                            WREPL_STATE_ACTIVE,
9403                                                                            WREPL_NODE_B, False);
9404                                 wins_name->id           = ++ctx->b.max_version;
9405                                 wins_name->addresses.addresses.num_ips = ARRAY_SIZE(addresses_B_1);
9406                                 wins_name->addresses.addresses.ips     = discard_const(addresses_B_1);
9407                                 wins_name->unknown      = "255.255.255.255";
9408                                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
9409                                 ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True);
9410
9411                                 /* overwrite the SGROUP record with unique,tombstone */
9412                                 wins_name->name         = &records[i].name;
9413                                 wins_name->flags        = WREPL_NAME_FLAGS(WREPL_TYPE_UNIQUE,
9414                                                                            WREPL_STATE_TOMBSTONE,
9415                                                                            WREPL_NODE_B, False);
9416                                 wins_name->id           = ++ctx->b.max_version;
9417                                 wins_name->addresses.ip = addresses_A_1[0].ip;
9418                                 wins_name->unknown      = "255.255.255.255";
9419                                 ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name);
9420                                 ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True);
9421                         }
9422                 }
9423
9424 done:
9425                 if (!ret) {
9426                         printf("conflict handled wrong or record[%u]: %s\n", i, records[i].line);
9427                         return ret;
9428                 }
9429         }
9430
9431         return ret;
9432 }
9433
9434 #define _NBT_ASSERT(v, correct) do { \
9435         if ((v) != (correct)) { \
9436                 printf("(%s) Incorrect value %s=%d - should be %s (%d)\n", \
9437                        __location__, #v, v, #correct, correct); \
9438                 return; \
9439         } \
9440 } while (0)
9441
9442 #define _NBT_ASSERT_STRING(v, correct) do { \
9443         if ( ((!v) && (correct)) || \
9444              ((v) && (!correct)) || \
9445              ((v) && (correct) && strcmp(v,correct) != 0)) { \
9446                 printf("(%s) Incorrect value %s=%s - should be %s\n", \
9447                        __location__, #v, v, correct); \
9448                 return; \
9449         } \
9450 } while (0)
9451
9452 static void test_conflict_owned_active_vs_replica_handler_query(struct nbt_name_socket *nbtsock, 
9453                                                                 struct nbt_name_packet *req_packet, 
9454                                                                 struct socket_address *src)
9455 {
9456         struct nbt_name *name;
9457         struct nbt_name_packet *rep_packet;
9458         struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private;
9459
9460         _NBT_ASSERT(req_packet->qdcount, 1);
9461         _NBT_ASSERT(req_packet->questions[0].question_type, NBT_QTYPE_NETBIOS);
9462         _NBT_ASSERT(req_packet->questions[0].question_class, NBT_QCLASS_IP);
9463
9464         name = &req_packet->questions[0].name;
9465
9466         _NBT_ASSERT(name->type, rec->name.type);
9467         _NBT_ASSERT_STRING(name->name, rec->name.name);
9468         _NBT_ASSERT_STRING(name->scope, rec->name.scope);
9469
9470         _NBT_ASSERT(rec->defend.expect_release, False);
9471
9472         rep_packet = talloc_zero(nbtsock, struct nbt_name_packet);
9473         if (rep_packet == NULL) return;
9474
9475         rep_packet->name_trn_id = req_packet->name_trn_id;
9476         rep_packet->ancount     = 1;
9477
9478         rep_packet->answers     = talloc_array(rep_packet, struct nbt_res_rec, 1);
9479         if (rep_packet->answers == NULL) return;
9480
9481         rep_packet->answers[0].name      = *name;
9482         rep_packet->answers[0].rr_class  = NBT_QCLASS_IP;
9483         rep_packet->answers[0].ttl       = 0;
9484
9485         if (rec->defend.positive) {
9486                 uint32_t i, num_ips;
9487                 const struct wrepl_ip *ips;             
9488
9489                 if (rec->defend.num_ips > 0) {
9490                         num_ips = rec->defend.num_ips;
9491                         ips     = rec->defend.ips;
9492                 } else {
9493                         num_ips = rec->wins.num_ips;
9494                         ips     = rec->wins.ips;
9495                 }
9496
9497                 /* send a positive reply */
9498                 rep_packet->operation   = 
9499                                         NBT_FLAG_REPLY | 
9500                                         NBT_OPCODE_QUERY | 
9501                                         NBT_FLAG_AUTHORITIVE |
9502                                         NBT_FLAG_RECURSION_DESIRED |
9503                                         NBT_FLAG_RECURSION_AVAIL;
9504
9505                 rep_packet->answers[0].rr_type   = NBT_QTYPE_NETBIOS;
9506
9507                 rep_packet->answers[0].rdata.netbios.length = num_ips*6;
9508                 rep_packet->answers[0].rdata.netbios.addresses = 
9509                         talloc_array(rep_packet->answers, struct nbt_rdata_address, num_ips);
9510                 if (rep_packet->answers[0].rdata.netbios.addresses == NULL) return;
9511
9512                 for (i=0; i < num_ips; i++) {
9513                         struct nbt_rdata_address *addr = 
9514                                 &rep_packet->answers[0].rdata.netbios.addresses[i];
9515                         addr->nb_flags  = rec->wins.nb_flags;
9516                         addr->ipaddr    = ips[i].ip;
9517                 }
9518                 DEBUG(2,("Sending positive name query reply for %s to %s:%d\n", 
9519                         nbt_name_string(rep_packet, name), src->addr, src->port));
9520         } else {
9521                 /* send a negative reply */
9522                 rep_packet->operation   =
9523                                         NBT_FLAG_REPLY | 
9524                                         NBT_OPCODE_QUERY | 
9525                                         NBT_FLAG_AUTHORITIVE |
9526                                         NBT_RCODE_NAM;
9527
9528                 rep_packet->answers[0].rr_type   = NBT_QTYPE_NULL;
9529
9530                 ZERO_STRUCT(rep_packet->answers[0].rdata);
9531
9532                 DEBUG(2,("Sending negative name query reply for %s to %s:%d\n", 
9533                         nbt_name_string(rep_packet, name), src->addr, src->port));
9534         }
9535
9536         nbt_name_reply_send(nbtsock, src, rep_packet);
9537         talloc_free(rep_packet);
9538
9539         /* make sure we push the reply to the wire */
9540         event_loop_once(nbtsock->event_ctx);
9541         msleep(25);
9542
9543         rec->defend.timeout     = 0;
9544         rec->defend.ret         = True;
9545 }
9546
9547 static void test_conflict_owned_active_vs_replica_handler_release(struct nbt_name_socket *nbtsock, 
9548                                                                   struct nbt_name_packet *req_packet, 
9549                                                                   struct socket_address *src)
9550 {
9551         struct nbt_name *name;
9552         struct nbt_name_packet *rep_packet;
9553         struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private;
9554
9555         _NBT_ASSERT(req_packet->qdcount, 1);
9556         _NBT_ASSERT(req_packet->questions[0].question_type, NBT_QTYPE_NETBIOS);
9557         _NBT_ASSERT(req_packet->questions[0].question_class, NBT_QCLASS_IP);
9558
9559         name = &req_packet->questions[0].name;
9560
9561         _NBT_ASSERT(name->type, rec->name.type);
9562         _NBT_ASSERT_STRING(name->name, rec->name.name);
9563         _NBT_ASSERT_STRING(name->scope, rec->name.scope);
9564
9565         _NBT_ASSERT(rec->defend.expect_release, True);
9566
9567         rep_packet = talloc_zero(nbtsock, struct nbt_name_packet);
9568         if (rep_packet == NULL) return;
9569
9570         rep_packet->name_trn_id = req_packet->name_trn_id;
9571         rep_packet->ancount     = 1;
9572         rep_packet->operation   = 
9573                                 NBT_FLAG_REPLY | 
9574                                 NBT_OPCODE_RELEASE |
9575                                 NBT_FLAG_AUTHORITIVE;
9576
9577         rep_packet->answers     = talloc_array(rep_packet, struct nbt_res_rec, 1);
9578         if (rep_packet->answers == NULL) return;
9579
9580         rep_packet->answers[0].name     = *name;
9581         rep_packet->answers[0].rr_type  = NBT_QTYPE_NETBIOS;
9582         rep_packet->answers[0].rr_class = NBT_QCLASS_IP;
9583         rep_packet->answers[0].ttl      = req_packet->additional[0].ttl;
9584         rep_packet->answers[0].rdata    = req_packet->additional[0].rdata;
9585
9586         DEBUG(2,("Sending name release reply for %s to %s:%d\n", 
9587                 nbt_name_string(rep_packet, name), src->addr, src->port));
9588
9589         nbt_name_reply_send(nbtsock, src, rep_packet);
9590         talloc_free(rep_packet);
9591
9592         /* make sure we push the reply to the wire */
9593         event_loop_once(nbtsock->event_ctx);
9594         msleep(25);
9595
9596         rec->defend.timeout     = 0;
9597         rec->defend.ret         = True;
9598 }
9599
9600 static void test_conflict_owned_active_vs_replica_handler(struct nbt_name_socket *nbtsock, 
9601                                                           struct nbt_name_packet *req_packet, 
9602                                                           struct socket_address *src)
9603 {
9604         struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private;
9605
9606         rec->defend.ret = False;
9607
9608         switch (req_packet->operation & NBT_OPCODE) {
9609         case NBT_OPCODE_QUERY:
9610                 test_conflict_owned_active_vs_replica_handler_query(nbtsock, req_packet, src);
9611                 break;
9612         case NBT_OPCODE_RELEASE:
9613                 test_conflict_owned_active_vs_replica_handler_release(nbtsock, req_packet, src);
9614                 break;
9615         default:
9616                 printf("%s: unexpected incoming packet\n", __location__);
9617                 return;
9618         }
9619 }
9620
9621 /*
9622   test WINS replication operations
9623 */
9624 BOOL torture_nbt_winsreplication(void)
9625 {
9626         const char *address;
9627         struct nbt_name name;
9628         TALLOC_CTX *mem_ctx = talloc_new(NULL);
9629         NTSTATUS status;
9630         BOOL ret = True;
9631         struct test_wrepl_conflict_conn *ctx;
9632
9633         make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host"));
9634
9635         /* do an initial name resolution to find its IP */
9636         status = resolve_name(&name, mem_ctx, &address, NULL);
9637         if (!NT_STATUS_IS_OK(status)) {
9638                 printf("Failed to resolve %s - %s\n",
9639                        name.name, nt_errstr(status));
9640                 talloc_free(mem_ctx);
9641                 return False;
9642         }
9643
9644         ret &= test_assoc_ctx1(mem_ctx, address);
9645         ret &= test_assoc_ctx2(mem_ctx, address);
9646
9647         ret &= test_wins_replication(mem_ctx, address);
9648
9649         if (lp_parm_bool(-1, "torture", "quick", False)) goto done;
9650
9651         ctx = test_create_conflict_ctx(mem_ctx, address);
9652         if (!ctx) return False;
9653
9654         ret &= test_conflict_same_owner(ctx);
9655         ret &= test_conflict_different_owner(ctx);
9656         ret &= test_conflict_owned_released_vs_replica(ctx);
9657         ret &= test_conflict_owned_active_vs_replica(ctx);
9658
9659 done:
9660         talloc_free(mem_ctx);
9661
9662         return ret;
9663 }