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