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