iscsi_target_parameters.c 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727
  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 -ENOMEM;
  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_REJECT(param);
  440. } else if (!strcmp(param->name, OFMARKER)) {
  441. SET_PSTATE_REJECT(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 -ENOMEM;
  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 -ENOMEM;
  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 -ENOMEM;
  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. bool keys_workaround)
  668. {
  669. if (IS_TYPE_BOOL_AND(param)) {
  670. if (!strcmp(param->value, NO))
  671. SET_PSTATE_REPLY_OPTIONAL(param);
  672. } else if (IS_TYPE_BOOL_OR(param)) {
  673. if (!strcmp(param->value, YES))
  674. SET_PSTATE_REPLY_OPTIONAL(param);
  675. if (keys_workaround) {
  676. /*
  677. * Required for gPXE iSCSI boot client
  678. */
  679. if (!strcmp(param->name, IMMEDIATEDATA))
  680. SET_PSTATE_REPLY_OPTIONAL(param);
  681. }
  682. } else if (IS_TYPE_NUMBER(param)) {
  683. if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH))
  684. SET_PSTATE_REPLY_OPTIONAL(param);
  685. if (keys_workaround) {
  686. /*
  687. * Required for Mellanox Flexboot PXE boot ROM
  688. */
  689. if (!strcmp(param->name, FIRSTBURSTLENGTH))
  690. SET_PSTATE_REPLY_OPTIONAL(param);
  691. /*
  692. * Required for gPXE iSCSI boot client
  693. */
  694. if (!strcmp(param->name, MAXCONNECTIONS))
  695. SET_PSTATE_REPLY_OPTIONAL(param);
  696. }
  697. } else if (IS_PHASE_DECLARATIVE(param))
  698. SET_PSTATE_REPLY_OPTIONAL(param);
  699. }
  700. static int iscsi_check_boolean_value(struct iscsi_param *param, char *value)
  701. {
  702. if (strcmp(value, YES) && strcmp(value, NO)) {
  703. pr_err("Illegal value for \"%s\", must be either"
  704. " \"%s\" or \"%s\".\n", param->name, YES, NO);
  705. return -1;
  706. }
  707. return 0;
  708. }
  709. static int iscsi_check_numerical_value(struct iscsi_param *param, char *value_ptr)
  710. {
  711. char *tmpptr;
  712. int value = 0;
  713. value = simple_strtoul(value_ptr, &tmpptr, 0);
  714. if (IS_TYPERANGE_0_TO_2(param)) {
  715. if ((value < 0) || (value > 2)) {
  716. pr_err("Illegal value for \"%s\", must be"
  717. " between 0 and 2.\n", param->name);
  718. return -1;
  719. }
  720. return 0;
  721. }
  722. if (IS_TYPERANGE_0_TO_3600(param)) {
  723. if ((value < 0) || (value > 3600)) {
  724. pr_err("Illegal value for \"%s\", must be"
  725. " between 0 and 3600.\n", param->name);
  726. return -1;
  727. }
  728. return 0;
  729. }
  730. if (IS_TYPERANGE_0_TO_32767(param)) {
  731. if ((value < 0) || (value > 32767)) {
  732. pr_err("Illegal value for \"%s\", must be"
  733. " between 0 and 32767.\n", param->name);
  734. return -1;
  735. }
  736. return 0;
  737. }
  738. if (IS_TYPERANGE_0_TO_65535(param)) {
  739. if ((value < 0) || (value > 65535)) {
  740. pr_err("Illegal value for \"%s\", must be"
  741. " between 0 and 65535.\n", param->name);
  742. return -1;
  743. }
  744. return 0;
  745. }
  746. if (IS_TYPERANGE_1_TO_65535(param)) {
  747. if ((value < 1) || (value > 65535)) {
  748. pr_err("Illegal value for \"%s\", must be"
  749. " between 1 and 65535.\n", param->name);
  750. return -1;
  751. }
  752. return 0;
  753. }
  754. if (IS_TYPERANGE_2_TO_3600(param)) {
  755. if ((value < 2) || (value > 3600)) {
  756. pr_err("Illegal value for \"%s\", must be"
  757. " between 2 and 3600.\n", param->name);
  758. return -1;
  759. }
  760. return 0;
  761. }
  762. if (IS_TYPERANGE_512_TO_16777215(param)) {
  763. if ((value < 512) || (value > 16777215)) {
  764. pr_err("Illegal value for \"%s\", must be"
  765. " between 512 and 16777215.\n", param->name);
  766. return -1;
  767. }
  768. return 0;
  769. }
  770. return 0;
  771. }
  772. static int iscsi_check_string_or_list_value(struct iscsi_param *param, char *value)
  773. {
  774. if (IS_PSTATE_PROPOSER(param))
  775. return 0;
  776. if (IS_TYPERANGE_AUTH_PARAM(param)) {
  777. if (strcmp(value, KRB5) && strcmp(value, SPKM1) &&
  778. strcmp(value, SPKM2) && strcmp(value, SRP) &&
  779. strcmp(value, CHAP) && strcmp(value, NONE)) {
  780. pr_err("Illegal value for \"%s\", must be"
  781. " \"%s\", \"%s\", \"%s\", \"%s\", \"%s\""
  782. " or \"%s\".\n", param->name, KRB5,
  783. SPKM1, SPKM2, SRP, CHAP, NONE);
  784. return -1;
  785. }
  786. }
  787. if (IS_TYPERANGE_DIGEST_PARAM(param)) {
  788. if (strcmp(value, CRC32C) && strcmp(value, NONE)) {
  789. pr_err("Illegal value for \"%s\", must be"
  790. " \"%s\" or \"%s\".\n", param->name,
  791. CRC32C, NONE);
  792. return -1;
  793. }
  794. }
  795. if (IS_TYPERANGE_SESSIONTYPE(param)) {
  796. if (strcmp(value, DISCOVERY) && strcmp(value, NORMAL)) {
  797. pr_err("Illegal value for \"%s\", must be"
  798. " \"%s\" or \"%s\".\n", param->name,
  799. DISCOVERY, NORMAL);
  800. return -1;
  801. }
  802. }
  803. return 0;
  804. }
  805. static char *iscsi_check_valuelist_for_support(
  806. struct iscsi_param *param,
  807. char *value)
  808. {
  809. char *tmp1 = NULL, *tmp2 = NULL;
  810. char *acceptor_values = NULL, *proposer_values = NULL;
  811. acceptor_values = param->value;
  812. proposer_values = value;
  813. do {
  814. if (!proposer_values)
  815. return NULL;
  816. tmp1 = strchr(proposer_values, ',');
  817. if (tmp1)
  818. *tmp1 = '\0';
  819. acceptor_values = param->value;
  820. do {
  821. if (!acceptor_values) {
  822. if (tmp1)
  823. *tmp1 = ',';
  824. return NULL;
  825. }
  826. tmp2 = strchr(acceptor_values, ',');
  827. if (tmp2)
  828. *tmp2 = '\0';
  829. if (!strcmp(acceptor_values, proposer_values)) {
  830. if (tmp2)
  831. *tmp2 = ',';
  832. goto out;
  833. }
  834. if (tmp2)
  835. *tmp2++ = ',';
  836. acceptor_values = tmp2;
  837. } while (acceptor_values);
  838. if (tmp1)
  839. *tmp1++ = ',';
  840. proposer_values = tmp1;
  841. } while (proposer_values);
  842. out:
  843. return proposer_values;
  844. }
  845. static int iscsi_check_acceptor_state(struct iscsi_param *param, char *value,
  846. struct iscsi_conn *conn)
  847. {
  848. u8 acceptor_boolean_value = 0, proposer_boolean_value = 0;
  849. char *negotiated_value = NULL;
  850. if (IS_PSTATE_ACCEPTOR(param)) {
  851. pr_err("Received key \"%s\" twice, protocol error.\n",
  852. param->name);
  853. return -1;
  854. }
  855. if (IS_PSTATE_REJECT(param))
  856. return 0;
  857. if (IS_TYPE_BOOL_AND(param)) {
  858. if (!strcmp(value, YES))
  859. proposer_boolean_value = 1;
  860. if (!strcmp(param->value, YES))
  861. acceptor_boolean_value = 1;
  862. if (acceptor_boolean_value && proposer_boolean_value)
  863. do {} while (0);
  864. else {
  865. if (iscsi_update_param_value(param, NO) < 0)
  866. return -1;
  867. if (!proposer_boolean_value)
  868. SET_PSTATE_REPLY_OPTIONAL(param);
  869. }
  870. } else if (IS_TYPE_BOOL_OR(param)) {
  871. if (!strcmp(value, YES))
  872. proposer_boolean_value = 1;
  873. if (!strcmp(param->value, YES))
  874. acceptor_boolean_value = 1;
  875. if (acceptor_boolean_value || proposer_boolean_value) {
  876. if (iscsi_update_param_value(param, YES) < 0)
  877. return -1;
  878. if (proposer_boolean_value)
  879. SET_PSTATE_REPLY_OPTIONAL(param);
  880. }
  881. } else if (IS_TYPE_NUMBER(param)) {
  882. char *tmpptr, buf[11];
  883. u32 acceptor_value = simple_strtoul(param->value, &tmpptr, 0);
  884. u32 proposer_value = simple_strtoul(value, &tmpptr, 0);
  885. memset(buf, 0, sizeof(buf));
  886. if (!strcmp(param->name, MAXCONNECTIONS) ||
  887. !strcmp(param->name, MAXBURSTLENGTH) ||
  888. !strcmp(param->name, FIRSTBURSTLENGTH) ||
  889. !strcmp(param->name, MAXOUTSTANDINGR2T) ||
  890. !strcmp(param->name, DEFAULTTIME2RETAIN) ||
  891. !strcmp(param->name, ERRORRECOVERYLEVEL)) {
  892. if (proposer_value > acceptor_value) {
  893. sprintf(buf, "%u", acceptor_value);
  894. if (iscsi_update_param_value(param,
  895. &buf[0]) < 0)
  896. return -1;
  897. } else {
  898. if (iscsi_update_param_value(param, value) < 0)
  899. return -1;
  900. }
  901. } else if (!strcmp(param->name, DEFAULTTIME2WAIT)) {
  902. if (acceptor_value > proposer_value) {
  903. sprintf(buf, "%u", acceptor_value);
  904. if (iscsi_update_param_value(param,
  905. &buf[0]) < 0)
  906. return -1;
  907. } else {
  908. if (iscsi_update_param_value(param, value) < 0)
  909. return -1;
  910. }
  911. } else {
  912. if (iscsi_update_param_value(param, value) < 0)
  913. return -1;
  914. }
  915. if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) {
  916. struct iscsi_param *param_mxdsl;
  917. unsigned long long tmp;
  918. int rc;
  919. rc = kstrtoull(param->value, 0, &tmp);
  920. if (rc < 0)
  921. return -1;
  922. conn->conn_ops->MaxRecvDataSegmentLength = tmp;
  923. pr_debug("Saving op->MaxRecvDataSegmentLength from"
  924. " original initiator received value: %u\n",
  925. conn->conn_ops->MaxRecvDataSegmentLength);
  926. param_mxdsl = iscsi_find_param_from_key(
  927. MAXXMITDATASEGMENTLENGTH,
  928. conn->param_list);
  929. if (!param_mxdsl)
  930. return -1;
  931. rc = iscsi_update_param_value(param,
  932. param_mxdsl->value);
  933. if (rc < 0)
  934. return -1;
  935. pr_debug("Updated %s to target MXDSL value: %s\n",
  936. param->name, param->value);
  937. }
  938. } else if (IS_TYPE_VALUE_LIST(param)) {
  939. negotiated_value = iscsi_check_valuelist_for_support(
  940. param, value);
  941. if (!negotiated_value) {
  942. pr_err("Proposer's value list \"%s\" contains"
  943. " no valid values from Acceptor's value list"
  944. " \"%s\".\n", value, param->value);
  945. return -1;
  946. }
  947. if (iscsi_update_param_value(param, negotiated_value) < 0)
  948. return -1;
  949. } else if (IS_PHASE_DECLARATIVE(param)) {
  950. if (iscsi_update_param_value(param, value) < 0)
  951. return -1;
  952. SET_PSTATE_REPLY_OPTIONAL(param);
  953. }
  954. return 0;
  955. }
  956. static int iscsi_check_proposer_state(struct iscsi_param *param, char *value)
  957. {
  958. if (IS_PSTATE_RESPONSE_GOT(param)) {
  959. pr_err("Received key \"%s\" twice, protocol error.\n",
  960. param->name);
  961. return -1;
  962. }
  963. if (IS_TYPE_VALUE_LIST(param)) {
  964. char *comma_ptr = NULL, *tmp_ptr = NULL;
  965. comma_ptr = strchr(value, ',');
  966. if (comma_ptr) {
  967. pr_err("Illegal \",\" in response for \"%s\".\n",
  968. param->name);
  969. return -1;
  970. }
  971. tmp_ptr = iscsi_check_valuelist_for_support(param, value);
  972. if (!tmp_ptr)
  973. return -1;
  974. }
  975. if (iscsi_update_param_value(param, value) < 0)
  976. return -1;
  977. return 0;
  978. }
  979. static int iscsi_check_value(struct iscsi_param *param, char *value)
  980. {
  981. char *comma_ptr = NULL;
  982. if (!strcmp(value, REJECT)) {
  983. if (!strcmp(param->name, IFMARKINT) ||
  984. !strcmp(param->name, OFMARKINT)) {
  985. /*
  986. * Reject is not fatal for [I,O]FMarkInt, and causes
  987. * [I,O]FMarker to be reset to No. (See iSCSI v20 A.3.2)
  988. */
  989. SET_PSTATE_REJECT(param);
  990. return 0;
  991. }
  992. pr_err("Received %s=%s\n", param->name, value);
  993. return -1;
  994. }
  995. if (!strcmp(value, IRRELEVANT)) {
  996. pr_debug("Received %s=%s\n", param->name, value);
  997. SET_PSTATE_IRRELEVANT(param);
  998. return 0;
  999. }
  1000. if (!strcmp(value, NOTUNDERSTOOD)) {
  1001. if (!IS_PSTATE_PROPOSER(param)) {
  1002. pr_err("Received illegal offer %s=%s\n",
  1003. param->name, value);
  1004. return -1;
  1005. }
  1006. /* #warning FIXME: Add check for X-ExtensionKey here */
  1007. pr_err("Standard iSCSI key \"%s\" cannot be answered"
  1008. " with \"%s\", protocol error.\n", param->name, value);
  1009. return -1;
  1010. }
  1011. do {
  1012. comma_ptr = NULL;
  1013. comma_ptr = strchr(value, ',');
  1014. if (comma_ptr && !IS_TYPE_VALUE_LIST(param)) {
  1015. pr_err("Detected value separator \",\", but"
  1016. " key \"%s\" does not allow a value list,"
  1017. " protocol error.\n", param->name);
  1018. return -1;
  1019. }
  1020. if (comma_ptr)
  1021. *comma_ptr = '\0';
  1022. if (strlen(value) > VALUE_MAXLEN) {
  1023. pr_err("Value for key \"%s\" exceeds %d,"
  1024. " protocol error.\n", param->name,
  1025. VALUE_MAXLEN);
  1026. return -1;
  1027. }
  1028. if (IS_TYPE_BOOL_AND(param) || IS_TYPE_BOOL_OR(param)) {
  1029. if (iscsi_check_boolean_value(param, value) < 0)
  1030. return -1;
  1031. } else if (IS_TYPE_NUMBER(param)) {
  1032. if (iscsi_check_numerical_value(param, value) < 0)
  1033. return -1;
  1034. } else if (IS_TYPE_STRING(param) || IS_TYPE_VALUE_LIST(param)) {
  1035. if (iscsi_check_string_or_list_value(param, value) < 0)
  1036. return -1;
  1037. } else {
  1038. pr_err("Huh? 0x%02x\n", param->type);
  1039. return -1;
  1040. }
  1041. if (comma_ptr)
  1042. *comma_ptr++ = ',';
  1043. value = comma_ptr;
  1044. } while (value);
  1045. return 0;
  1046. }
  1047. static struct iscsi_param *__iscsi_check_key(
  1048. char *key,
  1049. int sender,
  1050. struct iscsi_param_list *param_list)
  1051. {
  1052. struct iscsi_param *param;
  1053. if (strlen(key) > KEY_MAXLEN) {
  1054. pr_err("Length of key name \"%s\" exceeds %d.\n",
  1055. key, KEY_MAXLEN);
  1056. return NULL;
  1057. }
  1058. param = iscsi_find_param_from_key(key, param_list);
  1059. if (!param)
  1060. return NULL;
  1061. if ((sender & SENDER_INITIATOR) && !IS_SENDER_INITIATOR(param)) {
  1062. pr_err("Key \"%s\" may not be sent to %s,"
  1063. " protocol error.\n", param->name,
  1064. (sender & SENDER_RECEIVER) ? "target" : "initiator");
  1065. return NULL;
  1066. }
  1067. if ((sender & SENDER_TARGET) && !IS_SENDER_TARGET(param)) {
  1068. pr_err("Key \"%s\" may not be sent to %s,"
  1069. " protocol error.\n", param->name,
  1070. (sender & SENDER_RECEIVER) ? "initiator" : "target");
  1071. return NULL;
  1072. }
  1073. return param;
  1074. }
  1075. static struct iscsi_param *iscsi_check_key(
  1076. char *key,
  1077. int phase,
  1078. int sender,
  1079. struct iscsi_param_list *param_list)
  1080. {
  1081. struct iscsi_param *param;
  1082. /*
  1083. * Key name length must not exceed 63 bytes. (See iSCSI v20 5.1)
  1084. */
  1085. if (strlen(key) > KEY_MAXLEN) {
  1086. pr_err("Length of key name \"%s\" exceeds %d.\n",
  1087. key, KEY_MAXLEN);
  1088. return NULL;
  1089. }
  1090. param = iscsi_find_param_from_key(key, param_list);
  1091. if (!param)
  1092. return NULL;
  1093. if ((sender & SENDER_INITIATOR) && !IS_SENDER_INITIATOR(param)) {
  1094. pr_err("Key \"%s\" may not be sent to %s,"
  1095. " protocol error.\n", param->name,
  1096. (sender & SENDER_RECEIVER) ? "target" : "initiator");
  1097. return NULL;
  1098. }
  1099. if ((sender & SENDER_TARGET) && !IS_SENDER_TARGET(param)) {
  1100. pr_err("Key \"%s\" may not be sent to %s,"
  1101. " protocol error.\n", param->name,
  1102. (sender & SENDER_RECEIVER) ? "initiator" : "target");
  1103. return NULL;
  1104. }
  1105. if (IS_PSTATE_ACCEPTOR(param)) {
  1106. pr_err("Key \"%s\" received twice, protocol error.\n",
  1107. key);
  1108. return NULL;
  1109. }
  1110. if (!phase)
  1111. return param;
  1112. if (!(param->phase & phase)) {
  1113. pr_err("Key \"%s\" may not be negotiated during ",
  1114. param->name);
  1115. switch (phase) {
  1116. case PHASE_SECURITY:
  1117. pr_debug("Security phase.\n");
  1118. break;
  1119. case PHASE_OPERATIONAL:
  1120. pr_debug("Operational phase.\n");
  1121. break;
  1122. default:
  1123. pr_debug("Unknown phase.\n");
  1124. }
  1125. return NULL;
  1126. }
  1127. return param;
  1128. }
  1129. static int iscsi_enforce_integrity_rules(
  1130. u8 phase,
  1131. struct iscsi_param_list *param_list)
  1132. {
  1133. char *tmpptr;
  1134. u8 DataSequenceInOrder = 0;
  1135. u8 ErrorRecoveryLevel = 0, SessionType = 0;
  1136. u32 FirstBurstLength = 0, MaxBurstLength = 0;
  1137. struct iscsi_param *param = NULL;
  1138. list_for_each_entry(param, &param_list->param_list, p_list) {
  1139. if (!(param->phase & phase))
  1140. continue;
  1141. if (!strcmp(param->name, SESSIONTYPE))
  1142. if (!strcmp(param->value, NORMAL))
  1143. SessionType = 1;
  1144. if (!strcmp(param->name, ERRORRECOVERYLEVEL))
  1145. ErrorRecoveryLevel = simple_strtoul(param->value,
  1146. &tmpptr, 0);
  1147. if (!strcmp(param->name, DATASEQUENCEINORDER))
  1148. if (!strcmp(param->value, YES))
  1149. DataSequenceInOrder = 1;
  1150. if (!strcmp(param->name, MAXBURSTLENGTH))
  1151. MaxBurstLength = simple_strtoul(param->value,
  1152. &tmpptr, 0);
  1153. }
  1154. list_for_each_entry(param, &param_list->param_list, p_list) {
  1155. if (!(param->phase & phase))
  1156. continue;
  1157. if (!SessionType && !IS_PSTATE_ACCEPTOR(param))
  1158. continue;
  1159. if (!strcmp(param->name, MAXOUTSTANDINGR2T) &&
  1160. DataSequenceInOrder && (ErrorRecoveryLevel > 0)) {
  1161. if (strcmp(param->value, "1")) {
  1162. if (iscsi_update_param_value(param, "1") < 0)
  1163. return -1;
  1164. pr_debug("Reset \"%s\" to \"%s\".\n",
  1165. param->name, param->value);
  1166. }
  1167. }
  1168. if (!strcmp(param->name, MAXCONNECTIONS) && !SessionType) {
  1169. if (strcmp(param->value, "1")) {
  1170. if (iscsi_update_param_value(param, "1") < 0)
  1171. return -1;
  1172. pr_debug("Reset \"%s\" to \"%s\".\n",
  1173. param->name, param->value);
  1174. }
  1175. }
  1176. if (!strcmp(param->name, FIRSTBURSTLENGTH)) {
  1177. FirstBurstLength = simple_strtoul(param->value,
  1178. &tmpptr, 0);
  1179. if (FirstBurstLength > MaxBurstLength) {
  1180. char tmpbuf[11];
  1181. memset(tmpbuf, 0, sizeof(tmpbuf));
  1182. sprintf(tmpbuf, "%u", MaxBurstLength);
  1183. if (iscsi_update_param_value(param, tmpbuf))
  1184. return -1;
  1185. pr_debug("Reset \"%s\" to \"%s\".\n",
  1186. param->name, param->value);
  1187. }
  1188. }
  1189. }
  1190. return 0;
  1191. }
  1192. int iscsi_decode_text_input(
  1193. u8 phase,
  1194. u8 sender,
  1195. char *textbuf,
  1196. u32 length,
  1197. struct iscsi_conn *conn)
  1198. {
  1199. struct iscsi_param_list *param_list = conn->param_list;
  1200. char *tmpbuf, *start = NULL, *end = NULL;
  1201. tmpbuf = kzalloc(length + 1, GFP_KERNEL);
  1202. if (!tmpbuf) {
  1203. pr_err("Unable to allocate %u + 1 bytes for tmpbuf.\n", length);
  1204. return -ENOMEM;
  1205. }
  1206. memcpy(tmpbuf, textbuf, length);
  1207. tmpbuf[length] = '\0';
  1208. start = tmpbuf;
  1209. end = (start + length);
  1210. while (start < end) {
  1211. char *key, *value;
  1212. struct iscsi_param *param;
  1213. if (iscsi_extract_key_value(start, &key, &value) < 0) {
  1214. kfree(tmpbuf);
  1215. return -1;
  1216. }
  1217. pr_debug("Got key: %s=%s\n", key, value);
  1218. if (phase & PHASE_SECURITY) {
  1219. if (iscsi_check_for_auth_key(key) > 0) {
  1220. kfree(tmpbuf);
  1221. return 1;
  1222. }
  1223. }
  1224. param = iscsi_check_key(key, phase, sender, param_list);
  1225. if (!param) {
  1226. if (iscsi_add_notunderstood_response(key,
  1227. value, param_list) < 0) {
  1228. kfree(tmpbuf);
  1229. return -1;
  1230. }
  1231. start += strlen(key) + strlen(value) + 2;
  1232. continue;
  1233. }
  1234. if (iscsi_check_value(param, value) < 0) {
  1235. kfree(tmpbuf);
  1236. return -1;
  1237. }
  1238. start += strlen(key) + strlen(value) + 2;
  1239. if (IS_PSTATE_PROPOSER(param)) {
  1240. if (iscsi_check_proposer_state(param, value) < 0) {
  1241. kfree(tmpbuf);
  1242. return -1;
  1243. }
  1244. SET_PSTATE_RESPONSE_GOT(param);
  1245. } else {
  1246. if (iscsi_check_acceptor_state(param, value, conn) < 0) {
  1247. kfree(tmpbuf);
  1248. return -1;
  1249. }
  1250. SET_PSTATE_ACCEPTOR(param);
  1251. }
  1252. }
  1253. kfree(tmpbuf);
  1254. return 0;
  1255. }
  1256. int iscsi_encode_text_output(
  1257. u8 phase,
  1258. u8 sender,
  1259. char *textbuf,
  1260. u32 *length,
  1261. struct iscsi_param_list *param_list,
  1262. bool keys_workaround)
  1263. {
  1264. char *output_buf = NULL;
  1265. struct iscsi_extra_response *er;
  1266. struct iscsi_param *param;
  1267. output_buf = textbuf + *length;
  1268. if (iscsi_enforce_integrity_rules(phase, param_list) < 0)
  1269. return -1;
  1270. list_for_each_entry(param, &param_list->param_list, p_list) {
  1271. if (!(param->sender & sender))
  1272. continue;
  1273. if (IS_PSTATE_ACCEPTOR(param) &&
  1274. !IS_PSTATE_RESPONSE_SENT(param) &&
  1275. !IS_PSTATE_REPLY_OPTIONAL(param) &&
  1276. (param->phase & phase)) {
  1277. *length += sprintf(output_buf, "%s=%s",
  1278. param->name, param->value);
  1279. *length += 1;
  1280. output_buf = textbuf + *length;
  1281. SET_PSTATE_RESPONSE_SENT(param);
  1282. pr_debug("Sending key: %s=%s\n",
  1283. param->name, param->value);
  1284. continue;
  1285. }
  1286. if (IS_PSTATE_NEGOTIATE(param) &&
  1287. !IS_PSTATE_ACCEPTOR(param) &&
  1288. !IS_PSTATE_PROPOSER(param) &&
  1289. (param->phase & phase)) {
  1290. *length += sprintf(output_buf, "%s=%s",
  1291. param->name, param->value);
  1292. *length += 1;
  1293. output_buf = textbuf + *length;
  1294. SET_PSTATE_PROPOSER(param);
  1295. iscsi_check_proposer_for_optional_reply(param,
  1296. keys_workaround);
  1297. pr_debug("Sending key: %s=%s\n",
  1298. param->name, param->value);
  1299. }
  1300. }
  1301. list_for_each_entry(er, &param_list->extra_response_list, er_list) {
  1302. *length += sprintf(output_buf, "%s=%s", er->key, er->value);
  1303. *length += 1;
  1304. output_buf = textbuf + *length;
  1305. pr_debug("Sending key: %s=%s\n", er->key, er->value);
  1306. }
  1307. iscsi_release_extra_responses(param_list);
  1308. return 0;
  1309. }
  1310. int iscsi_check_negotiated_keys(struct iscsi_param_list *param_list)
  1311. {
  1312. int ret = 0;
  1313. struct iscsi_param *param;
  1314. list_for_each_entry(param, &param_list->param_list, p_list) {
  1315. if (IS_PSTATE_NEGOTIATE(param) &&
  1316. IS_PSTATE_PROPOSER(param) &&
  1317. !IS_PSTATE_RESPONSE_GOT(param) &&
  1318. !IS_PSTATE_REPLY_OPTIONAL(param) &&
  1319. !IS_PHASE_DECLARATIVE(param)) {
  1320. pr_err("No response for proposed key \"%s\".\n",
  1321. param->name);
  1322. ret = -1;
  1323. }
  1324. }
  1325. return ret;
  1326. }
  1327. int iscsi_change_param_value(
  1328. char *keyvalue,
  1329. struct iscsi_param_list *param_list,
  1330. int check_key)
  1331. {
  1332. char *key = NULL, *value = NULL;
  1333. struct iscsi_param *param;
  1334. int sender = 0;
  1335. if (iscsi_extract_key_value(keyvalue, &key, &value) < 0)
  1336. return -1;
  1337. if (!check_key) {
  1338. param = __iscsi_check_key(keyvalue, sender, param_list);
  1339. if (!param)
  1340. return -1;
  1341. } else {
  1342. param = iscsi_check_key(keyvalue, 0, sender, param_list);
  1343. if (!param)
  1344. return -1;
  1345. param->set_param = 1;
  1346. if (iscsi_check_value(param, value) < 0) {
  1347. param->set_param = 0;
  1348. return -1;
  1349. }
  1350. param->set_param = 0;
  1351. }
  1352. if (iscsi_update_param_value(param, value) < 0)
  1353. return -1;
  1354. return 0;
  1355. }
  1356. void iscsi_set_connection_parameters(
  1357. struct iscsi_conn_ops *ops,
  1358. struct iscsi_param_list *param_list)
  1359. {
  1360. char *tmpptr;
  1361. struct iscsi_param *param;
  1362. pr_debug("---------------------------------------------------"
  1363. "---------------\n");
  1364. list_for_each_entry(param, &param_list->param_list, p_list) {
  1365. /*
  1366. * Special case to set MAXXMITDATASEGMENTLENGTH from the
  1367. * target requested MaxRecvDataSegmentLength, even though
  1368. * this key is not sent over the wire.
  1369. */
  1370. if (!strcmp(param->name, MAXXMITDATASEGMENTLENGTH)) {
  1371. ops->MaxXmitDataSegmentLength =
  1372. simple_strtoul(param->value, &tmpptr, 0);
  1373. pr_debug("MaxXmitDataSegmentLength: %s\n",
  1374. param->value);
  1375. }
  1376. if (!IS_PSTATE_ACCEPTOR(param) && !IS_PSTATE_PROPOSER(param))
  1377. continue;
  1378. if (!strcmp(param->name, AUTHMETHOD)) {
  1379. pr_debug("AuthMethod: %s\n",
  1380. param->value);
  1381. } else if (!strcmp(param->name, HEADERDIGEST)) {
  1382. ops->HeaderDigest = !strcmp(param->value, CRC32C);
  1383. pr_debug("HeaderDigest: %s\n",
  1384. param->value);
  1385. } else if (!strcmp(param->name, DATADIGEST)) {
  1386. ops->DataDigest = !strcmp(param->value, CRC32C);
  1387. pr_debug("DataDigest: %s\n",
  1388. param->value);
  1389. } else if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH)) {
  1390. /*
  1391. * At this point iscsi_check_acceptor_state() will have
  1392. * set ops->MaxRecvDataSegmentLength from the original
  1393. * initiator provided value.
  1394. */
  1395. pr_debug("MaxRecvDataSegmentLength: %u\n",
  1396. ops->MaxRecvDataSegmentLength);
  1397. } else if (!strcmp(param->name, INITIATORRECVDATASEGMENTLENGTH)) {
  1398. ops->InitiatorRecvDataSegmentLength =
  1399. simple_strtoul(param->value, &tmpptr, 0);
  1400. pr_debug("InitiatorRecvDataSegmentLength: %s\n",
  1401. param->value);
  1402. ops->MaxRecvDataSegmentLength =
  1403. ops->InitiatorRecvDataSegmentLength;
  1404. pr_debug("Set MRDSL from InitiatorRecvDataSegmentLength\n");
  1405. } else if (!strcmp(param->name, TARGETRECVDATASEGMENTLENGTH)) {
  1406. ops->TargetRecvDataSegmentLength =
  1407. simple_strtoul(param->value, &tmpptr, 0);
  1408. pr_debug("TargetRecvDataSegmentLength: %s\n",
  1409. param->value);
  1410. ops->MaxXmitDataSegmentLength =
  1411. ops->TargetRecvDataSegmentLength;
  1412. pr_debug("Set MXDSL from TargetRecvDataSegmentLength\n");
  1413. }
  1414. }
  1415. pr_debug("----------------------------------------------------"
  1416. "--------------\n");
  1417. }
  1418. void iscsi_set_session_parameters(
  1419. struct iscsi_sess_ops *ops,
  1420. struct iscsi_param_list *param_list,
  1421. int leading)
  1422. {
  1423. char *tmpptr;
  1424. struct iscsi_param *param;
  1425. pr_debug("----------------------------------------------------"
  1426. "--------------\n");
  1427. list_for_each_entry(param, &param_list->param_list, p_list) {
  1428. if (!IS_PSTATE_ACCEPTOR(param) && !IS_PSTATE_PROPOSER(param))
  1429. continue;
  1430. if (!strcmp(param->name, INITIATORNAME)) {
  1431. if (!param->value)
  1432. continue;
  1433. if (leading)
  1434. snprintf(ops->InitiatorName,
  1435. sizeof(ops->InitiatorName),
  1436. "%s", param->value);
  1437. pr_debug("InitiatorName: %s\n",
  1438. param->value);
  1439. } else if (!strcmp(param->name, INITIATORALIAS)) {
  1440. if (!param->value)
  1441. continue;
  1442. snprintf(ops->InitiatorAlias,
  1443. sizeof(ops->InitiatorAlias),
  1444. "%s", param->value);
  1445. pr_debug("InitiatorAlias: %s\n",
  1446. param->value);
  1447. } else if (!strcmp(param->name, TARGETNAME)) {
  1448. if (!param->value)
  1449. continue;
  1450. if (leading)
  1451. snprintf(ops->TargetName,
  1452. sizeof(ops->TargetName),
  1453. "%s", param->value);
  1454. pr_debug("TargetName: %s\n",
  1455. param->value);
  1456. } else if (!strcmp(param->name, TARGETALIAS)) {
  1457. if (!param->value)
  1458. continue;
  1459. snprintf(ops->TargetAlias, sizeof(ops->TargetAlias),
  1460. "%s", param->value);
  1461. pr_debug("TargetAlias: %s\n",
  1462. param->value);
  1463. } else if (!strcmp(param->name, TARGETPORTALGROUPTAG)) {
  1464. ops->TargetPortalGroupTag =
  1465. simple_strtoul(param->value, &tmpptr, 0);
  1466. pr_debug("TargetPortalGroupTag: %s\n",
  1467. param->value);
  1468. } else if (!strcmp(param->name, MAXCONNECTIONS)) {
  1469. ops->MaxConnections =
  1470. simple_strtoul(param->value, &tmpptr, 0);
  1471. pr_debug("MaxConnections: %s\n",
  1472. param->value);
  1473. } else if (!strcmp(param->name, INITIALR2T)) {
  1474. ops->InitialR2T = !strcmp(param->value, YES);
  1475. pr_debug("InitialR2T: %s\n",
  1476. param->value);
  1477. } else if (!strcmp(param->name, IMMEDIATEDATA)) {
  1478. ops->ImmediateData = !strcmp(param->value, YES);
  1479. pr_debug("ImmediateData: %s\n",
  1480. param->value);
  1481. } else if (!strcmp(param->name, MAXBURSTLENGTH)) {
  1482. ops->MaxBurstLength =
  1483. simple_strtoul(param->value, &tmpptr, 0);
  1484. pr_debug("MaxBurstLength: %s\n",
  1485. param->value);
  1486. } else if (!strcmp(param->name, FIRSTBURSTLENGTH)) {
  1487. ops->FirstBurstLength =
  1488. simple_strtoul(param->value, &tmpptr, 0);
  1489. pr_debug("FirstBurstLength: %s\n",
  1490. param->value);
  1491. } else if (!strcmp(param->name, DEFAULTTIME2WAIT)) {
  1492. ops->DefaultTime2Wait =
  1493. simple_strtoul(param->value, &tmpptr, 0);
  1494. pr_debug("DefaultTime2Wait: %s\n",
  1495. param->value);
  1496. } else if (!strcmp(param->name, DEFAULTTIME2RETAIN)) {
  1497. ops->DefaultTime2Retain =
  1498. simple_strtoul(param->value, &tmpptr, 0);
  1499. pr_debug("DefaultTime2Retain: %s\n",
  1500. param->value);
  1501. } else if (!strcmp(param->name, MAXOUTSTANDINGR2T)) {
  1502. ops->MaxOutstandingR2T =
  1503. simple_strtoul(param->value, &tmpptr, 0);
  1504. pr_debug("MaxOutstandingR2T: %s\n",
  1505. param->value);
  1506. } else if (!strcmp(param->name, DATAPDUINORDER)) {
  1507. ops->DataPDUInOrder = !strcmp(param->value, YES);
  1508. pr_debug("DataPDUInOrder: %s\n",
  1509. param->value);
  1510. } else if (!strcmp(param->name, DATASEQUENCEINORDER)) {
  1511. ops->DataSequenceInOrder = !strcmp(param->value, YES);
  1512. pr_debug("DataSequenceInOrder: %s\n",
  1513. param->value);
  1514. } else if (!strcmp(param->name, ERRORRECOVERYLEVEL)) {
  1515. ops->ErrorRecoveryLevel =
  1516. simple_strtoul(param->value, &tmpptr, 0);
  1517. pr_debug("ErrorRecoveryLevel: %s\n",
  1518. param->value);
  1519. } else if (!strcmp(param->name, SESSIONTYPE)) {
  1520. ops->SessionType = !strcmp(param->value, DISCOVERY);
  1521. pr_debug("SessionType: %s\n",
  1522. param->value);
  1523. } else if (!strcmp(param->name, RDMAEXTENSIONS)) {
  1524. ops->RDMAExtensions = !strcmp(param->value, YES);
  1525. pr_debug("RDMAExtensions: %s\n",
  1526. param->value);
  1527. }
  1528. }
  1529. pr_debug("----------------------------------------------------"
  1530. "--------------\n");
  1531. }