iscsi_target_configfs.c 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605
  1. /*******************************************************************************
  2. * This file contains the configfs implementation for iSCSI Target mode
  3. * from the LIO-Target Project.
  4. *
  5. * (c) Copyright 2007-2013 Datera, Inc.
  6. *
  7. * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. ****************************************************************************/
  19. #include <linux/configfs.h>
  20. #include <linux/ctype.h>
  21. #include <linux/export.h>
  22. #include <linux/inet.h>
  23. #include <linux/module.h>
  24. #include <net/ipv6.h>
  25. #include <target/target_core_base.h>
  26. #include <target/target_core_fabric.h>
  27. #include <target/iscsi/iscsi_transport.h>
  28. #include <target/iscsi/iscsi_target_core.h>
  29. #include "iscsi_target_parameters.h"
  30. #include "iscsi_target_device.h"
  31. #include "iscsi_target_erl0.h"
  32. #include "iscsi_target_nodeattrib.h"
  33. #include "iscsi_target_tpg.h"
  34. #include "iscsi_target_util.h"
  35. #include "iscsi_target.h"
  36. #include <target/iscsi/iscsi_target_stat.h>
  37. /* Start items for lio_target_portal_cit */
  38. static inline struct iscsi_tpg_np *to_iscsi_tpg_np(struct config_item *item)
  39. {
  40. return container_of(to_tpg_np(item), struct iscsi_tpg_np, se_tpg_np);
  41. }
  42. static ssize_t lio_target_np_driver_show(struct config_item *item, char *page,
  43. enum iscsit_transport_type type)
  44. {
  45. struct iscsi_tpg_np *tpg_np = to_iscsi_tpg_np(item);
  46. struct iscsi_tpg_np *tpg_np_new;
  47. ssize_t rb;
  48. tpg_np_new = iscsit_tpg_locate_child_np(tpg_np, type);
  49. if (tpg_np_new)
  50. rb = sprintf(page, "1\n");
  51. else
  52. rb = sprintf(page, "0\n");
  53. return rb;
  54. }
  55. static ssize_t lio_target_np_driver_store(struct config_item *item,
  56. const char *page, size_t count, enum iscsit_transport_type type,
  57. const char *mod_name)
  58. {
  59. struct iscsi_tpg_np *tpg_np = to_iscsi_tpg_np(item);
  60. struct iscsi_np *np;
  61. struct iscsi_portal_group *tpg;
  62. struct iscsi_tpg_np *tpg_np_new = NULL;
  63. u32 op;
  64. int rc;
  65. rc = kstrtou32(page, 0, &op);
  66. if (rc)
  67. return rc;
  68. if ((op != 1) && (op != 0)) {
  69. pr_err("Illegal value for tpg_enable: %u\n", op);
  70. return -EINVAL;
  71. }
  72. np = tpg_np->tpg_np;
  73. if (!np) {
  74. pr_err("Unable to locate struct iscsi_np from"
  75. " struct iscsi_tpg_np\n");
  76. return -EINVAL;
  77. }
  78. tpg = tpg_np->tpg;
  79. if (iscsit_get_tpg(tpg) < 0)
  80. return -EINVAL;
  81. if (op) {
  82. if (strlen(mod_name)) {
  83. rc = request_module(mod_name);
  84. if (rc != 0) {
  85. pr_warn("Unable to request_module for %s\n",
  86. mod_name);
  87. rc = 0;
  88. }
  89. }
  90. tpg_np_new = iscsit_tpg_add_network_portal(tpg,
  91. &np->np_sockaddr, tpg_np, type);
  92. if (IS_ERR(tpg_np_new)) {
  93. rc = PTR_ERR(tpg_np_new);
  94. goto out;
  95. }
  96. } else {
  97. tpg_np_new = iscsit_tpg_locate_child_np(tpg_np, type);
  98. if (tpg_np_new) {
  99. rc = iscsit_tpg_del_network_portal(tpg, tpg_np_new);
  100. if (rc < 0)
  101. goto out;
  102. }
  103. }
  104. iscsit_put_tpg(tpg);
  105. return count;
  106. out:
  107. iscsit_put_tpg(tpg);
  108. return rc;
  109. }
  110. static ssize_t lio_target_np_iser_show(struct config_item *item, char *page)
  111. {
  112. return lio_target_np_driver_show(item, page, ISCSI_INFINIBAND);
  113. }
  114. static ssize_t lio_target_np_iser_store(struct config_item *item,
  115. const char *page, size_t count)
  116. {
  117. return lio_target_np_driver_store(item, page, count,
  118. ISCSI_INFINIBAND, "ib_isert");
  119. }
  120. CONFIGFS_ATTR(lio_target_np_, iser);
  121. static ssize_t lio_target_np_cxgbit_show(struct config_item *item, char *page)
  122. {
  123. return lio_target_np_driver_show(item, page, ISCSI_CXGBIT);
  124. }
  125. static ssize_t lio_target_np_cxgbit_store(struct config_item *item,
  126. const char *page, size_t count)
  127. {
  128. return lio_target_np_driver_store(item, page, count,
  129. ISCSI_CXGBIT, "cxgbit");
  130. }
  131. CONFIGFS_ATTR(lio_target_np_, cxgbit);
  132. static struct configfs_attribute *lio_target_portal_attrs[] = {
  133. &lio_target_np_attr_iser,
  134. &lio_target_np_attr_cxgbit,
  135. NULL,
  136. };
  137. /* Stop items for lio_target_portal_cit */
  138. /* Start items for lio_target_np_cit */
  139. #define MAX_PORTAL_LEN 256
  140. static struct se_tpg_np *lio_target_call_addnptotpg(
  141. struct se_portal_group *se_tpg,
  142. struct config_group *group,
  143. const char *name)
  144. {
  145. struct iscsi_portal_group *tpg;
  146. struct iscsi_tpg_np *tpg_np;
  147. char *str, *str2, *ip_str, *port_str;
  148. struct sockaddr_storage sockaddr = { };
  149. int ret;
  150. char buf[MAX_PORTAL_LEN + 1];
  151. if (strlen(name) > MAX_PORTAL_LEN) {
  152. pr_err("strlen(name): %d exceeds MAX_PORTAL_LEN: %d\n",
  153. (int)strlen(name), MAX_PORTAL_LEN);
  154. return ERR_PTR(-EOVERFLOW);
  155. }
  156. memset(buf, 0, MAX_PORTAL_LEN + 1);
  157. snprintf(buf, MAX_PORTAL_LEN + 1, "%s", name);
  158. str = strstr(buf, "[");
  159. if (str) {
  160. str2 = strstr(str, "]");
  161. if (!str2) {
  162. pr_err("Unable to locate trailing \"]\""
  163. " in IPv6 iSCSI network portal address\n");
  164. return ERR_PTR(-EINVAL);
  165. }
  166. ip_str = str + 1; /* Skip over leading "[" */
  167. *str2 = '\0'; /* Terminate the unbracketed IPv6 address */
  168. str2++; /* Skip over the \0 */
  169. port_str = strstr(str2, ":");
  170. if (!port_str) {
  171. pr_err("Unable to locate \":port\""
  172. " in IPv6 iSCSI network portal address\n");
  173. return ERR_PTR(-EINVAL);
  174. }
  175. *port_str = '\0'; /* Terminate string for IP */
  176. port_str++; /* Skip over ":" */
  177. } else {
  178. ip_str = &buf[0];
  179. port_str = strstr(ip_str, ":");
  180. if (!port_str) {
  181. pr_err("Unable to locate \":port\""
  182. " in IPv4 iSCSI network portal address\n");
  183. return ERR_PTR(-EINVAL);
  184. }
  185. *port_str = '\0'; /* Terminate string for IP */
  186. port_str++; /* Skip over ":" */
  187. }
  188. ret = inet_pton_with_scope(&init_net, AF_UNSPEC, ip_str,
  189. port_str, &sockaddr);
  190. if (ret) {
  191. pr_err("malformed ip/port passed: %s\n", name);
  192. return ERR_PTR(ret);
  193. }
  194. tpg = container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
  195. ret = iscsit_get_tpg(tpg);
  196. if (ret < 0)
  197. return ERR_PTR(-EINVAL);
  198. pr_debug("LIO_Target_ConfigFS: REGISTER -> %s TPGT: %hu"
  199. " PORTAL: %s\n",
  200. config_item_name(&se_tpg->se_tpg_wwn->wwn_group.cg_item),
  201. tpg->tpgt, name);
  202. /*
  203. * Assume ISCSI_TCP by default. Other network portals for other
  204. * iSCSI fabrics:
  205. *
  206. * Traditional iSCSI over SCTP (initial support)
  207. * iSER/TCP (TODO, hardware available)
  208. * iSER/SCTP (TODO, software emulation with osc-iwarp)
  209. * iSER/IB (TODO, hardware available)
  210. *
  211. * can be enabled with attributes under
  212. * sys/kernel/config/iscsi/$IQN/$TPG/np/$IP:$PORT/
  213. *
  214. */
  215. tpg_np = iscsit_tpg_add_network_portal(tpg, &sockaddr, NULL,
  216. ISCSI_TCP);
  217. if (IS_ERR(tpg_np)) {
  218. iscsit_put_tpg(tpg);
  219. return ERR_CAST(tpg_np);
  220. }
  221. pr_debug("LIO_Target_ConfigFS: addnptotpg done!\n");
  222. iscsit_put_tpg(tpg);
  223. return &tpg_np->se_tpg_np;
  224. }
  225. static void lio_target_call_delnpfromtpg(
  226. struct se_tpg_np *se_tpg_np)
  227. {
  228. struct iscsi_portal_group *tpg;
  229. struct iscsi_tpg_np *tpg_np;
  230. struct se_portal_group *se_tpg;
  231. int ret;
  232. tpg_np = container_of(se_tpg_np, struct iscsi_tpg_np, se_tpg_np);
  233. tpg = tpg_np->tpg;
  234. ret = iscsit_get_tpg(tpg);
  235. if (ret < 0)
  236. return;
  237. se_tpg = &tpg->tpg_se_tpg;
  238. pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s TPGT: %hu"
  239. " PORTAL: %pISpc\n", config_item_name(&se_tpg->se_tpg_wwn->wwn_group.cg_item),
  240. tpg->tpgt, &tpg_np->tpg_np->np_sockaddr);
  241. ret = iscsit_tpg_del_network_portal(tpg, tpg_np);
  242. if (ret < 0)
  243. goto out;
  244. pr_debug("LIO_Target_ConfigFS: delnpfromtpg done!\n");
  245. out:
  246. iscsit_put_tpg(tpg);
  247. }
  248. /* End items for lio_target_np_cit */
  249. /* Start items for lio_target_nacl_attrib_cit */
  250. #define ISCSI_NACL_ATTR(name) \
  251. static ssize_t iscsi_nacl_attrib_##name##_show(struct config_item *item,\
  252. char *page) \
  253. { \
  254. struct se_node_acl *se_nacl = attrib_to_nacl(item); \
  255. struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \
  256. se_node_acl); \
  257. \
  258. return sprintf(page, "%u\n", nacl->node_attrib.name); \
  259. } \
  260. \
  261. static ssize_t iscsi_nacl_attrib_##name##_store(struct config_item *item,\
  262. const char *page, size_t count) \
  263. { \
  264. struct se_node_acl *se_nacl = attrib_to_nacl(item); \
  265. struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \
  266. se_node_acl); \
  267. u32 val; \
  268. int ret; \
  269. \
  270. ret = kstrtou32(page, 0, &val); \
  271. if (ret) \
  272. return ret; \
  273. ret = iscsit_na_##name(nacl, val); \
  274. if (ret < 0) \
  275. return ret; \
  276. \
  277. return count; \
  278. } \
  279. \
  280. CONFIGFS_ATTR(iscsi_nacl_attrib_, name)
  281. ISCSI_NACL_ATTR(dataout_timeout);
  282. ISCSI_NACL_ATTR(dataout_timeout_retries);
  283. ISCSI_NACL_ATTR(default_erl);
  284. ISCSI_NACL_ATTR(nopin_timeout);
  285. ISCSI_NACL_ATTR(nopin_response_timeout);
  286. ISCSI_NACL_ATTR(random_datain_pdu_offsets);
  287. ISCSI_NACL_ATTR(random_datain_seq_offsets);
  288. ISCSI_NACL_ATTR(random_r2t_offsets);
  289. static struct configfs_attribute *lio_target_nacl_attrib_attrs[] = {
  290. &iscsi_nacl_attrib_attr_dataout_timeout,
  291. &iscsi_nacl_attrib_attr_dataout_timeout_retries,
  292. &iscsi_nacl_attrib_attr_default_erl,
  293. &iscsi_nacl_attrib_attr_nopin_timeout,
  294. &iscsi_nacl_attrib_attr_nopin_response_timeout,
  295. &iscsi_nacl_attrib_attr_random_datain_pdu_offsets,
  296. &iscsi_nacl_attrib_attr_random_datain_seq_offsets,
  297. &iscsi_nacl_attrib_attr_random_r2t_offsets,
  298. NULL,
  299. };
  300. /* End items for lio_target_nacl_attrib_cit */
  301. /* Start items for lio_target_nacl_auth_cit */
  302. #define __DEF_NACL_AUTH_STR(prefix, name, flags) \
  303. static ssize_t __iscsi_##prefix##_##name##_show( \
  304. struct iscsi_node_acl *nacl, \
  305. char *page) \
  306. { \
  307. struct iscsi_node_auth *auth = &nacl->node_auth; \
  308. \
  309. if (!capable(CAP_SYS_ADMIN)) \
  310. return -EPERM; \
  311. return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \
  312. } \
  313. \
  314. static ssize_t __iscsi_##prefix##_##name##_store( \
  315. struct iscsi_node_acl *nacl, \
  316. const char *page, \
  317. size_t count) \
  318. { \
  319. struct iscsi_node_auth *auth = &nacl->node_auth; \
  320. \
  321. if (!capable(CAP_SYS_ADMIN)) \
  322. return -EPERM; \
  323. if (count >= sizeof(auth->name)) \
  324. return -EINVAL; \
  325. snprintf(auth->name, sizeof(auth->name), "%s", page); \
  326. if (!strncmp("NULL", auth->name, 4)) \
  327. auth->naf_flags &= ~flags; \
  328. else \
  329. auth->naf_flags |= flags; \
  330. \
  331. if ((auth->naf_flags & NAF_USERID_IN_SET) && \
  332. (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
  333. auth->authenticate_target = 1; \
  334. else \
  335. auth->authenticate_target = 0; \
  336. \
  337. return count; \
  338. }
  339. #define DEF_NACL_AUTH_STR(name, flags) \
  340. __DEF_NACL_AUTH_STR(nacl_auth, name, flags) \
  341. static ssize_t iscsi_nacl_auth_##name##_show(struct config_item *item, \
  342. char *page) \
  343. { \
  344. struct se_node_acl *nacl = auth_to_nacl(item); \
  345. return __iscsi_nacl_auth_##name##_show(container_of(nacl, \
  346. struct iscsi_node_acl, se_node_acl), page); \
  347. } \
  348. static ssize_t iscsi_nacl_auth_##name##_store(struct config_item *item, \
  349. const char *page, size_t count) \
  350. { \
  351. struct se_node_acl *nacl = auth_to_nacl(item); \
  352. return __iscsi_nacl_auth_##name##_store(container_of(nacl, \
  353. struct iscsi_node_acl, se_node_acl), page, count); \
  354. } \
  355. \
  356. CONFIGFS_ATTR(iscsi_nacl_auth_, name)
  357. /*
  358. * One-way authentication userid
  359. */
  360. DEF_NACL_AUTH_STR(userid, NAF_USERID_SET);
  361. DEF_NACL_AUTH_STR(password, NAF_PASSWORD_SET);
  362. DEF_NACL_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
  363. DEF_NACL_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
  364. #define __DEF_NACL_AUTH_INT(prefix, name) \
  365. static ssize_t __iscsi_##prefix##_##name##_show( \
  366. struct iscsi_node_acl *nacl, \
  367. char *page) \
  368. { \
  369. struct iscsi_node_auth *auth = &nacl->node_auth; \
  370. \
  371. if (!capable(CAP_SYS_ADMIN)) \
  372. return -EPERM; \
  373. \
  374. return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
  375. }
  376. #define DEF_NACL_AUTH_INT(name) \
  377. __DEF_NACL_AUTH_INT(nacl_auth, name) \
  378. static ssize_t iscsi_nacl_auth_##name##_show(struct config_item *item, \
  379. char *page) \
  380. { \
  381. struct se_node_acl *nacl = auth_to_nacl(item); \
  382. return __iscsi_nacl_auth_##name##_show(container_of(nacl, \
  383. struct iscsi_node_acl, se_node_acl), page); \
  384. } \
  385. \
  386. CONFIGFS_ATTR_RO(iscsi_nacl_auth_, name)
  387. DEF_NACL_AUTH_INT(authenticate_target);
  388. static struct configfs_attribute *lio_target_nacl_auth_attrs[] = {
  389. &iscsi_nacl_auth_attr_userid,
  390. &iscsi_nacl_auth_attr_password,
  391. &iscsi_nacl_auth_attr_authenticate_target,
  392. &iscsi_nacl_auth_attr_userid_mutual,
  393. &iscsi_nacl_auth_attr_password_mutual,
  394. NULL,
  395. };
  396. /* End items for lio_target_nacl_auth_cit */
  397. /* Start items for lio_target_nacl_param_cit */
  398. #define ISCSI_NACL_PARAM(name) \
  399. static ssize_t iscsi_nacl_param_##name##_show(struct config_item *item, \
  400. char *page) \
  401. { \
  402. struct se_node_acl *se_nacl = param_to_nacl(item); \
  403. struct iscsi_session *sess; \
  404. struct se_session *se_sess; \
  405. ssize_t rb; \
  406. \
  407. spin_lock_bh(&se_nacl->nacl_sess_lock); \
  408. se_sess = se_nacl->nacl_sess; \
  409. if (!se_sess) { \
  410. rb = snprintf(page, PAGE_SIZE, \
  411. "No Active iSCSI Session\n"); \
  412. } else { \
  413. sess = se_sess->fabric_sess_ptr; \
  414. rb = snprintf(page, PAGE_SIZE, "%u\n", \
  415. (u32)sess->sess_ops->name); \
  416. } \
  417. spin_unlock_bh(&se_nacl->nacl_sess_lock); \
  418. \
  419. return rb; \
  420. } \
  421. \
  422. CONFIGFS_ATTR_RO(iscsi_nacl_param_, name)
  423. ISCSI_NACL_PARAM(MaxConnections);
  424. ISCSI_NACL_PARAM(InitialR2T);
  425. ISCSI_NACL_PARAM(ImmediateData);
  426. ISCSI_NACL_PARAM(MaxBurstLength);
  427. ISCSI_NACL_PARAM(FirstBurstLength);
  428. ISCSI_NACL_PARAM(DefaultTime2Wait);
  429. ISCSI_NACL_PARAM(DefaultTime2Retain);
  430. ISCSI_NACL_PARAM(MaxOutstandingR2T);
  431. ISCSI_NACL_PARAM(DataPDUInOrder);
  432. ISCSI_NACL_PARAM(DataSequenceInOrder);
  433. ISCSI_NACL_PARAM(ErrorRecoveryLevel);
  434. static struct configfs_attribute *lio_target_nacl_param_attrs[] = {
  435. &iscsi_nacl_param_attr_MaxConnections,
  436. &iscsi_nacl_param_attr_InitialR2T,
  437. &iscsi_nacl_param_attr_ImmediateData,
  438. &iscsi_nacl_param_attr_MaxBurstLength,
  439. &iscsi_nacl_param_attr_FirstBurstLength,
  440. &iscsi_nacl_param_attr_DefaultTime2Wait,
  441. &iscsi_nacl_param_attr_DefaultTime2Retain,
  442. &iscsi_nacl_param_attr_MaxOutstandingR2T,
  443. &iscsi_nacl_param_attr_DataPDUInOrder,
  444. &iscsi_nacl_param_attr_DataSequenceInOrder,
  445. &iscsi_nacl_param_attr_ErrorRecoveryLevel,
  446. NULL,
  447. };
  448. /* End items for lio_target_nacl_param_cit */
  449. /* Start items for lio_target_acl_cit */
  450. static ssize_t lio_target_nacl_info_show(struct config_item *item, char *page)
  451. {
  452. struct se_node_acl *se_nacl = acl_to_nacl(item);
  453. struct iscsi_session *sess;
  454. struct iscsi_conn *conn;
  455. struct se_session *se_sess;
  456. ssize_t rb = 0;
  457. u32 max_cmd_sn;
  458. spin_lock_bh(&se_nacl->nacl_sess_lock);
  459. se_sess = se_nacl->nacl_sess;
  460. if (!se_sess) {
  461. rb += sprintf(page+rb, "No active iSCSI Session for Initiator"
  462. " Endpoint: %s\n", se_nacl->initiatorname);
  463. } else {
  464. sess = se_sess->fabric_sess_ptr;
  465. rb += sprintf(page+rb, "InitiatorName: %s\n",
  466. sess->sess_ops->InitiatorName);
  467. rb += sprintf(page+rb, "InitiatorAlias: %s\n",
  468. sess->sess_ops->InitiatorAlias);
  469. rb += sprintf(page+rb,
  470. "LIO Session ID: %u ISID: 0x%6ph TSIH: %hu ",
  471. sess->sid, sess->isid, sess->tsih);
  472. rb += sprintf(page+rb, "SessionType: %s\n",
  473. (sess->sess_ops->SessionType) ?
  474. "Discovery" : "Normal");
  475. rb += sprintf(page+rb, "Session State: ");
  476. switch (sess->session_state) {
  477. case TARG_SESS_STATE_FREE:
  478. rb += sprintf(page+rb, "TARG_SESS_FREE\n");
  479. break;
  480. case TARG_SESS_STATE_ACTIVE:
  481. rb += sprintf(page+rb, "TARG_SESS_STATE_ACTIVE\n");
  482. break;
  483. case TARG_SESS_STATE_LOGGED_IN:
  484. rb += sprintf(page+rb, "TARG_SESS_STATE_LOGGED_IN\n");
  485. break;
  486. case TARG_SESS_STATE_FAILED:
  487. rb += sprintf(page+rb, "TARG_SESS_STATE_FAILED\n");
  488. break;
  489. case TARG_SESS_STATE_IN_CONTINUE:
  490. rb += sprintf(page+rb, "TARG_SESS_STATE_IN_CONTINUE\n");
  491. break;
  492. default:
  493. rb += sprintf(page+rb, "ERROR: Unknown Session"
  494. " State!\n");
  495. break;
  496. }
  497. rb += sprintf(page+rb, "---------------------[iSCSI Session"
  498. " Values]-----------------------\n");
  499. rb += sprintf(page+rb, " CmdSN/WR : CmdSN/WC : ExpCmdSN"
  500. " : MaxCmdSN : ITT : TTT\n");
  501. max_cmd_sn = (u32) atomic_read(&sess->max_cmd_sn);
  502. rb += sprintf(page+rb, " 0x%08x 0x%08x 0x%08x 0x%08x"
  503. " 0x%08x 0x%08x\n",
  504. sess->cmdsn_window,
  505. (max_cmd_sn - sess->exp_cmd_sn) + 1,
  506. sess->exp_cmd_sn, max_cmd_sn,
  507. sess->init_task_tag, sess->targ_xfer_tag);
  508. rb += sprintf(page+rb, "----------------------[iSCSI"
  509. " Connections]-------------------------\n");
  510. spin_lock(&sess->conn_lock);
  511. list_for_each_entry(conn, &sess->sess_conn_list, conn_list) {
  512. rb += sprintf(page+rb, "CID: %hu Connection"
  513. " State: ", conn->cid);
  514. switch (conn->conn_state) {
  515. case TARG_CONN_STATE_FREE:
  516. rb += sprintf(page+rb,
  517. "TARG_CONN_STATE_FREE\n");
  518. break;
  519. case TARG_CONN_STATE_XPT_UP:
  520. rb += sprintf(page+rb,
  521. "TARG_CONN_STATE_XPT_UP\n");
  522. break;
  523. case TARG_CONN_STATE_IN_LOGIN:
  524. rb += sprintf(page+rb,
  525. "TARG_CONN_STATE_IN_LOGIN\n");
  526. break;
  527. case TARG_CONN_STATE_LOGGED_IN:
  528. rb += sprintf(page+rb,
  529. "TARG_CONN_STATE_LOGGED_IN\n");
  530. break;
  531. case TARG_CONN_STATE_IN_LOGOUT:
  532. rb += sprintf(page+rb,
  533. "TARG_CONN_STATE_IN_LOGOUT\n");
  534. break;
  535. case TARG_CONN_STATE_LOGOUT_REQUESTED:
  536. rb += sprintf(page+rb,
  537. "TARG_CONN_STATE_LOGOUT_REQUESTED\n");
  538. break;
  539. case TARG_CONN_STATE_CLEANUP_WAIT:
  540. rb += sprintf(page+rb,
  541. "TARG_CONN_STATE_CLEANUP_WAIT\n");
  542. break;
  543. default:
  544. rb += sprintf(page+rb,
  545. "ERROR: Unknown Connection State!\n");
  546. break;
  547. }
  548. rb += sprintf(page+rb, " Address %pISc %s", &conn->login_sockaddr,
  549. (conn->network_transport == ISCSI_TCP) ?
  550. "TCP" : "SCTP");
  551. rb += sprintf(page+rb, " StatSN: 0x%08x\n",
  552. conn->stat_sn);
  553. }
  554. spin_unlock(&sess->conn_lock);
  555. }
  556. spin_unlock_bh(&se_nacl->nacl_sess_lock);
  557. return rb;
  558. }
  559. static ssize_t lio_target_nacl_cmdsn_depth_show(struct config_item *item,
  560. char *page)
  561. {
  562. return sprintf(page, "%u\n", acl_to_nacl(item)->queue_depth);
  563. }
  564. static ssize_t lio_target_nacl_cmdsn_depth_store(struct config_item *item,
  565. const char *page, size_t count)
  566. {
  567. struct se_node_acl *se_nacl = acl_to_nacl(item);
  568. struct se_portal_group *se_tpg = se_nacl->se_tpg;
  569. struct iscsi_portal_group *tpg = container_of(se_tpg,
  570. struct iscsi_portal_group, tpg_se_tpg);
  571. struct config_item *acl_ci, *tpg_ci, *wwn_ci;
  572. u32 cmdsn_depth = 0;
  573. int ret;
  574. ret = kstrtou32(page, 0, &cmdsn_depth);
  575. if (ret)
  576. return ret;
  577. if (cmdsn_depth > TA_DEFAULT_CMDSN_DEPTH_MAX) {
  578. pr_err("Passed cmdsn_depth: %u exceeds"
  579. " TA_DEFAULT_CMDSN_DEPTH_MAX: %u\n", cmdsn_depth,
  580. TA_DEFAULT_CMDSN_DEPTH_MAX);
  581. return -EINVAL;
  582. }
  583. acl_ci = &se_nacl->acl_group.cg_item;
  584. if (!acl_ci) {
  585. pr_err("Unable to locatel acl_ci\n");
  586. return -EINVAL;
  587. }
  588. tpg_ci = &acl_ci->ci_parent->ci_group->cg_item;
  589. if (!tpg_ci) {
  590. pr_err("Unable to locate tpg_ci\n");
  591. return -EINVAL;
  592. }
  593. wwn_ci = &tpg_ci->ci_group->cg_item;
  594. if (!wwn_ci) {
  595. pr_err("Unable to locate config_item wwn_ci\n");
  596. return -EINVAL;
  597. }
  598. if (iscsit_get_tpg(tpg) < 0)
  599. return -EINVAL;
  600. ret = core_tpg_set_initiator_node_queue_depth(se_nacl, cmdsn_depth);
  601. pr_debug("LIO_Target_ConfigFS: %s/%s Set CmdSN Window: %u for"
  602. "InitiatorName: %s\n", config_item_name(wwn_ci),
  603. config_item_name(tpg_ci), cmdsn_depth,
  604. config_item_name(acl_ci));
  605. iscsit_put_tpg(tpg);
  606. return (!ret) ? count : (ssize_t)ret;
  607. }
  608. static ssize_t lio_target_nacl_tag_show(struct config_item *item, char *page)
  609. {
  610. return snprintf(page, PAGE_SIZE, "%s", acl_to_nacl(item)->acl_tag);
  611. }
  612. static ssize_t lio_target_nacl_tag_store(struct config_item *item,
  613. const char *page, size_t count)
  614. {
  615. struct se_node_acl *se_nacl = acl_to_nacl(item);
  616. int ret;
  617. ret = core_tpg_set_initiator_node_tag(se_nacl->se_tpg, se_nacl, page);
  618. if (ret < 0)
  619. return ret;
  620. return count;
  621. }
  622. CONFIGFS_ATTR_RO(lio_target_nacl_, info);
  623. CONFIGFS_ATTR(lio_target_nacl_, cmdsn_depth);
  624. CONFIGFS_ATTR(lio_target_nacl_, tag);
  625. static struct configfs_attribute *lio_target_initiator_attrs[] = {
  626. &lio_target_nacl_attr_info,
  627. &lio_target_nacl_attr_cmdsn_depth,
  628. &lio_target_nacl_attr_tag,
  629. NULL,
  630. };
  631. static int lio_target_init_nodeacl(struct se_node_acl *se_nacl,
  632. const char *name)
  633. {
  634. struct iscsi_node_acl *acl =
  635. container_of(se_nacl, struct iscsi_node_acl, se_node_acl);
  636. config_group_init_type_name(&acl->node_stat_grps.iscsi_sess_stats_group,
  637. "iscsi_sess_stats", &iscsi_stat_sess_cit);
  638. configfs_add_default_group(&acl->node_stat_grps.iscsi_sess_stats_group,
  639. &se_nacl->acl_fabric_stat_group);
  640. return 0;
  641. }
  642. /* End items for lio_target_acl_cit */
  643. /* Start items for lio_target_tpg_attrib_cit */
  644. #define DEF_TPG_ATTRIB(name) \
  645. \
  646. static ssize_t iscsi_tpg_attrib_##name##_show(struct config_item *item, \
  647. char *page) \
  648. { \
  649. struct se_portal_group *se_tpg = attrib_to_tpg(item); \
  650. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  651. struct iscsi_portal_group, tpg_se_tpg); \
  652. ssize_t rb; \
  653. \
  654. if (iscsit_get_tpg(tpg) < 0) \
  655. return -EINVAL; \
  656. \
  657. rb = sprintf(page, "%u\n", tpg->tpg_attrib.name); \
  658. iscsit_put_tpg(tpg); \
  659. return rb; \
  660. } \
  661. \
  662. static ssize_t iscsi_tpg_attrib_##name##_store(struct config_item *item,\
  663. const char *page, size_t count) \
  664. { \
  665. struct se_portal_group *se_tpg = attrib_to_tpg(item); \
  666. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  667. struct iscsi_portal_group, tpg_se_tpg); \
  668. u32 val; \
  669. int ret; \
  670. \
  671. if (iscsit_get_tpg(tpg) < 0) \
  672. return -EINVAL; \
  673. \
  674. ret = kstrtou32(page, 0, &val); \
  675. if (ret) \
  676. goto out; \
  677. ret = iscsit_ta_##name(tpg, val); \
  678. if (ret < 0) \
  679. goto out; \
  680. \
  681. iscsit_put_tpg(tpg); \
  682. return count; \
  683. out: \
  684. iscsit_put_tpg(tpg); \
  685. return ret; \
  686. } \
  687. CONFIGFS_ATTR(iscsi_tpg_attrib_, name)
  688. DEF_TPG_ATTRIB(authentication);
  689. DEF_TPG_ATTRIB(login_timeout);
  690. DEF_TPG_ATTRIB(netif_timeout);
  691. DEF_TPG_ATTRIB(generate_node_acls);
  692. DEF_TPG_ATTRIB(default_cmdsn_depth);
  693. DEF_TPG_ATTRIB(cache_dynamic_acls);
  694. DEF_TPG_ATTRIB(demo_mode_write_protect);
  695. DEF_TPG_ATTRIB(prod_mode_write_protect);
  696. DEF_TPG_ATTRIB(demo_mode_discovery);
  697. DEF_TPG_ATTRIB(default_erl);
  698. DEF_TPG_ATTRIB(t10_pi);
  699. DEF_TPG_ATTRIB(fabric_prot_type);
  700. DEF_TPG_ATTRIB(tpg_enabled_sendtargets);
  701. DEF_TPG_ATTRIB(login_keys_workaround);
  702. static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = {
  703. &iscsi_tpg_attrib_attr_authentication,
  704. &iscsi_tpg_attrib_attr_login_timeout,
  705. &iscsi_tpg_attrib_attr_netif_timeout,
  706. &iscsi_tpg_attrib_attr_generate_node_acls,
  707. &iscsi_tpg_attrib_attr_default_cmdsn_depth,
  708. &iscsi_tpg_attrib_attr_cache_dynamic_acls,
  709. &iscsi_tpg_attrib_attr_demo_mode_write_protect,
  710. &iscsi_tpg_attrib_attr_prod_mode_write_protect,
  711. &iscsi_tpg_attrib_attr_demo_mode_discovery,
  712. &iscsi_tpg_attrib_attr_default_erl,
  713. &iscsi_tpg_attrib_attr_t10_pi,
  714. &iscsi_tpg_attrib_attr_fabric_prot_type,
  715. &iscsi_tpg_attrib_attr_tpg_enabled_sendtargets,
  716. &iscsi_tpg_attrib_attr_login_keys_workaround,
  717. NULL,
  718. };
  719. /* End items for lio_target_tpg_attrib_cit */
  720. /* Start items for lio_target_tpg_auth_cit */
  721. #define __DEF_TPG_AUTH_STR(prefix, name, flags) \
  722. static ssize_t __iscsi_##prefix##_##name##_show(struct se_portal_group *se_tpg, \
  723. char *page) \
  724. { \
  725. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  726. struct iscsi_portal_group, tpg_se_tpg); \
  727. struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
  728. \
  729. if (!capable(CAP_SYS_ADMIN)) \
  730. return -EPERM; \
  731. \
  732. return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \
  733. } \
  734. \
  735. static ssize_t __iscsi_##prefix##_##name##_store(struct se_portal_group *se_tpg,\
  736. const char *page, size_t count) \
  737. { \
  738. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  739. struct iscsi_portal_group, tpg_se_tpg); \
  740. struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
  741. \
  742. if (!capable(CAP_SYS_ADMIN)) \
  743. return -EPERM; \
  744. \
  745. snprintf(auth->name, sizeof(auth->name), "%s", page); \
  746. if (!(strncmp("NULL", auth->name, 4))) \
  747. auth->naf_flags &= ~flags; \
  748. else \
  749. auth->naf_flags |= flags; \
  750. \
  751. if ((auth->naf_flags & NAF_USERID_IN_SET) && \
  752. (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
  753. auth->authenticate_target = 1; \
  754. else \
  755. auth->authenticate_target = 0; \
  756. \
  757. return count; \
  758. }
  759. #define DEF_TPG_AUTH_STR(name, flags) \
  760. __DEF_TPG_AUTH_STR(tpg_auth, name, flags) \
  761. static ssize_t iscsi_tpg_auth_##name##_show(struct config_item *item, \
  762. char *page) \
  763. { \
  764. return __iscsi_tpg_auth_##name##_show(auth_to_tpg(item), page); \
  765. } \
  766. \
  767. static ssize_t iscsi_tpg_auth_##name##_store(struct config_item *item, \
  768. const char *page, size_t count) \
  769. { \
  770. return __iscsi_tpg_auth_##name##_store(auth_to_tpg(item), page, count); \
  771. } \
  772. \
  773. CONFIGFS_ATTR(iscsi_tpg_auth_, name);
  774. DEF_TPG_AUTH_STR(userid, NAF_USERID_SET);
  775. DEF_TPG_AUTH_STR(password, NAF_PASSWORD_SET);
  776. DEF_TPG_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
  777. DEF_TPG_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
  778. #define __DEF_TPG_AUTH_INT(prefix, name) \
  779. static ssize_t __iscsi_##prefix##_##name##_show(struct se_portal_group *se_tpg, \
  780. char *page) \
  781. { \
  782. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  783. struct iscsi_portal_group, tpg_se_tpg); \
  784. struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
  785. \
  786. if (!capable(CAP_SYS_ADMIN)) \
  787. return -EPERM; \
  788. \
  789. return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
  790. }
  791. #define DEF_TPG_AUTH_INT(name) \
  792. __DEF_TPG_AUTH_INT(tpg_auth, name) \
  793. static ssize_t iscsi_tpg_auth_##name##_show(struct config_item *item, \
  794. char *page) \
  795. { \
  796. return __iscsi_tpg_auth_##name##_show(auth_to_tpg(item), page); \
  797. } \
  798. CONFIGFS_ATTR_RO(iscsi_tpg_auth_, name);
  799. DEF_TPG_AUTH_INT(authenticate_target);
  800. static struct configfs_attribute *lio_target_tpg_auth_attrs[] = {
  801. &iscsi_tpg_auth_attr_userid,
  802. &iscsi_tpg_auth_attr_password,
  803. &iscsi_tpg_auth_attr_authenticate_target,
  804. &iscsi_tpg_auth_attr_userid_mutual,
  805. &iscsi_tpg_auth_attr_password_mutual,
  806. NULL,
  807. };
  808. /* End items for lio_target_tpg_auth_cit */
  809. /* Start items for lio_target_tpg_param_cit */
  810. #define DEF_TPG_PARAM(name) \
  811. static ssize_t iscsi_tpg_param_##name##_show(struct config_item *item, \
  812. char *page) \
  813. { \
  814. struct se_portal_group *se_tpg = param_to_tpg(item); \
  815. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  816. struct iscsi_portal_group, tpg_se_tpg); \
  817. struct iscsi_param *param; \
  818. ssize_t rb; \
  819. \
  820. if (iscsit_get_tpg(tpg) < 0) \
  821. return -EINVAL; \
  822. \
  823. param = iscsi_find_param_from_key(__stringify(name), \
  824. tpg->param_list); \
  825. if (!param) { \
  826. iscsit_put_tpg(tpg); \
  827. return -EINVAL; \
  828. } \
  829. rb = snprintf(page, PAGE_SIZE, "%s\n", param->value); \
  830. \
  831. iscsit_put_tpg(tpg); \
  832. return rb; \
  833. } \
  834. static ssize_t iscsi_tpg_param_##name##_store(struct config_item *item, \
  835. const char *page, size_t count) \
  836. { \
  837. struct se_portal_group *se_tpg = param_to_tpg(item); \
  838. struct iscsi_portal_group *tpg = container_of(se_tpg, \
  839. struct iscsi_portal_group, tpg_se_tpg); \
  840. char *buf; \
  841. int ret, len; \
  842. \
  843. buf = kzalloc(PAGE_SIZE, GFP_KERNEL); \
  844. if (!buf) \
  845. return -ENOMEM; \
  846. len = snprintf(buf, PAGE_SIZE, "%s=%s", __stringify(name), page); \
  847. if (isspace(buf[len-1])) \
  848. buf[len-1] = '\0'; /* Kill newline */ \
  849. \
  850. if (iscsit_get_tpg(tpg) < 0) { \
  851. kfree(buf); \
  852. return -EINVAL; \
  853. } \
  854. \
  855. ret = iscsi_change_param_value(buf, tpg->param_list, 1); \
  856. if (ret < 0) \
  857. goto out; \
  858. \
  859. kfree(buf); \
  860. iscsit_put_tpg(tpg); \
  861. return count; \
  862. out: \
  863. kfree(buf); \
  864. iscsit_put_tpg(tpg); \
  865. return -EINVAL; \
  866. } \
  867. CONFIGFS_ATTR(iscsi_tpg_param_, name)
  868. DEF_TPG_PARAM(AuthMethod);
  869. DEF_TPG_PARAM(HeaderDigest);
  870. DEF_TPG_PARAM(DataDigest);
  871. DEF_TPG_PARAM(MaxConnections);
  872. DEF_TPG_PARAM(TargetAlias);
  873. DEF_TPG_PARAM(InitialR2T);
  874. DEF_TPG_PARAM(ImmediateData);
  875. DEF_TPG_PARAM(MaxRecvDataSegmentLength);
  876. DEF_TPG_PARAM(MaxXmitDataSegmentLength);
  877. DEF_TPG_PARAM(MaxBurstLength);
  878. DEF_TPG_PARAM(FirstBurstLength);
  879. DEF_TPG_PARAM(DefaultTime2Wait);
  880. DEF_TPG_PARAM(DefaultTime2Retain);
  881. DEF_TPG_PARAM(MaxOutstandingR2T);
  882. DEF_TPG_PARAM(DataPDUInOrder);
  883. DEF_TPG_PARAM(DataSequenceInOrder);
  884. DEF_TPG_PARAM(ErrorRecoveryLevel);
  885. DEF_TPG_PARAM(IFMarker);
  886. DEF_TPG_PARAM(OFMarker);
  887. DEF_TPG_PARAM(IFMarkInt);
  888. DEF_TPG_PARAM(OFMarkInt);
  889. static struct configfs_attribute *lio_target_tpg_param_attrs[] = {
  890. &iscsi_tpg_param_attr_AuthMethod,
  891. &iscsi_tpg_param_attr_HeaderDigest,
  892. &iscsi_tpg_param_attr_DataDigest,
  893. &iscsi_tpg_param_attr_MaxConnections,
  894. &iscsi_tpg_param_attr_TargetAlias,
  895. &iscsi_tpg_param_attr_InitialR2T,
  896. &iscsi_tpg_param_attr_ImmediateData,
  897. &iscsi_tpg_param_attr_MaxRecvDataSegmentLength,
  898. &iscsi_tpg_param_attr_MaxXmitDataSegmentLength,
  899. &iscsi_tpg_param_attr_MaxBurstLength,
  900. &iscsi_tpg_param_attr_FirstBurstLength,
  901. &iscsi_tpg_param_attr_DefaultTime2Wait,
  902. &iscsi_tpg_param_attr_DefaultTime2Retain,
  903. &iscsi_tpg_param_attr_MaxOutstandingR2T,
  904. &iscsi_tpg_param_attr_DataPDUInOrder,
  905. &iscsi_tpg_param_attr_DataSequenceInOrder,
  906. &iscsi_tpg_param_attr_ErrorRecoveryLevel,
  907. &iscsi_tpg_param_attr_IFMarker,
  908. &iscsi_tpg_param_attr_OFMarker,
  909. &iscsi_tpg_param_attr_IFMarkInt,
  910. &iscsi_tpg_param_attr_OFMarkInt,
  911. NULL,
  912. };
  913. /* End items for lio_target_tpg_param_cit */
  914. /* Start items for lio_target_tpg_cit */
  915. static ssize_t lio_target_tpg_enable_show(struct config_item *item, char *page)
  916. {
  917. struct se_portal_group *se_tpg = to_tpg(item);
  918. struct iscsi_portal_group *tpg = container_of(se_tpg,
  919. struct iscsi_portal_group, tpg_se_tpg);
  920. ssize_t len;
  921. spin_lock(&tpg->tpg_state_lock);
  922. len = sprintf(page, "%d\n",
  923. (tpg->tpg_state == TPG_STATE_ACTIVE) ? 1 : 0);
  924. spin_unlock(&tpg->tpg_state_lock);
  925. return len;
  926. }
  927. static ssize_t lio_target_tpg_enable_store(struct config_item *item,
  928. const char *page, size_t count)
  929. {
  930. struct se_portal_group *se_tpg = to_tpg(item);
  931. struct iscsi_portal_group *tpg = container_of(se_tpg,
  932. struct iscsi_portal_group, tpg_se_tpg);
  933. u32 op;
  934. int ret;
  935. ret = kstrtou32(page, 0, &op);
  936. if (ret)
  937. return ret;
  938. if ((op != 1) && (op != 0)) {
  939. pr_err("Illegal value for tpg_enable: %u\n", op);
  940. return -EINVAL;
  941. }
  942. ret = iscsit_get_tpg(tpg);
  943. if (ret < 0)
  944. return -EINVAL;
  945. if (op) {
  946. ret = iscsit_tpg_enable_portal_group(tpg);
  947. if (ret < 0)
  948. goto out;
  949. } else {
  950. /*
  951. * iscsit_tpg_disable_portal_group() assumes force=1
  952. */
  953. ret = iscsit_tpg_disable_portal_group(tpg, 1);
  954. if (ret < 0)
  955. goto out;
  956. }
  957. iscsit_put_tpg(tpg);
  958. return count;
  959. out:
  960. iscsit_put_tpg(tpg);
  961. return -EINVAL;
  962. }
  963. static ssize_t lio_target_tpg_dynamic_sessions_show(struct config_item *item,
  964. char *page)
  965. {
  966. return target_show_dynamic_sessions(to_tpg(item), page);
  967. }
  968. CONFIGFS_ATTR(lio_target_tpg_, enable);
  969. CONFIGFS_ATTR_RO(lio_target_tpg_, dynamic_sessions);
  970. static struct configfs_attribute *lio_target_tpg_attrs[] = {
  971. &lio_target_tpg_attr_enable,
  972. &lio_target_tpg_attr_dynamic_sessions,
  973. NULL,
  974. };
  975. /* End items for lio_target_tpg_cit */
  976. /* Start items for lio_target_tiqn_cit */
  977. static struct se_portal_group *lio_target_tiqn_addtpg(
  978. struct se_wwn *wwn,
  979. struct config_group *group,
  980. const char *name)
  981. {
  982. struct iscsi_portal_group *tpg;
  983. struct iscsi_tiqn *tiqn;
  984. char *tpgt_str;
  985. int ret;
  986. u16 tpgt;
  987. tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
  988. /*
  989. * Only tpgt_# directory groups can be created below
  990. * target/iscsi/iqn.superturodiskarry/
  991. */
  992. tpgt_str = strstr(name, "tpgt_");
  993. if (!tpgt_str) {
  994. pr_err("Unable to locate \"tpgt_#\" directory"
  995. " group\n");
  996. return NULL;
  997. }
  998. tpgt_str += 5; /* Skip ahead of "tpgt_" */
  999. ret = kstrtou16(tpgt_str, 0, &tpgt);
  1000. if (ret)
  1001. return NULL;
  1002. tpg = iscsit_alloc_portal_group(tiqn, tpgt);
  1003. if (!tpg)
  1004. return NULL;
  1005. ret = core_tpg_register(wwn, &tpg->tpg_se_tpg, SCSI_PROTOCOL_ISCSI);
  1006. if (ret < 0)
  1007. goto free_out;
  1008. ret = iscsit_tpg_add_portal_group(tiqn, tpg);
  1009. if (ret != 0)
  1010. goto out;
  1011. pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
  1012. pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated TPG: %s\n",
  1013. name);
  1014. return &tpg->tpg_se_tpg;
  1015. out:
  1016. core_tpg_deregister(&tpg->tpg_se_tpg);
  1017. free_out:
  1018. kfree(tpg);
  1019. return NULL;
  1020. }
  1021. static void lio_target_tiqn_deltpg(struct se_portal_group *se_tpg)
  1022. {
  1023. struct iscsi_portal_group *tpg;
  1024. struct iscsi_tiqn *tiqn;
  1025. tpg = container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
  1026. tiqn = tpg->tpg_tiqn;
  1027. /*
  1028. * iscsit_tpg_del_portal_group() assumes force=1
  1029. */
  1030. pr_debug("LIO_Target_ConfigFS: DEREGISTER -> Releasing TPG\n");
  1031. iscsit_tpg_del_portal_group(tiqn, tpg, 1);
  1032. }
  1033. /* End items for lio_target_tiqn_cit */
  1034. /* Start LIO-Target TIQN struct contig_item lio_target_cit */
  1035. static ssize_t lio_target_wwn_lio_version_show(struct config_item *item,
  1036. char *page)
  1037. {
  1038. return sprintf(page, "Datera Inc. iSCSI Target "ISCSIT_VERSION"\n");
  1039. }
  1040. CONFIGFS_ATTR_RO(lio_target_wwn_, lio_version);
  1041. static struct configfs_attribute *lio_target_wwn_attrs[] = {
  1042. &lio_target_wwn_attr_lio_version,
  1043. NULL,
  1044. };
  1045. static struct se_wwn *lio_target_call_coreaddtiqn(
  1046. struct target_fabric_configfs *tf,
  1047. struct config_group *group,
  1048. const char *name)
  1049. {
  1050. struct iscsi_tiqn *tiqn;
  1051. tiqn = iscsit_add_tiqn((unsigned char *)name);
  1052. if (IS_ERR(tiqn))
  1053. return ERR_CAST(tiqn);
  1054. pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
  1055. pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated Node:"
  1056. " %s\n", name);
  1057. return &tiqn->tiqn_wwn;
  1058. }
  1059. static void lio_target_add_wwn_groups(struct se_wwn *wwn)
  1060. {
  1061. struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
  1062. config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_instance_group,
  1063. "iscsi_instance", &iscsi_stat_instance_cit);
  1064. configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_instance_group,
  1065. &tiqn->tiqn_wwn.fabric_stat_group);
  1066. config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_sess_err_group,
  1067. "iscsi_sess_err", &iscsi_stat_sess_err_cit);
  1068. configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_sess_err_group,
  1069. &tiqn->tiqn_wwn.fabric_stat_group);
  1070. config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group,
  1071. "iscsi_tgt_attr", &iscsi_stat_tgt_attr_cit);
  1072. configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group,
  1073. &tiqn->tiqn_wwn.fabric_stat_group);
  1074. config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_login_stats_group,
  1075. "iscsi_login_stats", &iscsi_stat_login_cit);
  1076. configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_login_stats_group,
  1077. &tiqn->tiqn_wwn.fabric_stat_group);
  1078. config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group,
  1079. "iscsi_logout_stats", &iscsi_stat_logout_cit);
  1080. configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group,
  1081. &tiqn->tiqn_wwn.fabric_stat_group);
  1082. }
  1083. static void lio_target_call_coredeltiqn(
  1084. struct se_wwn *wwn)
  1085. {
  1086. struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
  1087. pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s\n",
  1088. tiqn->tiqn);
  1089. iscsit_del_tiqn(tiqn);
  1090. }
  1091. /* End LIO-Target TIQN struct contig_lio_target_cit */
  1092. /* Start lio_target_discovery_auth_cit */
  1093. #define DEF_DISC_AUTH_STR(name, flags) \
  1094. __DEF_NACL_AUTH_STR(disc, name, flags) \
  1095. static ssize_t iscsi_disc_##name##_show(struct config_item *item, char *page) \
  1096. { \
  1097. return __iscsi_disc_##name##_show(&iscsit_global->discovery_acl,\
  1098. page); \
  1099. } \
  1100. static ssize_t iscsi_disc_##name##_store(struct config_item *item, \
  1101. const char *page, size_t count) \
  1102. { \
  1103. return __iscsi_disc_##name##_store(&iscsit_global->discovery_acl, \
  1104. page, count); \
  1105. \
  1106. } \
  1107. CONFIGFS_ATTR(iscsi_disc_, name)
  1108. DEF_DISC_AUTH_STR(userid, NAF_USERID_SET);
  1109. DEF_DISC_AUTH_STR(password, NAF_PASSWORD_SET);
  1110. DEF_DISC_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
  1111. DEF_DISC_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
  1112. #define DEF_DISC_AUTH_INT(name) \
  1113. __DEF_NACL_AUTH_INT(disc, name) \
  1114. static ssize_t iscsi_disc_##name##_show(struct config_item *item, char *page) \
  1115. { \
  1116. return __iscsi_disc_##name##_show(&iscsit_global->discovery_acl, \
  1117. page); \
  1118. } \
  1119. CONFIGFS_ATTR_RO(iscsi_disc_, name)
  1120. DEF_DISC_AUTH_INT(authenticate_target);
  1121. static ssize_t iscsi_disc_enforce_discovery_auth_show(struct config_item *item,
  1122. char *page)
  1123. {
  1124. struct iscsi_node_auth *discovery_auth = &iscsit_global->discovery_acl.node_auth;
  1125. return sprintf(page, "%d\n", discovery_auth->enforce_discovery_auth);
  1126. }
  1127. static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,
  1128. const char *page, size_t count)
  1129. {
  1130. struct iscsi_param *param;
  1131. struct iscsi_portal_group *discovery_tpg = iscsit_global->discovery_tpg;
  1132. u32 op;
  1133. int err;
  1134. err = kstrtou32(page, 0, &op);
  1135. if (err)
  1136. return -EINVAL;
  1137. if ((op != 1) && (op != 0)) {
  1138. pr_err("Illegal value for enforce_discovery_auth:"
  1139. " %u\n", op);
  1140. return -EINVAL;
  1141. }
  1142. if (!discovery_tpg) {
  1143. pr_err("iscsit_global->discovery_tpg is NULL\n");
  1144. return -EINVAL;
  1145. }
  1146. param = iscsi_find_param_from_key(AUTHMETHOD,
  1147. discovery_tpg->param_list);
  1148. if (!param)
  1149. return -EINVAL;
  1150. if (op) {
  1151. /*
  1152. * Reset the AuthMethod key to CHAP.
  1153. */
  1154. if (iscsi_update_param_value(param, CHAP) < 0)
  1155. return -EINVAL;
  1156. discovery_tpg->tpg_attrib.authentication = 1;
  1157. iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 1;
  1158. pr_debug("LIO-CORE[0] Successfully enabled"
  1159. " authentication enforcement for iSCSI"
  1160. " Discovery TPG\n");
  1161. } else {
  1162. /*
  1163. * Reset the AuthMethod key to CHAP,None
  1164. */
  1165. if (iscsi_update_param_value(param, "CHAP,None") < 0)
  1166. return -EINVAL;
  1167. discovery_tpg->tpg_attrib.authentication = 0;
  1168. iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 0;
  1169. pr_debug("LIO-CORE[0] Successfully disabled"
  1170. " authentication enforcement for iSCSI"
  1171. " Discovery TPG\n");
  1172. }
  1173. return count;
  1174. }
  1175. CONFIGFS_ATTR(iscsi_disc_, enforce_discovery_auth);
  1176. static struct configfs_attribute *lio_target_discovery_auth_attrs[] = {
  1177. &iscsi_disc_attr_userid,
  1178. &iscsi_disc_attr_password,
  1179. &iscsi_disc_attr_authenticate_target,
  1180. &iscsi_disc_attr_userid_mutual,
  1181. &iscsi_disc_attr_password_mutual,
  1182. &iscsi_disc_attr_enforce_discovery_auth,
  1183. NULL,
  1184. };
  1185. /* End lio_target_discovery_auth_cit */
  1186. /* Start functions for target_core_fabric_ops */
  1187. static char *iscsi_get_fabric_name(void)
  1188. {
  1189. return "iSCSI";
  1190. }
  1191. static int iscsi_get_cmd_state(struct se_cmd *se_cmd)
  1192. {
  1193. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1194. return cmd->i_state;
  1195. }
  1196. static u32 lio_sess_get_index(struct se_session *se_sess)
  1197. {
  1198. struct iscsi_session *sess = se_sess->fabric_sess_ptr;
  1199. return sess->session_index;
  1200. }
  1201. static u32 lio_sess_get_initiator_sid(
  1202. struct se_session *se_sess,
  1203. unsigned char *buf,
  1204. u32 size)
  1205. {
  1206. struct iscsi_session *sess = se_sess->fabric_sess_ptr;
  1207. /*
  1208. * iSCSI Initiator Session Identifier from RFC-3720.
  1209. */
  1210. return snprintf(buf, size, "%6phN", sess->isid);
  1211. }
  1212. static int lio_queue_data_in(struct se_cmd *se_cmd)
  1213. {
  1214. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1215. struct iscsi_conn *conn = cmd->conn;
  1216. cmd->i_state = ISTATE_SEND_DATAIN;
  1217. return conn->conn_transport->iscsit_queue_data_in(conn, cmd);
  1218. }
  1219. static int lio_write_pending(struct se_cmd *se_cmd)
  1220. {
  1221. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1222. struct iscsi_conn *conn = cmd->conn;
  1223. if (!cmd->immediate_data && !cmd->unsolicited_data)
  1224. return conn->conn_transport->iscsit_get_dataout(conn, cmd, false);
  1225. return 0;
  1226. }
  1227. static int lio_write_pending_status(struct se_cmd *se_cmd)
  1228. {
  1229. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1230. int ret;
  1231. spin_lock_bh(&cmd->istate_lock);
  1232. ret = !(cmd->cmd_flags & ICF_GOT_LAST_DATAOUT);
  1233. spin_unlock_bh(&cmd->istate_lock);
  1234. return ret;
  1235. }
  1236. static int lio_queue_status(struct se_cmd *se_cmd)
  1237. {
  1238. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1239. struct iscsi_conn *conn = cmd->conn;
  1240. cmd->i_state = ISTATE_SEND_STATUS;
  1241. if (cmd->se_cmd.scsi_status || cmd->sense_reason) {
  1242. return iscsit_add_cmd_to_response_queue(cmd, conn, cmd->i_state);
  1243. }
  1244. return conn->conn_transport->iscsit_queue_status(conn, cmd);
  1245. }
  1246. static void lio_queue_tm_rsp(struct se_cmd *se_cmd)
  1247. {
  1248. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1249. cmd->i_state = ISTATE_SEND_TASKMGTRSP;
  1250. iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
  1251. }
  1252. static void lio_aborted_task(struct se_cmd *se_cmd)
  1253. {
  1254. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1255. cmd->conn->conn_transport->iscsit_aborted_task(cmd->conn, cmd);
  1256. }
  1257. static inline struct iscsi_portal_group *iscsi_tpg(struct se_portal_group *se_tpg)
  1258. {
  1259. return container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
  1260. }
  1261. static char *lio_tpg_get_endpoint_wwn(struct se_portal_group *se_tpg)
  1262. {
  1263. return iscsi_tpg(se_tpg)->tpg_tiqn->tiqn;
  1264. }
  1265. static u16 lio_tpg_get_tag(struct se_portal_group *se_tpg)
  1266. {
  1267. return iscsi_tpg(se_tpg)->tpgt;
  1268. }
  1269. static u32 lio_tpg_get_default_depth(struct se_portal_group *se_tpg)
  1270. {
  1271. return iscsi_tpg(se_tpg)->tpg_attrib.default_cmdsn_depth;
  1272. }
  1273. static int lio_tpg_check_demo_mode(struct se_portal_group *se_tpg)
  1274. {
  1275. return iscsi_tpg(se_tpg)->tpg_attrib.generate_node_acls;
  1276. }
  1277. static int lio_tpg_check_demo_mode_cache(struct se_portal_group *se_tpg)
  1278. {
  1279. return iscsi_tpg(se_tpg)->tpg_attrib.cache_dynamic_acls;
  1280. }
  1281. static int lio_tpg_check_demo_mode_write_protect(
  1282. struct se_portal_group *se_tpg)
  1283. {
  1284. return iscsi_tpg(se_tpg)->tpg_attrib.demo_mode_write_protect;
  1285. }
  1286. static int lio_tpg_check_prod_mode_write_protect(
  1287. struct se_portal_group *se_tpg)
  1288. {
  1289. return iscsi_tpg(se_tpg)->tpg_attrib.prod_mode_write_protect;
  1290. }
  1291. static int lio_tpg_check_prot_fabric_only(
  1292. struct se_portal_group *se_tpg)
  1293. {
  1294. /*
  1295. * Only report fabric_prot_type if t10_pi has also been enabled
  1296. * for incoming ib_isert sessions.
  1297. */
  1298. if (!iscsi_tpg(se_tpg)->tpg_attrib.t10_pi)
  1299. return 0;
  1300. return iscsi_tpg(se_tpg)->tpg_attrib.fabric_prot_type;
  1301. }
  1302. /*
  1303. * This function calls iscsit_inc_session_usage_count() on the
  1304. * struct iscsi_session in question.
  1305. */
  1306. static void lio_tpg_close_session(struct se_session *se_sess)
  1307. {
  1308. struct iscsi_session *sess = se_sess->fabric_sess_ptr;
  1309. struct se_portal_group *se_tpg = &sess->tpg->tpg_se_tpg;
  1310. spin_lock_bh(&se_tpg->session_lock);
  1311. spin_lock(&sess->conn_lock);
  1312. if (atomic_read(&sess->session_fall_back_to_erl0) ||
  1313. atomic_read(&sess->session_logout) ||
  1314. atomic_read(&sess->session_close) ||
  1315. (sess->time2retain_timer_flags & ISCSI_TF_EXPIRED)) {
  1316. spin_unlock(&sess->conn_lock);
  1317. spin_unlock_bh(&se_tpg->session_lock);
  1318. return;
  1319. }
  1320. iscsit_inc_session_usage_count(sess);
  1321. atomic_set(&sess->session_reinstatement, 1);
  1322. atomic_set(&sess->session_fall_back_to_erl0, 1);
  1323. atomic_set(&sess->session_close, 1);
  1324. spin_unlock(&sess->conn_lock);
  1325. iscsit_stop_time2retain_timer(sess);
  1326. spin_unlock_bh(&se_tpg->session_lock);
  1327. iscsit_stop_session(sess, 1, 1);
  1328. iscsit_dec_session_usage_count(sess);
  1329. }
  1330. static u32 lio_tpg_get_inst_index(struct se_portal_group *se_tpg)
  1331. {
  1332. return iscsi_tpg(se_tpg)->tpg_tiqn->tiqn_index;
  1333. }
  1334. static void lio_set_default_node_attributes(struct se_node_acl *se_acl)
  1335. {
  1336. struct iscsi_node_acl *acl = container_of(se_acl, struct iscsi_node_acl,
  1337. se_node_acl);
  1338. struct se_portal_group *se_tpg = se_acl->se_tpg;
  1339. struct iscsi_portal_group *tpg = container_of(se_tpg,
  1340. struct iscsi_portal_group, tpg_se_tpg);
  1341. acl->node_attrib.nacl = acl;
  1342. iscsit_set_default_node_attribues(acl, tpg);
  1343. }
  1344. static int lio_check_stop_free(struct se_cmd *se_cmd)
  1345. {
  1346. return target_put_sess_cmd(se_cmd);
  1347. }
  1348. static void lio_release_cmd(struct se_cmd *se_cmd)
  1349. {
  1350. struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
  1351. pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd);
  1352. iscsit_release_cmd(cmd);
  1353. }
  1354. const struct target_core_fabric_ops iscsi_ops = {
  1355. .module = THIS_MODULE,
  1356. .name = "iscsi",
  1357. .node_acl_size = sizeof(struct iscsi_node_acl),
  1358. .get_fabric_name = iscsi_get_fabric_name,
  1359. .tpg_get_wwn = lio_tpg_get_endpoint_wwn,
  1360. .tpg_get_tag = lio_tpg_get_tag,
  1361. .tpg_get_default_depth = lio_tpg_get_default_depth,
  1362. .tpg_check_demo_mode = lio_tpg_check_demo_mode,
  1363. .tpg_check_demo_mode_cache = lio_tpg_check_demo_mode_cache,
  1364. .tpg_check_demo_mode_write_protect =
  1365. lio_tpg_check_demo_mode_write_protect,
  1366. .tpg_check_prod_mode_write_protect =
  1367. lio_tpg_check_prod_mode_write_protect,
  1368. .tpg_check_prot_fabric_only = &lio_tpg_check_prot_fabric_only,
  1369. .tpg_get_inst_index = lio_tpg_get_inst_index,
  1370. .check_stop_free = lio_check_stop_free,
  1371. .release_cmd = lio_release_cmd,
  1372. .close_session = lio_tpg_close_session,
  1373. .sess_get_index = lio_sess_get_index,
  1374. .sess_get_initiator_sid = lio_sess_get_initiator_sid,
  1375. .write_pending = lio_write_pending,
  1376. .write_pending_status = lio_write_pending_status,
  1377. .set_default_node_attributes = lio_set_default_node_attributes,
  1378. .get_cmd_state = iscsi_get_cmd_state,
  1379. .queue_data_in = lio_queue_data_in,
  1380. .queue_status = lio_queue_status,
  1381. .queue_tm_rsp = lio_queue_tm_rsp,
  1382. .aborted_task = lio_aborted_task,
  1383. .fabric_make_wwn = lio_target_call_coreaddtiqn,
  1384. .fabric_drop_wwn = lio_target_call_coredeltiqn,
  1385. .add_wwn_groups = lio_target_add_wwn_groups,
  1386. .fabric_make_tpg = lio_target_tiqn_addtpg,
  1387. .fabric_drop_tpg = lio_target_tiqn_deltpg,
  1388. .fabric_make_np = lio_target_call_addnptotpg,
  1389. .fabric_drop_np = lio_target_call_delnpfromtpg,
  1390. .fabric_init_nodeacl = lio_target_init_nodeacl,
  1391. .tfc_discovery_attrs = lio_target_discovery_auth_attrs,
  1392. .tfc_wwn_attrs = lio_target_wwn_attrs,
  1393. .tfc_tpg_base_attrs = lio_target_tpg_attrs,
  1394. .tfc_tpg_attrib_attrs = lio_target_tpg_attrib_attrs,
  1395. .tfc_tpg_auth_attrs = lio_target_tpg_auth_attrs,
  1396. .tfc_tpg_param_attrs = lio_target_tpg_param_attrs,
  1397. .tfc_tpg_np_base_attrs = lio_target_portal_attrs,
  1398. .tfc_tpg_nacl_base_attrs = lio_target_initiator_attrs,
  1399. .tfc_tpg_nacl_attrib_attrs = lio_target_nacl_attrib_attrs,
  1400. .tfc_tpg_nacl_auth_attrs = lio_target_nacl_auth_attrs,
  1401. .tfc_tpg_nacl_param_attrs = lio_target_nacl_param_attrs,
  1402. };