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