iscsi_target_parameters.c 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728
  1. /*******************************************************************************
  2. * This file contains main functions related to iSCSI Parameter negotiation.
  3. *
  4. * (c) Copyright 2007-2013 Datera, Inc.
  5. *
  6. * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. ******************************************************************************/
  18. #include <linux/slab.h>
  19. #include <target/iscsi/iscsi_target_core.h>
  20. #include "iscsi_target_util.h"
  21. #include "iscsi_target_parameters.h"
  22. int iscsi_login_rx_data(
  23. struct iscsi_conn *conn,
  24. char *buf,
  25. int length)
  26. {
  27. int rx_got;
  28. struct kvec iov;
  29. memset(&iov, 0, sizeof(struct kvec));
  30. iov.iov_len = length;
  31. iov.iov_base = buf;
  32. rx_got = rx_data(conn, &iov, 1, length);
  33. if (rx_got != length) {
  34. pr_err("rx_data returned %d, expecting %d.\n",
  35. rx_got, length);
  36. return -1;
  37. }
  38. return 0 ;
  39. }
  40. int iscsi_login_tx_data(
  41. struct iscsi_conn *conn,
  42. char *pdu_buf,
  43. char *text_buf,
  44. int text_length)
  45. {
  46. int length, tx_sent, iov_cnt = 1;
  47. struct kvec iov[2];
  48. length = (ISCSI_HDR_LEN + text_length);
  49. memset(&iov[0], 0, 2 * sizeof(struct kvec));
  50. iov[0].iov_len = ISCSI_HDR_LEN;
  51. iov[0].iov_base = pdu_buf;
  52. if (text_buf && text_length) {
  53. iov[1].iov_len = text_length;
  54. iov[1].iov_base = text_buf;
  55. iov_cnt++;
  56. }
  57. tx_sent = tx_data(conn, &iov[0], iov_cnt, length);
  58. if (tx_sent != length) {
  59. pr_err("tx_data returned %d, expecting %d.\n",
  60. tx_sent, length);
  61. return -1;
  62. }
  63. return 0;
  64. }
  65. void iscsi_dump_conn_ops(struct iscsi_conn_ops *conn_ops)
  66. {
  67. pr_debug("HeaderDigest: %s\n", (conn_ops->HeaderDigest) ?
  68. "CRC32C" : "None");
  69. pr_debug("DataDigest: %s\n", (conn_ops->DataDigest) ?
  70. "CRC32C" : "None");
  71. pr_debug("MaxRecvDataSegmentLength: %u\n",
  72. conn_ops->MaxRecvDataSegmentLength);
  73. }
  74. void iscsi_dump_sess_ops(struct iscsi_sess_ops *sess_ops)
  75. {
  76. pr_debug("InitiatorName: %s\n", sess_ops->InitiatorName);
  77. pr_debug("InitiatorAlias: %s\n", sess_ops->InitiatorAlias);
  78. pr_debug("TargetName: %s\n", sess_ops->TargetName);
  79. pr_debug("TargetAlias: %s\n", sess_ops->TargetAlias);
  80. pr_debug("TargetPortalGroupTag: %hu\n",
  81. sess_ops->TargetPortalGroupTag);
  82. pr_debug("MaxConnections: %hu\n", sess_ops->MaxConnections);
  83. pr_debug("InitialR2T: %s\n",
  84. (sess_ops->InitialR2T) ? "Yes" : "No");
  85. pr_debug("ImmediateData: %s\n", (sess_ops->ImmediateData) ?
  86. "Yes" : "No");
  87. pr_debug("MaxBurstLength: %u\n", sess_ops->MaxBurstLength);
  88. pr_debug("FirstBurstLength: %u\n", sess_ops->FirstBurstLength);
  89. pr_debug("DefaultTime2Wait: %hu\n", sess_ops->DefaultTime2Wait);
  90. pr_debug("DefaultTime2Retain: %hu\n",
  91. sess_ops->DefaultTime2Retain);
  92. pr_debug("MaxOutstandingR2T: %hu\n",
  93. sess_ops->MaxOutstandingR2T);
  94. pr_debug("DataPDUInOrder: %s\n",
  95. (sess_ops->DataPDUInOrder) ? "Yes" : "No");
  96. pr_debug("DataSequenceInOrder: %s\n",
  97. (sess_ops->DataSequenceInOrder) ? "Yes" : "No");
  98. pr_debug("ErrorRecoveryLevel: %hu\n",
  99. sess_ops->ErrorRecoveryLevel);
  100. pr_debug("SessionType: %s\n", (sess_ops->SessionType) ?
  101. "Discovery" : "Normal");
  102. }
  103. void iscsi_print_params(struct iscsi_param_list *param_list)
  104. {
  105. struct iscsi_param *param;
  106. list_for_each_entry(param, &param_list->param_list, p_list)
  107. pr_debug("%s: %s\n", param->name, param->value);
  108. }
  109. static struct iscsi_param *iscsi_set_default_param(struct iscsi_param_list *param_list,
  110. char *name, char *value, u8 phase, u8 scope, u8 sender,
  111. u16 type_range, u8 use)
  112. {
  113. struct iscsi_param *param = NULL;
  114. param = kzalloc(sizeof(struct iscsi_param), GFP_KERNEL);
  115. if (!param) {
  116. pr_err("Unable to allocate memory for parameter.\n");
  117. goto out;
  118. }
  119. INIT_LIST_HEAD(&param->p_list);
  120. param->name = kstrdup(name, GFP_KERNEL);
  121. if (!param->name) {
  122. pr_err("Unable to allocate memory for parameter name.\n");
  123. goto out;
  124. }
  125. param->value = kstrdup(value, GFP_KERNEL);
  126. if (!param->value) {
  127. pr_err("Unable to allocate memory for parameter value.\n");
  128. goto out;
  129. }
  130. param->phase = phase;
  131. param->scope = scope;
  132. param->sender = sender;
  133. param->use = use;
  134. param->type_range = type_range;
  135. switch (param->type_range) {
  136. case TYPERANGE_BOOL_AND:
  137. param->type = TYPE_BOOL_AND;
  138. break;
  139. case TYPERANGE_BOOL_OR:
  140. param->type = TYPE_BOOL_OR;
  141. break;
  142. case TYPERANGE_0_TO_2:
  143. case TYPERANGE_0_TO_3600:
  144. case TYPERANGE_0_TO_32767:
  145. case TYPERANGE_0_TO_65535:
  146. case TYPERANGE_1_TO_65535:
  147. case TYPERANGE_2_TO_3600:
  148. case TYPERANGE_512_TO_16777215:
  149. param->type = TYPE_NUMBER;
  150. break;
  151. case TYPERANGE_AUTH:
  152. case TYPERANGE_DIGEST:
  153. param->type = TYPE_VALUE_LIST | TYPE_STRING;
  154. break;
  155. case TYPERANGE_ISCSINAME:
  156. case TYPERANGE_SESSIONTYPE:
  157. case TYPERANGE_TARGETADDRESS:
  158. case TYPERANGE_UTF8:
  159. param->type = TYPE_STRING;
  160. break;
  161. default:
  162. pr_err("Unknown type_range 0x%02x\n",
  163. param->type_range);
  164. goto out;
  165. }
  166. list_add_tail(&param->p_list, &param_list->param_list);
  167. return param;
  168. out:
  169. if (param) {
  170. kfree(param->value);
  171. kfree(param->name);
  172. kfree(param);
  173. }
  174. return NULL;
  175. }
  176. /* #warning Add extension keys */
  177. int iscsi_create_default_params(struct iscsi_param_list **param_list_ptr)
  178. {
  179. struct iscsi_param *param = NULL;
  180. struct iscsi_param_list *pl;
  181. pl = kzalloc(sizeof(struct iscsi_param_list), GFP_KERNEL);
  182. if (!pl) {
  183. pr_err("Unable to allocate memory for"
  184. " struct iscsi_param_list.\n");
  185. return -1 ;
  186. }
  187. INIT_LIST_HEAD(&pl->param_list);
  188. INIT_LIST_HEAD(&pl->extra_response_list);
  189. /*
  190. * The format for setting the initial parameter definitions are:
  191. *
  192. * Parameter name:
  193. * Initial value:
  194. * Allowable phase:
  195. * Scope:
  196. * Allowable senders:
  197. * Typerange:
  198. * Use:
  199. */
  200. param = iscsi_set_default_param(pl, AUTHMETHOD, INITIAL_AUTHMETHOD,
  201. PHASE_SECURITY, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
  202. TYPERANGE_AUTH, USE_INITIAL_ONLY);
  203. if (!param)
  204. goto out;
  205. param = iscsi_set_default_param(pl, HEADERDIGEST, INITIAL_HEADERDIGEST,
  206. PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
  207. TYPERANGE_DIGEST, USE_INITIAL_ONLY);
  208. if (!param)
  209. goto out;
  210. param = iscsi_set_default_param(pl, DATADIGEST, INITIAL_DATADIGEST,
  211. PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
  212. TYPERANGE_DIGEST, USE_INITIAL_ONLY);
  213. if (!param)
  214. goto out;
  215. param = iscsi_set_default_param(pl, MAXCONNECTIONS,
  216. INITIAL_MAXCONNECTIONS, PHASE_OPERATIONAL,
  217. SCOPE_SESSION_WIDE, SENDER_BOTH,
  218. TYPERANGE_1_TO_65535, USE_LEADING_ONLY);
  219. if (!param)
  220. goto out;
  221. param = iscsi_set_default_param(pl, SENDTARGETS, INITIAL_SENDTARGETS,
  222. PHASE_FFP0, SCOPE_SESSION_WIDE, SENDER_INITIATOR,
  223. TYPERANGE_UTF8, 0);
  224. if (!param)
  225. goto out;
  226. param = iscsi_set_default_param(pl, TARGETNAME, INITIAL_TARGETNAME,
  227. PHASE_DECLARATIVE, SCOPE_SESSION_WIDE, SENDER_BOTH,
  228. TYPERANGE_ISCSINAME, USE_ALL);
  229. if (!param)
  230. goto out;
  231. param = iscsi_set_default_param(pl, INITIATORNAME,
  232. INITIAL_INITIATORNAME, PHASE_DECLARATIVE,
  233. SCOPE_SESSION_WIDE, SENDER_INITIATOR,
  234. TYPERANGE_ISCSINAME, USE_INITIAL_ONLY);
  235. if (!param)
  236. goto out;
  237. param = iscsi_set_default_param(pl, TARGETALIAS, INITIAL_TARGETALIAS,
  238. PHASE_DECLARATIVE, SCOPE_SESSION_WIDE, SENDER_TARGET,
  239. TYPERANGE_UTF8, USE_ALL);
  240. if (!param)
  241. goto out;
  242. param = iscsi_set_default_param(pl, INITIATORALIAS,
  243. INITIAL_INITIATORALIAS, PHASE_DECLARATIVE,
  244. SCOPE_SESSION_WIDE, SENDER_INITIATOR, TYPERANGE_UTF8,
  245. USE_ALL);
  246. if (!param)
  247. goto out;
  248. param = iscsi_set_default_param(pl, TARGETADDRESS,
  249. INITIAL_TARGETADDRESS, PHASE_DECLARATIVE,
  250. SCOPE_SESSION_WIDE, SENDER_TARGET,
  251. TYPERANGE_TARGETADDRESS, USE_ALL);
  252. if (!param)
  253. goto out;
  254. param = iscsi_set_default_param(pl, TARGETPORTALGROUPTAG,
  255. INITIAL_TARGETPORTALGROUPTAG,
  256. PHASE_DECLARATIVE, SCOPE_SESSION_WIDE, SENDER_TARGET,
  257. TYPERANGE_0_TO_65535, USE_INITIAL_ONLY);
  258. if (!param)
  259. goto out;
  260. param = iscsi_set_default_param(pl, INITIALR2T, INITIAL_INITIALR2T,
  261. PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
  262. TYPERANGE_BOOL_OR, USE_LEADING_ONLY);
  263. if (!param)
  264. goto out;
  265. param = iscsi_set_default_param(pl, IMMEDIATEDATA,
  266. INITIAL_IMMEDIATEDATA, PHASE_OPERATIONAL,
  267. SCOPE_SESSION_WIDE, SENDER_BOTH, TYPERANGE_BOOL_AND,
  268. USE_LEADING_ONLY);
  269. if (!param)
  270. goto out;
  271. param = iscsi_set_default_param(pl, MAXXMITDATASEGMENTLENGTH,
  272. INITIAL_MAXXMITDATASEGMENTLENGTH,
  273. PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
  274. TYPERANGE_512_TO_16777215, USE_ALL);
  275. if (!param)
  276. goto out;
  277. param = iscsi_set_default_param(pl, MAXRECVDATASEGMENTLENGTH,
  278. INITIAL_MAXRECVDATASEGMENTLENGTH,
  279. PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
  280. TYPERANGE_512_TO_16777215, USE_ALL);
  281. if (!param)
  282. goto out;
  283. param = iscsi_set_default_param(pl, MAXBURSTLENGTH,
  284. INITIAL_MAXBURSTLENGTH, PHASE_OPERATIONAL,
  285. SCOPE_SESSION_WIDE, SENDER_BOTH,
  286. TYPERANGE_512_TO_16777215, USE_LEADING_ONLY);
  287. if (!param)
  288. goto out;
  289. param = iscsi_set_default_param(pl, FIRSTBURSTLENGTH,
  290. INITIAL_FIRSTBURSTLENGTH,
  291. PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
  292. TYPERANGE_512_TO_16777215, USE_LEADING_ONLY);
  293. if (!param)
  294. goto out;
  295. param = iscsi_set_default_param(pl, DEFAULTTIME2WAIT,
  296. INITIAL_DEFAULTTIME2WAIT,
  297. PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
  298. TYPERANGE_0_TO_3600, USE_LEADING_ONLY);
  299. if (!param)
  300. goto out;
  301. param = iscsi_set_default_param(pl, DEFAULTTIME2RETAIN,
  302. INITIAL_DEFAULTTIME2RETAIN,
  303. PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
  304. TYPERANGE_0_TO_3600, USE_LEADING_ONLY);
  305. if (!param)
  306. goto out;
  307. param = iscsi_set_default_param(pl, MAXOUTSTANDINGR2T,
  308. INITIAL_MAXOUTSTANDINGR2T,
  309. PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
  310. TYPERANGE_1_TO_65535, USE_LEADING_ONLY);
  311. if (!param)
  312. goto out;
  313. param = iscsi_set_default_param(pl, DATAPDUINORDER,
  314. INITIAL_DATAPDUINORDER, PHASE_OPERATIONAL,
  315. SCOPE_SESSION_WIDE, SENDER_BOTH, TYPERANGE_BOOL_OR,
  316. USE_LEADING_ONLY);
  317. if (!param)
  318. goto out;
  319. param = iscsi_set_default_param(pl, DATASEQUENCEINORDER,
  320. INITIAL_DATASEQUENCEINORDER,
  321. PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
  322. TYPERANGE_BOOL_OR, USE_LEADING_ONLY);
  323. if (!param)
  324. goto out;
  325. param = iscsi_set_default_param(pl, ERRORRECOVERYLEVEL,
  326. INITIAL_ERRORRECOVERYLEVEL,
  327. PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
  328. TYPERANGE_0_TO_2, USE_LEADING_ONLY);
  329. if (!param)
  330. goto out;
  331. param = iscsi_set_default_param(pl, SESSIONTYPE, INITIAL_SESSIONTYPE,
  332. PHASE_DECLARATIVE, SCOPE_SESSION_WIDE, SENDER_INITIATOR,
  333. TYPERANGE_SESSIONTYPE, USE_LEADING_ONLY);
  334. if (!param)
  335. goto out;
  336. param = iscsi_set_default_param(pl, IFMARKER, INITIAL_IFMARKER,
  337. PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
  338. TYPERANGE_BOOL_AND, USE_INITIAL_ONLY);
  339. if (!param)
  340. goto out;
  341. param = iscsi_set_default_param(pl, OFMARKER, INITIAL_OFMARKER,
  342. PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
  343. TYPERANGE_BOOL_AND, USE_INITIAL_ONLY);
  344. if (!param)
  345. goto out;
  346. param = iscsi_set_default_param(pl, IFMARKINT, INITIAL_IFMARKINT,
  347. PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
  348. TYPERANGE_UTF8, USE_INITIAL_ONLY);
  349. if (!param)
  350. goto out;
  351. param = iscsi_set_default_param(pl, OFMARKINT, INITIAL_OFMARKINT,
  352. PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
  353. TYPERANGE_UTF8, USE_INITIAL_ONLY);
  354. if (!param)
  355. goto out;
  356. /*
  357. * Extra parameters for ISER from RFC-5046
  358. */
  359. param = iscsi_set_default_param(pl, RDMAEXTENSIONS, INITIAL_RDMAEXTENSIONS,
  360. PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
  361. TYPERANGE_BOOL_AND, USE_LEADING_ONLY);
  362. if (!param)
  363. goto out;
  364. param = iscsi_set_default_param(pl, INITIATORRECVDATASEGMENTLENGTH,
  365. INITIAL_INITIATORRECVDATASEGMENTLENGTH,
  366. PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
  367. TYPERANGE_512_TO_16777215, USE_ALL);
  368. if (!param)
  369. goto out;
  370. param = iscsi_set_default_param(pl, TARGETRECVDATASEGMENTLENGTH,
  371. INITIAL_TARGETRECVDATASEGMENTLENGTH,
  372. PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
  373. TYPERANGE_512_TO_16777215, USE_ALL);
  374. if (!param)
  375. goto out;
  376. *param_list_ptr = pl;
  377. return 0;
  378. out:
  379. iscsi_release_param_list(pl);
  380. return -1;
  381. }
  382. int iscsi_set_keys_to_negotiate(
  383. struct iscsi_param_list *param_list,
  384. bool iser)
  385. {
  386. struct iscsi_param *param;
  387. param_list->iser = iser;
  388. list_for_each_entry(param, &param_list->param_list, p_list) {
  389. param->state = 0;
  390. if (!strcmp(param->name, AUTHMETHOD)) {
  391. SET_PSTATE_NEGOTIATE(param);
  392. } else if (!strcmp(param->name, HEADERDIGEST)) {
  393. if (!iser)
  394. SET_PSTATE_NEGOTIATE(param);
  395. } else if (!strcmp(param->name, DATADIGEST)) {
  396. if (!iser)
  397. SET_PSTATE_NEGOTIATE(param);
  398. } else if (!strcmp(param->name, MAXCONNECTIONS)) {
  399. SET_PSTATE_NEGOTIATE(param);
  400. } else if (!strcmp(param->name, TARGETNAME)) {
  401. continue;
  402. } else if (!strcmp(param->name, INITIATORNAME)) {
  403. continue;
  404. } else if (!strcmp(param->name, TARGETALIAS)) {
  405. if (param->value)
  406. SET_PSTATE_NEGOTIATE(param);
  407. } else if (!strcmp(param->name, INITIATORALIAS)) {
  408. continue;
  409. } else if (!strcmp(param->name, TARGETPORTALGROUPTAG)) {
  410. SET_PSTATE_NEGOTIATE(param);
  411. } else if (!strcmp(param->name, INITIALR2T)) {
  412. SET_PSTATE_NEGOTIATE(param);
  413. } else if (!strcmp(param->name, IMMEDIATEDATA)) {
  414. SET_PSTATE_NEGOTIATE(param);
  415. } else if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) {
  416. if (!iser)
  417. SET_PSTATE_NEGOTIATE(param);
  418. } else if (!strcmp(param->name, MAXXMITDATASEGMENTLENGTH)) {
  419. continue;
  420. } else if (!strcmp(param->name, MAXBURSTLENGTH)) {
  421. SET_PSTATE_NEGOTIATE(param);
  422. } else if (!strcmp(param->name, FIRSTBURSTLENGTH)) {
  423. SET_PSTATE_NEGOTIATE(param);
  424. } else if (!strcmp(param->name, DEFAULTTIME2WAIT)) {
  425. SET_PSTATE_NEGOTIATE(param);
  426. } else if (!strcmp(param->name, DEFAULTTIME2RETAIN)) {
  427. SET_PSTATE_NEGOTIATE(param);
  428. } else if (!strcmp(param->name, MAXOUTSTANDINGR2T)) {
  429. SET_PSTATE_NEGOTIATE(param);
  430. } else if (!strcmp(param->name, DATAPDUINORDER)) {
  431. SET_PSTATE_NEGOTIATE(param);
  432. } else if (!strcmp(param->name, DATASEQUENCEINORDER)) {
  433. SET_PSTATE_NEGOTIATE(param);
  434. } else if (!strcmp(param->name, ERRORRECOVERYLEVEL)) {
  435. SET_PSTATE_NEGOTIATE(param);
  436. } else if (!strcmp(param->name, SESSIONTYPE)) {
  437. SET_PSTATE_NEGOTIATE(param);
  438. } else if (!strcmp(param->name, IFMARKER)) {
  439. SET_PSTATE_NEGOTIATE(param);
  440. } else if (!strcmp(param->name, OFMARKER)) {
  441. SET_PSTATE_NEGOTIATE(param);
  442. } else if (!strcmp(param->name, IFMARKINT)) {
  443. SET_PSTATE_REJECT(param);
  444. } else if (!strcmp(param->name, OFMARKINT)) {
  445. SET_PSTATE_REJECT(param);
  446. } else if (!strcmp(param->name, RDMAEXTENSIONS)) {
  447. if (iser)
  448. SET_PSTATE_NEGOTIATE(param);
  449. } else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH)) {
  450. if (iser)
  451. SET_PSTATE_NEGOTIATE(param);
  452. } else if (!strcmp(param->name, TARGETRECVDATASEGMENTLENGTH)) {
  453. if (iser)
  454. SET_PSTATE_NEGOTIATE(param);
  455. }
  456. }
  457. return 0;
  458. }
  459. int iscsi_set_keys_irrelevant_for_discovery(
  460. struct iscsi_param_list *param_list)
  461. {
  462. struct iscsi_param *param;
  463. list_for_each_entry(param, &param_list->param_list, p_list) {
  464. if (!strcmp(param->name, MAXCONNECTIONS))
  465. param->state &= ~PSTATE_NEGOTIATE;
  466. else if (!strcmp(param->name, INITIALR2T))
  467. param->state &= ~PSTATE_NEGOTIATE;
  468. else if (!strcmp(param->name, IMMEDIATEDATA))
  469. param->state &= ~PSTATE_NEGOTIATE;
  470. else if (!strcmp(param->name, MAXBURSTLENGTH))
  471. param->state &= ~PSTATE_NEGOTIATE;
  472. else if (!strcmp(param->name, FIRSTBURSTLENGTH))
  473. param->state &= ~PSTATE_NEGOTIATE;
  474. else if (!strcmp(param->name, MAXOUTSTANDINGR2T))
  475. param->state &= ~PSTATE_NEGOTIATE;
  476. else if (!strcmp(param->name, DATAPDUINORDER))
  477. param->state &= ~PSTATE_NEGOTIATE;
  478. else if (!strcmp(param->name, DATASEQUENCEINORDER))
  479. param->state &= ~PSTATE_NEGOTIATE;
  480. else if (!strcmp(param->name, ERRORRECOVERYLEVEL))
  481. param->state &= ~PSTATE_NEGOTIATE;
  482. else if (!strcmp(param->name, DEFAULTTIME2WAIT))
  483. param->state &= ~PSTATE_NEGOTIATE;
  484. else if (!strcmp(param->name, DEFAULTTIME2RETAIN))
  485. param->state &= ~PSTATE_NEGOTIATE;
  486. else if (!strcmp(param->name, IFMARKER))
  487. param->state &= ~PSTATE_NEGOTIATE;
  488. else if (!strcmp(param->name, OFMARKER))
  489. param->state &= ~PSTATE_NEGOTIATE;
  490. else if (!strcmp(param->name, IFMARKINT))
  491. param->state &= ~PSTATE_NEGOTIATE;
  492. else if (!strcmp(param->name, OFMARKINT))
  493. param->state &= ~PSTATE_NEGOTIATE;
  494. else if (!strcmp(param->name, RDMAEXTENSIONS))
  495. param->state &= ~PSTATE_NEGOTIATE;
  496. else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH))
  497. param->state &= ~PSTATE_NEGOTIATE;
  498. else if (!strcmp(param->name, TARGETRECVDATASEGMENTLENGTH))
  499. param->state &= ~PSTATE_NEGOTIATE;
  500. }
  501. return 0;
  502. }
  503. int iscsi_copy_param_list(
  504. struct iscsi_param_list **dst_param_list,
  505. struct iscsi_param_list *src_param_list,
  506. int leading)
  507. {
  508. struct iscsi_param *param = NULL;
  509. struct iscsi_param *new_param = NULL;
  510. struct iscsi_param_list *param_list = NULL;
  511. param_list = kzalloc(sizeof(struct iscsi_param_list), GFP_KERNEL);
  512. if (!param_list) {
  513. pr_err("Unable to allocate memory for struct iscsi_param_list.\n");
  514. return -1;
  515. }
  516. INIT_LIST_HEAD(&param_list->param_list);
  517. INIT_LIST_HEAD(&param_list->extra_response_list);
  518. list_for_each_entry(param, &src_param_list->param_list, p_list) {
  519. if (!leading && (param->scope & SCOPE_SESSION_WIDE)) {
  520. if ((strcmp(param->name, "TargetName") != 0) &&
  521. (strcmp(param->name, "InitiatorName") != 0) &&
  522. (strcmp(param->name, "TargetPortalGroupTag") != 0))
  523. continue;
  524. }
  525. new_param = kzalloc(sizeof(struct iscsi_param), GFP_KERNEL);
  526. if (!new_param) {
  527. pr_err("Unable to allocate memory for struct iscsi_param.\n");
  528. goto err_out;
  529. }
  530. new_param->name = kstrdup(param->name, GFP_KERNEL);
  531. new_param->value = kstrdup(param->value, GFP_KERNEL);
  532. if (!new_param->value || !new_param->name) {
  533. kfree(new_param->value);
  534. kfree(new_param->name);
  535. kfree(new_param);
  536. pr_err("Unable to allocate memory for parameter name/value.\n");
  537. goto err_out;
  538. }
  539. new_param->set_param = param->set_param;
  540. new_param->phase = param->phase;
  541. new_param->scope = param->scope;
  542. new_param->sender = param->sender;
  543. new_param->type = param->type;
  544. new_param->use = param->use;
  545. new_param->type_range = param->type_range;
  546. list_add_tail(&new_param->p_list, &param_list->param_list);
  547. }
  548. if (!list_empty(&param_list->param_list)) {
  549. *dst_param_list = param_list;
  550. } else {
  551. pr_err("No parameters allocated.\n");
  552. goto err_out;
  553. }
  554. return 0;
  555. err_out:
  556. iscsi_release_param_list(param_list);
  557. return -1;
  558. }
  559. static void iscsi_release_extra_responses(struct iscsi_param_list *param_list)
  560. {
  561. struct iscsi_extra_response *er, *er_tmp;
  562. list_for_each_entry_safe(er, er_tmp, &param_list->extra_response_list,
  563. er_list) {
  564. list_del(&er->er_list);
  565. kfree(er);
  566. }
  567. }
  568. void iscsi_release_param_list(struct iscsi_param_list *param_list)
  569. {
  570. struct iscsi_param *param, *param_tmp;
  571. list_for_each_entry_safe(param, param_tmp, &param_list->param_list,
  572. p_list) {
  573. list_del(&param->p_list);
  574. kfree(param->name);
  575. kfree(param->value);
  576. kfree(param);
  577. }
  578. iscsi_release_extra_responses(param_list);
  579. kfree(param_list);
  580. }
  581. struct iscsi_param *iscsi_find_param_from_key(
  582. char *key,
  583. struct iscsi_param_list *param_list)
  584. {
  585. struct iscsi_param *param;
  586. if (!key || !param_list) {
  587. pr_err("Key or parameter list pointer is NULL.\n");
  588. return NULL;
  589. }
  590. list_for_each_entry(param, &param_list->param_list, p_list) {
  591. if (!strcmp(key, param->name))
  592. return param;
  593. }
  594. pr_err("Unable to locate key \"%s\".\n", key);
  595. return NULL;
  596. }
  597. int iscsi_extract_key_value(char *textbuf, char **key, char **value)
  598. {
  599. *value = strchr(textbuf, '=');
  600. if (!*value) {
  601. pr_err("Unable to locate \"=\" separator for key,"
  602. " ignoring request.\n");
  603. return -1;
  604. }
  605. *key = textbuf;
  606. **value = '\0';
  607. *value = *value + 1;
  608. return 0;
  609. }
  610. int iscsi_update_param_value(struct iscsi_param *param, char *value)
  611. {
  612. kfree(param->value);
  613. param->value = kstrdup(value, GFP_KERNEL);
  614. if (!param->value) {
  615. pr_err("Unable to allocate memory for value.\n");
  616. return -ENOMEM;
  617. }
  618. pr_debug("iSCSI Parameter updated to %s=%s\n",
  619. param->name, param->value);
  620. return 0;
  621. }
  622. static int iscsi_add_notunderstood_response(
  623. char *key,
  624. char *value,
  625. struct iscsi_param_list *param_list)
  626. {
  627. struct iscsi_extra_response *extra_response;
  628. if (strlen(value) > VALUE_MAXLEN) {
  629. pr_err("Value for notunderstood key \"%s\" exceeds %d,"
  630. " protocol error.\n", key, VALUE_MAXLEN);
  631. return -1;
  632. }
  633. extra_response = kzalloc(sizeof(struct iscsi_extra_response), GFP_KERNEL);
  634. if (!extra_response) {
  635. pr_err("Unable to allocate memory for"
  636. " struct iscsi_extra_response.\n");
  637. return -1;
  638. }
  639. INIT_LIST_HEAD(&extra_response->er_list);
  640. strlcpy(extra_response->key, key, sizeof(extra_response->key));
  641. strlcpy(extra_response->value, NOTUNDERSTOOD,
  642. sizeof(extra_response->value));
  643. list_add_tail(&extra_response->er_list,
  644. &param_list->extra_response_list);
  645. return 0;
  646. }
  647. static int iscsi_check_for_auth_key(char *key)
  648. {
  649. /*
  650. * RFC 1994
  651. */
  652. if (!strcmp(key, "CHAP_A") || !strcmp(key, "CHAP_I") ||
  653. !strcmp(key, "CHAP_C") || !strcmp(key, "CHAP_N") ||
  654. !strcmp(key, "CHAP_R"))
  655. return 1;
  656. /*
  657. * RFC 2945
  658. */
  659. if (!strcmp(key, "SRP_U") || !strcmp(key, "SRP_N") ||
  660. !strcmp(key, "SRP_g") || !strcmp(key, "SRP_s") ||
  661. !strcmp(key, "SRP_A") || !strcmp(key, "SRP_B") ||
  662. !strcmp(key, "SRP_M") || !strcmp(key, "SRP_HM"))
  663. return 1;
  664. return 0;
  665. }
  666. static void iscsi_check_proposer_for_optional_reply(struct iscsi_param *param)
  667. {
  668. if (IS_TYPE_BOOL_AND(param)) {
  669. if (!strcmp(param->value, NO))
  670. SET_PSTATE_REPLY_OPTIONAL(param);
  671. } else if (IS_TYPE_BOOL_OR(param)) {
  672. if (!strcmp(param->value, YES))
  673. SET_PSTATE_REPLY_OPTIONAL(param);
  674. /*
  675. * Required for gPXE iSCSI boot client
  676. */
  677. if (!strcmp(param->name, IMMEDIATEDATA))
  678. SET_PSTATE_REPLY_OPTIONAL(param);
  679. } else if (IS_TYPE_NUMBER(param)) {
  680. if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH))
  681. SET_PSTATE_REPLY_OPTIONAL(param);
  682. /*
  683. * The GlobalSAN iSCSI Initiator for MacOSX does
  684. * not respond to MaxBurstLength, FirstBurstLength,
  685. * DefaultTime2Wait or DefaultTime2Retain parameter keys.
  686. * So, we set them to 'reply optional' here, and assume the
  687. * the defaults from iscsi_parameters.h if the initiator
  688. * is not RFC compliant and the keys are not negotiated.
  689. */
  690. if (!strcmp(param->name, MAXBURSTLENGTH))
  691. SET_PSTATE_REPLY_OPTIONAL(param);
  692. if (!strcmp(param->name, FIRSTBURSTLENGTH))
  693. SET_PSTATE_REPLY_OPTIONAL(param);
  694. if (!strcmp(param->name, DEFAULTTIME2WAIT))
  695. SET_PSTATE_REPLY_OPTIONAL(param);
  696. if (!strcmp(param->name, DEFAULTTIME2RETAIN))
  697. SET_PSTATE_REPLY_OPTIONAL(param);
  698. /*
  699. * Required for gPXE iSCSI boot client
  700. */
  701. if (!strcmp(param->name, MAXCONNECTIONS))
  702. SET_PSTATE_REPLY_OPTIONAL(param);
  703. } else if (IS_PHASE_DECLARATIVE(param))
  704. SET_PSTATE_REPLY_OPTIONAL(param);
  705. }
  706. static int iscsi_check_boolean_value(struct iscsi_param *param, char *value)
  707. {
  708. if (strcmp(value, YES) && strcmp(value, NO)) {
  709. pr_err("Illegal value for \"%s\", must be either"
  710. " \"%s\" or \"%s\".\n", param->name, YES, NO);
  711. return -1;
  712. }
  713. return 0;
  714. }
  715. static int iscsi_check_numerical_value(struct iscsi_param *param, char *value_ptr)
  716. {
  717. char *tmpptr;
  718. int value = 0;
  719. value = simple_strtoul(value_ptr, &tmpptr, 0);
  720. if (IS_TYPERANGE_0_TO_2(param)) {
  721. if ((value < 0) || (value > 2)) {
  722. pr_err("Illegal value for \"%s\", must be"
  723. " between 0 and 2.\n", param->name);
  724. return -1;
  725. }
  726. return 0;
  727. }
  728. if (IS_TYPERANGE_0_TO_3600(param)) {
  729. if ((value < 0) || (value > 3600)) {
  730. pr_err("Illegal value for \"%s\", must be"
  731. " between 0 and 3600.\n", param->name);
  732. return -1;
  733. }
  734. return 0;
  735. }
  736. if (IS_TYPERANGE_0_TO_32767(param)) {
  737. if ((value < 0) || (value > 32767)) {
  738. pr_err("Illegal value for \"%s\", must be"
  739. " between 0 and 32767.\n", param->name);
  740. return -1;
  741. }
  742. return 0;
  743. }
  744. if (IS_TYPERANGE_0_TO_65535(param)) {
  745. if ((value < 0) || (value > 65535)) {
  746. pr_err("Illegal value for \"%s\", must be"
  747. " between 0 and 65535.\n", param->name);
  748. return -1;
  749. }
  750. return 0;
  751. }
  752. if (IS_TYPERANGE_1_TO_65535(param)) {
  753. if ((value < 1) || (value > 65535)) {
  754. pr_err("Illegal value for \"%s\", must be"
  755. " between 1 and 65535.\n", param->name);
  756. return -1;
  757. }
  758. return 0;
  759. }
  760. if (IS_TYPERANGE_2_TO_3600(param)) {
  761. if ((value < 2) || (value > 3600)) {
  762. pr_err("Illegal value for \"%s\", must be"
  763. " between 2 and 3600.\n", param->name);
  764. return -1;
  765. }
  766. return 0;
  767. }
  768. if (IS_TYPERANGE_512_TO_16777215(param)) {
  769. if ((value < 512) || (value > 16777215)) {
  770. pr_err("Illegal value for \"%s\", must be"
  771. " between 512 and 16777215.\n", param->name);
  772. return -1;
  773. }
  774. return 0;
  775. }
  776. return 0;
  777. }
  778. static int iscsi_check_string_or_list_value(struct iscsi_param *param, char *value)
  779. {
  780. if (IS_PSTATE_PROPOSER(param))
  781. return 0;
  782. if (IS_TYPERANGE_AUTH_PARAM(param)) {
  783. if (strcmp(value, KRB5) && strcmp(value, SPKM1) &&
  784. strcmp(value, SPKM2) && strcmp(value, SRP) &&
  785. strcmp(value, CHAP) && strcmp(value, NONE)) {
  786. pr_err("Illegal value for \"%s\", must be"
  787. " \"%s\", \"%s\", \"%s\", \"%s\", \"%s\""
  788. " or \"%s\".\n", param->name, KRB5,
  789. SPKM1, SPKM2, SRP, CHAP, NONE);
  790. return -1;
  791. }
  792. }
  793. if (IS_TYPERANGE_DIGEST_PARAM(param)) {
  794. if (strcmp(value, CRC32C) && strcmp(value, NONE)) {
  795. pr_err("Illegal value for \"%s\", must be"
  796. " \"%s\" or \"%s\".\n", param->name,
  797. CRC32C, NONE);
  798. return -1;
  799. }
  800. }
  801. if (IS_TYPERANGE_SESSIONTYPE(param)) {
  802. if (strcmp(value, DISCOVERY) && strcmp(value, NORMAL)) {
  803. pr_err("Illegal value for \"%s\", must be"
  804. " \"%s\" or \"%s\".\n", param->name,
  805. DISCOVERY, NORMAL);
  806. return -1;
  807. }
  808. }
  809. return 0;
  810. }
  811. static char *iscsi_check_valuelist_for_support(
  812. struct iscsi_param *param,
  813. char *value)
  814. {
  815. char *tmp1 = NULL, *tmp2 = NULL;
  816. char *acceptor_values = NULL, *proposer_values = NULL;
  817. acceptor_values = param->value;
  818. proposer_values = value;
  819. do {
  820. if (!proposer_values)
  821. return NULL;
  822. tmp1 = strchr(proposer_values, ',');
  823. if (tmp1)
  824. *tmp1 = '\0';
  825. acceptor_values = param->value;
  826. do {
  827. if (!acceptor_values) {
  828. if (tmp1)
  829. *tmp1 = ',';
  830. return NULL;
  831. }
  832. tmp2 = strchr(acceptor_values, ',');
  833. if (tmp2)
  834. *tmp2 = '\0';
  835. if (!strcmp(acceptor_values, proposer_values)) {
  836. if (tmp2)
  837. *tmp2 = ',';
  838. goto out;
  839. }
  840. if (tmp2)
  841. *tmp2++ = ',';
  842. acceptor_values = tmp2;
  843. } while (acceptor_values);
  844. if (tmp1)
  845. *tmp1++ = ',';
  846. proposer_values = tmp1;
  847. } while (proposer_values);
  848. out:
  849. return proposer_values;
  850. }
  851. static int iscsi_check_acceptor_state(struct iscsi_param *param, char *value,
  852. struct iscsi_conn *conn)
  853. {
  854. u8 acceptor_boolean_value = 0, proposer_boolean_value = 0;
  855. char *negotiated_value = NULL;
  856. if (IS_PSTATE_ACCEPTOR(param)) {
  857. pr_err("Received key \"%s\" twice, protocol error.\n",
  858. param->name);
  859. return -1;
  860. }
  861. if (IS_PSTATE_REJECT(param))
  862. return 0;
  863. if (IS_TYPE_BOOL_AND(param)) {
  864. if (!strcmp(value, YES))
  865. proposer_boolean_value = 1;
  866. if (!strcmp(param->value, YES))
  867. acceptor_boolean_value = 1;
  868. if (acceptor_boolean_value && proposer_boolean_value)
  869. do {} while (0);
  870. else {
  871. if (iscsi_update_param_value(param, NO) < 0)
  872. return -1;
  873. if (!proposer_boolean_value)
  874. SET_PSTATE_REPLY_OPTIONAL(param);
  875. }
  876. } else if (IS_TYPE_BOOL_OR(param)) {
  877. if (!strcmp(value, YES))
  878. proposer_boolean_value = 1;
  879. if (!strcmp(param->value, YES))
  880. acceptor_boolean_value = 1;
  881. if (acceptor_boolean_value || proposer_boolean_value) {
  882. if (iscsi_update_param_value(param, YES) < 0)
  883. return -1;
  884. if (proposer_boolean_value)
  885. SET_PSTATE_REPLY_OPTIONAL(param);
  886. }
  887. } else if (IS_TYPE_NUMBER(param)) {
  888. char *tmpptr, buf[11];
  889. u32 acceptor_value = simple_strtoul(param->value, &tmpptr, 0);
  890. u32 proposer_value = simple_strtoul(value, &tmpptr, 0);
  891. memset(buf, 0, sizeof(buf));
  892. if (!strcmp(param->name, MAXCONNECTIONS) ||
  893. !strcmp(param->name, MAXBURSTLENGTH) ||
  894. !strcmp(param->name, FIRSTBURSTLENGTH) ||
  895. !strcmp(param->name, MAXOUTSTANDINGR2T) ||
  896. !strcmp(param->name, DEFAULTTIME2RETAIN) ||
  897. !strcmp(param->name, ERRORRECOVERYLEVEL)) {
  898. if (proposer_value > acceptor_value) {
  899. sprintf(buf, "%u", acceptor_value);
  900. if (iscsi_update_param_value(param,
  901. &buf[0]) < 0)
  902. return -1;
  903. } else {
  904. if (iscsi_update_param_value(param, value) < 0)
  905. return -1;
  906. }
  907. } else if (!strcmp(param->name, DEFAULTTIME2WAIT)) {
  908. if (acceptor_value > proposer_value) {
  909. sprintf(buf, "%u", acceptor_value);
  910. if (iscsi_update_param_value(param,
  911. &buf[0]) < 0)
  912. return -1;
  913. } else {
  914. if (iscsi_update_param_value(param, value) < 0)
  915. return -1;
  916. }
  917. } else {
  918. if (iscsi_update_param_value(param, value) < 0)
  919. return -1;
  920. }
  921. if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) {
  922. struct iscsi_param *param_mxdsl;
  923. unsigned long long tmp;
  924. int rc;
  925. rc = kstrtoull(param->value, 0, &tmp);
  926. if (rc < 0)
  927. return -1;
  928. conn->conn_ops->MaxRecvDataSegmentLength = tmp;
  929. pr_debug("Saving op->MaxRecvDataSegmentLength from"
  930. " original initiator received value: %u\n",
  931. conn->conn_ops->MaxRecvDataSegmentLength);
  932. param_mxdsl = iscsi_find_param_from_key(
  933. MAXXMITDATASEGMENTLENGTH,
  934. conn->param_list);
  935. if (!param_mxdsl)
  936. return -1;
  937. rc = iscsi_update_param_value(param,
  938. param_mxdsl->value);
  939. if (rc < 0)
  940. return -1;
  941. pr_debug("Updated %s to target MXDSL value: %s\n",
  942. param->name, param->value);
  943. }
  944. } else if (IS_TYPE_VALUE_LIST(param)) {
  945. negotiated_value = iscsi_check_valuelist_for_support(
  946. param, value);
  947. if (!negotiated_value) {
  948. pr_err("Proposer's value list \"%s\" contains"
  949. " no valid values from Acceptor's value list"
  950. " \"%s\".\n", value, param->value);
  951. return -1;
  952. }
  953. if (iscsi_update_param_value(param, negotiated_value) < 0)
  954. return -1;
  955. } else if (IS_PHASE_DECLARATIVE(param)) {
  956. if (iscsi_update_param_value(param, value) < 0)
  957. return -1;
  958. SET_PSTATE_REPLY_OPTIONAL(param);
  959. }
  960. return 0;
  961. }
  962. static int iscsi_check_proposer_state(struct iscsi_param *param, char *value)
  963. {
  964. if (IS_PSTATE_RESPONSE_GOT(param)) {
  965. pr_err("Received key \"%s\" twice, protocol error.\n",
  966. param->name);
  967. return -1;
  968. }
  969. if (IS_TYPE_VALUE_LIST(param)) {
  970. char *comma_ptr = NULL, *tmp_ptr = NULL;
  971. comma_ptr = strchr(value, ',');
  972. if (comma_ptr) {
  973. pr_err("Illegal \",\" in response for \"%s\".\n",
  974. param->name);
  975. return -1;
  976. }
  977. tmp_ptr = iscsi_check_valuelist_for_support(param, value);
  978. if (!tmp_ptr)
  979. return -1;
  980. }
  981. if (iscsi_update_param_value(param, value) < 0)
  982. return -1;
  983. return 0;
  984. }
  985. static int iscsi_check_value(struct iscsi_param *param, char *value)
  986. {
  987. char *comma_ptr = NULL;
  988. if (!strcmp(value, REJECT)) {
  989. if (!strcmp(param->name, IFMARKINT) ||
  990. !strcmp(param->name, OFMARKINT)) {
  991. /*
  992. * Reject is not fatal for [I,O]FMarkInt, and causes
  993. * [I,O]FMarker to be reset to No. (See iSCSI v20 A.3.2)
  994. */
  995. SET_PSTATE_REJECT(param);
  996. return 0;
  997. }
  998. pr_err("Received %s=%s\n", param->name, value);
  999. return -1;
  1000. }
  1001. if (!strcmp(value, IRRELEVANT)) {
  1002. pr_debug("Received %s=%s\n", param->name, value);
  1003. SET_PSTATE_IRRELEVANT(param);
  1004. return 0;
  1005. }
  1006. if (!strcmp(value, NOTUNDERSTOOD)) {
  1007. if (!IS_PSTATE_PROPOSER(param)) {
  1008. pr_err("Received illegal offer %s=%s\n",
  1009. param->name, value);
  1010. return -1;
  1011. }
  1012. /* #warning FIXME: Add check for X-ExtensionKey here */
  1013. pr_err("Standard iSCSI key \"%s\" cannot be answered"
  1014. " with \"%s\", protocol error.\n", param->name, value);
  1015. return -1;
  1016. }
  1017. do {
  1018. comma_ptr = NULL;
  1019. comma_ptr = strchr(value, ',');
  1020. if (comma_ptr && !IS_TYPE_VALUE_LIST(param)) {
  1021. pr_err("Detected value separator \",\", but"
  1022. " key \"%s\" does not allow a value list,"
  1023. " protocol error.\n", param->name);
  1024. return -1;
  1025. }
  1026. if (comma_ptr)
  1027. *comma_ptr = '\0';
  1028. if (strlen(value) > VALUE_MAXLEN) {
  1029. pr_err("Value for key \"%s\" exceeds %d,"
  1030. " protocol error.\n", param->name,
  1031. VALUE_MAXLEN);
  1032. return -1;
  1033. }
  1034. if (IS_TYPE_BOOL_AND(param) || IS_TYPE_BOOL_OR(param)) {
  1035. if (iscsi_check_boolean_value(param, value) < 0)
  1036. return -1;
  1037. } else if (IS_TYPE_NUMBER(param)) {
  1038. if (iscsi_check_numerical_value(param, value) < 0)
  1039. return -1;
  1040. } else if (IS_TYPE_STRING(param) || IS_TYPE_VALUE_LIST(param)) {
  1041. if (iscsi_check_string_or_list_value(param, value) < 0)
  1042. return -1;
  1043. } else {
  1044. pr_err("Huh? 0x%02x\n", param->type);
  1045. return -1;
  1046. }
  1047. if (comma_ptr)
  1048. *comma_ptr++ = ',';
  1049. value = comma_ptr;
  1050. } while (value);
  1051. return 0;
  1052. }
  1053. static struct iscsi_param *__iscsi_check_key(
  1054. char *key,
  1055. int sender,
  1056. struct iscsi_param_list *param_list)
  1057. {
  1058. struct iscsi_param *param;
  1059. if (strlen(key) > KEY_MAXLEN) {
  1060. pr_err("Length of key name \"%s\" exceeds %d.\n",
  1061. key, KEY_MAXLEN);
  1062. return NULL;
  1063. }
  1064. param = iscsi_find_param_from_key(key, param_list);
  1065. if (!param)
  1066. return NULL;
  1067. if ((sender & SENDER_INITIATOR) && !IS_SENDER_INITIATOR(param)) {
  1068. pr_err("Key \"%s\" may not be sent to %s,"
  1069. " protocol error.\n", param->name,
  1070. (sender & SENDER_RECEIVER) ? "target" : "initiator");
  1071. return NULL;
  1072. }
  1073. if ((sender & SENDER_TARGET) && !IS_SENDER_TARGET(param)) {
  1074. pr_err("Key \"%s\" may not be sent to %s,"
  1075. " protocol error.\n", param->name,
  1076. (sender & SENDER_RECEIVER) ? "initiator" : "target");
  1077. return NULL;
  1078. }
  1079. return param;
  1080. }
  1081. static struct iscsi_param *iscsi_check_key(
  1082. char *key,
  1083. int phase,
  1084. int sender,
  1085. struct iscsi_param_list *param_list)
  1086. {
  1087. struct iscsi_param *param;
  1088. /*
  1089. * Key name length must not exceed 63 bytes. (See iSCSI v20 5.1)
  1090. */
  1091. if (strlen(key) > KEY_MAXLEN) {
  1092. pr_err("Length of key name \"%s\" exceeds %d.\n",
  1093. key, KEY_MAXLEN);
  1094. return NULL;
  1095. }
  1096. param = iscsi_find_param_from_key(key, param_list);
  1097. if (!param)
  1098. return NULL;
  1099. if ((sender & SENDER_INITIATOR) && !IS_SENDER_INITIATOR(param)) {
  1100. pr_err("Key \"%s\" may not be sent to %s,"
  1101. " protocol error.\n", param->name,
  1102. (sender & SENDER_RECEIVER) ? "target" : "initiator");
  1103. return NULL;
  1104. }
  1105. if ((sender & SENDER_TARGET) && !IS_SENDER_TARGET(param)) {
  1106. pr_err("Key \"%s\" may not be sent to %s,"
  1107. " protocol error.\n", param->name,
  1108. (sender & SENDER_RECEIVER) ? "initiator" : "target");
  1109. return NULL;
  1110. }
  1111. if (IS_PSTATE_ACCEPTOR(param)) {
  1112. pr_err("Key \"%s\" received twice, protocol error.\n",
  1113. key);
  1114. return NULL;
  1115. }
  1116. if (!phase)
  1117. return param;
  1118. if (!(param->phase & phase)) {
  1119. pr_err("Key \"%s\" may not be negotiated during ",
  1120. param->name);
  1121. switch (phase) {
  1122. case PHASE_SECURITY:
  1123. pr_debug("Security phase.\n");
  1124. break;
  1125. case PHASE_OPERATIONAL:
  1126. pr_debug("Operational phase.\n");
  1127. break;
  1128. default:
  1129. pr_debug("Unknown phase.\n");
  1130. }
  1131. return NULL;
  1132. }
  1133. return param;
  1134. }
  1135. static int iscsi_enforce_integrity_rules(
  1136. u8 phase,
  1137. struct iscsi_param_list *param_list)
  1138. {
  1139. char *tmpptr;
  1140. u8 DataSequenceInOrder = 0;
  1141. u8 ErrorRecoveryLevel = 0, SessionType = 0;
  1142. u32 FirstBurstLength = 0, MaxBurstLength = 0;
  1143. struct iscsi_param *param = NULL;
  1144. list_for_each_entry(param, &param_list->param_list, p_list) {
  1145. if (!(param->phase & phase))
  1146. continue;
  1147. if (!strcmp(param->name, SESSIONTYPE))
  1148. if (!strcmp(param->value, NORMAL))
  1149. SessionType = 1;
  1150. if (!strcmp(param->name, ERRORRECOVERYLEVEL))
  1151. ErrorRecoveryLevel = simple_strtoul(param->value,
  1152. &tmpptr, 0);
  1153. if (!strcmp(param->name, DATASEQUENCEINORDER))
  1154. if (!strcmp(param->value, YES))
  1155. DataSequenceInOrder = 1;
  1156. if (!strcmp(param->name, MAXBURSTLENGTH))
  1157. MaxBurstLength = simple_strtoul(param->value,
  1158. &tmpptr, 0);
  1159. }
  1160. list_for_each_entry(param, &param_list->param_list, p_list) {
  1161. if (!(param->phase & phase))
  1162. continue;
  1163. if (!SessionType && !IS_PSTATE_ACCEPTOR(param))
  1164. continue;
  1165. if (!strcmp(param->name, MAXOUTSTANDINGR2T) &&
  1166. DataSequenceInOrder && (ErrorRecoveryLevel > 0)) {
  1167. if (strcmp(param->value, "1")) {
  1168. if (iscsi_update_param_value(param, "1") < 0)
  1169. return -1;
  1170. pr_debug("Reset \"%s\" to \"%s\".\n",
  1171. param->name, param->value);
  1172. }
  1173. }
  1174. if (!strcmp(param->name, MAXCONNECTIONS) && !SessionType) {
  1175. if (strcmp(param->value, "1")) {
  1176. if (iscsi_update_param_value(param, "1") < 0)
  1177. return -1;
  1178. pr_debug("Reset \"%s\" to \"%s\".\n",
  1179. param->name, param->value);
  1180. }
  1181. }
  1182. if (!strcmp(param->name, FIRSTBURSTLENGTH)) {
  1183. FirstBurstLength = simple_strtoul(param->value,
  1184. &tmpptr, 0);
  1185. if (FirstBurstLength > MaxBurstLength) {
  1186. char tmpbuf[11];
  1187. memset(tmpbuf, 0, sizeof(tmpbuf));
  1188. sprintf(tmpbuf, "%u", MaxBurstLength);
  1189. if (iscsi_update_param_value(param, tmpbuf))
  1190. return -1;
  1191. pr_debug("Reset \"%s\" to \"%s\".\n",
  1192. param->name, param->value);
  1193. }
  1194. }
  1195. }
  1196. return 0;
  1197. }
  1198. int iscsi_decode_text_input(
  1199. u8 phase,
  1200. u8 sender,
  1201. char *textbuf,
  1202. u32 length,
  1203. struct iscsi_conn *conn)
  1204. {
  1205. struct iscsi_param_list *param_list = conn->param_list;
  1206. char *tmpbuf, *start = NULL, *end = NULL;
  1207. tmpbuf = kzalloc(length + 1, GFP_KERNEL);
  1208. if (!tmpbuf) {
  1209. pr_err("Unable to allocate %u + 1 bytes for tmpbuf.\n", length);
  1210. return -1;
  1211. }
  1212. memcpy(tmpbuf, textbuf, length);
  1213. tmpbuf[length] = '\0';
  1214. start = tmpbuf;
  1215. end = (start + length);
  1216. while (start < end) {
  1217. char *key, *value;
  1218. struct iscsi_param *param;
  1219. if (iscsi_extract_key_value(start, &key, &value) < 0) {
  1220. kfree(tmpbuf);
  1221. return -1;
  1222. }
  1223. pr_debug("Got key: %s=%s\n", key, value);
  1224. if (phase & PHASE_SECURITY) {
  1225. if (iscsi_check_for_auth_key(key) > 0) {
  1226. kfree(tmpbuf);
  1227. return 1;
  1228. }
  1229. }
  1230. param = iscsi_check_key(key, phase, sender, param_list);
  1231. if (!param) {
  1232. if (iscsi_add_notunderstood_response(key,
  1233. value, param_list) < 0) {
  1234. kfree(tmpbuf);
  1235. return -1;
  1236. }
  1237. start += strlen(key) + strlen(value) + 2;
  1238. continue;
  1239. }
  1240. if (iscsi_check_value(param, value) < 0) {
  1241. kfree(tmpbuf);
  1242. return -1;
  1243. }
  1244. start += strlen(key) + strlen(value) + 2;
  1245. if (IS_PSTATE_PROPOSER(param)) {
  1246. if (iscsi_check_proposer_state(param, value) < 0) {
  1247. kfree(tmpbuf);
  1248. return -1;
  1249. }
  1250. SET_PSTATE_RESPONSE_GOT(param);
  1251. } else {
  1252. if (iscsi_check_acceptor_state(param, value, conn) < 0) {
  1253. kfree(tmpbuf);
  1254. return -1;
  1255. }
  1256. SET_PSTATE_ACCEPTOR(param);
  1257. }
  1258. }
  1259. kfree(tmpbuf);
  1260. return 0;
  1261. }
  1262. int iscsi_encode_text_output(
  1263. u8 phase,
  1264. u8 sender,
  1265. char *textbuf,
  1266. u32 *length,
  1267. struct iscsi_param_list *param_list)
  1268. {
  1269. char *output_buf = NULL;
  1270. struct iscsi_extra_response *er;
  1271. struct iscsi_param *param;
  1272. output_buf = textbuf + *length;
  1273. if (iscsi_enforce_integrity_rules(phase, param_list) < 0)
  1274. return -1;
  1275. list_for_each_entry(param, &param_list->param_list, p_list) {
  1276. if (!(param->sender & sender))
  1277. continue;
  1278. if (IS_PSTATE_ACCEPTOR(param) &&
  1279. !IS_PSTATE_RESPONSE_SENT(param) &&
  1280. !IS_PSTATE_REPLY_OPTIONAL(param) &&
  1281. (param->phase & phase)) {
  1282. *length += sprintf(output_buf, "%s=%s",
  1283. param->name, param->value);
  1284. *length += 1;
  1285. output_buf = textbuf + *length;
  1286. SET_PSTATE_RESPONSE_SENT(param);
  1287. pr_debug("Sending key: %s=%s\n",
  1288. param->name, param->value);
  1289. continue;
  1290. }
  1291. if (IS_PSTATE_NEGOTIATE(param) &&
  1292. !IS_PSTATE_ACCEPTOR(param) &&
  1293. !IS_PSTATE_PROPOSER(param) &&
  1294. (param->phase & phase)) {
  1295. *length += sprintf(output_buf, "%s=%s",
  1296. param->name, param->value);
  1297. *length += 1;
  1298. output_buf = textbuf + *length;
  1299. SET_PSTATE_PROPOSER(param);
  1300. iscsi_check_proposer_for_optional_reply(param);
  1301. pr_debug("Sending key: %s=%s\n",
  1302. param->name, param->value);
  1303. }
  1304. }
  1305. list_for_each_entry(er, &param_list->extra_response_list, er_list) {
  1306. *length += sprintf(output_buf, "%s=%s", er->key, er->value);
  1307. *length += 1;
  1308. output_buf = textbuf + *length;
  1309. pr_debug("Sending key: %s=%s\n", er->key, er->value);
  1310. }
  1311. iscsi_release_extra_responses(param_list);
  1312. return 0;
  1313. }
  1314. int iscsi_check_negotiated_keys(struct iscsi_param_list *param_list)
  1315. {
  1316. int ret = 0;
  1317. struct iscsi_param *param;
  1318. list_for_each_entry(param, &param_list->param_list, p_list) {
  1319. if (IS_PSTATE_NEGOTIATE(param) &&
  1320. IS_PSTATE_PROPOSER(param) &&
  1321. !IS_PSTATE_RESPONSE_GOT(param) &&
  1322. !IS_PSTATE_REPLY_OPTIONAL(param) &&
  1323. !IS_PHASE_DECLARATIVE(param)) {
  1324. pr_err("No response for proposed key \"%s\".\n",
  1325. param->name);
  1326. ret = -1;
  1327. }
  1328. }
  1329. return ret;
  1330. }
  1331. int iscsi_change_param_value(
  1332. char *keyvalue,
  1333. struct iscsi_param_list *param_list,
  1334. int check_key)
  1335. {
  1336. char *key = NULL, *value = NULL;
  1337. struct iscsi_param *param;
  1338. int sender = 0;
  1339. if (iscsi_extract_key_value(keyvalue, &key, &value) < 0)
  1340. return -1;
  1341. if (!check_key) {
  1342. param = __iscsi_check_key(keyvalue, sender, param_list);
  1343. if (!param)
  1344. return -1;
  1345. } else {
  1346. param = iscsi_check_key(keyvalue, 0, sender, param_list);
  1347. if (!param)
  1348. return -1;
  1349. param->set_param = 1;
  1350. if (iscsi_check_value(param, value) < 0) {
  1351. param->set_param = 0;
  1352. return -1;
  1353. }
  1354. param->set_param = 0;
  1355. }
  1356. if (iscsi_update_param_value(param, value) < 0)
  1357. return -1;
  1358. return 0;
  1359. }
  1360. void iscsi_set_connection_parameters(
  1361. struct iscsi_conn_ops *ops,
  1362. struct iscsi_param_list *param_list)
  1363. {
  1364. char *tmpptr;
  1365. struct iscsi_param *param;
  1366. pr_debug("---------------------------------------------------"
  1367. "---------------\n");
  1368. list_for_each_entry(param, &param_list->param_list, p_list) {
  1369. /*
  1370. * Special case to set MAXXMITDATASEGMENTLENGTH from the
  1371. * target requested MaxRecvDataSegmentLength, even though
  1372. * this key is not sent over the wire.
  1373. */
  1374. if (!strcmp(param->name, MAXXMITDATASEGMENTLENGTH)) {
  1375. ops->MaxXmitDataSegmentLength =
  1376. simple_strtoul(param->value, &tmpptr, 0);
  1377. pr_debug("MaxXmitDataSegmentLength: %s\n",
  1378. param->value);
  1379. }
  1380. if (!IS_PSTATE_ACCEPTOR(param) && !IS_PSTATE_PROPOSER(param))
  1381. continue;
  1382. if (!strcmp(param->name, AUTHMETHOD)) {
  1383. pr_debug("AuthMethod: %s\n",
  1384. param->value);
  1385. } else if (!strcmp(param->name, HEADERDIGEST)) {
  1386. ops->HeaderDigest = !strcmp(param->value, CRC32C);
  1387. pr_debug("HeaderDigest: %s\n",
  1388. param->value);
  1389. } else if (!strcmp(param->name, DATADIGEST)) {
  1390. ops->DataDigest = !strcmp(param->value, CRC32C);
  1391. pr_debug("DataDigest: %s\n",
  1392. param->value);
  1393. } else if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) {
  1394. /*
  1395. * At this point iscsi_check_acceptor_state() will have
  1396. * set ops->MaxRecvDataSegmentLength from the original
  1397. * initiator provided value.
  1398. */
  1399. pr_debug("MaxRecvDataSegmentLength: %u\n",
  1400. ops->MaxRecvDataSegmentLength);
  1401. } else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH)) {
  1402. ops->InitiatorRecvDataSegmentLength =
  1403. simple_strtoul(param->value, &tmpptr, 0);
  1404. pr_debug("InitiatorRecvDataSegmentLength: %s\n",
  1405. param->value);
  1406. ops->MaxRecvDataSegmentLength =
  1407. ops->InitiatorRecvDataSegmentLength;
  1408. pr_debug("Set MRDSL from InitiatorRecvDataSegmentLength\n");
  1409. } else if (!strcmp(param->name, TARGETRECVDATASEGMENTLENGTH)) {
  1410. ops->TargetRecvDataSegmentLength =
  1411. simple_strtoul(param->value, &tmpptr, 0);
  1412. pr_debug("TargetRecvDataSegmentLength: %s\n",
  1413. param->value);
  1414. ops->MaxXmitDataSegmentLength =
  1415. ops->TargetRecvDataSegmentLength;
  1416. pr_debug("Set MXDSL from TargetRecvDataSegmentLength\n");
  1417. }
  1418. }
  1419. pr_debug("----------------------------------------------------"
  1420. "--------------\n");
  1421. }
  1422. void iscsi_set_session_parameters(
  1423. struct iscsi_sess_ops *ops,
  1424. struct iscsi_param_list *param_list,
  1425. int leading)
  1426. {
  1427. char *tmpptr;
  1428. struct iscsi_param *param;
  1429. pr_debug("----------------------------------------------------"
  1430. "--------------\n");
  1431. list_for_each_entry(param, &param_list->param_list, p_list) {
  1432. if (!IS_PSTATE_ACCEPTOR(param) && !IS_PSTATE_PROPOSER(param))
  1433. continue;
  1434. if (!strcmp(param->name, INITIATORNAME)) {
  1435. if (!param->value)
  1436. continue;
  1437. if (leading)
  1438. snprintf(ops->InitiatorName,
  1439. sizeof(ops->InitiatorName),
  1440. "%s", param->value);
  1441. pr_debug("InitiatorName: %s\n",
  1442. param->value);
  1443. } else if (!strcmp(param->name, INITIATORALIAS)) {
  1444. if (!param->value)
  1445. continue;
  1446. snprintf(ops->InitiatorAlias,
  1447. sizeof(ops->InitiatorAlias),
  1448. "%s", param->value);
  1449. pr_debug("InitiatorAlias: %s\n",
  1450. param->value);
  1451. } else if (!strcmp(param->name, TARGETNAME)) {
  1452. if (!param->value)
  1453. continue;
  1454. if (leading)
  1455. snprintf(ops->TargetName,
  1456. sizeof(ops->TargetName),
  1457. "%s", param->value);
  1458. pr_debug("TargetName: %s\n",
  1459. param->value);
  1460. } else if (!strcmp(param->name, TARGETALIAS)) {
  1461. if (!param->value)
  1462. continue;
  1463. snprintf(ops->TargetAlias, sizeof(ops->TargetAlias),
  1464. "%s", param->value);
  1465. pr_debug("TargetAlias: %s\n",
  1466. param->value);
  1467. } else if (!strcmp(param->name, TARGETPORTALGROUPTAG)) {
  1468. ops->TargetPortalGroupTag =
  1469. simple_strtoul(param->value, &tmpptr, 0);
  1470. pr_debug("TargetPortalGroupTag: %s\n",
  1471. param->value);
  1472. } else if (!strcmp(param->name, MAXCONNECTIONS)) {
  1473. ops->MaxConnections =
  1474. simple_strtoul(param->value, &tmpptr, 0);
  1475. pr_debug("MaxConnections: %s\n",
  1476. param->value);
  1477. } else if (!strcmp(param->name, INITIALR2T)) {
  1478. ops->InitialR2T = !strcmp(param->value, YES);
  1479. pr_debug("InitialR2T: %s\n",
  1480. param->value);
  1481. } else if (!strcmp(param->name, IMMEDIATEDATA)) {
  1482. ops->ImmediateData = !strcmp(param->value, YES);
  1483. pr_debug("ImmediateData: %s\n",
  1484. param->value);
  1485. } else if (!strcmp(param->name, MAXBURSTLENGTH)) {
  1486. ops->MaxBurstLength =
  1487. simple_strtoul(param->value, &tmpptr, 0);
  1488. pr_debug("MaxBurstLength: %s\n",
  1489. param->value);
  1490. } else if (!strcmp(param->name, FIRSTBURSTLENGTH)) {
  1491. ops->FirstBurstLength =
  1492. simple_strtoul(param->value, &tmpptr, 0);
  1493. pr_debug("FirstBurstLength: %s\n",
  1494. param->value);
  1495. } else if (!strcmp(param->name, DEFAULTTIME2WAIT)) {
  1496. ops->DefaultTime2Wait =
  1497. simple_strtoul(param->value, &tmpptr, 0);
  1498. pr_debug("DefaultTime2Wait: %s\n",
  1499. param->value);
  1500. } else if (!strcmp(param->name, DEFAULTTIME2RETAIN)) {
  1501. ops->DefaultTime2Retain =
  1502. simple_strtoul(param->value, &tmpptr, 0);
  1503. pr_debug("DefaultTime2Retain: %s\n",
  1504. param->value);
  1505. } else if (!strcmp(param->name, MAXOUTSTANDINGR2T)) {
  1506. ops->MaxOutstandingR2T =
  1507. simple_strtoul(param->value, &tmpptr, 0);
  1508. pr_debug("MaxOutstandingR2T: %s\n",
  1509. param->value);
  1510. } else if (!strcmp(param->name, DATAPDUINORDER)) {
  1511. ops->DataPDUInOrder = !strcmp(param->value, YES);
  1512. pr_debug("DataPDUInOrder: %s\n",
  1513. param->value);
  1514. } else if (!strcmp(param->name, DATASEQUENCEINORDER)) {
  1515. ops->DataSequenceInOrder = !strcmp(param->value, YES);
  1516. pr_debug("DataSequenceInOrder: %s\n",
  1517. param->value);
  1518. } else if (!strcmp(param->name, ERRORRECOVERYLEVEL)) {
  1519. ops->ErrorRecoveryLevel =
  1520. simple_strtoul(param->value, &tmpptr, 0);
  1521. pr_debug("ErrorRecoveryLevel: %s\n",
  1522. param->value);
  1523. } else if (!strcmp(param->name, SESSIONTYPE)) {
  1524. ops->SessionType = !strcmp(param->value, DISCOVERY);
  1525. pr_debug("SessionType: %s\n",
  1526. param->value);
  1527. } else if (!strcmp(param->name, RDMAEXTENSIONS)) {
  1528. ops->RDMAExtensions = !strcmp(param->value, YES);
  1529. pr_debug("RDMAExtensions: %s\n",
  1530. param->value);
  1531. }
  1532. }
  1533. pr_debug("----------------------------------------------------"
  1534. "--------------\n");
  1535. }