repl5_init.c 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. #include <config.h>
  11. #endif
  12. /*
  13. repl5_init.c - plugin initialization functions
  14. */
  15. /*
  16. * Add an entry like the following to dse.ldif to enable this plugin:
  17. dn: cn=Multi-Master Replication Plugin,cn=plugins,cn=config
  18. objectclass: top
  19. objectclass: nsSlapdPlugin
  20. objectclass: extensibleObject
  21. cn: Multi-Master Replication Plugin
  22. nsslapd-pluginpath: /export2/servers/Hydra-supplier/lib/replication-plugin.so
  23. nsslapd-plugininitfunc: replication_multimaster_plugin_init
  24. nsslapd-plugintype: object
  25. nsslapd-pluginenabled: on
  26. nsslapd-plugin-depends-on-type: database
  27. nsslapd-plugin-depends-on-named: Class of Service
  28. nsslapd-pluginid: replication-multimaster
  29. nsslapd-pluginversion: 5.0b1
  30. nsslapd-pluginvendor: Netscape Communications
  31. nsslapd-plugindescription: Multi-Master Replication Plugin
  32. */
  33. #include "slapi-plugin.h"
  34. #include "repl5.h"
  35. #include "cl5.h" /* changelog interface */
  36. #include "plstr.h"
  37. #define NSDS_REPL_NAME_PREFIX "Netscape Replication"
  38. static char *start_oid_list[] = {
  39. REPL_START_NSDS50_REPLICATION_REQUEST_OID,
  40. REPL_START_NSDS90_REPLICATION_REQUEST_OID,
  41. NULL};
  42. static char *start_name_list[] = {
  43. NSDS_REPL_NAME_PREFIX " Start Session",
  44. NULL};
  45. static char *end_oid_list[] = {
  46. REPL_END_NSDS50_REPLICATION_REQUEST_OID,
  47. NULL};
  48. static char *end_name_list[] = {
  49. NSDS_REPL_NAME_PREFIX " End Session",
  50. NULL};
  51. static char *total_oid_list[] = {
  52. REPL_NSDS50_REPLICATION_ENTRY_REQUEST_OID,
  53. REPL_NSDS71_REPLICATION_ENTRY_REQUEST_OID,
  54. NULL};
  55. static char *total_name_list[] = {
  56. NSDS_REPL_NAME_PREFIX " Total Update Entry",
  57. NULL};
  58. static char *response_oid_list[] = {
  59. REPL_NSDS50_REPLICATION_RESPONSE_OID,
  60. NULL};
  61. static char *response_name_list[] = {
  62. NSDS_REPL_NAME_PREFIX " Response",
  63. NULL};
  64. static char *cleanruv_oid_list[] = {
  65. REPL_CLEANRUV_OID,
  66. NULL};
  67. static char *cleanruv_name_list[] = {
  68. NSDS_REPL_NAME_PREFIX " CleanAllRUV",
  69. NULL};
  70. static char *cleanruv_abort_oid_list[] = {
  71. REPL_ABORT_CLEANRUV_OID,
  72. NULL};
  73. static char *cleanruv_abort_name_list[] = {
  74. NSDS_REPL_NAME_PREFIX " CleanAllRUV Abort",
  75. NULL};
  76. static char *cleanruv_maxcsn_oid_list[] = {
  77. REPL_CLEANRUV_GET_MAXCSN_OID,
  78. NULL};
  79. static char *cleanruv_maxcsn_name_list[] = {
  80. NSDS_REPL_NAME_PREFIX " CleanAllRUV Retrieve MaxCSN",
  81. NULL};
  82. static char *cleanruv_status_oid_list[] = {
  83. REPL_CLEANRUV_CHECK_STATUS_OID,
  84. NULL};
  85. static char *cleanruv_status_name_list[] = {
  86. NSDS_REPL_NAME_PREFIX " CleanAllRUV Check Status",
  87. NULL};
  88. /* List of plugin identities for every plugin registered. Plugin identity
  89. is passed by the server in the plugin init function and must be supplied
  90. by the plugin to all internal operations it initiates
  91. */
  92. /* ----------------------------- Multi-Master Replication Plugin */
  93. static Slapi_PluginDesc multimasterdesc = {"replication-multimaster", VENDOR, DS_PACKAGE_VERSION, "Multi-master Replication Plugin"};
  94. static Slapi_PluginDesc multimasterpreopdesc = {"replication-multimaster-preop", VENDOR, DS_PACKAGE_VERSION, "Multi-master replication pre-operation plugin"};
  95. static Slapi_PluginDesc multimasterpostopdesc = {"replication-multimaster-postop", VENDOR, DS_PACKAGE_VERSION, "Multi-master replication post-operation plugin"};
  96. static Slapi_PluginDesc multimasterinternalpreopdesc = {"replication-multimaster-internalpreop", VENDOR, DS_PACKAGE_VERSION, "Multi-master replication internal pre-operation plugin"};
  97. static Slapi_PluginDesc multimasterinternalpostopdesc = {"replication-multimaster-internalpostop", VENDOR, DS_PACKAGE_VERSION, "Multimaster replication internal post-operation plugin"};
  98. static Slapi_PluginDesc multimasterbepreopdesc = {"replication-multimaster-bepreop", VENDOR, DS_PACKAGE_VERSION, "Multimaster replication bepre-operation plugin"};
  99. static Slapi_PluginDesc multimasterbepostopdesc = {"replication-multimaster-bepostop", VENDOR, DS_PACKAGE_VERSION, "Multimaster replication bepost-operation plugin"};
  100. static Slapi_PluginDesc multimasterbetxnpostopdesc = {"replication-multimaster-betxnpostop", VENDOR, DS_PACKAGE_VERSION, "Multimaster replication be transaction post-operation plugin"};
  101. static Slapi_PluginDesc multimasterextopdesc = {"replication-multimaster-extop", VENDOR, DS_PACKAGE_VERSION, "Multimaster replication extended-operation plugin"};
  102. static int multimaster_stopped_flag; /* A flag which is set when all the plugin threads are to stop */
  103. static int multimaster_started_flag = 0;
  104. /* Thread private data and interface */
  105. static PRUintn thread_private_agmtname; /* thread private index for logging*/
  106. static PRUintn thread_private_cache;
  107. static PRUintn thread_primary_csn;
  108. char *
  109. get_thread_private_agmtname()
  110. {
  111. char *agmtname = NULL;
  112. if (thread_private_agmtname)
  113. agmtname = PR_GetThreadPrivate(thread_private_agmtname);
  114. return (agmtname ? agmtname : "");
  115. }
  116. void
  117. set_thread_private_agmtname(const char *agmtname)
  118. {
  119. if (thread_private_agmtname)
  120. PR_SetThreadPrivate(thread_private_agmtname, (void *)agmtname);
  121. }
  122. CSNPL_CTX *
  123. get_thread_primary_csn(void)
  124. {
  125. CSNPL_CTX *prim_csn = NULL;
  126. if (thread_primary_csn)
  127. prim_csn = (CSNPL_CTX *)PR_GetThreadPrivate(thread_primary_csn);
  128. return prim_csn;
  129. }
  130. void
  131. set_thread_primary_csn(const CSN *prim_csn, Replica *repl)
  132. {
  133. if (thread_primary_csn) {
  134. if (prim_csn) {
  135. CSNPL_CTX *csnpl_ctx = (CSNPL_CTX *)slapi_ch_calloc(1, sizeof(CSNPL_CTX));
  136. csnpl_ctx->prim_csn = csn_dup(prim_csn);
  137. /* repl_alloc, repl_cnt and sec_repl are 0 by calloc */
  138. csnpl_ctx->prim_repl = repl;
  139. PR_SetThreadPrivate(thread_primary_csn, (void *)csnpl_ctx);
  140. } else {
  141. PR_SetThreadPrivate(thread_primary_csn, NULL);
  142. }
  143. }
  144. }
  145. void
  146. add_replica_to_primcsn(CSNPL_CTX *csnpl_ctx, Replica *repl)
  147. {
  148. size_t found = 0;
  149. size_t it = 0;
  150. if (repl == csnpl_ctx->prim_repl)
  151. return;
  152. while (it < csnpl_ctx->repl_cnt) {
  153. if (csnpl_ctx->sec_repl[it] == repl) {
  154. found = 1;
  155. break;
  156. }
  157. it++;
  158. }
  159. if (found)
  160. return;
  161. if (csnpl_ctx->repl_cnt < csnpl_ctx->repl_alloc) {
  162. csnpl_ctx->sec_repl[csnpl_ctx->repl_cnt++] = repl;
  163. return;
  164. }
  165. csnpl_ctx->repl_alloc += CSNPL_CTX_REPLCNT;
  166. if (csnpl_ctx->repl_cnt == 0) {
  167. csnpl_ctx->sec_repl = (Replica **)slapi_ch_calloc(csnpl_ctx->repl_alloc, sizeof(Replica *));
  168. } else {
  169. csnpl_ctx->sec_repl = (Replica **)slapi_ch_realloc((char *)csnpl_ctx->sec_repl, csnpl_ctx->repl_alloc * sizeof(Replica *));
  170. }
  171. csnpl_ctx->sec_repl[csnpl_ctx->repl_cnt++] = repl;
  172. return;
  173. }
  174. void *
  175. get_thread_private_cache()
  176. {
  177. void *buf = NULL;
  178. if (thread_private_cache)
  179. buf = PR_GetThreadPrivate(thread_private_cache);
  180. return buf;
  181. }
  182. void
  183. set_thread_private_cache(void *buf)
  184. {
  185. if (thread_private_cache)
  186. PR_SetThreadPrivate(thread_private_cache, buf);
  187. }
  188. char *
  189. get_repl_session_id(Slapi_PBlock *pb, char *idstr, CSN **csn)
  190. {
  191. int opid = -1;
  192. PRUint64 connid = 0;
  193. CSN *opcsn;
  194. char opcsnstr[CSN_STRSIZE];
  195. *idstr = '\0';
  196. opcsn = NULL;
  197. opcsnstr[0] = '\0';
  198. if (pb) {
  199. Slapi_Operation *op;
  200. slapi_pblock_get(pb, SLAPI_OPERATION_ID, &opid);
  201. /* Avoid "Connection is NULL and hence cannot access SLAPI_CONN_ID" */
  202. if (opid) {
  203. slapi_pblock_get(pb, SLAPI_CONN_ID, &connid);
  204. snprintf(idstr, REPL_SESSION_ID_SIZE, "conn=%" PRIu64 " op=%d",
  205. connid, opid);
  206. }
  207. slapi_pblock_get(pb, SLAPI_OPERATION, &op);
  208. opcsn = operation_get_csn(op);
  209. if (opcsn) {
  210. csn_as_string(opcsn, PR_FALSE, opcsnstr);
  211. PL_strcatn(idstr, REPL_SESSION_ID_SIZE, " csn=");
  212. PL_strcatn(idstr, REPL_SESSION_ID_SIZE, opcsnstr);
  213. }
  214. }
  215. if (csn) {
  216. *csn = opcsn;
  217. }
  218. return idstr;
  219. }
  220. /* preop acquires csn generator handle */
  221. int repl5_is_betxn = 0;
  222. int
  223. multimaster_preop_init(Slapi_PBlock *pb)
  224. {
  225. int rc = 0; /* OK */
  226. if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) != 0 ||
  227. slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterpreopdesc) != 0 ||
  228. slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_BIND_FN, (void *)multimaster_preop_bind) != 0 ||
  229. slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_ADD_FN, (void *)multimaster_preop_add) != 0 ||
  230. slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_DELETE_FN, (void *)multimaster_preop_delete) != 0 ||
  231. slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODIFY_FN, (void *)multimaster_preop_modify) != 0 ||
  232. slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODRDN_FN, (void *)multimaster_preop_modrdn) != 0 ||
  233. slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_SEARCH_FN, (void *)multimaster_preop_search) != 0 ||
  234. slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_COMPARE_FN, (void *)multimaster_preop_compare) != 0 ||
  235. slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_ENTRY_FN, (void *)multimaster_ruv_search) != 0) {
  236. slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_preop_init - Failed\n");
  237. rc = -1;
  238. }
  239. return rc;
  240. }
  241. /* process_postop (core op of post op) frees CSN,
  242. * which should be called after betxn is finieshed. */
  243. int
  244. multimaster_postop_init(Slapi_PBlock *pb)
  245. {
  246. int rc = 0; /* OK */
  247. if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) != 0 ||
  248. slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterpostopdesc) != 0 ||
  249. slapi_pblock_set(pb, SLAPI_PLUGIN_POST_BIND_FN, (void *)multimaster_postop_bind) != 0 ||
  250. slapi_pblock_set(pb, SLAPI_PLUGIN_POST_ADD_FN, (void *)multimaster_postop_add) != 0 ||
  251. slapi_pblock_set(pb, SLAPI_PLUGIN_POST_DELETE_FN, (void *)multimaster_postop_delete) != 0 ||
  252. slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODIFY_FN, (void *)multimaster_postop_modify) != 0 ||
  253. slapi_pblock_set(pb, SLAPI_PLUGIN_POST_MODRDN_FN, (void *)multimaster_postop_modrdn) != 0) {
  254. slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_postop_init - Failed\n");
  255. rc = -1;
  256. }
  257. return rc;
  258. }
  259. int
  260. multimaster_internalpreop_init(Slapi_PBlock *pb)
  261. {
  262. int rc = 0; /* OK */
  263. if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) != 0 ||
  264. slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterinternalpreopdesc) != 0 ||
  265. slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN, (void *)multimaster_preop_add) != 0 ||
  266. slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN, (void *)multimaster_preop_delete) != 0 ||
  267. slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN, (void *)multimaster_preop_modify) != 0 ||
  268. slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN, (void *)multimaster_preop_modrdn) != 0) {
  269. slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_internalpreop_init - Failed\n");
  270. rc = -1;
  271. }
  272. return rc;
  273. }
  274. int
  275. multimaster_internalpostop_init(Slapi_PBlock *pb)
  276. {
  277. int rc = 0; /* OK */
  278. if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) != 0 ||
  279. slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterinternalpostopdesc) != 0 ||
  280. slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_ADD_FN, (void *)multimaster_postop_add) != 0 ||
  281. slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN, (void *)multimaster_postop_delete) != 0 ||
  282. slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN, (void *)multimaster_postop_modify) != 0 ||
  283. slapi_pblock_set(pb, SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN, (void *)multimaster_postop_modrdn) != 0) {
  284. slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_internalpostop_init - Failed\n");
  285. rc = -1;
  286. }
  287. return rc;
  288. }
  289. /*
  290. * bepreop: setting SLAPI_TXN_RUV_MODS_FN, cleanup old stateinfo.
  291. * If betxn is off, preop urp is called here, too.
  292. */
  293. int
  294. multimaster_bepreop_init(Slapi_PBlock *pb)
  295. {
  296. int rc = 0; /* OK */
  297. if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) != 0 ||
  298. slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterbepreopdesc) != 0 ||
  299. slapi_pblock_set(pb, SLAPI_PLUGIN_BE_PRE_ADD_FN, (void *)multimaster_bepreop_add) != 0 ||
  300. slapi_pblock_set(pb, SLAPI_PLUGIN_BE_PRE_DELETE_FN, (void *)multimaster_bepreop_delete) != 0 ||
  301. slapi_pblock_set(pb, SLAPI_PLUGIN_BE_PRE_MODIFY_FN, (void *)multimaster_bepreop_modify) != 0 ||
  302. slapi_pblock_set(pb, SLAPI_PLUGIN_BE_PRE_MODRDN_FN, (void *)multimaster_bepreop_modrdn) != 0 ||
  303. slapi_pblock_set(pb, SLAPI_PLUGIN_BE_PRE_CLOSE_FN, (void *)cl5Close) != 0 ||
  304. slapi_pblock_set(pb, SLAPI_PLUGIN_BE_PRE_BACKUP_FN, (void *)cl5WriteRUV) != 0) {
  305. slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_bepreop_init - Failed\n");
  306. rc = -1;
  307. }
  308. return rc;
  309. }
  310. /*
  311. * betxnpreop: if betxn is on, call preop urp at betxnpreop.
  312. */
  313. int
  314. multimaster_betxnpreop_init(Slapi_PBlock *pb __attribute__((unused)))
  315. {
  316. int rc = 0; /* OK */
  317. return rc;
  318. }
  319. /*
  320. * This bepostop_init is registered only if plugintype is NOT betxn.
  321. * if plugintype is betxn, callbacks are set in each multimaster_betxnpostop
  322. * function.
  323. */
  324. int
  325. multimaster_bepostop_init(Slapi_PBlock *pb)
  326. {
  327. int rc = 0; /* OK */
  328. if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) != 0 ||
  329. slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterbepostopdesc) != 0 ||
  330. slapi_pblock_set(pb, SLAPI_PLUGIN_BE_POST_MODRDN_FN, (void *)multimaster_bepostop_modrdn) != 0 ||
  331. slapi_pblock_set(pb, SLAPI_PLUGIN_BE_POST_DELETE_FN, (void *)multimaster_bepostop_delete) != 0 ||
  332. slapi_pblock_set(pb, SLAPI_PLUGIN_BE_POST_OPEN_FN, (void *)changelog5_init) != 0 ||
  333. slapi_pblock_set(pb, SLAPI_PLUGIN_BE_POST_BACKUP_FN, (void *)cl5DeleteRUV) != 0) {
  334. slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_bepostop_init - Failed\n");
  335. rc = -1;
  336. }
  337. return rc;
  338. }
  339. /*
  340. * This betxn_bepostop_init is registered only if plugintype is betxn.
  341. * Note: other callbacks (add/delete/modify/modrdn) are set in each
  342. * multimaster_betxnpostop function.
  343. */
  344. int
  345. multimaster_betxn_bepostop_init(Slapi_PBlock *pb)
  346. {
  347. int rc = 0; /* OK */
  348. if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) ||
  349. slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterbepostopdesc) ||
  350. slapi_pblock_set(pb, SLAPI_PLUGIN_BE_POST_OPEN_FN, (void *)changelog5_init) ||
  351. slapi_pblock_set(pb, SLAPI_PLUGIN_BE_POST_BACKUP_FN, (void *)cl5DeleteRUV)) {
  352. slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_betxn_bepostop_init - Failed\n");
  353. rc = -1;
  354. }
  355. return rc;
  356. }
  357. int
  358. multimaster_betxnpostop_init(Slapi_PBlock *pb)
  359. {
  360. int rc = 0; /* OK */
  361. void *add_fn;
  362. void *del_fn;
  363. void *mod_fn;
  364. void *mdn_fn;
  365. if (repl5_is_betxn) {
  366. add_fn = multimaster_be_betxnpostop_add;
  367. del_fn = multimaster_be_betxnpostop_delete;
  368. mod_fn = multimaster_be_betxnpostop_modify;
  369. mdn_fn = multimaster_be_betxnpostop_modrdn;
  370. } else {
  371. add_fn = multimaster_betxnpostop_add;
  372. del_fn = multimaster_betxnpostop_delete;
  373. mod_fn = multimaster_betxnpostop_modify;
  374. mdn_fn = multimaster_betxnpostop_modrdn;
  375. }
  376. if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) ||
  377. slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION,
  378. (void *)&multimasterbetxnpostopdesc) ||
  379. slapi_pblock_set(pb, SLAPI_PLUGIN_BE_TXN_POST_ADD_FN, add_fn) ||
  380. slapi_pblock_set(pb, SLAPI_PLUGIN_BE_TXN_POST_DELETE_FN, del_fn) ||
  381. slapi_pblock_set(pb, SLAPI_PLUGIN_BE_TXN_POST_MODRDN_FN, mdn_fn) ||
  382. slapi_pblock_set(pb, SLAPI_PLUGIN_BE_TXN_POST_MODIFY_FN, mod_fn)) {
  383. slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name,
  384. "multimaster_betxnpostop_init - Failed\n");
  385. rc = -1;
  386. }
  387. return rc;
  388. }
  389. int
  390. multimaster_start_extop_init(Slapi_PBlock *pb)
  391. {
  392. int rc = 0; /* OK */
  393. if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) != 0 ||
  394. slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterextopdesc) != 0 ||
  395. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_OIDLIST, (void *)start_oid_list) != 0 ||
  396. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_NAMELIST, (void *)start_name_list) != 0 ||
  397. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_FN, (void *)multimaster_extop_StartNSDS50ReplicationRequest)) {
  398. slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_start_extop_init - (StartNSDS50ReplicationRequest) failed\n");
  399. rc = -1;
  400. }
  401. return rc;
  402. }
  403. int
  404. multimaster_end_extop_init(Slapi_PBlock *pb)
  405. {
  406. int rc = 0; /* OK */
  407. if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) != 0 ||
  408. slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterextopdesc) != 0 ||
  409. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_OIDLIST, (void *)end_oid_list) != 0 ||
  410. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_NAMELIST, (void *)end_name_list) != 0 ||
  411. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_FN, (void *)multimaster_extop_EndNSDS50ReplicationRequest)) {
  412. slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_end_extop_init - (EndNSDS50ReplicationRequest) failed\n");
  413. rc = -1;
  414. }
  415. return rc;
  416. }
  417. int
  418. multimaster_cleanruv_maxcsn_extop_init(Slapi_PBlock *pb)
  419. {
  420. int rc = 0; /* OK */
  421. void *identity = NULL;
  422. /* get plugin identity and store it to pass to internal operations */
  423. slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &identity);
  424. PR_ASSERT(identity);
  425. if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) != 0 ||
  426. slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterextopdesc) != 0 ||
  427. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_OIDLIST, (void *)cleanruv_maxcsn_oid_list) != 0 ||
  428. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_NAMELIST, (void *)cleanruv_maxcsn_name_list) != 0 ||
  429. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_FN, (void *)multimaster_extop_cleanruv_get_maxcsn)) {
  430. slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_cleanruv_maxcsn_extop_init - Failed\n");
  431. rc = -1;
  432. }
  433. return rc;
  434. }
  435. int
  436. multimaster_cleanruv_status_extop_init(Slapi_PBlock *pb)
  437. {
  438. int rc = 0; /* OK */
  439. void *identity = NULL;
  440. /* get plugin identity and store it to pass to internal operations */
  441. slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &identity);
  442. PR_ASSERT(identity);
  443. if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) != 0 ||
  444. slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterextopdesc) != 0 ||
  445. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_OIDLIST, (void *)cleanruv_status_oid_list) != 0 ||
  446. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_NAMELIST, (void *)cleanruv_status_name_list) != 0 ||
  447. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_FN, (void *)multimaster_extop_cleanruv_check_status)) {
  448. slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_cleanruv_status_extop_init - Failed\n");
  449. rc = -1;
  450. }
  451. return rc;
  452. }
  453. int
  454. multimaster_total_extop_init(Slapi_PBlock *pb)
  455. {
  456. int rc = 0; /* OK */
  457. void *identity = NULL;
  458. /* get plugin identity and store it to pass to internal operations */
  459. slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &identity);
  460. PR_ASSERT(identity);
  461. if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) != 0 ||
  462. slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterextopdesc) != 0 ||
  463. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_OIDLIST, (void *)total_oid_list) != 0 ||
  464. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_NAMELIST, (void *)total_name_list) != 0 ||
  465. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_FN, (void *)multimaster_extop_NSDS50ReplicationEntry)) {
  466. slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_total_extop_init - (NSDS50ReplicationEntry failed\n");
  467. rc = -1;
  468. }
  469. return rc;
  470. }
  471. int
  472. multimaster_response_extop_init(Slapi_PBlock *pb)
  473. {
  474. int rc = 0; /* OK */
  475. void *identity = NULL;
  476. /* get plugin identity and store it to pass to internal operations */
  477. slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &identity);
  478. PR_ASSERT(identity);
  479. if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) != 0 ||
  480. slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterextopdesc) != 0 ||
  481. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_OIDLIST, (void *)response_oid_list) != 0 ||
  482. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_NAMELIST, (void *)response_name_list) != 0 ||
  483. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_FN, (void *)extop_noop)) {
  484. slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_response_extop_init - (NSDS50ReplicationResponse failed\n");
  485. rc = -1;
  486. }
  487. return rc;
  488. }
  489. int
  490. multimaster_cleanruv_extop_init(Slapi_PBlock *pb)
  491. {
  492. int rc = 0; /* OK */
  493. void *identity = NULL;
  494. /* get plugin identity and store it to pass to internal operations */
  495. slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &identity);
  496. PR_ASSERT(identity);
  497. if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) != 0 ||
  498. slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterextopdesc) != 0 ||
  499. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_OIDLIST, (void *)cleanruv_oid_list) != 0 ||
  500. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_NAMELIST, (void *)cleanruv_name_list) != 0 ||
  501. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_FN, (void *)multimaster_extop_cleanruv)) {
  502. slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_cleanruv_extop_init - Failed\n");
  503. rc = -1;
  504. }
  505. return rc;
  506. }
  507. int
  508. multimaster_cleanruv_abort_extop_init(Slapi_PBlock *pb)
  509. {
  510. int rc = 0; /* OK */
  511. void *identity = NULL;
  512. /* get plugin identity and store it to pass to internal operations */
  513. slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &identity);
  514. PR_ASSERT(identity);
  515. if (slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01) != 0 ||
  516. slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterextopdesc) != 0 ||
  517. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_OIDLIST, (void *)cleanruv_abort_oid_list) != 0 ||
  518. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_NAMELIST, (void *)cleanruv_abort_name_list) != 0 ||
  519. slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_FN, (void *)multimaster_extop_abort_cleanruv)) {
  520. slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "multimaster_cleanruv_abort_extop_init - Failed\n");
  521. rc = -1;
  522. }
  523. return rc;
  524. }
  525. static PRBool
  526. check_for_ldif_dump(Slapi_PBlock *pb)
  527. {
  528. int i;
  529. int argc;
  530. char **argv;
  531. PRBool return_value = PR_FALSE;
  532. slapi_pblock_get(pb, SLAPI_ARGC, &argc);
  533. slapi_pblock_get(pb, SLAPI_ARGV, &argv);
  534. for (i = 1; i < argc && !return_value; i++) {
  535. if (strcmp(argv[i], "db2ldif") == 0) {
  536. return_value = PR_TRUE;
  537. }
  538. }
  539. return return_value;
  540. }
  541. /*
  542. * If the entries do not exist, it create the entries of the schema replication policies
  543. * returns 0 if success
  544. */
  545. static int
  546. create_repl_schema_policy(void)
  547. {
  548. /* DN part of this entry_string: no need to be optimized. */
  549. char entry_string[1024];
  550. Slapi_PBlock *pb;
  551. Slapi_Entry *e;
  552. int return_value;
  553. char *repl_schema_top, *repl_schema_supplier, *repl_schema_consumer;
  554. char *default_supplier_policy = NULL;
  555. char *default_consumer_policy = NULL;
  556. int rc = 0;
  557. slapi_schema_get_repl_entries(&repl_schema_top, &repl_schema_supplier, &repl_schema_consumer, &default_supplier_policy, &default_consumer_policy);
  558. /* Create cn=replSchema,cn=config */
  559. PR_snprintf(entry_string, sizeof(entry_string), "dn: %s\nobjectclass: top\nobjectclass: nsSchemaPolicy\ncn: replSchema\n", repl_schema_top);
  560. e = slapi_str2entry(entry_string, 0);
  561. pb = slapi_pblock_new();
  562. slapi_add_entry_internal_set_pb(pb, e, NULL, /* controls */
  563. repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION), 0 /* flags */);
  564. slapi_add_internal_pb(pb);
  565. slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &return_value);
  566. if (return_value != LDAP_SUCCESS && return_value != LDAP_ALREADY_EXISTS) {
  567. slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "create_repl_schema_policy - "
  568. "Unable to create configuration entry %s: %s\n",
  569. repl_schema_top,
  570. ldap_err2string(return_value));
  571. rc = -1;
  572. slapi_entry_free(e); /* The entry was not consumed */
  573. goto done;
  574. }
  575. slapi_pblock_destroy(pb);
  576. /* Create cn=supplierUpdatePolicy,cn=replSchema,cn=config */
  577. PR_snprintf(entry_string, sizeof(entry_string), "dn: %s\nobjectclass: top\nobjectclass: nsSchemaPolicy\ncn: supplierUpdatePolicy\n%s",
  578. repl_schema_supplier,
  579. default_supplier_policy ? default_supplier_policy : "");
  580. e = slapi_str2entry(entry_string, 0);
  581. pb = slapi_pblock_new();
  582. slapi_add_entry_internal_set_pb(pb, e, NULL, /* controls */
  583. repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION), 0 /* flags */);
  584. slapi_add_internal_pb(pb);
  585. slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &return_value);
  586. if (return_value != LDAP_SUCCESS && return_value != LDAP_ALREADY_EXISTS) {
  587. slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "create_repl_schema_policy - Unable to "
  588. "create configuration entry %s: %s\n",
  589. repl_schema_supplier,
  590. ldap_err2string(return_value));
  591. rc = -1;
  592. slapi_entry_free(e); /* The entry was not consumed */
  593. goto done;
  594. }
  595. slapi_pblock_destroy(pb);
  596. /* Create cn=consumerUpdatePolicy,cn=replSchema,cn=config */
  597. PR_snprintf(entry_string, sizeof(entry_string), "dn: %s\nobjectclass: top\nobjectclass: nsSchemaPolicy\ncn: consumerUpdatePolicy\n%s",
  598. repl_schema_consumer,
  599. default_consumer_policy ? default_consumer_policy : "");
  600. e = slapi_str2entry(entry_string, 0);
  601. pb = slapi_pblock_new();
  602. slapi_add_entry_internal_set_pb(pb, e, NULL, /* controls */
  603. repl_get_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION), 0 /* flags */);
  604. slapi_add_internal_pb(pb);
  605. slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &return_value);
  606. if (return_value != LDAP_SUCCESS && return_value != LDAP_ALREADY_EXISTS) {
  607. slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "create_repl_schema_policy - "
  608. "Unable to create configuration entry %s: %s\n",
  609. repl_schema_consumer,
  610. ldap_err2string(return_value));
  611. rc = -1;
  612. slapi_entry_free(e); /* The entry was not consumed */
  613. goto done;
  614. }
  615. slapi_pblock_destroy(pb);
  616. pb = NULL;
  617. /* Load the policies of the schema replication */
  618. if (slapi_schema_load_repl_policies()) {
  619. slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name, "create_repl_schema_policy - "
  620. "Unable to load the schema replication policies\n");
  621. rc = -1;
  622. goto done;
  623. }
  624. done:
  625. slapi_pblock_destroy(pb);
  626. pb = NULL;
  627. return rc;
  628. }
  629. static PRBool is_ldif_dump = PR_FALSE;
  630. PRBool
  631. ldif_dump_is_running()
  632. {
  633. return is_ldif_dump;
  634. }
  635. int
  636. multimaster_start(Slapi_PBlock *pb)
  637. {
  638. int rc = 0; /* OK */
  639. if (!multimaster_started_flag) {
  640. /* Get any registered replication session API */
  641. repl_session_plugin_init();
  642. /* Initialize thread private data for logging. Ignore if fails */
  643. PR_NewThreadPrivateIndex(&thread_private_agmtname, NULL);
  644. PR_NewThreadPrivateIndex(&thread_private_cache, NULL);
  645. PR_NewThreadPrivateIndex(&thread_primary_csn, csnplFreeCSNPL_CTX);
  646. /* Decode the command line args to see if we're dumping to LDIF */
  647. is_ldif_dump = check_for_ldif_dump(pb);
  648. /* allow online replica configuration */
  649. rc = replica_config_init();
  650. if (rc != 0)
  651. goto out;
  652. slapi_register_supported_control(REPL_NSDS50_UPDATE_INFO_CONTROL_OID,
  653. SLAPI_OPERATION_ADD | SLAPI_OPERATION_DELETE |
  654. SLAPI_OPERATION_MODIFY | SLAPI_OPERATION_MODDN);
  655. /* Stash away our partial URL, used in RUVs */
  656. rc = multimaster_set_local_purl();
  657. if (rc != 0)
  658. goto out;
  659. /* initialize name hash */
  660. rc = replica_init_name_hash();
  661. if (rc != 0)
  662. goto out;
  663. /* initialize dn hash */
  664. rc = replica_init_dn_hash();
  665. if (rc != 0)
  666. goto out;
  667. /* create replicas */
  668. multimaster_mtnode_construct_replicas();
  669. /* Initialise the 5.0 Changelog */
  670. rc = changelog5_init();
  671. if (rc != 0)
  672. goto out;
  673. /* Initialize the replication agreements, unless we're dumping LDIF */
  674. if (!is_ldif_dump) {
  675. rc = agmtlist_config_init();
  676. if (rc != 0)
  677. goto out;
  678. }
  679. rc = create_repl_schema_policy();
  680. if (rc != 0)
  681. goto out;
  682. /* check if the replica's data was reloaded offline and we need
  683. to reinitialize replica's changelog. This should be done
  684. after the changelog is initialized */
  685. replica_enumerate_replicas(replica_check_for_data_reload, NULL);
  686. /* register to be notified when backend state changes */
  687. slapi_register_backend_state_change((void *)multimaster_be_state_change,
  688. multimaster_be_state_change);
  689. multimaster_started_flag = 1;
  690. multimaster_stopped_flag = 0;
  691. }
  692. out:
  693. return rc;
  694. }
  695. int
  696. multimaster_stop(Slapi_PBlock *pb __attribute__((unused)))
  697. {
  698. int rc = 0; /* OK */
  699. if (!multimaster_stopped_flag) {
  700. if (!is_ldif_dump) {
  701. /* Shut down replication agreements */
  702. agmtlist_shutdown();
  703. }
  704. /* if we are cleaning a ruv, stop */
  705. stop_ruv_cleaning();
  706. /* unregister backend state change notification */
  707. slapi_unregister_backend_state_change((void *)multimaster_be_state_change);
  708. changelog5_cleanup(); /* Shut down the changelog */
  709. multimaster_mtnode_extension_destroy(); /* Destroy mapping tree node exts */
  710. replica_destroy_name_hash(); /* destroy the hash and its remaining content */
  711. replica_config_destroy(); /* Destroy replica config info */
  712. multimaster_stopped_flag = 1;
  713. }
  714. return rc;
  715. }
  716. PRBool
  717. multimaster_started()
  718. {
  719. return (multimaster_started_flag != 0);
  720. }
  721. /*
  722. * Initialize the multimaster replication plugin.
  723. */
  724. int
  725. replication_multimaster_plugin_init(Slapi_PBlock *pb)
  726. {
  727. static int multimaster_initialised = 0;
  728. int rc = 0; /* OK */
  729. void *identity = NULL;
  730. Slapi_Entry *plugin_entry = NULL;
  731. slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &identity);
  732. PR_ASSERT(identity);
  733. repl_set_plugin_identity(PLUGIN_MULTIMASTER_REPLICATION, identity);
  734. /* need the repl plugin path for the chain on update function */
  735. /* slapi_pblock_get(pb, SLAPI_ADD_ENTRY, &entry);
  736. PR_ASSERT(entry);
  737. path = slapi_entry_attr_get_charptr(entry, "nsslapd-pluginpath");
  738. repl_set_repl_plugin_path(path);
  739. slapi_ch_free_string(&path);
  740. */
  741. multimaster_mtnode_extension_init();
  742. if ((slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &plugin_entry) == 0) &&
  743. plugin_entry) {
  744. repl5_is_betxn = slapi_entry_attr_get_bool(plugin_entry,
  745. "nsslapd-pluginbetxn");
  746. }
  747. if (!multimaster_initialised) {
  748. /* Initialize extensions */
  749. repl_con_init_ext();
  750. repl_sup_init_ext();
  751. rc = slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01);
  752. rc = slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&multimasterdesc);
  753. rc = slapi_pblock_set(pb, SLAPI_PLUGIN_START_FN, (void *)multimaster_start);
  754. rc = slapi_pblock_set(pb, SLAPI_PLUGIN_CLOSE_FN, (void *)multimaster_stop);
  755. /* Register the plugin interfaces we implement */
  756. /* preop acquires csn generator handle */
  757. rc = slapi_register_plugin("preoperation", 1 /* Enabled */,
  758. "multimaster_preop_init",
  759. multimaster_preop_init,
  760. "Multimaster replication preoperation plugin",
  761. NULL, identity);
  762. /* bepreop: setting SLAPI_TXN_RUV_MODS_FN and cleanup old stateinfo
  763. * -- should be done before transaction */
  764. /* if betxn is off, urp is called at bepreop. */
  765. rc = slapi_register_plugin("bepreoperation", 1 /* Enabled */,
  766. "multimaster_bepreop_init",
  767. multimaster_bepreop_init,
  768. "Multimaster replication bepreoperation plugin",
  769. NULL, identity);
  770. /* is_betxn: be post ops (add/del/mod/mdn) are combined into betxn ops.
  771. * no betxn: be post ops are regsitered at bepostoperation. */
  772. rc = slapi_register_plugin("betxnpostoperation", 1 /* Enabled */,
  773. "multimaster_betxnpostop_init",
  774. multimaster_betxnpostop_init,
  775. "Multimaster replication betxnpostoperation plugin",
  776. NULL, identity);
  777. if (repl5_is_betxn) {
  778. /* if betxn is on, urp is called at betxnpreop. */
  779. rc = slapi_register_plugin("betxnpreoperation", 1 /* Enabled */,
  780. "multimaster_betxnpreop_init",
  781. multimaster_betxnpreop_init,
  782. "Multimaster replication betxnpreoperation plugin",
  783. NULL, identity);
  784. /* bepostop configures open and backup only (no betxn) */
  785. rc = slapi_register_plugin("bepostoperation", 1 /* Enabled */,
  786. "multimaster_betxn_bepostop_init",
  787. multimaster_betxn_bepostop_init,
  788. "Multimaster replication bepostoperation plugin",
  789. NULL, identity);
  790. } else {
  791. /* bepostop configures open and backup only as well as add/del/
  792. * mod/mdn bepost ops */
  793. rc = slapi_register_plugin("bepostoperation", 1 /* Enabled */,
  794. "multimaster_bepostop_init",
  795. multimaster_bepostop_init,
  796. "Multimaster replication bepostoperation2 plugin",
  797. NULL, identity);
  798. }
  799. /* process_postop (core op of post op) frees CSN,
  800. * which should wait until betxn is done. */
  801. rc = slapi_register_plugin("postoperation", 1 /* Enabled */,
  802. "multimaster_postop_init",
  803. multimaster_postop_init,
  804. "Multimaster replication postoperation plugin",
  805. NULL, identity);
  806. rc = slapi_register_plugin("internalpreoperation", 1 /* Enabled */,
  807. "multimaster_internalpreop_init",
  808. multimaster_internalpreop_init,
  809. "Multimaster replication internal preoperation plugin",
  810. NULL, identity);
  811. rc = slapi_register_plugin("internalpostoperation", 1 /* Enabled */,
  812. "multimaster_internalpostop_init",
  813. multimaster_internalpostop_init,
  814. "Multimaster replication internal postoperation plugin",
  815. NULL, identity);
  816. rc = slapi_register_plugin("extendedop", 1 /* Enabled */, "multimaster_start_extop_init", multimaster_start_extop_init, "Multimaster replication start extended operation plugin", NULL, identity);
  817. rc = slapi_register_plugin("extendedop", 1 /* Enabled */, "multimaster_end_extop_init", multimaster_end_extop_init, "Multimaster replication end extended operation plugin", NULL, identity);
  818. rc = slapi_register_plugin("extendedop", 1 /* Enabled */, "multimaster_total_extop_init", multimaster_total_extop_init, "Multimaster replication total update extended operation plugin", NULL, identity);
  819. rc = slapi_register_plugin("extendedop", 1 /* Enabled */, "multimaster_response_extop_init", multimaster_response_extop_init, "Multimaster replication extended response plugin", NULL, identity);
  820. rc = slapi_register_plugin("extendedop", 1 /* Enabled */, "multimaster_cleanruv_extop_init", multimaster_cleanruv_extop_init, "Multimaster replication cleanruv extended operation plugin", NULL, identity);
  821. rc = slapi_register_plugin("extendedop", 1 /* Enabled */, "multimaster_cleanruv_abort_extop_init", multimaster_cleanruv_abort_extop_init, "Multimaster replication cleanruv abort extended operation plugin", NULL, identity);
  822. rc = slapi_register_plugin("extendedop", 1 /* Enabled */, "multimaster_cleanruv_maxcsn_extop_init", multimaster_cleanruv_maxcsn_extop_init, "Multimaster replication cleanruv maxcsn extended operation plugin", NULL, identity);
  823. rc = slapi_register_plugin("extendedop", 1 /* Enabled */, "multimaster_cleanruv_status_extop_init", multimaster_cleanruv_status_extop_init, "Multimaster replication cleanruv status extended operation plugin", NULL, identity);
  824. if (0 == rc) {
  825. multimaster_initialised = 1;
  826. }
  827. }
  828. return rc;
  829. }