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