totemconfig.c 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260
  1. /*
  2. * Copyright (c) 2002-2005 MontaVista Software, Inc.
  3. * Copyright (c) 2006-2018 Red Hat, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. * Author: Steven Dake (sdake@redhat.com)
  8. * Jan Friesse (jfriesse@redhat.com)
  9. *
  10. * This software licensed under BSD license, the text of which follows:
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * - Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  21. * contributors may be used to endorse or promote products derived from this
  22. * software without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  28. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  29. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  30. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  31. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  32. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  33. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  34. * THE POSSIBILITY OF SUCH DAMAGE.
  35. */
  36. #include <config.h>
  37. #include <stdio.h>
  38. #include <string.h>
  39. #include <stdlib.h>
  40. #include <errno.h>
  41. #include <unistd.h>
  42. #include <sys/socket.h>
  43. #include <sys/types.h>
  44. #include <sys/stat.h>
  45. #include <fcntl.h>
  46. #include <ifaddrs.h>
  47. #include <netdb.h>
  48. #include <netinet/in.h>
  49. #include <arpa/inet.h>
  50. #include <sys/param.h>
  51. #include <sys/utsname.h>
  52. #include <corosync/swab.h>
  53. #include <qb/qblist.h>
  54. #include <qb/qbdefs.h>
  55. #include <libknet.h>
  56. #include <corosync/totem/totem.h>
  57. #include <corosync/config.h>
  58. #include <corosync/logsys.h>
  59. #include <corosync/icmap.h>
  60. #include "util.h"
  61. #include "totemconfig.h"
  62. #define TOKEN_RETRANSMITS_BEFORE_LOSS_CONST 4
  63. #define TOKEN_TIMEOUT 1000
  64. #define TOKEN_WARNING 75
  65. #define TOKEN_COEFFICIENT 650
  66. #define JOIN_TIMEOUT 50
  67. #define MERGE_TIMEOUT 200
  68. #define DOWNCHECK_TIMEOUT 1000
  69. #define FAIL_TO_RECV_CONST 2500
  70. #define SEQNO_UNCHANGED_CONST 30
  71. #define MINIMUM_TIMEOUT (int)(1000/HZ)*3
  72. #define MINIMUM_TIMEOUT_HOLD (int)(MINIMUM_TIMEOUT * 0.8 - (1000/HZ))
  73. #define MAX_NETWORK_DELAY 50
  74. #define WINDOW_SIZE 50
  75. #define MAX_MESSAGES 17
  76. #define MISS_COUNT_CONST 5
  77. /* These currently match the defaults in libknet.h */
  78. #define KNET_PING_INTERVAL 1000
  79. #define KNET_PING_TIMEOUT 2000
  80. #define KNET_PING_PRECISION 2048
  81. #define KNET_PONG_COUNT 2
  82. #define KNET_PMTUD_INTERVAL 30
  83. #define KNET_DEFAULT_TRANSPORT KNET_TRANSPORT_UDP
  84. #define DEFAULT_PORT 5405
  85. static char error_string_response[768];
  86. static void add_totem_config_notification(struct totem_config *totem_config);
  87. static void *totem_get_param_by_name(struct totem_config *totem_config, const char *param_name)
  88. {
  89. if (strcmp(param_name, "totem.token") == 0)
  90. return &totem_config->token_timeout;
  91. if (strcmp(param_name, "totem.token_warning") == 0)
  92. return &totem_config->token_warning;
  93. if (strcmp(param_name, "totem.token_retransmit") == 0)
  94. return &totem_config->token_retransmit_timeout;
  95. if (strcmp(param_name, "totem.hold") == 0)
  96. return &totem_config->token_hold_timeout;
  97. if (strcmp(param_name, "totem.token_retransmits_before_loss_const") == 0)
  98. return &totem_config->token_retransmits_before_loss_const;
  99. if (strcmp(param_name, "totem.join") == 0)
  100. return &totem_config->join_timeout;
  101. if (strcmp(param_name, "totem.send_join") == 0)
  102. return &totem_config->send_join_timeout;
  103. if (strcmp(param_name, "totem.consensus") == 0)
  104. return &totem_config->consensus_timeout;
  105. if (strcmp(param_name, "totem.merge") == 0)
  106. return &totem_config->merge_timeout;
  107. if (strcmp(param_name, "totem.downcheck") == 0)
  108. return &totem_config->downcheck_timeout;
  109. if (strcmp(param_name, "totem.fail_recv_const") == 0)
  110. return &totem_config->fail_to_recv_const;
  111. if (strcmp(param_name, "totem.seqno_unchanged_const") == 0)
  112. return &totem_config->seqno_unchanged_const;
  113. if (strcmp(param_name, "totem.heartbeat_failures_allowed") == 0)
  114. return &totem_config->heartbeat_failures_allowed;
  115. if (strcmp(param_name, "totem.max_network_delay") == 0)
  116. return &totem_config->max_network_delay;
  117. if (strcmp(param_name, "totem.window_size") == 0)
  118. return &totem_config->window_size;
  119. if (strcmp(param_name, "totem.max_messages") == 0)
  120. return &totem_config->max_messages;
  121. if (strcmp(param_name, "totem.miss_count_const") == 0)
  122. return &totem_config->miss_count_const;
  123. if (strcmp(param_name, "totem.knet_pmtud_interval") == 0)
  124. return &totem_config->knet_pmtud_interval;
  125. if (strcmp(param_name, "totem.knet_compression_threshold") == 0)
  126. return &totem_config->knet_compression_threshold;
  127. if (strcmp(param_name, "totem.knet_compression_level") == 0)
  128. return &totem_config->knet_compression_level;
  129. if (strcmp(param_name, "totem.knet_compression_model") == 0)
  130. return &totem_config->knet_compression_model;
  131. return NULL;
  132. }
  133. /*
  134. * Read key_name from icmap. If key is not found or key_name == delete_key or if allow_zero is false
  135. * and readed value is zero, default value is used and stored into totem_config.
  136. */
  137. static void totem_volatile_config_set_uint32_value (struct totem_config *totem_config,
  138. const char *key_name, const char *deleted_key, unsigned int default_value,
  139. int allow_zero_value)
  140. {
  141. char runtime_key_name[ICMAP_KEYNAME_MAXLEN];
  142. if (icmap_get_uint32(key_name, totem_get_param_by_name(totem_config, key_name)) != CS_OK ||
  143. (deleted_key != NULL && strcmp(deleted_key, key_name) == 0) ||
  144. (!allow_zero_value && *(uint32_t *)totem_get_param_by_name(totem_config, key_name) == 0)) {
  145. *(uint32_t *)totem_get_param_by_name(totem_config, key_name) = default_value;
  146. }
  147. /*
  148. * Store totem_config value to cmap runtime section
  149. */
  150. if (strlen("runtime.config.") + strlen(key_name) >= ICMAP_KEYNAME_MAXLEN) {
  151. /*
  152. * This shouldn't happen
  153. */
  154. return ;
  155. }
  156. strcpy(runtime_key_name, "runtime.config.");
  157. strcat(runtime_key_name, key_name);
  158. icmap_set_uint32(runtime_key_name, *(uint32_t *)totem_get_param_by_name(totem_config, key_name));
  159. }
  160. static void totem_volatile_config_set_int32_value (struct totem_config *totem_config,
  161. const char *key_name, const char *deleted_key, int default_value,
  162. int allow_zero_value)
  163. {
  164. char runtime_key_name[ICMAP_KEYNAME_MAXLEN];
  165. if (icmap_get_int32(key_name, totem_get_param_by_name(totem_config, key_name)) != CS_OK ||
  166. (deleted_key != NULL && strcmp(deleted_key, key_name) == 0) ||
  167. (!allow_zero_value && *(int32_t *)totem_get_param_by_name(totem_config, key_name) == 0)) {
  168. *(int32_t *)totem_get_param_by_name(totem_config, key_name) = default_value;
  169. }
  170. /*
  171. * Store totem_config value to cmap runtime section
  172. */
  173. if (strlen("runtime.config.") + strlen(key_name) >= ICMAP_KEYNAME_MAXLEN) {
  174. /*
  175. * This shouldn't happen
  176. */
  177. return ;
  178. }
  179. strcpy(runtime_key_name, "runtime.config.");
  180. strcat(runtime_key_name, key_name);
  181. icmap_set_int32(runtime_key_name, *(int32_t *)totem_get_param_by_name(totem_config, key_name));
  182. }
  183. static void totem_volatile_config_set_string_value (struct totem_config *totem_config,
  184. const char *key_name, const char *deleted_key, const char *default_value)
  185. {
  186. char runtime_key_name[ICMAP_KEYNAME_MAXLEN];
  187. void **config_value;
  188. void *old_config_ptr;
  189. config_value = totem_get_param_by_name(totem_config, key_name);
  190. old_config_ptr = *config_value;
  191. if (icmap_get_string(key_name, totem_get_param_by_name(totem_config, key_name)) != CS_OK ||
  192. (deleted_key != NULL && strcmp(deleted_key, key_name) == 0)) {
  193. /* Need to strdup() here so that the free() below works for a default and a configured value */
  194. *config_value = strdup(default_value);
  195. }
  196. free(old_config_ptr);
  197. /*
  198. * Store totem_config value to cmap runtime section
  199. */
  200. if (strlen("runtime.config.") + strlen(key_name) >= ICMAP_KEYNAME_MAXLEN) {
  201. /*
  202. * This shouldn't happen
  203. */
  204. return ;
  205. }
  206. strcpy(runtime_key_name, "runtime.config.");
  207. strcat(runtime_key_name, key_name);
  208. icmap_set_string(runtime_key_name, (char *)*config_value);
  209. }
  210. /*
  211. * Read and validate config values from cmap and store them into totem_config. If key doesn't exists,
  212. * default value is stored. deleted_key is name of key beeing processed by delete operation
  213. * from cmap. It is considered as non existing even if it can be read. Can be NULL.
  214. */
  215. static void totem_volatile_config_read (struct totem_config *totem_config, const char *deleted_key)
  216. {
  217. uint32_t u32;
  218. totem_volatile_config_set_uint32_value(totem_config, "totem.token_retransmits_before_loss_const", deleted_key,
  219. TOKEN_RETRANSMITS_BEFORE_LOSS_CONST, 0);
  220. totem_volatile_config_set_uint32_value(totem_config, "totem.token", deleted_key, TOKEN_TIMEOUT, 0);
  221. totem_volatile_config_set_uint32_value(totem_config, "totem.token_warning", deleted_key, TOKEN_WARNING, 1);
  222. if (totem_config->interfaces[0].member_count > 2) {
  223. u32 = TOKEN_COEFFICIENT;
  224. icmap_get_uint32("totem.token_coefficient", &u32);
  225. totem_config->token_timeout += (totem_config->interfaces[0].member_count - 2) * u32;
  226. /*
  227. * Store totem_config value to cmap runtime section
  228. */
  229. icmap_set_uint32("runtime.config.totem.token", totem_config->token_timeout);
  230. }
  231. totem_volatile_config_set_uint32_value(totem_config, "totem.max_network_delay", deleted_key, MAX_NETWORK_DELAY, 0);
  232. totem_volatile_config_set_uint32_value(totem_config, "totem.window_size", deleted_key, WINDOW_SIZE, 0);
  233. totem_volatile_config_set_uint32_value(totem_config, "totem.max_messages", deleted_key, MAX_MESSAGES, 0);
  234. totem_volatile_config_set_uint32_value(totem_config, "totem.miss_count_const", deleted_key, MISS_COUNT_CONST, 0);
  235. totem_volatile_config_set_uint32_value(totem_config, "totem.knet_pmtud_interval", deleted_key, KNET_PMTUD_INTERVAL, 0);
  236. totem_volatile_config_set_uint32_value(totem_config, "totem.token_retransmit", deleted_key,
  237. (int)(totem_config->token_timeout / (totem_config->token_retransmits_before_loss_const + 0.2)), 0);
  238. totem_volatile_config_set_uint32_value(totem_config, "totem.hold", deleted_key,
  239. (int)(totem_config->token_retransmit_timeout * 0.8 - (1000/HZ)), 0);
  240. totem_volatile_config_set_uint32_value(totem_config, "totem.join", deleted_key, JOIN_TIMEOUT, 0);
  241. totem_volatile_config_set_uint32_value(totem_config, "totem.consensus", deleted_key,
  242. (int)(float)(1.2 * totem_config->token_timeout), 0);
  243. totem_volatile_config_set_uint32_value(totem_config, "totem.merge", deleted_key, MERGE_TIMEOUT, 0);
  244. totem_volatile_config_set_uint32_value(totem_config, "totem.downcheck", deleted_key, DOWNCHECK_TIMEOUT, 0);
  245. totem_volatile_config_set_uint32_value(totem_config, "totem.fail_recv_const", deleted_key, FAIL_TO_RECV_CONST, 0);
  246. totem_volatile_config_set_uint32_value(totem_config, "totem.seqno_unchanged_const", deleted_key,
  247. SEQNO_UNCHANGED_CONST, 0);
  248. totem_volatile_config_set_uint32_value(totem_config, "totem.send_join", deleted_key, 0, 1);
  249. totem_volatile_config_set_uint32_value(totem_config, "totem.heartbeat_failures_allowed", deleted_key, 0, 1);
  250. totem_volatile_config_set_uint32_value(totem_config, "totem.knet_compression_threshold", deleted_key, 0, 1);
  251. totem_volatile_config_set_int32_value(totem_config, "totem.knet_compression_level", deleted_key, 0, 1);
  252. totem_volatile_config_set_string_value(totem_config, "totem.knet_compression_model", deleted_key, "none");
  253. }
  254. static int totem_volatile_config_validate (
  255. struct totem_config *totem_config,
  256. const char **error_string)
  257. {
  258. static char local_error_reason[512];
  259. const char *error_reason = local_error_reason;
  260. char name_key[ICMAP_KEYNAME_MAXLEN];
  261. char *name_str;
  262. int i, num_configured, members;
  263. uint32_t tmp_config_value;
  264. if (totem_config->max_network_delay < MINIMUM_TIMEOUT) {
  265. snprintf (local_error_reason, sizeof(local_error_reason),
  266. "The max_network_delay parameter (%d ms) may not be less than (%d ms).",
  267. totem_config->max_network_delay, MINIMUM_TIMEOUT);
  268. goto parse_error;
  269. }
  270. if (totem_config->token_timeout < MINIMUM_TIMEOUT) {
  271. snprintf (local_error_reason, sizeof(local_error_reason),
  272. "The token timeout parameter (%d ms) may not be less than (%d ms).",
  273. totem_config->token_timeout, MINIMUM_TIMEOUT);
  274. goto parse_error;
  275. }
  276. if (totem_config->token_warning > 100 || totem_config->token_warning < 0) {
  277. snprintf (local_error_reason, sizeof(local_error_reason),
  278. "The token warning parameter (%d%%) must be between 0 (disabled) and 100.",
  279. totem_config->token_warning);
  280. goto parse_error;
  281. }
  282. if (totem_config->token_retransmit_timeout < MINIMUM_TIMEOUT) {
  283. if (icmap_get_uint32("totem.token_retransmit", &tmp_config_value) == CS_OK) {
  284. snprintf (local_error_reason, sizeof(local_error_reason),
  285. "The token retransmit timeout parameter (%d ms) may not be less than (%d ms).",
  286. totem_config->token_retransmit_timeout, MINIMUM_TIMEOUT);
  287. goto parse_error;
  288. } else {
  289. snprintf (local_error_reason, sizeof(local_error_reason),
  290. "Not appropriate token or token_retransmits_before_loss_const value set");
  291. goto parse_error;
  292. }
  293. }
  294. if (totem_config->token_hold_timeout < MINIMUM_TIMEOUT_HOLD) {
  295. snprintf (local_error_reason, sizeof(local_error_reason),
  296. "The token hold timeout parameter (%d ms) may not be less than (%d ms).",
  297. totem_config->token_hold_timeout, MINIMUM_TIMEOUT_HOLD);
  298. goto parse_error;
  299. }
  300. if (totem_config->join_timeout < MINIMUM_TIMEOUT) {
  301. snprintf (local_error_reason, sizeof(local_error_reason),
  302. "The join timeout parameter (%d ms) may not be less than (%d ms).",
  303. totem_config->join_timeout, MINIMUM_TIMEOUT);
  304. goto parse_error;
  305. }
  306. if (totem_config->consensus_timeout < MINIMUM_TIMEOUT) {
  307. snprintf (local_error_reason, sizeof(local_error_reason),
  308. "The consensus timeout parameter (%d ms) may not be less than (%d ms).",
  309. totem_config->consensus_timeout, MINIMUM_TIMEOUT);
  310. goto parse_error;
  311. }
  312. if (totem_config->consensus_timeout < totem_config->join_timeout) {
  313. snprintf (local_error_reason, sizeof(local_error_reason),
  314. "The consensus timeout parameter (%d ms) may not be less than join timeout (%d ms).",
  315. totem_config->consensus_timeout, totem_config->join_timeout);
  316. goto parse_error;
  317. }
  318. if (totem_config->merge_timeout < MINIMUM_TIMEOUT) {
  319. snprintf (local_error_reason, sizeof(local_error_reason),
  320. "The merge timeout parameter (%d ms) may not be less than (%d ms).",
  321. totem_config->merge_timeout, MINIMUM_TIMEOUT);
  322. goto parse_error;
  323. }
  324. if (totem_config->downcheck_timeout < MINIMUM_TIMEOUT) {
  325. snprintf (local_error_reason, sizeof(local_error_reason),
  326. "The downcheck timeout parameter (%d ms) may not be less than (%d ms).",
  327. totem_config->downcheck_timeout, MINIMUM_TIMEOUT);
  328. goto parse_error;
  329. }
  330. /* Check that we have nodelist 'name' if there is more than one link */
  331. num_configured = 0;
  332. for (i = 0; i < INTERFACE_MAX; i++) {
  333. if (totem_config->interfaces[i].configured) {
  334. num_configured++;
  335. }
  336. }
  337. if (num_configured > 1) {
  338. members = totem_config->interfaces[0].member_count;
  339. for (i=0; i<totem_config->interfaces[0].member_count; i++) {
  340. snprintf(name_key, sizeof(name_key), "nodelist.node.%d.name", i);
  341. if (icmap_get_string(name_key, &name_str) != CS_OK) {
  342. snprintf (local_error_reason, sizeof(local_error_reason),
  343. "for a multi-link configuration, all nodes must have a 'name' attribute");
  344. goto parse_error;
  345. }
  346. }
  347. for (i=0; i<num_configured; i++) {
  348. if (totem_config->interfaces[i].member_count != members) {
  349. snprintf (local_error_reason, sizeof(local_error_reason),
  350. "Not all nodes have the same number of links");
  351. goto parse_error;
  352. }
  353. }
  354. }
  355. return 0;
  356. parse_error:
  357. snprintf (error_string_response, sizeof(error_string_response),
  358. "parse error in config: %s\n", error_reason);
  359. *error_string = error_string_response;
  360. return (-1);
  361. }
  362. static int totem_get_crypto(struct totem_config *totem_config, const char **error_string)
  363. {
  364. char *str;
  365. const char *tmp_cipher;
  366. const char *tmp_hash;
  367. const char *tmp_model;
  368. tmp_hash = "none";
  369. tmp_cipher = "none";
  370. tmp_model = "none";
  371. if (icmap_get_string("totem.crypto_model", &str) == CS_OK) {
  372. if (strcmp(str, "nss") == 0) {
  373. tmp_model = "nss";
  374. }
  375. if (strcmp(str, "openssl") == 0) {
  376. tmp_model = "openssl";
  377. }
  378. free(str);
  379. } else {
  380. tmp_model = "nss";
  381. }
  382. if (icmap_get_string("totem.secauth", &str) == CS_OK) {
  383. if (strcmp(str, "on") == 0) {
  384. tmp_cipher = "aes256";
  385. tmp_hash = "sha256";
  386. }
  387. free(str);
  388. }
  389. if (icmap_get_string("totem.crypto_cipher", &str) == CS_OK) {
  390. if (strcmp(str, "none") == 0) {
  391. tmp_cipher = "none";
  392. }
  393. if (strcmp(str, "aes256") == 0) {
  394. tmp_cipher = "aes256";
  395. }
  396. if (strcmp(str, "aes192") == 0) {
  397. tmp_cipher = "aes192";
  398. }
  399. if (strcmp(str, "aes128") == 0) {
  400. tmp_cipher = "aes128";
  401. }
  402. free(str);
  403. }
  404. if (icmap_get_string("totem.crypto_hash", &str) == CS_OK) {
  405. if (strcmp(str, "none") == 0) {
  406. tmp_hash = "none";
  407. }
  408. if (strcmp(str, "md5") == 0) {
  409. tmp_hash = "md5";
  410. }
  411. if (strcmp(str, "sha1") == 0) {
  412. tmp_hash = "sha1";
  413. }
  414. if (strcmp(str, "sha256") == 0) {
  415. tmp_hash = "sha256";
  416. }
  417. if (strcmp(str, "sha384") == 0) {
  418. tmp_hash = "sha384";
  419. }
  420. if (strcmp(str, "sha512") == 0) {
  421. tmp_hash = "sha512";
  422. }
  423. free(str);
  424. }
  425. if ((strcmp(tmp_cipher, "none") != 0) &&
  426. (strcmp(tmp_hash, "none") == 0)) {
  427. *error_string = "crypto_cipher requires crypto_hash with value other than none";
  428. return -1;
  429. }
  430. if (strcmp(tmp_model, "none") == 0) {
  431. *error_string = "crypto_model should be 'nss' or 'openssl'";
  432. return -1;
  433. }
  434. free(totem_config->crypto_cipher_type);
  435. free(totem_config->crypto_hash_type);
  436. free(totem_config->crypto_model);
  437. totem_config->crypto_cipher_type = strdup(tmp_cipher);
  438. totem_config->crypto_hash_type = strdup(tmp_hash);
  439. totem_config->crypto_model = strdup(tmp_model);
  440. return 0;
  441. }
  442. static int nodelist_byname(const char *find_name, int strip_domain)
  443. {
  444. icmap_iter_t iter;
  445. const char *iter_key;
  446. char name_str[ICMAP_KEYNAME_MAXLEN];
  447. int res = 0;
  448. unsigned int node_pos;
  449. char *name;
  450. unsigned int namelen;
  451. iter = icmap_iter_init("nodelist.node.");
  452. while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
  453. res = sscanf(iter_key, "nodelist.node.%u.%s", &node_pos, name_str);
  454. if (res != 2) {
  455. continue;
  456. }
  457. /* ring0_addr is allowed as a fallback */
  458. if (strcmp(name_str, "name") && strcmp(name_str, "ring0_addr")) {
  459. continue;
  460. }
  461. if (icmap_get_string(iter_key, &name) != CS_OK) {
  462. continue;
  463. }
  464. namelen = strlen(name);
  465. if (strip_domain) {
  466. char *dot;
  467. dot = strchr(name, '.');
  468. if (dot) {
  469. namelen = name - dot - 1;
  470. }
  471. }
  472. if (strncmp(find_name, name, namelen) == 0 &&
  473. strlen(find_name) == strlen(name)) {
  474. icmap_iter_finalize(iter);
  475. return node_pos;
  476. }
  477. }
  478. icmap_iter_finalize(iter);
  479. return -1;
  480. }
  481. /* Compare two addresses - only address part (sin_addr/sin6_addr) is checked */
  482. static int ipaddr_equal(const struct sockaddr *addr1, const struct sockaddr *addr2)
  483. {
  484. int addrlen = 0;
  485. const void *addr1p, *addr2p;
  486. if (addr1->sa_family != addr2->sa_family)
  487. return 0;
  488. if (addr1->sa_family == AF_INET) {
  489. addrlen = sizeof(struct in_addr);
  490. addr1p = &((struct sockaddr_in *)addr1)->sin_addr;
  491. addr2p = &((struct sockaddr_in *)addr2)->sin_addr;
  492. }
  493. if (addr1->sa_family == AF_INET6) {
  494. addrlen = sizeof(struct in6_addr);
  495. addr1p = &((struct sockaddr_in6 *)addr1)->sin6_addr;
  496. addr2p = &((struct sockaddr_in6 *)addr2)->sin6_addr;
  497. }
  498. assert(addrlen);
  499. return (memcmp(addr1p, addr2p, addrlen) == 0);
  500. }
  501. /* Finds the local node and returns its position in the nodelist.
  502. * Uses nodelist.local_node_pos as a cache to save effort
  503. */
  504. static int find_local_node(int use_cache)
  505. {
  506. char nodename2[PATH_MAX];
  507. char name_str[ICMAP_KEYNAME_MAXLEN];
  508. icmap_iter_t iter;
  509. const char *iter_key;
  510. unsigned int cached_pos;
  511. char *dot = NULL;
  512. const char *node;
  513. struct ifaddrs *ifa, *ifa_list;
  514. struct sockaddr *sa;
  515. int found = 0;
  516. int node_pos = -1;
  517. int res;
  518. struct utsname utsname;
  519. /* Check for cached value first */
  520. if (use_cache) {
  521. if (icmap_get_uint32("nodelist.local_node_pos", &cached_pos) == CS_OK) {
  522. return cached_pos;
  523. }
  524. }
  525. res = uname(&utsname);
  526. if (res) {
  527. return -1;
  528. }
  529. node = utsname.nodename;
  530. /* 1. Exact match */
  531. node_pos = nodelist_byname(node, 0);
  532. if (node_pos > -1) {
  533. found = 1;
  534. goto ret_found;
  535. }
  536. /* 2. Try to match with increasingly more
  537. * specific versions of it
  538. */
  539. strcpy(nodename2, node);
  540. dot = strrchr(nodename2, '.');
  541. while (dot) {
  542. *dot = '\0';
  543. node_pos = nodelist_byname(nodename2, 0);
  544. if (node_pos > -1) {
  545. found = 1;
  546. goto ret_found;
  547. }
  548. dot = strrchr(nodename2, '.');
  549. }
  550. node_pos = nodelist_byname(nodename2, 1);
  551. if (node_pos > -1) {
  552. found = 1;
  553. goto ret_found;
  554. }
  555. /*
  556. * The corosync.conf name may not be related to uname at all,
  557. * they may match a hostname on some network interface.
  558. */
  559. if (getifaddrs(&ifa_list))
  560. return -1;
  561. for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
  562. socklen_t salen = 0;
  563. /* Restore this */
  564. strcpy(nodename2, node);
  565. sa = ifa->ifa_addr;
  566. if (!sa) {
  567. continue;
  568. }
  569. if (sa->sa_family != AF_INET && sa->sa_family != AF_INET6) {
  570. continue;
  571. }
  572. if (sa->sa_family == AF_INET) {
  573. salen = sizeof(struct sockaddr_in);
  574. }
  575. if (sa->sa_family == AF_INET6) {
  576. salen = sizeof(struct sockaddr_in6);
  577. }
  578. if (getnameinfo(sa, salen,
  579. nodename2, sizeof(nodename2),
  580. NULL, 0, 0) == 0) {
  581. node_pos = nodelist_byname(nodename2, 0);
  582. if (node_pos > -1) {
  583. found = 1;
  584. goto out;
  585. }
  586. /* Truncate this name and try again */
  587. dot = strchr(nodename2, '.');
  588. if (dot) {
  589. *dot = '\0';
  590. node_pos = nodelist_byname(nodename2, 0);
  591. if (node_pos > -1) {
  592. found = 1;
  593. goto out;
  594. }
  595. }
  596. }
  597. /* See if it's the IP address that's in corosync.conf */
  598. if (getnameinfo(sa, sizeof(*sa),
  599. nodename2, sizeof(nodename2),
  600. NULL, 0, NI_NUMERICHOST))
  601. continue;
  602. node_pos = nodelist_byname(nodename2, 0);
  603. if (node_pos > -1) {
  604. found = 1;
  605. goto out;
  606. }
  607. }
  608. out:
  609. if (found) {
  610. freeifaddrs(ifa_list);
  611. goto ret_found;
  612. }
  613. /*
  614. * This section covers the usecase where the nodename specified in cluster.conf
  615. * is an alias specified in /etc/hosts. For example:
  616. * <ipaddr> hostname alias1 alias2
  617. * and <clusternode name="alias2">
  618. * the above calls use uname and getnameinfo does not return aliases.
  619. * here we take the name specified in cluster.conf, resolve it to an address
  620. * and then compare against all known local ip addresses.
  621. * if we have a match, we found our nodename. In theory this chunk of code
  622. * could replace all the checks above, but let's avoid any possible regressions
  623. * and use it as last.
  624. */
  625. iter = icmap_iter_init("nodelist.node.");
  626. while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
  627. char *dbnodename = NULL;
  628. struct addrinfo hints;
  629. struct addrinfo *result = NULL, *rp = NULL;
  630. res = sscanf(iter_key, "nodelist.node.%u.%s", &node_pos, name_str);
  631. if (res != 2) {
  632. continue;
  633. }
  634. /* 'ring0_addr' is allowed as a fallback, but 'name' will be found first
  635. * because the names are in alpha order.
  636. */
  637. if (strcmp(name_str, "name") && strcmp(name_str, "ring0_addr")) {
  638. continue;
  639. }
  640. if (icmap_get_string(iter_key, &dbnodename) != CS_OK) {
  641. continue;
  642. }
  643. memset(&hints, 0, sizeof(struct addrinfo));
  644. hints.ai_family = AF_UNSPEC;
  645. hints.ai_socktype = SOCK_DGRAM;
  646. hints.ai_flags = 0;
  647. hints.ai_protocol = IPPROTO_UDP;
  648. if (getaddrinfo(dbnodename, NULL, &hints, &result)) {
  649. continue;
  650. }
  651. for (rp = result; rp != NULL; rp = rp->ai_next) {
  652. for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
  653. if (ifa->ifa_addr &&
  654. ipaddr_equal(rp->ai_addr, ifa->ifa_addr)) {
  655. freeaddrinfo(result);
  656. found = 1;
  657. goto out2;
  658. }
  659. }
  660. }
  661. freeaddrinfo(result);
  662. }
  663. out2:
  664. icmap_iter_finalize(iter);
  665. freeifaddrs(ifa_list);
  666. ret_found:
  667. if (found) {
  668. res = icmap_set_uint32("nodelist.local_node_pos", node_pos);
  669. }
  670. return node_pos;
  671. }
  672. static enum totem_ip_version_enum totem_config_get_ip_version(struct totem_config *totem_config)
  673. {
  674. enum totem_ip_version_enum res;
  675. char *str;
  676. res = TOTEM_IP_VERSION_6_4;
  677. if (totem_config->transport_number == TOTEM_TRANSPORT_UDP) {
  678. res = TOTEM_IP_VERSION_4;
  679. }
  680. if (icmap_get_string("totem.ip_version", &str) == CS_OK) {
  681. if (strcmp(str, "ipv4") == 0) {
  682. res = TOTEM_IP_VERSION_4;
  683. }
  684. if (strcmp(str, "ipv6") == 0) {
  685. res = TOTEM_IP_VERSION_6;
  686. }
  687. if (strcmp(str, "ipv6-4") == 0) {
  688. res = TOTEM_IP_VERSION_6_4;
  689. }
  690. if (strcmp(str, "ipv4-6") == 0) {
  691. res = TOTEM_IP_VERSION_4_6;
  692. }
  693. free(str);
  694. }
  695. return (res);
  696. }
  697. static uint16_t generate_cluster_id (const char *cluster_name)
  698. {
  699. int i;
  700. int value = 0;
  701. for (i = 0; i < strlen(cluster_name); i++) {
  702. value <<= 1;
  703. value += cluster_name[i];
  704. }
  705. return (value & 0xFFFF);
  706. }
  707. static int get_cluster_mcast_addr (
  708. const char *cluster_name,
  709. unsigned int linknumber,
  710. enum totem_ip_version_enum ip_version,
  711. struct totem_ip_address *res)
  712. {
  713. uint16_t clusterid;
  714. char addr[INET6_ADDRSTRLEN + 1];
  715. int err;
  716. if (cluster_name == NULL) {
  717. return (-1);
  718. }
  719. clusterid = generate_cluster_id(cluster_name) + linknumber;
  720. memset (res, 0, sizeof(*res));
  721. switch (ip_version) {
  722. case TOTEM_IP_VERSION_4:
  723. case TOTEM_IP_VERSION_4_6:
  724. snprintf(addr, sizeof(addr), "239.192.%d.%d", clusterid >> 8, clusterid % 0xFF);
  725. break;
  726. case TOTEM_IP_VERSION_6:
  727. case TOTEM_IP_VERSION_6_4:
  728. snprintf(addr, sizeof(addr), "ff15::%x", clusterid);
  729. break;
  730. default:
  731. /*
  732. * Unknown family
  733. */
  734. return (-1);
  735. }
  736. err = totemip_parse (res, addr, ip_version);
  737. return (err);
  738. }
  739. static unsigned int generate_nodeid(
  740. struct totem_config *totem_config,
  741. char *addr)
  742. {
  743. unsigned int nodeid;
  744. struct totem_ip_address totemip;
  745. /* AF_INET hard-coded here because auto-generated nodeids
  746. are only for IPv4 */
  747. if (totemip_parse(&totemip, addr, TOTEM_IP_VERSION_4) != 0)
  748. return -1;
  749. memcpy (&nodeid, &totemip.addr, sizeof (unsigned int));
  750. #if __BYTE_ORDER == __LITTLE_ENDIAN
  751. nodeid = swab32 (nodeid);
  752. #endif
  753. if (totem_config->clear_node_high_bit) {
  754. nodeid &= 0x7FFFFFFF;
  755. }
  756. return nodeid;
  757. }
  758. static int check_for_duplicate_nodeids(
  759. struct totem_config *totem_config,
  760. const char **error_string)
  761. {
  762. icmap_iter_t iter;
  763. icmap_iter_t subiter;
  764. const char *iter_key;
  765. int res = 0;
  766. int retval = 0;
  767. char tmp_key[ICMAP_KEYNAME_MAXLEN];
  768. char *ring0_addr=NULL;
  769. char *ring0_addr1=NULL;
  770. unsigned int node_pos;
  771. unsigned int node_pos1;
  772. unsigned int last_node_pos = -1;
  773. unsigned int nodeid;
  774. unsigned int nodeid1;
  775. int autogenerated;
  776. iter = icmap_iter_init("nodelist.node.");
  777. while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
  778. res = sscanf(iter_key, "nodelist.node.%u.%s", &node_pos, tmp_key);
  779. if (res != 2) {
  780. continue;
  781. }
  782. /*
  783. * This relies on the fact the icmap keys are always returned in order
  784. * so all of the keys for a node will be grouped together. We're basically
  785. * just running the code below once for each node.
  786. */
  787. if (last_node_pos == node_pos) {
  788. continue;
  789. }
  790. last_node_pos = node_pos;
  791. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", node_pos);
  792. autogenerated = 0;
  793. /* Generated nodeids are only allowed for UDP/UDPU so ring0_addr is valid here */
  794. if (icmap_get_uint32(tmp_key, &nodeid) != CS_OK) {
  795. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.ring0_addr", node_pos);
  796. if (icmap_get_string(tmp_key, &ring0_addr) != CS_OK) {
  797. continue;
  798. }
  799. /* Generate nodeid so we can check that auto-generated nodeids don't clash either */
  800. nodeid = generate_nodeid(totem_config, ring0_addr);
  801. if (nodeid == -1) {
  802. continue;
  803. }
  804. autogenerated = 1;
  805. }
  806. node_pos1 = 0;
  807. subiter = icmap_iter_init("nodelist.node.");
  808. while (((iter_key = icmap_iter_next(subiter, NULL, NULL)) != NULL) && (node_pos1 < node_pos)) {
  809. res = sscanf(iter_key, "nodelist.node.%u.%s", &node_pos1, tmp_key);
  810. if ((res != 2) || (node_pos1 >= node_pos)) {
  811. continue;
  812. }
  813. if (strcmp(tmp_key, "nodeid") != 0) {
  814. continue;
  815. }
  816. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", node_pos1);
  817. if (icmap_get_uint32(tmp_key, &nodeid1) != CS_OK) {
  818. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.ring0_addr", node_pos1);
  819. if (icmap_get_string(tmp_key, &ring0_addr1) != CS_OK) {
  820. continue;
  821. }
  822. nodeid1 = generate_nodeid(totem_config, ring0_addr1);
  823. if (nodeid1 == -1) {
  824. continue;
  825. }
  826. }
  827. if (nodeid == nodeid1) {
  828. retval = -1;
  829. snprintf (error_string_response, sizeof(error_string_response),
  830. "Nodeid %u%s%s%s appears twice in corosync.conf", nodeid,
  831. autogenerated?"(autogenerated from ":"",
  832. autogenerated?ring0_addr:"",
  833. autogenerated?")":"");
  834. log_printf (LOGSYS_LEVEL_ERROR, error_string_response);
  835. *error_string = error_string_response;
  836. break;
  837. }
  838. }
  839. icmap_iter_finalize(subiter);
  840. }
  841. icmap_iter_finalize(iter);
  842. return retval;
  843. }
  844. /*
  845. * This needs to be done last of all. It would be nice to do it when reading the
  846. * interface params, but the totem params need to have them to be read first. We
  847. * need both, so this is a way round that circular dependancy.
  848. */
  849. static void calc_knet_ping_timers(struct totem_config *totem_config)
  850. {
  851. char runtime_key_name[ICMAP_KEYNAME_MAXLEN];
  852. int interface;
  853. for (interface = 0; interface < INTERFACE_MAX; interface++) {
  854. if (totem_config->interfaces[interface].configured) {
  855. if (!totem_config->interfaces[interface].knet_pong_count) {
  856. totem_config->interfaces[interface].knet_pong_count = KNET_PONG_COUNT;
  857. }
  858. if (!totem_config->interfaces[interface].knet_ping_timeout) {
  859. totem_config->interfaces[interface].knet_ping_timeout =
  860. totem_config->token_timeout / totem_config->interfaces[interface].knet_pong_count;
  861. }
  862. snprintf(runtime_key_name, sizeof(runtime_key_name),
  863. "runtime.config.totem.interface.%d.knet_ping_timeout", interface);
  864. icmap_set_uint32(runtime_key_name, totem_config->interfaces[interface].knet_ping_timeout);
  865. if (!totem_config->interfaces[interface].knet_ping_interval) {
  866. totem_config->interfaces[interface].knet_ping_interval =
  867. totem_config->token_timeout / (totem_config->interfaces[interface].knet_pong_count * 2);
  868. }
  869. snprintf(runtime_key_name, sizeof(runtime_key_name),
  870. "runtime.config.totem.interface.%d.knet_ping_interval", interface);
  871. icmap_set_uint32(runtime_key_name, totem_config->interfaces[interface].knet_ping_interval);
  872. }
  873. }
  874. }
  875. /*
  876. * Compute difference between two set of totem interface arrays. set1 and set2
  877. * are changed so for same ring, ip existing in both set1 and set2 are cleared
  878. * (set to 0), and ips which are only in set1 or set2 remains untouched.
  879. * totempg_node_add/remove is called.
  880. */
  881. static void compute_interfaces_diff(struct totem_interface *set1,
  882. struct totem_interface *set2)
  883. {
  884. int ring_no, set1_pos, set2_pos;
  885. struct totem_ip_address empty_ip_address;
  886. memset(&empty_ip_address, 0, sizeof(empty_ip_address));
  887. for (ring_no = 0; ring_no < INTERFACE_MAX; ring_no++) {
  888. if (!set1[ring_no].configured && !set2[ring_no].configured) {
  889. continue;
  890. }
  891. for (set1_pos = 0; set1_pos < set1[ring_no].member_count; set1_pos++) {
  892. for (set2_pos = 0; set2_pos < set2[ring_no].member_count; set2_pos++) {
  893. /*
  894. * For current ring_no remove all set1 items existing
  895. * in set2
  896. */
  897. if (memcmp(&set1[ring_no].member_list[set1_pos],
  898. &set2[ring_no].member_list[set2_pos],
  899. sizeof(struct totem_ip_address)) == 0) {
  900. memset(&set1[ring_no].member_list[set1_pos], 0,
  901. sizeof(struct totem_ip_address));
  902. memset(&set2[ring_no].member_list[set2_pos], 0,
  903. sizeof(struct totem_ip_address));
  904. }
  905. }
  906. }
  907. }
  908. for (ring_no = 0; ring_no < INTERFACE_MAX; ring_no++) {
  909. for (set1_pos = 0; set1_pos < set1[ring_no].member_count; set1_pos++) {
  910. /*
  911. * All items which remained in set1 doesn't exists in set2 any longer so
  912. * node has to be removed.
  913. */
  914. if (memcmp(&set1[ring_no].member_list[set1_pos], &empty_ip_address, sizeof(empty_ip_address)) != 0) {
  915. log_printf(LOGSYS_LEVEL_DEBUG,
  916. "removing dynamic member %s for ring %u",
  917. totemip_print(&set1[ring_no].member_list[set1_pos]),
  918. ring_no);
  919. totempg_member_remove(&set1[ring_no].member_list[set1_pos], ring_no);
  920. }
  921. }
  922. if (!set2[ring_no].configured) {
  923. continue;
  924. }
  925. for (set2_pos = 0; set2_pos < set2[ring_no].member_count; set2_pos++) {
  926. /*
  927. * All items which remained in set2 doesn't existed in set1 so this is no node
  928. * and has to be added.
  929. */
  930. if (memcmp(&set2[ring_no].member_list[set2_pos], &empty_ip_address, sizeof(empty_ip_address)) != 0) {
  931. log_printf(LOGSYS_LEVEL_DEBUG,
  932. "adding dynamic member %s for ring %u",
  933. totemip_print(&set2[ring_no].member_list[set2_pos]),
  934. ring_no);
  935. totempg_member_add(&set2[ring_no].member_list[set2_pos], ring_no);
  936. }
  937. }
  938. }
  939. }
  940. /*
  941. * Reconfigure links in totempg. Sets new local IP address and adds params for new links.
  942. */
  943. static void reconfigure_links(struct totem_config *totem_config)
  944. {
  945. int i;
  946. char tmp_key[ICMAP_KEYNAME_MAXLEN];
  947. char *addr_string;
  948. struct totem_ip_address local_ip;
  949. int err;
  950. int local_node_pos = find_local_node(0);
  951. for (i = 0; i<INTERFACE_MAX; i++) {
  952. if (!totem_config->interfaces[i].configured) {
  953. continue;
  954. }
  955. log_printf(LOGSYS_LEVEL_INFO, "Configuring link %d\n", i);
  956. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.ring%u_addr", local_node_pos, i);
  957. if (icmap_get_string(tmp_key, &addr_string) != CS_OK) {
  958. continue;
  959. }
  960. err = totemip_parse(&local_ip, addr_string, totem_config->ip_version);
  961. if (err != 0) {
  962. continue;
  963. }
  964. local_ip.nodeid = totem_config->node_id;
  965. /* In case this is a new link, fill in the defaults if there was no interface{} section for it */
  966. if (!totem_config->interfaces[i].knet_link_priority)
  967. totem_config->interfaces[i].knet_link_priority = 1;
  968. /* knet_ping_interval & knet_ping_timeout are set later once we know all the other params */
  969. if (!totem_config->interfaces[i].knet_ping_precision)
  970. totem_config->interfaces[i].knet_ping_precision = KNET_PING_PRECISION;
  971. if (!totem_config->interfaces[i].knet_pong_count)
  972. totem_config->interfaces[i].knet_pong_count = KNET_PONG_COUNT;
  973. if (!totem_config->interfaces[i].knet_transport)
  974. totem_config->interfaces[i].knet_transport = KNET_TRANSPORT_UDP;
  975. if (!totem_config->interfaces[i].ip_port)
  976. totem_config->interfaces[i].ip_port = DEFAULT_PORT + i;
  977. totempg_iface_set(&local_ip, totem_config->interfaces[i].ip_port, i);
  978. }
  979. }
  980. /* Check for differences in config that can't be done on-the-fly and print an error */
  981. static void check_things_have_not_changed(struct totem_config *totem_config)
  982. {
  983. int i,j;
  984. const char *ip_str;
  985. char addr_buf[INET6_ADDRSTRLEN];
  986. int changed = 0;
  987. for (i = 0; i<INTERFACE_MAX; i++) {
  988. if (totem_config->interfaces[i].configured &&
  989. totem_config->orig_interfaces[i].configured) {
  990. if (totem_config->interfaces[i].knet_transport !=
  991. totem_config->orig_interfaces[i].knet_transport) {
  992. log_printf(LOGSYS_LEVEL_ERROR,
  993. "New config has different knet transport for link %d. Internal value was NOT changed.\n", i);
  994. changed = 1;
  995. }
  996. for (j=0; j < min(totem_config->interfaces[i].member_count, totem_config->orig_interfaces[i].member_count); j++) {
  997. if (memcmp(&totem_config->interfaces[i].member_list[j],
  998. &totem_config->orig_interfaces[i].member_list[j],
  999. sizeof(struct totem_ip_address))) {
  1000. ip_str = totemip_print(&totem_config->orig_interfaces[i].member_list[j]);
  1001. /* if ip_str is NULL then the old address was invalid and is allowed to change */
  1002. if (ip_str) {
  1003. strncpy(addr_buf, ip_str, sizeof(addr_buf));
  1004. addr_buf[sizeof(addr_buf) - 1] = '\0';
  1005. log_printf(LOGSYS_LEVEL_ERROR,
  1006. "new config has different address for link %d (addr changed from %s to %s). Internal value was NOT changed.\n",
  1007. i, addr_buf, totemip_print(&totem_config->interfaces[i].member_list[j]));
  1008. changed = 1;
  1009. }
  1010. }
  1011. }
  1012. }
  1013. }
  1014. if (changed) {
  1015. log_printf(LOGSYS_LEVEL_ERROR, "To reconfigure an interface it must be deleted and recreated. A working interface needs to be available to corosync at all times");
  1016. }
  1017. }
  1018. static int put_nodelist_members_to_config(struct totem_config *totem_config, int reload, const char **error_string)
  1019. {
  1020. icmap_iter_t iter, iter2;
  1021. const char *iter_key, *iter_key2;
  1022. int res = 0;
  1023. unsigned int node_pos;
  1024. char tmp_key[ICMAP_KEYNAME_MAXLEN];
  1025. char tmp_key2[ICMAP_KEYNAME_MAXLEN];
  1026. char *node_addr_str;
  1027. int member_count;
  1028. unsigned int linknumber = 0;
  1029. int i, j;
  1030. int last_node_pos = -1;
  1031. struct totem_interface *new_interfaces = NULL;
  1032. if (reload) {
  1033. /*
  1034. * We need to compute diff only for reload. Also for initial configuration
  1035. * not all totem structures are initialized so corosync will crash during
  1036. * member_add/remove
  1037. */
  1038. new_interfaces = malloc (sizeof (struct totem_interface) * INTERFACE_MAX);
  1039. assert(new_interfaces != NULL);
  1040. }
  1041. /* Clear out nodelist so we can put the new one in if needed */
  1042. for (i = 0; i < INTERFACE_MAX; i++) {
  1043. for (j = 0; j < PROCESSOR_COUNT_MAX; j++) {
  1044. memset(&totem_config->interfaces[i].member_list[j], 0, sizeof(struct totem_ip_address));
  1045. }
  1046. totem_config->interfaces[i].member_count = 0;
  1047. }
  1048. iter = icmap_iter_init("nodelist.node.");
  1049. while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
  1050. res = sscanf(iter_key, "nodelist.node.%u.%s", &node_pos, tmp_key);
  1051. if (res != 2) {
  1052. continue;
  1053. }
  1054. /* If it's the same as the last node_pos then skip it */
  1055. if (node_pos == last_node_pos) {
  1056. continue;
  1057. }
  1058. last_node_pos = node_pos;
  1059. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.", node_pos);
  1060. iter2 = icmap_iter_init(tmp_key);
  1061. while ((iter_key2 = icmap_iter_next(iter2, NULL, NULL)) != NULL) {
  1062. unsigned int nodeid;
  1063. char *str;
  1064. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", node_pos);
  1065. if (icmap_get_uint32(tmp_key, &nodeid) != CS_OK) {
  1066. nodeid = 0;
  1067. }
  1068. res = sscanf(iter_key2, "nodelist.node.%u.ring%u%s", &node_pos, &linknumber, tmp_key2);
  1069. if (res != 3 || strcmp(tmp_key2, "_addr") != 0) {
  1070. continue;
  1071. }
  1072. if (icmap_get_string(iter_key2, &node_addr_str) != CS_OK) {
  1073. continue;
  1074. }
  1075. /* Generate nodeids if they are not provided and transport is UDP/U */
  1076. if (!nodeid &&
  1077. (totem_config->transport_number == TOTEM_TRANSPORT_UDP ||
  1078. totem_config->transport_number == TOTEM_TRANSPORT_UDPU)) {
  1079. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.ring0_addr", node_pos);
  1080. if (icmap_get_string(tmp_key, &str) == CS_OK) {
  1081. nodeid = generate_nodeid(totem_config, str);
  1082. if (nodeid == -1) {
  1083. sprintf(error_string_response,
  1084. "An IPV6 network requires that a node ID be specified "
  1085. "for address '%s'.", node_addr_str);
  1086. *error_string = error_string_response;
  1087. free(str);
  1088. return (-1);
  1089. }
  1090. log_printf(LOGSYS_LEVEL_DEBUG,
  1091. "Generated nodeid = 0x%x for %s", nodeid, str);
  1092. free(str);
  1093. }
  1094. }
  1095. member_count = totem_config->interfaces[linknumber].member_count;
  1096. res = totemip_parse(&totem_config->interfaces[linknumber].member_list[member_count],
  1097. node_addr_str, totem_config->ip_version);
  1098. if (res == 0) {
  1099. totem_config->interfaces[linknumber].member_list[member_count].nodeid = nodeid;
  1100. totem_config->interfaces[linknumber].member_count++;
  1101. totem_config->interfaces[linknumber].configured = 1;
  1102. } else {
  1103. sprintf(error_string_response, "failed to parse node address '%s'\n", node_addr_str);
  1104. *error_string = error_string_response;
  1105. memset(&totem_config->interfaces[linknumber].member_list[member_count], 0,
  1106. sizeof(struct totem_ip_address));
  1107. free(node_addr_str);
  1108. icmap_iter_finalize(iter2);
  1109. icmap_iter_finalize(iter);
  1110. return -1;
  1111. }
  1112. free(node_addr_str);
  1113. }
  1114. icmap_iter_finalize(iter2);
  1115. }
  1116. icmap_iter_finalize(iter);
  1117. if (reload) {
  1118. log_printf(LOGSYS_LEVEL_DEBUG, "About to reconfigure links from nodelist.\n");
  1119. reconfigure_links(totem_config);
  1120. memcpy(new_interfaces, totem_config->interfaces, sizeof (struct totem_interface) * INTERFACE_MAX);
  1121. check_things_have_not_changed(totem_config);
  1122. compute_interfaces_diff(totem_config->orig_interfaces, new_interfaces);
  1123. free(new_interfaces);
  1124. }
  1125. return 0;
  1126. }
  1127. static void config_convert_nodelist_to_interface(struct totem_config *totem_config)
  1128. {
  1129. int res = 0;
  1130. int node_pos;
  1131. char tmp_key[ICMAP_KEYNAME_MAXLEN];
  1132. char tmp_key2[ICMAP_KEYNAME_MAXLEN];
  1133. char *node_addr_str;
  1134. unsigned int linknumber = 0;
  1135. icmap_iter_t iter;
  1136. const char *iter_key;
  1137. node_pos = find_local_node(1);
  1138. if (node_pos > -1) {
  1139. /*
  1140. * We found node, so create interface section
  1141. */
  1142. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.", node_pos);
  1143. iter = icmap_iter_init(tmp_key);
  1144. while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
  1145. res = sscanf(iter_key, "nodelist.node.%u.ring%u%s", &node_pos, &linknumber, tmp_key2);
  1146. if (res != 3 || strcmp(tmp_key2, "_addr") != 0) {
  1147. continue ;
  1148. }
  1149. if (icmap_get_string(iter_key, &node_addr_str) != CS_OK) {
  1150. continue;
  1151. }
  1152. snprintf(tmp_key2, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.bindnetaddr", linknumber);
  1153. icmap_set_string(tmp_key2, node_addr_str);
  1154. free(node_addr_str);
  1155. }
  1156. icmap_iter_finalize(iter);
  1157. }
  1158. }
  1159. static int get_interface_params(struct totem_config *totem_config,
  1160. const char **error_string, uint64_t *warnings,
  1161. int reload)
  1162. {
  1163. int res = 0;
  1164. unsigned int linknumber = 0;
  1165. int member_count = 0;
  1166. int i;
  1167. icmap_iter_t iter, member_iter;
  1168. const char *iter_key;
  1169. const char *member_iter_key;
  1170. char linknumber_key[ICMAP_KEYNAME_MAXLEN];
  1171. char tmp_key[ICMAP_KEYNAME_MAXLEN];
  1172. uint8_t u8;
  1173. uint32_t u32;
  1174. char *str;
  1175. char *cluster_name = NULL;
  1176. enum totem_ip_version_enum tmp_ip_version = TOTEM_IP_VERSION_4;
  1177. if (reload) {
  1178. for (i=0; i<INTERFACE_MAX; i++) {
  1179. /*
  1180. * Set back to defaults things that might have been configured and
  1181. * now have been taken out of corosync.conf. These won't be caught by the
  1182. * code below which only looks at interface{} sections that actually exist.
  1183. */
  1184. totem_config->interfaces[i].configured = 0;
  1185. totem_config->interfaces[i].knet_ping_timeout = 0;
  1186. totem_config->interfaces[i].knet_ping_interval = 0;
  1187. totem_config->interfaces[i].knet_ping_precision = KNET_PING_PRECISION;
  1188. totem_config->interfaces[i].knet_pong_count = KNET_PONG_COUNT;
  1189. }
  1190. }
  1191. if (icmap_get_string("totem.cluster_name", &cluster_name) != CS_OK) {
  1192. cluster_name = NULL;
  1193. }
  1194. iter = icmap_iter_init("totem.interface.");
  1195. while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
  1196. res = sscanf(iter_key, "totem.interface.%[^.].%s", linknumber_key, tmp_key);
  1197. if (res != 2) {
  1198. continue;
  1199. }
  1200. if (strcmp(tmp_key, "bindnetaddr") != 0 && totem_config->transport_number == TOTEM_TRANSPORT_UDP) {
  1201. continue;
  1202. }
  1203. member_count = 0;
  1204. linknumber = atoi(linknumber_key);
  1205. if (linknumber >= INTERFACE_MAX) {
  1206. free(cluster_name);
  1207. snprintf (error_string_response, sizeof(error_string_response),
  1208. "parse error in config: interface ring number %u is bigger than allowed maximum %u\n",
  1209. linknumber, INTERFACE_MAX - 1);
  1210. *error_string = error_string_response;
  1211. return -1;
  1212. }
  1213. /* These things are only valid for the initial read */
  1214. if (!reload) {
  1215. /*
  1216. * Get the bind net address
  1217. */
  1218. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.bindnetaddr", linknumber);
  1219. if (icmap_get_string(tmp_key, &str) == CS_OK) {
  1220. res = totemip_parse (&totem_config->interfaces[linknumber].bindnet, str,
  1221. totem_config->ip_version);
  1222. if (res) {
  1223. sprintf(error_string_response, "failed to parse bindnet address '%s'\n", str);
  1224. *error_string = error_string_response;
  1225. free(str);
  1226. return -1;
  1227. }
  1228. free(str);
  1229. }
  1230. /*
  1231. * Get interface multicast address
  1232. */
  1233. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.mcastaddr", linknumber);
  1234. if (icmap_get_string(tmp_key, &str) == CS_OK) {
  1235. res = totemip_parse (&totem_config->interfaces[linknumber].mcast_addr, str,
  1236. totem_config->ip_version);
  1237. if (res) {
  1238. sprintf(error_string_response, "failed to parse mcast address '%s'\n", str);
  1239. *error_string = error_string_response;
  1240. free(str);
  1241. return -1;
  1242. }
  1243. free(str);
  1244. } else if (totem_config->transport_number == TOTEM_TRANSPORT_UDP) {
  1245. /*
  1246. * User not specified address -> autogenerate one from cluster_name key
  1247. * (if available). Return code is intentionally ignored, because
  1248. * udpu doesn't need mcastaddr and validity of mcastaddr for udp is
  1249. * checked later anyway.
  1250. */
  1251. if (totem_config->interfaces[0].bindnet.family == AF_INET) {
  1252. tmp_ip_version = TOTEM_IP_VERSION_4;
  1253. } else if (totem_config->interfaces[0].bindnet.family == AF_INET6) {
  1254. tmp_ip_version = TOTEM_IP_VERSION_6;
  1255. }
  1256. (void)get_cluster_mcast_addr (cluster_name,
  1257. linknumber,
  1258. tmp_ip_version,
  1259. &totem_config->interfaces[linknumber].mcast_addr);
  1260. }
  1261. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.broadcast", linknumber);
  1262. if (icmap_get_string(tmp_key, &str) == CS_OK) {
  1263. if (strcmp (str, "yes") == 0) {
  1264. totem_config->broadcast_use = 1;
  1265. }
  1266. free(str);
  1267. }
  1268. }
  1269. /* These things are only valid for the initial read OR a newly-defined link */
  1270. if (!reload || (totem_config->interfaces[linknumber].configured == 0)) {
  1271. /*
  1272. * Get mcast port
  1273. */
  1274. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.mcastport", linknumber);
  1275. if (icmap_get_uint16(tmp_key, &totem_config->interfaces[linknumber].ip_port) != CS_OK) {
  1276. if (totem_config->broadcast_use) {
  1277. totem_config->interfaces[linknumber].ip_port = DEFAULT_PORT + (2 * linknumber);
  1278. } else {
  1279. totem_config->interfaces[linknumber].ip_port = DEFAULT_PORT + linknumber;
  1280. }
  1281. }
  1282. /*
  1283. * Get the TTL
  1284. */
  1285. totem_config->interfaces[linknumber].ttl = 1;
  1286. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.ttl", linknumber);
  1287. if (icmap_get_uint8(tmp_key, &u8) == CS_OK) {
  1288. totem_config->interfaces[linknumber].ttl = u8;
  1289. }
  1290. totem_config->interfaces[linknumber].knet_transport = KNET_DEFAULT_TRANSPORT;
  1291. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.knet_transport", linknumber);
  1292. if (icmap_get_string(tmp_key, &str) == CS_OK) {
  1293. if (strcmp(str, "sctp") == 0) {
  1294. totem_config->interfaces[linknumber].knet_transport = KNET_TRANSPORT_SCTP;
  1295. }
  1296. else if (strcmp(str, "udp") == 0) {
  1297. totem_config->interfaces[linknumber].knet_transport = KNET_TRANSPORT_UDP;
  1298. }
  1299. else {
  1300. *error_string = "Unrecognised knet_transport. expected 'udp' or 'sctp'";
  1301. return -1;
  1302. }
  1303. }
  1304. }
  1305. totem_config->interfaces[linknumber].configured = 1;
  1306. /*
  1307. * Get the knet link params
  1308. */
  1309. totem_config->interfaces[linknumber].knet_link_priority = 1;
  1310. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.knet_link_priority", linknumber);
  1311. if (icmap_get_uint8(tmp_key, &u8) == CS_OK) {
  1312. totem_config->interfaces[linknumber].knet_link_priority = u8;
  1313. }
  1314. totem_config->interfaces[linknumber].knet_ping_interval = 0; /* real default applied later */
  1315. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.knet_ping_interval", linknumber);
  1316. if (icmap_get_uint32(tmp_key, &u32) == CS_OK) {
  1317. totem_config->interfaces[linknumber].knet_ping_interval = u32;
  1318. }
  1319. totem_config->interfaces[linknumber].knet_ping_timeout = 0; /* real default applied later */
  1320. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.knet_ping_timeout", linknumber);
  1321. if (icmap_get_uint32(tmp_key, &u32) == CS_OK) {
  1322. totem_config->interfaces[linknumber].knet_ping_timeout = u32;
  1323. }
  1324. totem_config->interfaces[linknumber].knet_ping_precision = KNET_PING_PRECISION;
  1325. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.knet_ping_precision", linknumber);
  1326. if (icmap_get_uint32(tmp_key, &u32) == CS_OK) {
  1327. totem_config->interfaces[linknumber].knet_ping_precision = u32;
  1328. }
  1329. totem_config->interfaces[linknumber].knet_pong_count = KNET_PONG_COUNT;
  1330. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.knet_pong_count", linknumber);
  1331. if (icmap_get_uint32(tmp_key, &u32) == CS_OK) {
  1332. totem_config->interfaces[linknumber].knet_pong_count = u32;
  1333. }
  1334. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.member.", linknumber);
  1335. member_iter = icmap_iter_init(tmp_key);
  1336. while ((member_iter_key = icmap_iter_next(member_iter, NULL, NULL)) != NULL) {
  1337. if (member_count == 0) {
  1338. if (icmap_get_string("nodelist.node.0.ring0_addr", &str) == CS_OK) {
  1339. free(str);
  1340. *warnings |= TOTEM_CONFIG_WARNING_MEMBERS_IGNORED;
  1341. break;
  1342. } else {
  1343. *warnings |= TOTEM_CONFIG_WARNING_MEMBERS_DEPRECATED;
  1344. }
  1345. }
  1346. if (icmap_get_string(member_iter_key, &str) == CS_OK) {
  1347. res = totemip_parse (&totem_config->interfaces[linknumber].member_list[member_count++],
  1348. str, totem_config->ip_version);
  1349. if (res) {
  1350. sprintf(error_string_response, "failed to parse node address '%s'\n", str);
  1351. *error_string = error_string_response;
  1352. icmap_iter_finalize(member_iter);
  1353. icmap_iter_finalize(iter);
  1354. free(str);
  1355. return -1;
  1356. }
  1357. free(str);
  1358. }
  1359. }
  1360. icmap_iter_finalize(member_iter);
  1361. totem_config->interfaces[linknumber].member_count = member_count;
  1362. }
  1363. icmap_iter_finalize(iter);
  1364. return 0;
  1365. }
  1366. extern int totem_config_read (
  1367. struct totem_config *totem_config,
  1368. const char **error_string,
  1369. uint64_t *warnings)
  1370. {
  1371. int res = 0;
  1372. char *str, *ring0_addr_str;
  1373. char tmp_key[ICMAP_KEYNAME_MAXLEN];
  1374. uint16_t u16;
  1375. int i;
  1376. int local_node_pos;
  1377. int nodeid_set;
  1378. *warnings = 0;
  1379. memset (totem_config, 0, sizeof (struct totem_config));
  1380. totem_config->interfaces = malloc (sizeof (struct totem_interface) * INTERFACE_MAX);
  1381. if (totem_config->interfaces == 0) {
  1382. *error_string = "Out of memory trying to allocate ethernet interface storage area";
  1383. return -1;
  1384. }
  1385. totem_config->transport_number = TOTEM_TRANSPORT_KNET;
  1386. if (icmap_get_string("totem.transport", &str) == CS_OK) {
  1387. if (strcmp (str, "udpu") == 0) {
  1388. totem_config->transport_number = TOTEM_TRANSPORT_UDPU;
  1389. }
  1390. if (strcmp (str, "udp") == 0) {
  1391. totem_config->transport_number = TOTEM_TRANSPORT_UDP;
  1392. }
  1393. if (strcmp (str, "knet") == 0) {
  1394. totem_config->transport_number = TOTEM_TRANSPORT_KNET;
  1395. }
  1396. free(str);
  1397. }
  1398. memset (totem_config->interfaces, 0,
  1399. sizeof (struct totem_interface) * INTERFACE_MAX);
  1400. strcpy (totem_config->link_mode, "passive");
  1401. icmap_get_uint32("totem.version", (uint32_t *)&totem_config->version);
  1402. if (totem_get_crypto(totem_config, error_string) != 0) {
  1403. return -1;
  1404. }
  1405. if (icmap_get_string("totem.link_mode", &str) == CS_OK) {
  1406. if (strlen(str) >= TOTEM_LINK_MODE_BYTES) {
  1407. *error_string = "totem.link_mode is too long";
  1408. free(str);
  1409. return -1;
  1410. }
  1411. strcpy (totem_config->link_mode, str);
  1412. free(str);
  1413. }
  1414. icmap_get_uint32("totem.nodeid", &totem_config->node_id);
  1415. totem_config->clear_node_high_bit = 0;
  1416. if (icmap_get_string("totem.clear_node_high_bit", &str) == CS_OK) {
  1417. if (strcmp (str, "yes") == 0) {
  1418. totem_config->clear_node_high_bit = 1;
  1419. }
  1420. free(str);
  1421. }
  1422. icmap_get_uint32("totem.threads", &totem_config->threads);
  1423. icmap_get_uint32("totem.netmtu", &totem_config->net_mtu);
  1424. totem_config->ip_version = totem_config_get_ip_version(totem_config);
  1425. if (icmap_get_string("totem.interface.0.bindnetaddr", &str) != CS_OK) {
  1426. /*
  1427. * We were not able to find ring 0 bindnet addr. Try to use nodelist informations
  1428. */
  1429. config_convert_nodelist_to_interface(totem_config);
  1430. } else {
  1431. if (icmap_get_string("nodelist.node.0.ring0_addr", &ring0_addr_str) == CS_OK) {
  1432. /*
  1433. * Both bindnetaddr and ring0_addr are set.
  1434. * Log warning information, and use nodelist instead
  1435. */
  1436. *warnings |= TOTEM_CONFIG_BINDNETADDR_NODELIST_SET;
  1437. config_convert_nodelist_to_interface(totem_config);
  1438. free(ring0_addr_str);
  1439. }
  1440. free(str);
  1441. }
  1442. /*
  1443. * Broadcast option is global but set in interface section,
  1444. * so reset before processing interfaces.
  1445. */
  1446. totem_config->broadcast_use = 0;
  1447. res = get_interface_params(totem_config, error_string, warnings, 0);
  1448. if (res < 0) {
  1449. return res;
  1450. }
  1451. /*
  1452. * Use broadcast is global, so if set, make sure to fill mcast addr correctly
  1453. * broadcast is only supported for UDP so just do interface 0;
  1454. */
  1455. if (totem_config->broadcast_use) {
  1456. totemip_parse (&totem_config->interfaces[0].mcast_addr,
  1457. "255.255.255.255", TOTEM_IP_VERSION_4);
  1458. }
  1459. /*
  1460. * Store automatically generated items back to icmap only for UDP
  1461. */
  1462. if (totem_config->transport_number == TOTEM_TRANSPORT_UDP) {
  1463. for (i = 0; i < INTERFACE_MAX; i++) {
  1464. if (!totem_config->interfaces[i].configured) {
  1465. continue;
  1466. }
  1467. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.mcastaddr", i);
  1468. if (icmap_get_string(tmp_key, &str) == CS_OK) {
  1469. free(str);
  1470. } else {
  1471. str = (char *)totemip_print(&totem_config->interfaces[i].mcast_addr);
  1472. icmap_set_string(tmp_key, str);
  1473. }
  1474. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.mcastport", i);
  1475. if (icmap_get_uint16(tmp_key, &u16) != CS_OK) {
  1476. icmap_set_uint16(tmp_key, totem_config->interfaces[i].ip_port);
  1477. }
  1478. }
  1479. }
  1480. /*
  1481. * Check existence of nodelist
  1482. */
  1483. if ((icmap_get_string("nodelist.node.0.name", &str) == CS_OK) ||
  1484. (icmap_get_string("nodelist.node.0.ring0_addr", &str) == CS_OK)) {
  1485. free(str);
  1486. /*
  1487. * find local node
  1488. */
  1489. local_node_pos = find_local_node(1);
  1490. if (local_node_pos != -1) {
  1491. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", local_node_pos);
  1492. nodeid_set = (totem_config->node_id != 0);
  1493. if (icmap_get_uint32(tmp_key, &totem_config->node_id) == CS_OK && nodeid_set) {
  1494. *warnings |= TOTEM_CONFIG_WARNING_TOTEM_NODEID_IGNORED;
  1495. }
  1496. if ((totem_config->transport_number == TOTEM_TRANSPORT_KNET) && (!totem_config->node_id)) {
  1497. *error_string = "Knet requires an explicit nodeid for the local node";
  1498. return -1;
  1499. }
  1500. if ((totem_config->transport_number == TOTEM_TRANSPORT_UDP ||
  1501. totem_config->transport_number == TOTEM_TRANSPORT_UDPU) && (!totem_config->node_id)) {
  1502. snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.ring0_addr", local_node_pos);
  1503. icmap_get_string(tmp_key, &str);
  1504. totem_config->node_id = generate_nodeid(totem_config, str);
  1505. if (totem_config->node_id == -1) {
  1506. *error_string = "An IPV6 network requires that a node ID be specified";
  1507. free(str);
  1508. return (-1);
  1509. }
  1510. totem_config->interfaces[0].member_list[local_node_pos].nodeid = totem_config->node_id;
  1511. free(str);
  1512. }
  1513. /* Users must not change this */
  1514. icmap_set_ro_access("nodelist.local_node_pos", 0, 1);
  1515. }
  1516. if (put_nodelist_members_to_config(totem_config, 0, error_string)) {
  1517. return -1;
  1518. }
  1519. }
  1520. /*
  1521. * Get things that might change in the future (and can depend on totem_config->interfaces);
  1522. */
  1523. totem_volatile_config_read(totem_config, NULL);
  1524. calc_knet_ping_timers(totem_config);
  1525. icmap_set_uint8("config.totemconfig_reload_in_progress", 0);
  1526. add_totem_config_notification(totem_config);
  1527. return 0;
  1528. }
  1529. int totem_config_validate (
  1530. struct totem_config *totem_config,
  1531. const char **error_string)
  1532. {
  1533. static char local_error_reason[512];
  1534. char parse_error[512];
  1535. static char addr_str_buf[INET6_ADDRSTRLEN];
  1536. const char *error_reason = local_error_reason;
  1537. int i,j;
  1538. uint32_t u32;
  1539. int num_configured = 0;
  1540. unsigned int interface_max = INTERFACE_MAX;
  1541. for (i = 0; i < INTERFACE_MAX; i++) {
  1542. if (totem_config->interfaces[i].configured) {
  1543. num_configured++;
  1544. }
  1545. }
  1546. if (num_configured == 0) {
  1547. error_reason = "No interfaces defined";
  1548. goto parse_error;
  1549. }
  1550. /* Check we found a local node name */
  1551. if (icmap_get_uint32("nodelist.local_node_pos", &u32) != CS_OK) {
  1552. error_reason = "No valid name found for local host";
  1553. goto parse_error;
  1554. }
  1555. for (i = 0; i < INTERFACE_MAX; i++) {
  1556. /*
  1557. * Some error checking of parsed data to make sure its valid
  1558. */
  1559. struct totem_ip_address null_addr;
  1560. if (!totem_config->interfaces[i].configured) {
  1561. continue;
  1562. }
  1563. memset (&null_addr, 0, sizeof (struct totem_ip_address));
  1564. if ((totem_config->transport_number == TOTEM_TRANSPORT_UDP) &&
  1565. memcmp (&totem_config->interfaces[i].mcast_addr, &null_addr,
  1566. sizeof (struct totem_ip_address)) == 0) {
  1567. error_reason = "No multicast address specified";
  1568. goto parse_error;
  1569. }
  1570. if (totem_config->interfaces[i].ip_port == 0) {
  1571. error_reason = "No multicast port specified";
  1572. goto parse_error;
  1573. }
  1574. if (totem_config->interfaces[i].ttl > 255) {
  1575. error_reason = "Invalid TTL (should be 0..255)";
  1576. goto parse_error;
  1577. }
  1578. if (totem_config->transport_number != TOTEM_TRANSPORT_UDP &&
  1579. totem_config->interfaces[i].ttl != 1) {
  1580. error_reason = "Can only set ttl on multicast transport types";
  1581. goto parse_error;
  1582. }
  1583. if (totem_config->interfaces[i].knet_link_priority > 255) {
  1584. error_reason = "Invalid link priority (should be 0..255)";
  1585. goto parse_error;
  1586. }
  1587. if (totem_config->transport_number != TOTEM_TRANSPORT_KNET &&
  1588. totem_config->interfaces[i].knet_link_priority != 1) {
  1589. error_reason = "Can only set link priority on knet transport type";
  1590. goto parse_error;
  1591. }
  1592. if (totem_config->interfaces[i].mcast_addr.family == AF_INET6 &&
  1593. totem_config->node_id == 0) {
  1594. error_reason = "An IPV6 network requires that a node ID be specified.";
  1595. goto parse_error;
  1596. }
  1597. if (totem_config->broadcast_use == 0 && totem_config->transport_number == TOTEM_TRANSPORT_UDP) {
  1598. if (totem_config->interfaces[i].mcast_addr.family != totem_config->interfaces[i].bindnet.family) {
  1599. error_reason = "Multicast address family does not match bind address family";
  1600. goto parse_error;
  1601. }
  1602. if (totemip_is_mcast (&totem_config->interfaces[i].mcast_addr) != 0) {
  1603. error_reason = "mcastaddr is not a correct multicast address.";
  1604. goto parse_error;
  1605. }
  1606. }
  1607. /* Verify that all nodes on the same knet link have the same IP family */
  1608. for (j=1; j<totem_config->interfaces[i].member_count; j++) {
  1609. if (totem_config->interfaces[i].configured) {
  1610. if (totem_config->interfaces[i].member_list[j].family !=
  1611. totem_config->interfaces[i].member_list[0].family) {
  1612. memcpy(addr_str_buf,
  1613. totemip_print(&(totem_config->interfaces[i].member_list[j])),
  1614. sizeof(addr_str_buf));
  1615. snprintf (local_error_reason, sizeof(local_error_reason),
  1616. "Nodes for link %d have different IP families "
  1617. "(compared %s with %s)", i,
  1618. addr_str_buf,
  1619. totemip_print(&(totem_config->interfaces[i].member_list[0])));
  1620. goto parse_error;
  1621. }
  1622. }
  1623. }
  1624. }
  1625. if (totem_config->version != 2) {
  1626. error_reason = "This totem parser can only parse version 2 configurations.";
  1627. goto parse_error;
  1628. }
  1629. if (totem_volatile_config_validate(totem_config, error_string) == -1) {
  1630. return (-1);
  1631. }
  1632. if (check_for_duplicate_nodeids(totem_config, error_string) == -1) {
  1633. return (-1);
  1634. }
  1635. /*
  1636. * KNET Link values validation
  1637. */
  1638. if (strcmp (totem_config->link_mode, "active") &&
  1639. strcmp (totem_config->link_mode, "rr") &&
  1640. strcmp (totem_config->link_mode, "passive")) {
  1641. snprintf (local_error_reason, sizeof(local_error_reason),
  1642. "The Knet link mode \"%s\" specified is invalid. It must be active, passive or rr.\n", totem_config->link_mode);
  1643. goto parse_error;
  1644. }
  1645. /* Only Knet does multiple interfaces */
  1646. if (totem_config->transport_number != TOTEM_TRANSPORT_KNET) {
  1647. interface_max = 1;
  1648. }
  1649. if (interface_max < num_configured) {
  1650. snprintf (parse_error, sizeof(parse_error),
  1651. "%d is too many configured interfaces for non-Knet transport.",
  1652. num_configured);
  1653. error_reason = parse_error;
  1654. goto parse_error;
  1655. }
  1656. /* Only knet allows crypto */
  1657. if (totem_config->transport_number != TOTEM_TRANSPORT_KNET) {
  1658. if ((strcmp(totem_config->crypto_cipher_type, "none") != 0) ||
  1659. (strcmp(totem_config->crypto_hash_type, "none") != 0)) {
  1660. snprintf (parse_error, sizeof(parse_error),
  1661. "crypto_cipher & crypto_hash are only valid for the Knet transport.");
  1662. error_reason = parse_error;
  1663. goto parse_error;
  1664. }
  1665. }
  1666. if (totem_config->net_mtu == 0) {
  1667. if (totem_config->transport_number == TOTEM_TRANSPORT_KNET) {
  1668. totem_config->net_mtu = KNET_MAX_PACKET_SIZE;
  1669. }
  1670. else {
  1671. totem_config->net_mtu = 1500;
  1672. }
  1673. }
  1674. return 0;
  1675. parse_error:
  1676. snprintf (error_string_response, sizeof(error_string_response),
  1677. "parse error in config: %s\n", error_reason);
  1678. *error_string = error_string_response;
  1679. return (-1);
  1680. }
  1681. static int read_keyfile (
  1682. const char *key_location,
  1683. struct totem_config *totem_config,
  1684. const char **error_string)
  1685. {
  1686. int fd;
  1687. int res;
  1688. int saved_errno;
  1689. char error_str[100];
  1690. const char *error_ptr;
  1691. fd = open (key_location, O_RDONLY);
  1692. if (fd == -1) {
  1693. error_ptr = qb_strerror_r(errno, error_str, sizeof(error_str));
  1694. snprintf (error_string_response, sizeof(error_string_response),
  1695. "Could not open %s: %s\n",
  1696. key_location, error_ptr);
  1697. goto parse_error;
  1698. }
  1699. res = read (fd, totem_config->private_key, TOTEM_PRIVATE_KEY_LEN_MAX);
  1700. saved_errno = errno;
  1701. close (fd);
  1702. if (res == -1) {
  1703. error_ptr = qb_strerror_r (saved_errno, error_str, sizeof(error_str));
  1704. snprintf (error_string_response, sizeof(error_string_response),
  1705. "Could not read %s: %s\n",
  1706. key_location, error_ptr);
  1707. goto parse_error;
  1708. }
  1709. if (res < TOTEM_PRIVATE_KEY_LEN_MIN) {
  1710. snprintf (error_string_response, sizeof(error_string_response),
  1711. "Could only read %d bits of minimum %u bits from %s.\n",
  1712. res * 8, TOTEM_PRIVATE_KEY_LEN_MIN * 8, key_location);
  1713. goto parse_error;
  1714. }
  1715. totem_config->private_key_len = res;
  1716. return 0;
  1717. parse_error:
  1718. *error_string = error_string_response;
  1719. return (-1);
  1720. }
  1721. int totem_config_keyread (
  1722. struct totem_config *totem_config,
  1723. const char **error_string)
  1724. {
  1725. int got_key = 0;
  1726. char *key_location = NULL;
  1727. int res;
  1728. size_t key_len;
  1729. memset (totem_config->private_key, 0, sizeof(totem_config->private_key));
  1730. totem_config->private_key_len = 0;
  1731. if (strcmp(totem_config->crypto_cipher_type, "none") == 0 &&
  1732. strcmp(totem_config->crypto_hash_type, "none") == 0) {
  1733. return (0);
  1734. }
  1735. /* cmap may store the location of the key file */
  1736. if (icmap_get_string("totem.keyfile", &key_location) == CS_OK) {
  1737. res = read_keyfile(key_location, totem_config, error_string);
  1738. free(key_location);
  1739. if (res) {
  1740. goto key_error;
  1741. }
  1742. got_key = 1;
  1743. } else { /* Or the key itself may be in the cmap */
  1744. if (icmap_get("totem.key", NULL, &key_len, NULL) == CS_OK) {
  1745. if (key_len > sizeof(totem_config->private_key)) {
  1746. sprintf(error_string_response, "key is too long");
  1747. goto key_error;
  1748. }
  1749. if (key_len < TOTEM_PRIVATE_KEY_LEN_MIN) {
  1750. sprintf(error_string_response, "key is too short");
  1751. goto key_error;
  1752. }
  1753. if (icmap_get("totem.key", totem_config->private_key, &key_len, NULL) == CS_OK) {
  1754. totem_config->private_key_len = key_len;
  1755. got_key = 1;
  1756. } else {
  1757. sprintf(error_string_response, "can't load private key");
  1758. goto key_error;
  1759. }
  1760. }
  1761. }
  1762. /* In desperation we read the default filename */
  1763. if (!got_key) {
  1764. res = read_keyfile(COROSYSCONFDIR "/authkey", totem_config, error_string);
  1765. if (res)
  1766. goto key_error;
  1767. }
  1768. return (0);
  1769. key_error:
  1770. *error_string = error_string_response;
  1771. return (-1);
  1772. }
  1773. static void debug_dump_totem_config(const struct totem_config *totem_config)
  1774. {
  1775. log_printf(LOGSYS_LEVEL_DEBUG, "Token Timeout (%d ms) retransmit timeout (%d ms)",
  1776. totem_config->token_timeout, totem_config->token_retransmit_timeout);
  1777. if (totem_config->token_warning) {
  1778. uint32_t token_warning_ms = totem_config->token_warning * totem_config->token_timeout / 100;
  1779. log_printf(LOGSYS_LEVEL_DEBUG, "Token warning every %d ms (%d%% of Token Timeout)",
  1780. token_warning_ms, totem_config->token_warning);
  1781. if (token_warning_ms < totem_config->token_retransmit_timeout)
  1782. log_printf (LOGSYS_LEVEL_DEBUG,
  1783. "The token warning interval (%d ms) is less than the token retransmit timeout (%d ms) "
  1784. "which can lead to spurious token warnings. Consider increasing the token_warning parameter.",
  1785. token_warning_ms, totem_config->token_retransmit_timeout);
  1786. } else
  1787. log_printf(LOGSYS_LEVEL_DEBUG, "Token warnings disabled");
  1788. log_printf(LOGSYS_LEVEL_DEBUG, "token hold (%d ms) retransmits before loss (%d retrans)",
  1789. totem_config->token_hold_timeout, totem_config->token_retransmits_before_loss_const);
  1790. log_printf(LOGSYS_LEVEL_DEBUG, "join (%d ms) send_join (%d ms) consensus (%d ms) merge (%d ms)",
  1791. totem_config->join_timeout, totem_config->send_join_timeout, totem_config->consensus_timeout,
  1792. totem_config->merge_timeout);
  1793. log_printf(LOGSYS_LEVEL_DEBUG, "downcheck (%d ms) fail to recv const (%d msgs)",
  1794. totem_config->downcheck_timeout, totem_config->fail_to_recv_const);
  1795. log_printf(LOGSYS_LEVEL_DEBUG,
  1796. "seqno unchanged const (%d rotations) Maximum network MTU %d",
  1797. totem_config->seqno_unchanged_const, totem_config->net_mtu);
  1798. log_printf(LOGSYS_LEVEL_DEBUG,
  1799. "window size per rotation (%d messages) maximum messages per rotation (%d messages)",
  1800. totem_config->window_size, totem_config->max_messages);
  1801. log_printf(LOGSYS_LEVEL_DEBUG, "missed count const (%d messages)", totem_config->miss_count_const);
  1802. log_printf(LOGSYS_LEVEL_DEBUG, "heartbeat_failures_allowed (%d)",
  1803. totem_config->heartbeat_failures_allowed);
  1804. log_printf(LOGSYS_LEVEL_DEBUG, "max_network_delay (%d ms)", totem_config->max_network_delay);
  1805. }
  1806. static void totem_change_notify(
  1807. int32_t event,
  1808. const char *key_name,
  1809. struct icmap_notify_value new_val,
  1810. struct icmap_notify_value old_val,
  1811. void *user_data)
  1812. {
  1813. struct totem_config *totem_config = (struct totem_config *)user_data;
  1814. uint32_t *param;
  1815. uint8_t reloading;
  1816. const char *deleted_key = NULL;
  1817. const char *error_string;
  1818. /*
  1819. * If a full reload is in progress then don't do anything until it's done and
  1820. * can reconfigure it all atomically
  1821. */
  1822. if (icmap_get_uint8("config.reload_in_progress", &reloading) == CS_OK && reloading)
  1823. return;
  1824. param = totem_get_param_by_name((struct totem_config *)user_data, key_name);
  1825. /*
  1826. * Process change only if changed key is found in totem_config (-> param is not NULL)
  1827. * or for special key token_coefficient. token_coefficient key is not stored in
  1828. * totem_config, but it is used for computation of token timeout.
  1829. */
  1830. if (!param && strcmp(key_name, "totem.token_coefficient") != 0)
  1831. return;
  1832. /*
  1833. * Values other than UINT32 are not supported, or needed (yet)
  1834. */
  1835. switch (event) {
  1836. case ICMAP_TRACK_DELETE:
  1837. deleted_key = key_name;
  1838. break;
  1839. case ICMAP_TRACK_ADD:
  1840. case ICMAP_TRACK_MODIFY:
  1841. deleted_key = NULL;
  1842. break;
  1843. default:
  1844. break;
  1845. }
  1846. totem_volatile_config_read (totem_config, deleted_key);
  1847. log_printf(LOGSYS_LEVEL_DEBUG, "Totem related config key changed. Dumping actual totem config.");
  1848. debug_dump_totem_config(totem_config);
  1849. if (totem_volatile_config_validate(totem_config, &error_string) == -1) {
  1850. log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string);
  1851. /*
  1852. * TODO: Consider corosync exit and/or load defaults for volatile
  1853. * values. For now, log error seems to be enough
  1854. */
  1855. }
  1856. }
  1857. static void totem_reload_notify(
  1858. int32_t event,
  1859. const char *key_name,
  1860. struct icmap_notify_value new_val,
  1861. struct icmap_notify_value old_val,
  1862. void *user_data)
  1863. {
  1864. struct totem_config *totem_config = (struct totem_config *)user_data;
  1865. const char *error_string;
  1866. uint64_t warnings;
  1867. /* Reload has completed */
  1868. if (*(uint8_t *)new_val.data == 0) {
  1869. totem_config->orig_interfaces = malloc (sizeof (struct totem_interface) * INTERFACE_MAX);
  1870. assert(totem_config->orig_interfaces != NULL);
  1871. memcpy(totem_config->orig_interfaces, totem_config->interfaces, sizeof (struct totem_interface) * INTERFACE_MAX);
  1872. get_interface_params(totem_config, &error_string, &warnings, 1);
  1873. if (put_nodelist_members_to_config (totem_config, 1, &error_string)) {
  1874. log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string);
  1875. }
  1876. totem_volatile_config_read (totem_config, NULL);
  1877. calc_knet_ping_timers(totem_config);
  1878. log_printf(LOGSYS_LEVEL_DEBUG, "Configuration reloaded. Dumping actual totem config.");
  1879. debug_dump_totem_config(totem_config);
  1880. if (totem_volatile_config_validate(totem_config, &error_string) == -1) {
  1881. log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string);
  1882. /*
  1883. * TODO: Consider corosync exit and/or load defaults for volatile
  1884. * values. For now, log error seems to be enough
  1885. */
  1886. }
  1887. /* Reinstate the local_node_pos */
  1888. (void)find_local_node(0);
  1889. /* Reconfigure network params as appropriate */
  1890. totempg_reconfigure();
  1891. free(totem_config->orig_interfaces);
  1892. icmap_set_uint8("config.totemconfig_reload_in_progress", 0);
  1893. } else {
  1894. icmap_set_uint8("config.totemconfig_reload_in_progress", 1);
  1895. }
  1896. }
  1897. static void add_totem_config_notification(struct totem_config *totem_config)
  1898. {
  1899. icmap_track_t icmap_track;
  1900. icmap_track_add("totem.",
  1901. ICMAP_TRACK_ADD | ICMAP_TRACK_DELETE | ICMAP_TRACK_MODIFY | ICMAP_TRACK_PREFIX,
  1902. totem_change_notify,
  1903. totem_config,
  1904. &icmap_track);
  1905. icmap_track_add("config.reload_in_progress",
  1906. ICMAP_TRACK_ADD | ICMAP_TRACK_MODIFY,
  1907. totem_reload_notify,
  1908. totem_config,
  1909. &icmap_track);
  1910. }