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