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