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