⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winsreplication.c

📁 samba最新软件
💻 C
📖 第 1 页 / 共 5 页
字号:
	}	talloc_free(pull_names.out.names);	return true;}static bool test_conflict_same_owner(struct torture_context *tctx, 									 struct test_wrepl_conflict_conn *ctx){	static bool ret = true;	struct nbt_name	name;	struct wrepl_wins_name wins_name1;	struct wrepl_wins_name wins_name2;	struct wrepl_wins_name *wins_name_tmp;	struct wrepl_wins_name *wins_name_last;	struct wrepl_wins_name *wins_name_cur;	uint32_t i,j;	uint8_t types[] = { 0x00, 0x1C };	struct {		enum wrepl_name_type type;		enum wrepl_name_state state;		enum wrepl_name_node node;		bool is_static;		uint32_t num_ips;		const struct wrepl_ip *ips;	} records[] = {		{		.type		= WREPL_TYPE_GROUP,		.state		= WREPL_STATE_ACTIVE,		.node		= WREPL_NODE_B,		.is_static	= false,		.num_ips	= ARRAY_SIZE(addresses_A_1),		.ips		= addresses_A_1,		},{		.type		= WREPL_TYPE_UNIQUE,		.state		= WREPL_STATE_ACTIVE,		.node		= WREPL_NODE_B,		.is_static	= false,		.num_ips	= ARRAY_SIZE(addresses_A_1),		.ips		= addresses_A_1,		},{		.type		= WREPL_TYPE_UNIQUE,		.state		= WREPL_STATE_ACTIVE,		.node		= WREPL_NODE_B,		.is_static	= false,		.num_ips	= ARRAY_SIZE(addresses_A_2),		.ips		= addresses_A_2,		},{		.type		= WREPL_TYPE_UNIQUE,		.state		= WREPL_STATE_ACTIVE,		.node		= WREPL_NODE_B,		.is_static	= true,		.num_ips	= ARRAY_SIZE(addresses_A_1),		.ips		= addresses_A_1,		},{		.type		= WREPL_TYPE_UNIQUE,		.state		= WREPL_STATE_ACTIVE,		.node		= WREPL_NODE_B,		.is_static	= false,		.num_ips	= ARRAY_SIZE(addresses_A_2),		.ips		= addresses_A_2,		},{		.type		= WREPL_TYPE_SGROUP,		.state		= WREPL_STATE_TOMBSTONE,		.node		= WREPL_NODE_B,		.is_static	= false,		.num_ips	= ARRAY_SIZE(addresses_A_2),		.ips		= addresses_A_2,		},{		.type		= WREPL_TYPE_MHOMED,		.state		= WREPL_STATE_TOMBSTONE,		.node		= WREPL_NODE_B,		.is_static	= false,		.num_ips	= ARRAY_SIZE(addresses_A_1),		.ips		= addresses_A_1,		},{		.type		= WREPL_TYPE_MHOMED,		.state		= WREPL_STATE_RELEASED,		.node		= WREPL_NODE_B,		.is_static	= false,		.num_ips	= ARRAY_SIZE(addresses_A_2),		.ips		= addresses_A_2,		},{		.type		= WREPL_TYPE_SGROUP,		.state		= WREPL_STATE_ACTIVE,		.node		= WREPL_NODE_B,		.is_static	= false,		.num_ips	= ARRAY_SIZE(addresses_A_1),		.ips		= addresses_A_1,		},{		.type		= WREPL_TYPE_SGROUP,		.state		= WREPL_STATE_ACTIVE,		.node		= WREPL_NODE_B,		.is_static	= false,		.num_ips	= ARRAY_SIZE(addresses_A_3_4),		.ips		= addresses_A_3_4,		},{		.type		= WREPL_TYPE_SGROUP,		.state		= WREPL_STATE_TOMBSTONE,		.node		= WREPL_NODE_B,		.is_static	= false,		.num_ips	= ARRAY_SIZE(addresses_B_3_4),		.ips		= addresses_B_3_4,		},{		/* the last one should always be a unique,tomstone record! */		.type		= WREPL_TYPE_UNIQUE,		.state		= WREPL_STATE_TOMBSTONE,		.node		= WREPL_NODE_B,		.is_static	= false,		.num_ips	= ARRAY_SIZE(addresses_A_1),		.ips		= addresses_A_1,		}	};	name.name	= "_SAME_OWNER_A";	name.type	= 0;	name.scope	= NULL;	wins_name_tmp	= NULL;	wins_name_last	= &wins_name2;	wins_name_cur	= &wins_name1;	for (j=0; ret && j < ARRAY_SIZE(types); j++) {		name.type = types[j];		torture_comment(tctx, "Test Replica Conflicts with same owner[%s] for %s\n",			nbt_name_string(ctx, &name), ctx->a.address);		for(i=0; ret && i < ARRAY_SIZE(records); i++) {			wins_name_tmp	= wins_name_last;			wins_name_last	= wins_name_cur;			wins_name_cur	= wins_name_tmp;			if (i > 0) {				torture_comment(tctx, "%s,%s%s vs. %s,%s%s with %s ip(s) => %s\n",					wrepl_name_type_string(records[i-1].type),					wrepl_name_state_string(records[i-1].state),					(records[i-1].is_static?",static":""),					wrepl_name_type_string(records[i].type),					wrepl_name_state_string(records[i].state),					(records[i].is_static?",static":""),					(records[i-1].ips==records[i].ips?"same":"different"),					"REPLACE");			}			wins_name_cur->name	= &name;			wins_name_cur->flags	= WREPL_NAME_FLAGS(records[i].type,								   records[i].state,								   records[i].node,								   records[i].is_static);			wins_name_cur->id	= ++ctx->a.max_version;			if (wins_name_cur->flags & 2) {				wins_name_cur->addresses.addresses.num_ips = records[i].num_ips;				wins_name_cur->addresses.addresses.ips     = discard_const(records[i].ips);			} else {				wins_name_cur->addresses.ip = records[i].ips[0].ip;			}			wins_name_cur->unknown	= "255.255.255.255";			ret &= test_wrepl_update_one(tctx, ctx, &ctx->a,wins_name_cur);			if (records[i].state == WREPL_STATE_RELEASED) {				ret &= test_wrepl_is_applied(tctx, ctx, &ctx->a, wins_name_last, false);				ret &= test_wrepl_is_applied(tctx, ctx, &ctx->a, wins_name_cur, false);			} else {				ret &= test_wrepl_is_applied(tctx, ctx, &ctx->a, wins_name_cur, true);			}			/* the first one is a cleanup run */			if (!ret && i == 0) ret = true;			if (!ret) {				torture_comment(tctx, "conflict handled wrong or record[%u]: %s\n", i, __location__);				return ret;			}		}	}	return ret;}static bool test_conflict_different_owner(struct torture_context *tctx, 										  struct test_wrepl_conflict_conn *ctx){	bool ret = true;	struct wrepl_wins_name wins_name1;	struct wrepl_wins_name wins_name2;	struct wrepl_wins_name *wins_name_r1;	struct wrepl_wins_name *wins_name_r2;	uint32_t i;	struct {		const char *line; /* just better debugging */		struct nbt_name name;		const char *comment;		bool extra; /* not the worst case, this is an extra test */		bool cleanup;		struct {			struct wrepl_wins_owner *owner;			enum wrepl_name_type type;			enum wrepl_name_state state;			enum wrepl_name_node node;			bool is_static;			uint32_t num_ips;			const struct wrepl_ip *ips;			bool apply_expected;			bool sgroup_merge;			struct wrepl_wins_owner *merge_owner;			bool sgroup_cleanup;		} r1, r2;	} records[] = {	/* 	 * NOTE: the first record and the last applied one	 *       needs to be from the same owner,	 *       to not conflict in the next smbtorture run!!!	 */	{		.line	= __location__,		.name	= _NBT_NAME("_DIFF_OWNER", 0x00, NULL),		.cleanup= true,		.r1	= {			.owner		= &ctx->b,			.type		= WREPL_TYPE_UNIQUE,			.state		= WREPL_STATE_TOMBSTONE,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_B_1),			.ips		= addresses_B_1,			.apply_expected	= true /* ignored */		},		.r2	= {			.owner		= &ctx->a,			.type		= WREPL_TYPE_UNIQUE,			.state		= WREPL_STATE_TOMBSTONE,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_A_1),			.ips		= addresses_A_1,			.apply_expected	= true /* ignored */		}	},/* * unique vs unique section */	/* 	 * unique,active vs. unique,active	 * => should be replaced	 */	{		.line	= __location__,		.name	= _NBT_NAME("_DIFF_OWNER", 0x00, NULL),		.r1	= {			.owner		= &ctx->a,			.type		= WREPL_TYPE_UNIQUE,			.state		= WREPL_STATE_ACTIVE,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_A_1),			.ips		= addresses_A_1,			.apply_expected	= true		},		.r2	= {			.owner		= &ctx->b,			.type		= WREPL_TYPE_UNIQUE,			.state		= WREPL_STATE_ACTIVE,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_B_1),			.ips		= addresses_B_1,			.apply_expected	= true		}	},	/* 	 * unique,active vs. unique,tombstone	 * => should NOT be replaced	 */	{		.line	= __location__,		.name	= _NBT_NAME("_DIFF_OWNER", 0x00, NULL),		.r1	= {			.owner		= &ctx->b,			.type		= WREPL_TYPE_UNIQUE,			.state		= WREPL_STATE_ACTIVE,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_B_1),			.ips		= addresses_B_1,			.apply_expected	= true		},		.r2	= {			.owner		= &ctx->a,			.type		= WREPL_TYPE_UNIQUE,			.state		= WREPL_STATE_TOMBSTONE,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_B_1),			.ips		= addresses_B_1,			.apply_expected	= false		}	},	/* 	 * unique,released vs. unique,active	 * => should be replaced	 */	{		.line	= __location__,		.name	= _NBT_NAME("_DIFF_OWNER", 0x00, NULL),		.r1	= {			.owner		= &ctx->b,			.type		= WREPL_TYPE_UNIQUE,			.state		= WREPL_STATE_RELEASED,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_B_1),			.ips		= addresses_B_1,			.apply_expected	= false		},		.r2	= {			.owner		= &ctx->a,			.type		= WREPL_TYPE_UNIQUE,			.state		= WREPL_STATE_ACTIVE,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_A_1),			.ips		= addresses_A_1,			.apply_expected	= true		}	},	/* 	 * unique,released vs. unique,tombstone	 * => should be replaced	 */	{		.line	= __location__,		.name	= _NBT_NAME("_DIFF_OWNER", 0x00, NULL),		.r1	= {			.owner		= &ctx->a,			.type		= WREPL_TYPE_UNIQUE,			.state		= WREPL_STATE_RELEASED,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_A_1),			.ips		= addresses_A_1,			.apply_expected	= false		},		.r2	= {			.owner		= &ctx->b,			.type		= WREPL_TYPE_UNIQUE,			.state		= WREPL_STATE_TOMBSTONE,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_B_1),			.ips		= addresses_B_1,			.apply_expected	= true		}	},	/* 	 * unique,tombstone vs. unique,active	 * => should be replaced	 */	{		.line	= __location__,		.name	= _NBT_NAME("_DIFF_OWNER", 0x00, NULL),		.r1	= {			.owner		= &ctx->b,			.type		= WREPL_TYPE_UNIQUE,			.state		= WREPL_STATE_TOMBSTONE,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_B_1),			.ips		= addresses_B_1,			.apply_expected	= true		},		.r2	= {			.owner		= &ctx->a,			.type		= WREPL_TYPE_UNIQUE,			.state		= WREPL_STATE_ACTIVE,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_A_1),			.ips		= addresses_A_1,			.apply_expected	= true		}	},	/* 	 * unique,tombstone vs. unique,tombstone	 * => should be replaced	 */	{		.line	= __location__,		.name	= _NBT_NAME("_DIFF_OWNER", 0x00, NULL),		.r1	= {			.owner		= &ctx->a,			.type		= WREPL_TYPE_UNIQUE,			.state		= WREPL_STATE_TOMBSTONE,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_A_1),			.ips		= addresses_A_1,			.apply_expected	= true		},		.r2	= {			.owner		= &ctx->b,			.type		= WREPL_TYPE_UNIQUE,			.state		= WREPL_STATE_TOMBSTONE,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_B_1),			.ips		= addresses_B_1,			.apply_expected	= true		}	},/* * unique vs normal groups section, */	/* 	 * unique,active vs. group,active	 * => should be replaced	 */	{		.line	= __location__,		.name	= _NBT_NAME("_DIFF_OWNER", 0x00, NULL),		.r1	= {			.owner		= &ctx->b,			.type		= WREPL_TYPE_UNIQUE,			.state		= WREPL_STATE_ACTIVE,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_B_1),			.ips		= addresses_B_1,			.apply_expected	= true		},		.r2	= {			.owner		= &ctx->a,			.type		= WREPL_TYPE_GROUP,			.state		= WREPL_STATE_ACTIVE,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_A_1),			.ips		= addresses_A_1,			.apply_expected	= true		}	},	/* 	 * unique,active vs. group,tombstone	 * => should NOT be replaced	 */	{		.line	= __location__,		.name	= _NBT_NAME("_DIFF_OWNER", 0x00, NULL),		.r1	= {			.owner		= &ctx->a,			.type		= WREPL_TYPE_UNIQUE,			.state		= WREPL_STATE_ACTIVE,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_A_1),			.ips		= addresses_A_1,			.apply_expected	= true		},		.r2	= {			.owner		= &ctx->b,			.type		= WREPL_TYPE_GROUP,			.state		= WREPL_STATE_TOMBSTONE,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_A_1),			.ips		= addresses_A_1,			.apply_expected	= false		}	},	/* 	 * unique,released vs. group,active	 * => should be replaced	 */	{		.line	= __location__,		.name	= _NBT_NAME("_DIFF_OWNER", 0x00, NULL),		.r1	= {			.owner		= &ctx->a,			.type		= WREPL_TYPE_UNIQUE,			.state		= WREPL_STATE_RELEASED,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_A_1),			.ips		= addresses_A_1,			.apply_expected	= false		},		.r2	= {			.owner		= &ctx->b,			.type		= WREPL_TYPE_GROUP,			.state		= WREPL_STATE_ACTIVE,			.node		= WREPL_NODE_B,			.is_static	= false,			.num_ips	= ARRAY_SIZE(addresses_B_1),			.ips		= addresses_B_1,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -