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