blob: 1eec37c47662071deedc511779293b2f4689f843 [file] [log] [blame]
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001/*******************************************************************************
2 * This file contains the configfs implementation for iSCSI Target mode
3 * from the LIO-Target Project.
4 *
Nicholas Bellinger4c762512013-09-05 15:29:12 -07005 * (c) Copyright 2007-2013 Datera, Inc.
Nicholas Bellingere48354c2011-07-23 06:43:04 +00006 *
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
20#include <linux/configfs.h>
Jörn Engelad7babd2013-07-03 11:35:11 -040021#include <linux/ctype.h>
Paul Gortmakerc53181a2011-08-30 18:16:43 -040022#include <linux/export.h>
Stephen Rothwellc3bc93d2012-01-23 11:39:49 +110023#include <linux/inet.h>
Nicholas Bellingere48354c2011-07-23 06:43:04 +000024#include <target/target_core_base.h>
Christoph Hellwigc4795fb2011-11-16 09:46:48 -050025#include <target/target_core_fabric.h>
Nicholas Bellingere48354c2011-07-23 06:43:04 +000026#include <target/target_core_fabric_configfs.h>
Nicholas Bellingere48354c2011-07-23 06:43:04 +000027#include <target/target_core_configfs.h>
28#include <target/configfs_macros.h>
Nicholas Bellinger2ec5a8c2013-03-20 15:29:15 -070029#include <target/iscsi/iscsi_transport.h>
Nicholas Bellingere48354c2011-07-23 06:43:04 +000030
31#include "iscsi_target_core.h"
32#include "iscsi_target_parameters.h"
33#include "iscsi_target_device.h"
34#include "iscsi_target_erl0.h"
35#include "iscsi_target_nodeattrib.h"
36#include "iscsi_target_tpg.h"
37#include "iscsi_target_util.h"
38#include "iscsi_target.h"
39#include "iscsi_target_stat.h"
40#include "iscsi_target_configfs.h"
41
42struct target_fabric_configfs *lio_target_fabric_configfs;
43
44struct lio_target_configfs_attribute {
45 struct configfs_attribute attr;
46 ssize_t (*show)(void *, char *);
47 ssize_t (*store)(void *, const char *, size_t);
48};
49
Nicholas Bellingere48354c2011-07-23 06:43:04 +000050/* Start items for lio_target_portal_cit */
51
52static ssize_t lio_target_np_show_sctp(
53 struct se_tpg_np *se_tpg_np,
54 char *page)
55{
56 struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np,
57 struct iscsi_tpg_np, se_tpg_np);
58 struct iscsi_tpg_np *tpg_np_sctp;
59 ssize_t rb;
60
61 tpg_np_sctp = iscsit_tpg_locate_child_np(tpg_np, ISCSI_SCTP_TCP);
62 if (tpg_np_sctp)
63 rb = sprintf(page, "1\n");
64 else
65 rb = sprintf(page, "0\n");
66
67 return rb;
68}
69
70static ssize_t lio_target_np_store_sctp(
71 struct se_tpg_np *se_tpg_np,
72 const char *page,
73 size_t count)
74{
75 struct iscsi_np *np;
76 struct iscsi_portal_group *tpg;
77 struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np,
78 struct iscsi_tpg_np, se_tpg_np);
79 struct iscsi_tpg_np *tpg_np_sctp = NULL;
Nicholas Bellingere48354c2011-07-23 06:43:04 +000080 u32 op;
81 int ret;
82
Jörn Engelad7babd2013-07-03 11:35:11 -040083 ret = kstrtou32(page, 0, &op);
84 if (ret)
85 return ret;
Nicholas Bellingere48354c2011-07-23 06:43:04 +000086 if ((op != 1) && (op != 0)) {
87 pr_err("Illegal value for tpg_enable: %u\n", op);
88 return -EINVAL;
89 }
90 np = tpg_np->tpg_np;
91 if (!np) {
92 pr_err("Unable to locate struct iscsi_np from"
93 " struct iscsi_tpg_np\n");
94 return -EINVAL;
95 }
96
97 tpg = tpg_np->tpg;
98 if (iscsit_get_tpg(tpg) < 0)
99 return -EINVAL;
100
101 if (op) {
102 /*
103 * Use existing np->np_sockaddr for SCTP network portal reference
104 */
105 tpg_np_sctp = iscsit_tpg_add_network_portal(tpg, &np->np_sockaddr,
106 np->np_ip, tpg_np, ISCSI_SCTP_TCP);
107 if (!tpg_np_sctp || IS_ERR(tpg_np_sctp))
108 goto out;
109 } else {
110 tpg_np_sctp = iscsit_tpg_locate_child_np(tpg_np, ISCSI_SCTP_TCP);
111 if (!tpg_np_sctp)
112 goto out;
113
114 ret = iscsit_tpg_del_network_portal(tpg, tpg_np_sctp);
115 if (ret < 0)
116 goto out;
117 }
118
119 iscsit_put_tpg(tpg);
120 return count;
121out:
122 iscsit_put_tpg(tpg);
123 return -EINVAL;
124}
125
126TF_NP_BASE_ATTR(lio_target, sctp, S_IRUGO | S_IWUSR);
127
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800128static ssize_t lio_target_np_show_iser(
129 struct se_tpg_np *se_tpg_np,
130 char *page)
131{
132 struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np,
133 struct iscsi_tpg_np, se_tpg_np);
134 struct iscsi_tpg_np *tpg_np_iser;
135 ssize_t rb;
136
137 tpg_np_iser = iscsit_tpg_locate_child_np(tpg_np, ISCSI_INFINIBAND);
138 if (tpg_np_iser)
139 rb = sprintf(page, "1\n");
140 else
141 rb = sprintf(page, "0\n");
142
143 return rb;
144}
145
146static ssize_t lio_target_np_store_iser(
147 struct se_tpg_np *se_tpg_np,
148 const char *page,
149 size_t count)
150{
151 struct iscsi_np *np;
152 struct iscsi_portal_group *tpg;
153 struct iscsi_tpg_np *tpg_np = container_of(se_tpg_np,
154 struct iscsi_tpg_np, se_tpg_np);
155 struct iscsi_tpg_np *tpg_np_iser = NULL;
156 char *endptr;
157 u32 op;
Andy Grover58bd0c62013-05-29 12:05:59 -0700158 int rc = 0;
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800159
160 op = simple_strtoul(page, &endptr, 0);
161 if ((op != 1) && (op != 0)) {
162 pr_err("Illegal value for tpg_enable: %u\n", op);
163 return -EINVAL;
164 }
165 np = tpg_np->tpg_np;
166 if (!np) {
167 pr_err("Unable to locate struct iscsi_np from"
168 " struct iscsi_tpg_np\n");
169 return -EINVAL;
170 }
171
172 tpg = tpg_np->tpg;
173 if (iscsit_get_tpg(tpg) < 0)
174 return -EINVAL;
175
176 if (op) {
Andy Grover58bd0c62013-05-29 12:05:59 -0700177 rc = request_module("ib_isert");
178 if (rc != 0) {
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800179 pr_warn("Unable to request_module for ib_isert\n");
Andy Grover58bd0c62013-05-29 12:05:59 -0700180 rc = 0;
181 }
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800182
183 tpg_np_iser = iscsit_tpg_add_network_portal(tpg, &np->np_sockaddr,
184 np->np_ip, tpg_np, ISCSI_INFINIBAND);
Andy Grover58bd0c62013-05-29 12:05:59 -0700185 if (IS_ERR(tpg_np_iser)) {
186 rc = PTR_ERR(tpg_np_iser);
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800187 goto out;
Andy Grover58bd0c62013-05-29 12:05:59 -0700188 }
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800189 } else {
190 tpg_np_iser = iscsit_tpg_locate_child_np(tpg_np, ISCSI_INFINIBAND);
Andy Grover58bd0c62013-05-29 12:05:59 -0700191 if (tpg_np_iser) {
192 rc = iscsit_tpg_del_network_portal(tpg, tpg_np_iser);
193 if (rc < 0)
194 goto out;
195 }
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800196 }
197
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800198 iscsit_put_tpg(tpg);
199 return count;
200out:
201 iscsit_put_tpg(tpg);
Andy Grover58bd0c62013-05-29 12:05:59 -0700202 return rc;
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800203}
204
205TF_NP_BASE_ATTR(lio_target, iser, S_IRUGO | S_IWUSR);
206
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000207static struct configfs_attribute *lio_target_portal_attrs[] = {
208 &lio_target_np_sctp.attr,
Nicholas Bellinger72438cd2013-03-06 22:20:36 -0800209 &lio_target_np_iser.attr,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000210 NULL,
211};
212
213/* Stop items for lio_target_portal_cit */
214
215/* Start items for lio_target_np_cit */
216
217#define MAX_PORTAL_LEN 256
218
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -0400219static struct se_tpg_np *lio_target_call_addnptotpg(
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000220 struct se_portal_group *se_tpg,
221 struct config_group *group,
222 const char *name)
223{
224 struct iscsi_portal_group *tpg;
225 struct iscsi_tpg_np *tpg_np;
226 char *str, *str2, *ip_str, *port_str;
227 struct __kernel_sockaddr_storage sockaddr;
228 struct sockaddr_in *sock_in;
229 struct sockaddr_in6 *sock_in6;
230 unsigned long port;
231 int ret;
232 char buf[MAX_PORTAL_LEN + 1];
233
234 if (strlen(name) > MAX_PORTAL_LEN) {
235 pr_err("strlen(name): %d exceeds MAX_PORTAL_LEN: %d\n",
236 (int)strlen(name), MAX_PORTAL_LEN);
237 return ERR_PTR(-EOVERFLOW);
238 }
239 memset(buf, 0, MAX_PORTAL_LEN + 1);
Nicholas Bellinger7bbb6542011-07-27 12:37:03 -0700240 snprintf(buf, MAX_PORTAL_LEN + 1, "%s", name);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000241
242 memset(&sockaddr, 0, sizeof(struct __kernel_sockaddr_storage));
243
244 str = strstr(buf, "[");
245 if (str) {
246 const char *end;
247
248 str2 = strstr(str, "]");
249 if (!str2) {
250 pr_err("Unable to locate trailing \"]\""
251 " in IPv6 iSCSI network portal address\n");
252 return ERR_PTR(-EINVAL);
253 }
254 str++; /* Skip over leading "[" */
255 *str2 = '\0'; /* Terminate the IPv6 address */
256 str2++; /* Skip over the "]" */
257 port_str = strstr(str2, ":");
258 if (!port_str) {
259 pr_err("Unable to locate \":port\""
260 " in IPv6 iSCSI network portal address\n");
261 return ERR_PTR(-EINVAL);
262 }
263 *port_str = '\0'; /* Terminate string for IP */
264 port_str++; /* Skip over ":" */
265
Jingoo Han57103d72013-07-19 16:22:19 +0900266 ret = kstrtoul(port_str, 0, &port);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000267 if (ret < 0) {
Jingoo Han57103d72013-07-19 16:22:19 +0900268 pr_err("kstrtoul() failed for port_str: %d\n", ret);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000269 return ERR_PTR(ret);
270 }
271 sock_in6 = (struct sockaddr_in6 *)&sockaddr;
272 sock_in6->sin6_family = AF_INET6;
273 sock_in6->sin6_port = htons((unsigned short)port);
274 ret = in6_pton(str, IPV6_ADDRESS_SPACE,
275 (void *)&sock_in6->sin6_addr.in6_u, -1, &end);
276 if (ret <= 0) {
277 pr_err("in6_pton returned: %d\n", ret);
278 return ERR_PTR(-EINVAL);
279 }
280 } else {
281 str = ip_str = &buf[0];
282 port_str = strstr(ip_str, ":");
283 if (!port_str) {
284 pr_err("Unable to locate \":port\""
285 " in IPv4 iSCSI network portal address\n");
286 return ERR_PTR(-EINVAL);
287 }
288 *port_str = '\0'; /* Terminate string for IP */
289 port_str++; /* Skip over ":" */
290
Jingoo Han57103d72013-07-19 16:22:19 +0900291 ret = kstrtoul(port_str, 0, &port);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000292 if (ret < 0) {
Jingoo Han57103d72013-07-19 16:22:19 +0900293 pr_err("kstrtoul() failed for port_str: %d\n", ret);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000294 return ERR_PTR(ret);
295 }
296 sock_in = (struct sockaddr_in *)&sockaddr;
297 sock_in->sin_family = AF_INET;
298 sock_in->sin_port = htons((unsigned short)port);
299 sock_in->sin_addr.s_addr = in_aton(ip_str);
300 }
301 tpg = container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
302 ret = iscsit_get_tpg(tpg);
303 if (ret < 0)
304 return ERR_PTR(-EINVAL);
305
306 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s TPGT: %hu"
307 " PORTAL: %s\n",
308 config_item_name(&se_tpg->se_tpg_wwn->wwn_group.cg_item),
309 tpg->tpgt, name);
310 /*
311 * Assume ISCSI_TCP by default. Other network portals for other
312 * iSCSI fabrics:
313 *
314 * Traditional iSCSI over SCTP (initial support)
315 * iSER/TCP (TODO, hardware available)
316 * iSER/SCTP (TODO, software emulation with osc-iwarp)
317 * iSER/IB (TODO, hardware available)
318 *
Masanari Iida20879692012-08-27 22:46:00 +0900319 * can be enabled with attributes under
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000320 * sys/kernel/config/iscsi/$IQN/$TPG/np/$IP:$PORT/
321 *
322 */
323 tpg_np = iscsit_tpg_add_network_portal(tpg, &sockaddr, str, NULL,
324 ISCSI_TCP);
325 if (IS_ERR(tpg_np)) {
326 iscsit_put_tpg(tpg);
Thomas Meyere1750ba2011-08-01 23:58:18 +0200327 return ERR_CAST(tpg_np);
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000328 }
329 pr_debug("LIO_Target_ConfigFS: addnptotpg done!\n");
330
331 iscsit_put_tpg(tpg);
332 return &tpg_np->se_tpg_np;
333}
334
335static void lio_target_call_delnpfromtpg(
336 struct se_tpg_np *se_tpg_np)
337{
338 struct iscsi_portal_group *tpg;
339 struct iscsi_tpg_np *tpg_np;
340 struct se_portal_group *se_tpg;
341 int ret;
342
343 tpg_np = container_of(se_tpg_np, struct iscsi_tpg_np, se_tpg_np);
344 tpg = tpg_np->tpg;
345 ret = iscsit_get_tpg(tpg);
346 if (ret < 0)
347 return;
348
349 se_tpg = &tpg->tpg_se_tpg;
350 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s TPGT: %hu"
351 " PORTAL: %s:%hu\n", config_item_name(&se_tpg->se_tpg_wwn->wwn_group.cg_item),
352 tpg->tpgt, tpg_np->tpg_np->np_ip, tpg_np->tpg_np->np_port);
353
354 ret = iscsit_tpg_del_network_portal(tpg, tpg_np);
355 if (ret < 0)
356 goto out;
357
358 pr_debug("LIO_Target_ConfigFS: delnpfromtpg done!\n");
359out:
360 iscsit_put_tpg(tpg);
361}
362
363/* End items for lio_target_np_cit */
364
365/* Start items for lio_target_nacl_attrib_cit */
366
367#define DEF_NACL_ATTRIB(name) \
368static ssize_t iscsi_nacl_attrib_show_##name( \
369 struct se_node_acl *se_nacl, \
370 char *page) \
371{ \
372 struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \
373 se_node_acl); \
374 \
Andy Groverb7eec2c2013-10-09 11:05:57 -0700375 return sprintf(page, "%u\n", nacl->node_attrib.name); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000376} \
377 \
378static ssize_t iscsi_nacl_attrib_store_##name( \
379 struct se_node_acl *se_nacl, \
380 const char *page, \
381 size_t count) \
382{ \
383 struct iscsi_node_acl *nacl = container_of(se_nacl, struct iscsi_node_acl, \
384 se_node_acl); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000385 u32 val; \
386 int ret; \
387 \
Jörn Engelad7babd2013-07-03 11:35:11 -0400388 ret = kstrtou32(page, 0, &val); \
389 if (ret) \
390 return ret; \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000391 ret = iscsit_na_##name(nacl, val); \
392 if (ret < 0) \
393 return ret; \
394 \
395 return count; \
396}
397
398#define NACL_ATTR(_name, _mode) TF_NACL_ATTRIB_ATTR(iscsi, _name, _mode);
399/*
400 * Define iscsi_node_attrib_s_dataout_timeout
401 */
402DEF_NACL_ATTRIB(dataout_timeout);
403NACL_ATTR(dataout_timeout, S_IRUGO | S_IWUSR);
404/*
405 * Define iscsi_node_attrib_s_dataout_timeout_retries
406 */
407DEF_NACL_ATTRIB(dataout_timeout_retries);
408NACL_ATTR(dataout_timeout_retries, S_IRUGO | S_IWUSR);
409/*
410 * Define iscsi_node_attrib_s_default_erl
411 */
412DEF_NACL_ATTRIB(default_erl);
413NACL_ATTR(default_erl, S_IRUGO | S_IWUSR);
414/*
415 * Define iscsi_node_attrib_s_nopin_timeout
416 */
417DEF_NACL_ATTRIB(nopin_timeout);
418NACL_ATTR(nopin_timeout, S_IRUGO | S_IWUSR);
419/*
420 * Define iscsi_node_attrib_s_nopin_response_timeout
421 */
422DEF_NACL_ATTRIB(nopin_response_timeout);
423NACL_ATTR(nopin_response_timeout, S_IRUGO | S_IWUSR);
424/*
425 * Define iscsi_node_attrib_s_random_datain_pdu_offsets
426 */
427DEF_NACL_ATTRIB(random_datain_pdu_offsets);
428NACL_ATTR(random_datain_pdu_offsets, S_IRUGO | S_IWUSR);
429/*
430 * Define iscsi_node_attrib_s_random_datain_seq_offsets
431 */
432DEF_NACL_ATTRIB(random_datain_seq_offsets);
433NACL_ATTR(random_datain_seq_offsets, S_IRUGO | S_IWUSR);
434/*
435 * Define iscsi_node_attrib_s_random_r2t_offsets
436 */
437DEF_NACL_ATTRIB(random_r2t_offsets);
438NACL_ATTR(random_r2t_offsets, S_IRUGO | S_IWUSR);
439
440static struct configfs_attribute *lio_target_nacl_attrib_attrs[] = {
441 &iscsi_nacl_attrib_dataout_timeout.attr,
442 &iscsi_nacl_attrib_dataout_timeout_retries.attr,
443 &iscsi_nacl_attrib_default_erl.attr,
444 &iscsi_nacl_attrib_nopin_timeout.attr,
445 &iscsi_nacl_attrib_nopin_response_timeout.attr,
446 &iscsi_nacl_attrib_random_datain_pdu_offsets.attr,
447 &iscsi_nacl_attrib_random_datain_seq_offsets.attr,
448 &iscsi_nacl_attrib_random_r2t_offsets.attr,
449 NULL,
450};
451
452/* End items for lio_target_nacl_attrib_cit */
453
454/* Start items for lio_target_nacl_auth_cit */
455
456#define __DEF_NACL_AUTH_STR(prefix, name, flags) \
457static ssize_t __iscsi_##prefix##_show_##name( \
458 struct iscsi_node_acl *nacl, \
459 char *page) \
460{ \
461 struct iscsi_node_auth *auth = &nacl->node_auth; \
462 \
463 if (!capable(CAP_SYS_ADMIN)) \
464 return -EPERM; \
465 return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \
466} \
467 \
468static ssize_t __iscsi_##prefix##_store_##name( \
469 struct iscsi_node_acl *nacl, \
470 const char *page, \
471 size_t count) \
472{ \
473 struct iscsi_node_auth *auth = &nacl->node_auth; \
474 \
475 if (!capable(CAP_SYS_ADMIN)) \
476 return -EPERM; \
477 \
Jörn Engel0fbfc462013-07-03 11:35:11 -0400478 snprintf(auth->name, sizeof(auth->name), "%s", page); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000479 if (!strncmp("NULL", auth->name, 4)) \
480 auth->naf_flags &= ~flags; \
481 else \
482 auth->naf_flags |= flags; \
483 \
484 if ((auth->naf_flags & NAF_USERID_IN_SET) && \
485 (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
486 auth->authenticate_target = 1; \
487 else \
488 auth->authenticate_target = 0; \
489 \
490 return count; \
491}
492
493#define __DEF_NACL_AUTH_INT(prefix, name) \
494static ssize_t __iscsi_##prefix##_show_##name( \
495 struct iscsi_node_acl *nacl, \
496 char *page) \
497{ \
498 struct iscsi_node_auth *auth = &nacl->node_auth; \
499 \
500 if (!capable(CAP_SYS_ADMIN)) \
501 return -EPERM; \
502 \
503 return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
504}
505
506#define DEF_NACL_AUTH_STR(name, flags) \
507 __DEF_NACL_AUTH_STR(nacl_auth, name, flags) \
508static ssize_t iscsi_nacl_auth_show_##name( \
509 struct se_node_acl *nacl, \
510 char *page) \
511{ \
512 return __iscsi_nacl_auth_show_##name(container_of(nacl, \
513 struct iscsi_node_acl, se_node_acl), page); \
514} \
515static ssize_t iscsi_nacl_auth_store_##name( \
516 struct se_node_acl *nacl, \
517 const char *page, \
518 size_t count) \
519{ \
520 return __iscsi_nacl_auth_store_##name(container_of(nacl, \
521 struct iscsi_node_acl, se_node_acl), page, count); \
522}
523
524#define DEF_NACL_AUTH_INT(name) \
525 __DEF_NACL_AUTH_INT(nacl_auth, name) \
526static ssize_t iscsi_nacl_auth_show_##name( \
527 struct se_node_acl *nacl, \
528 char *page) \
529{ \
530 return __iscsi_nacl_auth_show_##name(container_of(nacl, \
531 struct iscsi_node_acl, se_node_acl), page); \
532}
533
534#define AUTH_ATTR(_name, _mode) TF_NACL_AUTH_ATTR(iscsi, _name, _mode);
535#define AUTH_ATTR_RO(_name) TF_NACL_AUTH_ATTR_RO(iscsi, _name);
536
537/*
538 * One-way authentication userid
539 */
540DEF_NACL_AUTH_STR(userid, NAF_USERID_SET);
541AUTH_ATTR(userid, S_IRUGO | S_IWUSR);
542/*
543 * One-way authentication password
544 */
545DEF_NACL_AUTH_STR(password, NAF_PASSWORD_SET);
546AUTH_ATTR(password, S_IRUGO | S_IWUSR);
547/*
548 * Enforce mutual authentication
549 */
550DEF_NACL_AUTH_INT(authenticate_target);
551AUTH_ATTR_RO(authenticate_target);
552/*
553 * Mutual authentication userid
554 */
555DEF_NACL_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
556AUTH_ATTR(userid_mutual, S_IRUGO | S_IWUSR);
557/*
558 * Mutual authentication password
559 */
560DEF_NACL_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
561AUTH_ATTR(password_mutual, S_IRUGO | S_IWUSR);
562
563static struct configfs_attribute *lio_target_nacl_auth_attrs[] = {
564 &iscsi_nacl_auth_userid.attr,
565 &iscsi_nacl_auth_password.attr,
566 &iscsi_nacl_auth_authenticate_target.attr,
567 &iscsi_nacl_auth_userid_mutual.attr,
568 &iscsi_nacl_auth_password_mutual.attr,
569 NULL,
570};
571
572/* End items for lio_target_nacl_auth_cit */
573
574/* Start items for lio_target_nacl_param_cit */
575
576#define DEF_NACL_PARAM(name) \
577static ssize_t iscsi_nacl_param_show_##name( \
578 struct se_node_acl *se_nacl, \
579 char *page) \
580{ \
581 struct iscsi_session *sess; \
582 struct se_session *se_sess; \
583 ssize_t rb; \
584 \
585 spin_lock_bh(&se_nacl->nacl_sess_lock); \
586 se_sess = se_nacl->nacl_sess; \
587 if (!se_sess) { \
588 rb = snprintf(page, PAGE_SIZE, \
589 "No Active iSCSI Session\n"); \
590 } else { \
591 sess = se_sess->fabric_sess_ptr; \
592 rb = snprintf(page, PAGE_SIZE, "%u\n", \
593 (u32)sess->sess_ops->name); \
594 } \
595 spin_unlock_bh(&se_nacl->nacl_sess_lock); \
596 \
597 return rb; \
598}
599
600#define NACL_PARAM_ATTR(_name) TF_NACL_PARAM_ATTR_RO(iscsi, _name);
601
602DEF_NACL_PARAM(MaxConnections);
603NACL_PARAM_ATTR(MaxConnections);
604
605DEF_NACL_PARAM(InitialR2T);
606NACL_PARAM_ATTR(InitialR2T);
607
608DEF_NACL_PARAM(ImmediateData);
609NACL_PARAM_ATTR(ImmediateData);
610
611DEF_NACL_PARAM(MaxBurstLength);
612NACL_PARAM_ATTR(MaxBurstLength);
613
614DEF_NACL_PARAM(FirstBurstLength);
615NACL_PARAM_ATTR(FirstBurstLength);
616
617DEF_NACL_PARAM(DefaultTime2Wait);
618NACL_PARAM_ATTR(DefaultTime2Wait);
619
620DEF_NACL_PARAM(DefaultTime2Retain);
621NACL_PARAM_ATTR(DefaultTime2Retain);
622
623DEF_NACL_PARAM(MaxOutstandingR2T);
624NACL_PARAM_ATTR(MaxOutstandingR2T);
625
626DEF_NACL_PARAM(DataPDUInOrder);
627NACL_PARAM_ATTR(DataPDUInOrder);
628
629DEF_NACL_PARAM(DataSequenceInOrder);
630NACL_PARAM_ATTR(DataSequenceInOrder);
631
632DEF_NACL_PARAM(ErrorRecoveryLevel);
633NACL_PARAM_ATTR(ErrorRecoveryLevel);
634
635static struct configfs_attribute *lio_target_nacl_param_attrs[] = {
636 &iscsi_nacl_param_MaxConnections.attr,
637 &iscsi_nacl_param_InitialR2T.attr,
638 &iscsi_nacl_param_ImmediateData.attr,
639 &iscsi_nacl_param_MaxBurstLength.attr,
640 &iscsi_nacl_param_FirstBurstLength.attr,
641 &iscsi_nacl_param_DefaultTime2Wait.attr,
642 &iscsi_nacl_param_DefaultTime2Retain.attr,
643 &iscsi_nacl_param_MaxOutstandingR2T.attr,
644 &iscsi_nacl_param_DataPDUInOrder.attr,
645 &iscsi_nacl_param_DataSequenceInOrder.attr,
646 &iscsi_nacl_param_ErrorRecoveryLevel.attr,
647 NULL,
648};
649
650/* End items for lio_target_nacl_param_cit */
651
652/* Start items for lio_target_acl_cit */
653
654static ssize_t lio_target_nacl_show_info(
655 struct se_node_acl *se_nacl,
656 char *page)
657{
658 struct iscsi_session *sess;
659 struct iscsi_conn *conn;
660 struct se_session *se_sess;
661 ssize_t rb = 0;
662
663 spin_lock_bh(&se_nacl->nacl_sess_lock);
664 se_sess = se_nacl->nacl_sess;
665 if (!se_sess) {
666 rb += sprintf(page+rb, "No active iSCSI Session for Initiator"
667 " Endpoint: %s\n", se_nacl->initiatorname);
668 } else {
669 sess = se_sess->fabric_sess_ptr;
670
671 if (sess->sess_ops->InitiatorName)
672 rb += sprintf(page+rb, "InitiatorName: %s\n",
673 sess->sess_ops->InitiatorName);
674 if (sess->sess_ops->InitiatorAlias)
675 rb += sprintf(page+rb, "InitiatorAlias: %s\n",
676 sess->sess_ops->InitiatorAlias);
677
678 rb += sprintf(page+rb, "LIO Session ID: %u "
679 "ISID: 0x%02x %02x %02x %02x %02x %02x "
680 "TSIH: %hu ", sess->sid,
681 sess->isid[0], sess->isid[1], sess->isid[2],
682 sess->isid[3], sess->isid[4], sess->isid[5],
683 sess->tsih);
684 rb += sprintf(page+rb, "SessionType: %s\n",
685 (sess->sess_ops->SessionType) ?
686 "Discovery" : "Normal");
687 rb += sprintf(page+rb, "Session State: ");
688 switch (sess->session_state) {
689 case TARG_SESS_STATE_FREE:
690 rb += sprintf(page+rb, "TARG_SESS_FREE\n");
691 break;
692 case TARG_SESS_STATE_ACTIVE:
693 rb += sprintf(page+rb, "TARG_SESS_STATE_ACTIVE\n");
694 break;
695 case TARG_SESS_STATE_LOGGED_IN:
696 rb += sprintf(page+rb, "TARG_SESS_STATE_LOGGED_IN\n");
697 break;
698 case TARG_SESS_STATE_FAILED:
699 rb += sprintf(page+rb, "TARG_SESS_STATE_FAILED\n");
700 break;
701 case TARG_SESS_STATE_IN_CONTINUE:
702 rb += sprintf(page+rb, "TARG_SESS_STATE_IN_CONTINUE\n");
703 break;
704 default:
705 rb += sprintf(page+rb, "ERROR: Unknown Session"
706 " State!\n");
707 break;
708 }
709
710 rb += sprintf(page+rb, "---------------------[iSCSI Session"
711 " Values]-----------------------\n");
712 rb += sprintf(page+rb, " CmdSN/WR : CmdSN/WC : ExpCmdSN"
713 " : MaxCmdSN : ITT : TTT\n");
714 rb += sprintf(page+rb, " 0x%08x 0x%08x 0x%08x 0x%08x"
715 " 0x%08x 0x%08x\n",
716 sess->cmdsn_window,
717 (sess->max_cmd_sn - sess->exp_cmd_sn) + 1,
718 sess->exp_cmd_sn, sess->max_cmd_sn,
719 sess->init_task_tag, sess->targ_xfer_tag);
720 rb += sprintf(page+rb, "----------------------[iSCSI"
721 " Connections]-------------------------\n");
722
723 spin_lock(&sess->conn_lock);
724 list_for_each_entry(conn, &sess->sess_conn_list, conn_list) {
725 rb += sprintf(page+rb, "CID: %hu Connection"
726 " State: ", conn->cid);
727 switch (conn->conn_state) {
728 case TARG_CONN_STATE_FREE:
729 rb += sprintf(page+rb,
730 "TARG_CONN_STATE_FREE\n");
731 break;
732 case TARG_CONN_STATE_XPT_UP:
733 rb += sprintf(page+rb,
734 "TARG_CONN_STATE_XPT_UP\n");
735 break;
736 case TARG_CONN_STATE_IN_LOGIN:
737 rb += sprintf(page+rb,
738 "TARG_CONN_STATE_IN_LOGIN\n");
739 break;
740 case TARG_CONN_STATE_LOGGED_IN:
741 rb += sprintf(page+rb,
742 "TARG_CONN_STATE_LOGGED_IN\n");
743 break;
744 case TARG_CONN_STATE_IN_LOGOUT:
745 rb += sprintf(page+rb,
746 "TARG_CONN_STATE_IN_LOGOUT\n");
747 break;
748 case TARG_CONN_STATE_LOGOUT_REQUESTED:
749 rb += sprintf(page+rb,
750 "TARG_CONN_STATE_LOGOUT_REQUESTED\n");
751 break;
752 case TARG_CONN_STATE_CLEANUP_WAIT:
753 rb += sprintf(page+rb,
754 "TARG_CONN_STATE_CLEANUP_WAIT\n");
755 break;
756 default:
757 rb += sprintf(page+rb,
758 "ERROR: Unknown Connection State!\n");
759 break;
760 }
761
762 rb += sprintf(page+rb, " Address %s %s", conn->login_ip,
763 (conn->network_transport == ISCSI_TCP) ?
764 "TCP" : "SCTP");
765 rb += sprintf(page+rb, " StatSN: 0x%08x\n",
766 conn->stat_sn);
767 }
768 spin_unlock(&sess->conn_lock);
769 }
770 spin_unlock_bh(&se_nacl->nacl_sess_lock);
771
772 return rb;
773}
774
775TF_NACL_BASE_ATTR_RO(lio_target, info);
776
777static ssize_t lio_target_nacl_show_cmdsn_depth(
778 struct se_node_acl *se_nacl,
779 char *page)
780{
781 return sprintf(page, "%u\n", se_nacl->queue_depth);
782}
783
784static ssize_t lio_target_nacl_store_cmdsn_depth(
785 struct se_node_acl *se_nacl,
786 const char *page,
787 size_t count)
788{
789 struct se_portal_group *se_tpg = se_nacl->se_tpg;
790 struct iscsi_portal_group *tpg = container_of(se_tpg,
791 struct iscsi_portal_group, tpg_se_tpg);
792 struct config_item *acl_ci, *tpg_ci, *wwn_ci;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000793 u32 cmdsn_depth = 0;
794 int ret;
795
Jörn Engelad7babd2013-07-03 11:35:11 -0400796 ret = kstrtou32(page, 0, &cmdsn_depth);
797 if (ret)
798 return ret;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000799 if (cmdsn_depth > TA_DEFAULT_CMDSN_DEPTH_MAX) {
800 pr_err("Passed cmdsn_depth: %u exceeds"
801 " TA_DEFAULT_CMDSN_DEPTH_MAX: %u\n", cmdsn_depth,
802 TA_DEFAULT_CMDSN_DEPTH_MAX);
803 return -EINVAL;
804 }
805 acl_ci = &se_nacl->acl_group.cg_item;
806 if (!acl_ci) {
807 pr_err("Unable to locatel acl_ci\n");
808 return -EINVAL;
809 }
810 tpg_ci = &acl_ci->ci_parent->ci_group->cg_item;
811 if (!tpg_ci) {
812 pr_err("Unable to locate tpg_ci\n");
813 return -EINVAL;
814 }
815 wwn_ci = &tpg_ci->ci_group->cg_item;
816 if (!wwn_ci) {
817 pr_err("Unable to locate config_item wwn_ci\n");
818 return -EINVAL;
819 }
820
821 if (iscsit_get_tpg(tpg) < 0)
822 return -EINVAL;
823 /*
824 * iscsit_tpg_set_initiator_node_queue_depth() assumes force=1
825 */
826 ret = iscsit_tpg_set_initiator_node_queue_depth(tpg,
827 config_item_name(acl_ci), cmdsn_depth, 1);
828
829 pr_debug("LIO_Target_ConfigFS: %s/%s Set CmdSN Window: %u for"
830 "InitiatorName: %s\n", config_item_name(wwn_ci),
831 config_item_name(tpg_ci), cmdsn_depth,
832 config_item_name(acl_ci));
833
834 iscsit_put_tpg(tpg);
835 return (!ret) ? count : (ssize_t)ret;
836}
837
838TF_NACL_BASE_ATTR(lio_target, cmdsn_depth, S_IRUGO | S_IWUSR);
839
Andy Grover79e62fc2012-12-11 16:30:53 -0800840static ssize_t lio_target_nacl_show_tag(
841 struct se_node_acl *se_nacl,
842 char *page)
843{
844 return snprintf(page, PAGE_SIZE, "%s", se_nacl->acl_tag);
845}
846
847static ssize_t lio_target_nacl_store_tag(
848 struct se_node_acl *se_nacl,
849 const char *page,
850 size_t count)
851{
852 int ret;
853
854 ret = core_tpg_set_initiator_node_tag(se_nacl->se_tpg, se_nacl, page);
855
856 if (ret < 0)
857 return ret;
858 return count;
859}
860
861TF_NACL_BASE_ATTR(lio_target, tag, S_IRUGO | S_IWUSR);
862
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000863static struct configfs_attribute *lio_target_initiator_attrs[] = {
864 &lio_target_nacl_info.attr,
865 &lio_target_nacl_cmdsn_depth.attr,
Andy Grover79e62fc2012-12-11 16:30:53 -0800866 &lio_target_nacl_tag.attr,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000867 NULL,
868};
869
870static struct se_node_acl *lio_tpg_alloc_fabric_acl(
871 struct se_portal_group *se_tpg)
872{
873 struct iscsi_node_acl *acl;
874
875 acl = kzalloc(sizeof(struct iscsi_node_acl), GFP_KERNEL);
876 if (!acl) {
877 pr_err("Unable to allocate memory for struct iscsi_node_acl\n");
878 return NULL;
879 }
880
881 return &acl->se_node_acl;
882}
883
884static struct se_node_acl *lio_target_make_nodeacl(
885 struct se_portal_group *se_tpg,
886 struct config_group *group,
887 const char *name)
888{
889 struct config_group *stats_cg;
890 struct iscsi_node_acl *acl;
891 struct se_node_acl *se_nacl_new, *se_nacl;
892 struct iscsi_portal_group *tpg = container_of(se_tpg,
893 struct iscsi_portal_group, tpg_se_tpg);
894 u32 cmdsn_depth;
895
896 se_nacl_new = lio_tpg_alloc_fabric_acl(se_tpg);
897 if (!se_nacl_new)
898 return ERR_PTR(-ENOMEM);
899
Andy Groverb7eec2c2013-10-09 11:05:57 -0700900 cmdsn_depth = tpg->tpg_attrib.default_cmdsn_depth;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000901 /*
902 * se_nacl_new may be released by core_tpg_add_initiator_node_acl()
903 * when converting a NdoeACL from demo mode -> explict
904 */
905 se_nacl = core_tpg_add_initiator_node_acl(se_tpg, se_nacl_new,
906 name, cmdsn_depth);
907 if (IS_ERR(se_nacl))
908 return se_nacl;
909
Nicholas Bellingerd0628332012-02-26 22:16:07 -0800910 acl = container_of(se_nacl, struct iscsi_node_acl, se_node_acl);
911 stats_cg = &se_nacl->acl_fabric_stat_group;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000912
Sebastian Andrzej Siewior13f6a912012-11-27 18:54:21 +0100913 stats_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000914 GFP_KERNEL);
915 if (!stats_cg->default_groups) {
916 pr_err("Unable to allocate memory for"
917 " stats_cg->default_groups\n");
918 core_tpg_del_initiator_node_acl(se_tpg, se_nacl, 1);
919 kfree(acl);
920 return ERR_PTR(-ENOMEM);
921 }
922
Andy Groverb7eec2c2013-10-09 11:05:57 -0700923 stats_cg->default_groups[0] = &acl->node_stat_grps.iscsi_sess_stats_group;
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000924 stats_cg->default_groups[1] = NULL;
Andy Groverb7eec2c2013-10-09 11:05:57 -0700925 config_group_init_type_name(&acl->node_stat_grps.iscsi_sess_stats_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000926 "iscsi_sess_stats", &iscsi_stat_sess_cit);
927
928 return se_nacl;
929}
930
931static void lio_target_drop_nodeacl(
932 struct se_node_acl *se_nacl)
933{
934 struct se_portal_group *se_tpg = se_nacl->se_tpg;
935 struct iscsi_node_acl *acl = container_of(se_nacl,
936 struct iscsi_node_acl, se_node_acl);
937 struct config_item *df_item;
938 struct config_group *stats_cg;
939 int i;
940
941 stats_cg = &acl->se_node_acl.acl_fabric_stat_group;
942 for (i = 0; stats_cg->default_groups[i]; i++) {
943 df_item = &stats_cg->default_groups[i]->cg_item;
944 stats_cg->default_groups[i] = NULL;
945 config_item_put(df_item);
946 }
947 kfree(stats_cg->default_groups);
948
949 core_tpg_del_initiator_node_acl(se_tpg, se_nacl, 1);
950 kfree(acl);
951}
952
953/* End items for lio_target_acl_cit */
954
955/* Start items for lio_target_tpg_attrib_cit */
956
957#define DEF_TPG_ATTRIB(name) \
958 \
959static ssize_t iscsi_tpg_attrib_show_##name( \
960 struct se_portal_group *se_tpg, \
961 char *page) \
962{ \
963 struct iscsi_portal_group *tpg = container_of(se_tpg, \
964 struct iscsi_portal_group, tpg_se_tpg); \
965 ssize_t rb; \
966 \
967 if (iscsit_get_tpg(tpg) < 0) \
968 return -EINVAL; \
969 \
Andy Groverb7eec2c2013-10-09 11:05:57 -0700970 rb = sprintf(page, "%u\n", tpg->tpg_attrib.name); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000971 iscsit_put_tpg(tpg); \
972 return rb; \
973} \
974 \
975static ssize_t iscsi_tpg_attrib_store_##name( \
976 struct se_portal_group *se_tpg, \
977 const char *page, \
978 size_t count) \
979{ \
980 struct iscsi_portal_group *tpg = container_of(se_tpg, \
981 struct iscsi_portal_group, tpg_se_tpg); \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000982 u32 val; \
983 int ret; \
984 \
985 if (iscsit_get_tpg(tpg) < 0) \
986 return -EINVAL; \
987 \
Jörn Engelad7babd2013-07-03 11:35:11 -0400988 ret = kstrtou32(page, 0, &val); \
989 if (ret) \
990 goto out; \
Nicholas Bellingere48354c2011-07-23 06:43:04 +0000991 ret = iscsit_ta_##name(tpg, val); \
992 if (ret < 0) \
993 goto out; \
994 \
995 iscsit_put_tpg(tpg); \
996 return count; \
997out: \
998 iscsit_put_tpg(tpg); \
999 return ret; \
1000}
1001
1002#define TPG_ATTR(_name, _mode) TF_TPG_ATTRIB_ATTR(iscsi, _name, _mode);
1003
1004/*
1005 * Define iscsi_tpg_attrib_s_authentication
1006 */
1007DEF_TPG_ATTRIB(authentication);
1008TPG_ATTR(authentication, S_IRUGO | S_IWUSR);
1009/*
1010 * Define iscsi_tpg_attrib_s_login_timeout
1011 */
1012DEF_TPG_ATTRIB(login_timeout);
1013TPG_ATTR(login_timeout, S_IRUGO | S_IWUSR);
1014/*
1015 * Define iscsi_tpg_attrib_s_netif_timeout
1016 */
1017DEF_TPG_ATTRIB(netif_timeout);
1018TPG_ATTR(netif_timeout, S_IRUGO | S_IWUSR);
1019/*
1020 * Define iscsi_tpg_attrib_s_generate_node_acls
1021 */
1022DEF_TPG_ATTRIB(generate_node_acls);
1023TPG_ATTR(generate_node_acls, S_IRUGO | S_IWUSR);
1024/*
1025 * Define iscsi_tpg_attrib_s_default_cmdsn_depth
1026 */
1027DEF_TPG_ATTRIB(default_cmdsn_depth);
1028TPG_ATTR(default_cmdsn_depth, S_IRUGO | S_IWUSR);
1029/*
1030 Define iscsi_tpg_attrib_s_cache_dynamic_acls
1031 */
1032DEF_TPG_ATTRIB(cache_dynamic_acls);
1033TPG_ATTR(cache_dynamic_acls, S_IRUGO | S_IWUSR);
1034/*
1035 * Define iscsi_tpg_attrib_s_demo_mode_write_protect
1036 */
1037DEF_TPG_ATTRIB(demo_mode_write_protect);
1038TPG_ATTR(demo_mode_write_protect, S_IRUGO | S_IWUSR);
1039/*
1040 * Define iscsi_tpg_attrib_s_prod_mode_write_protect
1041 */
1042DEF_TPG_ATTRIB(prod_mode_write_protect);
1043TPG_ATTR(prod_mode_write_protect, S_IRUGO | S_IWUSR);
Thomas Glanzmann4c54b6c2013-10-07 23:12:11 +02001044/*
1045 * Define iscsi_tpg_attrib_s_demo_mode_discovery,
1046 */
1047DEF_TPG_ATTRIB(demo_mode_discovery);
1048TPG_ATTR(demo_mode_discovery, S_IRUGO | S_IWUSR);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001049
1050static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = {
1051 &iscsi_tpg_attrib_authentication.attr,
1052 &iscsi_tpg_attrib_login_timeout.attr,
1053 &iscsi_tpg_attrib_netif_timeout.attr,
1054 &iscsi_tpg_attrib_generate_node_acls.attr,
1055 &iscsi_tpg_attrib_default_cmdsn_depth.attr,
1056 &iscsi_tpg_attrib_cache_dynamic_acls.attr,
1057 &iscsi_tpg_attrib_demo_mode_write_protect.attr,
1058 &iscsi_tpg_attrib_prod_mode_write_protect.attr,
Thomas Glanzmann4c54b6c2013-10-07 23:12:11 +02001059 &iscsi_tpg_attrib_demo_mode_discovery.attr,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001060 NULL,
1061};
1062
1063/* End items for lio_target_tpg_attrib_cit */
1064
Nicholas Bellingerc3e51442013-06-19 18:48:51 -07001065/* Start items for lio_target_tpg_auth_cit */
1066
1067#define __DEF_TPG_AUTH_STR(prefix, name, flags) \
1068static ssize_t __iscsi_##prefix##_show_##name( \
1069 struct se_portal_group *se_tpg, \
1070 char *page) \
1071{ \
1072 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1073 struct iscsi_portal_group, tpg_se_tpg); \
1074 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
1075 \
1076 if (!capable(CAP_SYS_ADMIN)) \
1077 return -EPERM; \
1078 \
1079 return snprintf(page, PAGE_SIZE, "%s\n", auth->name); \
1080} \
1081 \
1082static ssize_t __iscsi_##prefix##_store_##name( \
1083 struct se_portal_group *se_tpg, \
1084 const char *page, \
1085 size_t count) \
1086{ \
1087 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1088 struct iscsi_portal_group, tpg_se_tpg); \
1089 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
1090 \
1091 if (!capable(CAP_SYS_ADMIN)) \
1092 return -EPERM; \
1093 \
Nicholas Bellinger37b32c62013-07-06 16:48:55 -07001094 snprintf(auth->name, sizeof(auth->name), "%s", page); \
Nicholas Bellingerc3e51442013-06-19 18:48:51 -07001095 if (!(strncmp("NULL", auth->name, 4))) \
1096 auth->naf_flags &= ~flags; \
1097 else \
1098 auth->naf_flags |= flags; \
1099 \
1100 if ((auth->naf_flags & NAF_USERID_IN_SET) && \
1101 (auth->naf_flags & NAF_PASSWORD_IN_SET)) \
1102 auth->authenticate_target = 1; \
1103 else \
1104 auth->authenticate_target = 0; \
1105 \
1106 return count; \
1107}
1108
1109#define __DEF_TPG_AUTH_INT(prefix, name) \
1110static ssize_t __iscsi_##prefix##_show_##name( \
1111 struct se_portal_group *se_tpg, \
1112 char *page) \
1113{ \
1114 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1115 struct iscsi_portal_group, tpg_se_tpg); \
1116 struct iscsi_node_auth *auth = &tpg->tpg_demo_auth; \
1117 \
1118 if (!capable(CAP_SYS_ADMIN)) \
1119 return -EPERM; \
1120 \
1121 return snprintf(page, PAGE_SIZE, "%d\n", auth->name); \
1122}
1123
1124#define DEF_TPG_AUTH_STR(name, flags) \
1125 __DEF_TPG_AUTH_STR(tpg_auth, name, flags) \
1126static ssize_t iscsi_tpg_auth_show_##name( \
1127 struct se_portal_group *se_tpg, \
1128 char *page) \
1129{ \
1130 return __iscsi_tpg_auth_show_##name(se_tpg, page); \
1131} \
1132 \
1133static ssize_t iscsi_tpg_auth_store_##name( \
1134 struct se_portal_group *se_tpg, \
1135 const char *page, \
1136 size_t count) \
1137{ \
1138 return __iscsi_tpg_auth_store_##name(se_tpg, page, count); \
1139}
1140
1141#define DEF_TPG_AUTH_INT(name) \
1142 __DEF_TPG_AUTH_INT(tpg_auth, name) \
1143static ssize_t iscsi_tpg_auth_show_##name( \
1144 struct se_portal_group *se_tpg, \
1145 char *page) \
1146{ \
1147 return __iscsi_tpg_auth_show_##name(se_tpg, page); \
1148}
1149
1150#define TPG_AUTH_ATTR(_name, _mode) TF_TPG_AUTH_ATTR(iscsi, _name, _mode);
1151#define TPG_AUTH_ATTR_RO(_name) TF_TPG_AUTH_ATTR_RO(iscsi, _name);
1152
1153/*
1154 * * One-way authentication userid
1155 * */
1156DEF_TPG_AUTH_STR(userid, NAF_USERID_SET);
1157TPG_AUTH_ATTR(userid, S_IRUGO | S_IWUSR);
1158/*
1159 * * One-way authentication password
1160 * */
1161DEF_TPG_AUTH_STR(password, NAF_PASSWORD_SET);
1162TPG_AUTH_ATTR(password, S_IRUGO | S_IWUSR);
1163/*
1164 * * Enforce mutual authentication
1165 * */
1166DEF_TPG_AUTH_INT(authenticate_target);
1167TPG_AUTH_ATTR_RO(authenticate_target);
1168/*
1169 * * Mutual authentication userid
1170 * */
1171DEF_TPG_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
1172TPG_AUTH_ATTR(userid_mutual, S_IRUGO | S_IWUSR);
1173/*
1174 * * Mutual authentication password
1175 * */
1176DEF_TPG_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
1177TPG_AUTH_ATTR(password_mutual, S_IRUGO | S_IWUSR);
1178
1179static struct configfs_attribute *lio_target_tpg_auth_attrs[] = {
1180 &iscsi_tpg_auth_userid.attr,
1181 &iscsi_tpg_auth_password.attr,
1182 &iscsi_tpg_auth_authenticate_target.attr,
1183 &iscsi_tpg_auth_userid_mutual.attr,
1184 &iscsi_tpg_auth_password_mutual.attr,
1185 NULL,
1186};
1187
1188/* End items for lio_target_tpg_auth_cit */
1189
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001190/* Start items for lio_target_tpg_param_cit */
1191
1192#define DEF_TPG_PARAM(name) \
1193static ssize_t iscsi_tpg_param_show_##name( \
1194 struct se_portal_group *se_tpg, \
1195 char *page) \
1196{ \
1197 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1198 struct iscsi_portal_group, tpg_se_tpg); \
1199 struct iscsi_param *param; \
1200 ssize_t rb; \
1201 \
1202 if (iscsit_get_tpg(tpg) < 0) \
1203 return -EINVAL; \
1204 \
1205 param = iscsi_find_param_from_key(__stringify(name), \
1206 tpg->param_list); \
1207 if (!param) { \
1208 iscsit_put_tpg(tpg); \
1209 return -EINVAL; \
1210 } \
1211 rb = snprintf(page, PAGE_SIZE, "%s\n", param->value); \
1212 \
1213 iscsit_put_tpg(tpg); \
1214 return rb; \
1215} \
1216static ssize_t iscsi_tpg_param_store_##name( \
1217 struct se_portal_group *se_tpg, \
1218 const char *page, \
1219 size_t count) \
1220{ \
1221 struct iscsi_portal_group *tpg = container_of(se_tpg, \
1222 struct iscsi_portal_group, tpg_se_tpg); \
1223 char *buf; \
Jörn Engelad7babd2013-07-03 11:35:11 -04001224 int ret, len; \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001225 \
1226 buf = kzalloc(PAGE_SIZE, GFP_KERNEL); \
1227 if (!buf) \
1228 return -ENOMEM; \
Jörn Engelad7babd2013-07-03 11:35:11 -04001229 len = snprintf(buf, PAGE_SIZE, "%s=%s", __stringify(name), page); \
1230 if (isspace(buf[len-1])) \
1231 buf[len-1] = '\0'; /* Kill newline */ \
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001232 \
1233 if (iscsit_get_tpg(tpg) < 0) { \
1234 kfree(buf); \
1235 return -EINVAL; \
1236 } \
1237 \
1238 ret = iscsi_change_param_value(buf, tpg->param_list, 1); \
1239 if (ret < 0) \
1240 goto out; \
1241 \
1242 kfree(buf); \
1243 iscsit_put_tpg(tpg); \
1244 return count; \
1245out: \
1246 kfree(buf); \
1247 iscsit_put_tpg(tpg); \
1248 return -EINVAL; \
1249}
1250
1251#define TPG_PARAM_ATTR(_name, _mode) TF_TPG_PARAM_ATTR(iscsi, _name, _mode);
1252
1253DEF_TPG_PARAM(AuthMethod);
1254TPG_PARAM_ATTR(AuthMethod, S_IRUGO | S_IWUSR);
1255
1256DEF_TPG_PARAM(HeaderDigest);
1257TPG_PARAM_ATTR(HeaderDigest, S_IRUGO | S_IWUSR);
1258
1259DEF_TPG_PARAM(DataDigest);
1260TPG_PARAM_ATTR(DataDigest, S_IRUGO | S_IWUSR);
1261
1262DEF_TPG_PARAM(MaxConnections);
1263TPG_PARAM_ATTR(MaxConnections, S_IRUGO | S_IWUSR);
1264
1265DEF_TPG_PARAM(TargetAlias);
1266TPG_PARAM_ATTR(TargetAlias, S_IRUGO | S_IWUSR);
1267
1268DEF_TPG_PARAM(InitialR2T);
1269TPG_PARAM_ATTR(InitialR2T, S_IRUGO | S_IWUSR);
1270
1271DEF_TPG_PARAM(ImmediateData);
1272TPG_PARAM_ATTR(ImmediateData, S_IRUGO | S_IWUSR);
1273
1274DEF_TPG_PARAM(MaxRecvDataSegmentLength);
1275TPG_PARAM_ATTR(MaxRecvDataSegmentLength, S_IRUGO | S_IWUSR);
1276
Nicholas Bellingere004cb22012-09-29 21:47:16 -07001277DEF_TPG_PARAM(MaxXmitDataSegmentLength);
1278TPG_PARAM_ATTR(MaxXmitDataSegmentLength, S_IRUGO | S_IWUSR);
1279
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001280DEF_TPG_PARAM(MaxBurstLength);
1281TPG_PARAM_ATTR(MaxBurstLength, S_IRUGO | S_IWUSR);
1282
1283DEF_TPG_PARAM(FirstBurstLength);
1284TPG_PARAM_ATTR(FirstBurstLength, S_IRUGO | S_IWUSR);
1285
1286DEF_TPG_PARAM(DefaultTime2Wait);
1287TPG_PARAM_ATTR(DefaultTime2Wait, S_IRUGO | S_IWUSR);
1288
1289DEF_TPG_PARAM(DefaultTime2Retain);
1290TPG_PARAM_ATTR(DefaultTime2Retain, S_IRUGO | S_IWUSR);
1291
1292DEF_TPG_PARAM(MaxOutstandingR2T);
1293TPG_PARAM_ATTR(MaxOutstandingR2T, S_IRUGO | S_IWUSR);
1294
1295DEF_TPG_PARAM(DataPDUInOrder);
1296TPG_PARAM_ATTR(DataPDUInOrder, S_IRUGO | S_IWUSR);
1297
1298DEF_TPG_PARAM(DataSequenceInOrder);
1299TPG_PARAM_ATTR(DataSequenceInOrder, S_IRUGO | S_IWUSR);
1300
1301DEF_TPG_PARAM(ErrorRecoveryLevel);
1302TPG_PARAM_ATTR(ErrorRecoveryLevel, S_IRUGO | S_IWUSR);
1303
1304DEF_TPG_PARAM(IFMarker);
1305TPG_PARAM_ATTR(IFMarker, S_IRUGO | S_IWUSR);
1306
1307DEF_TPG_PARAM(OFMarker);
1308TPG_PARAM_ATTR(OFMarker, S_IRUGO | S_IWUSR);
1309
1310DEF_TPG_PARAM(IFMarkInt);
1311TPG_PARAM_ATTR(IFMarkInt, S_IRUGO | S_IWUSR);
1312
1313DEF_TPG_PARAM(OFMarkInt);
1314TPG_PARAM_ATTR(OFMarkInt, S_IRUGO | S_IWUSR);
1315
1316static struct configfs_attribute *lio_target_tpg_param_attrs[] = {
1317 &iscsi_tpg_param_AuthMethod.attr,
1318 &iscsi_tpg_param_HeaderDigest.attr,
1319 &iscsi_tpg_param_DataDigest.attr,
1320 &iscsi_tpg_param_MaxConnections.attr,
1321 &iscsi_tpg_param_TargetAlias.attr,
1322 &iscsi_tpg_param_InitialR2T.attr,
1323 &iscsi_tpg_param_ImmediateData.attr,
1324 &iscsi_tpg_param_MaxRecvDataSegmentLength.attr,
Nicholas Bellingere004cb22012-09-29 21:47:16 -07001325 &iscsi_tpg_param_MaxXmitDataSegmentLength.attr,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001326 &iscsi_tpg_param_MaxBurstLength.attr,
1327 &iscsi_tpg_param_FirstBurstLength.attr,
1328 &iscsi_tpg_param_DefaultTime2Wait.attr,
1329 &iscsi_tpg_param_DefaultTime2Retain.attr,
1330 &iscsi_tpg_param_MaxOutstandingR2T.attr,
1331 &iscsi_tpg_param_DataPDUInOrder.attr,
1332 &iscsi_tpg_param_DataSequenceInOrder.attr,
1333 &iscsi_tpg_param_ErrorRecoveryLevel.attr,
1334 &iscsi_tpg_param_IFMarker.attr,
1335 &iscsi_tpg_param_OFMarker.attr,
1336 &iscsi_tpg_param_IFMarkInt.attr,
1337 &iscsi_tpg_param_OFMarkInt.attr,
1338 NULL,
1339};
1340
1341/* End items for lio_target_tpg_param_cit */
1342
1343/* Start items for lio_target_tpg_cit */
1344
1345static ssize_t lio_target_tpg_show_enable(
1346 struct se_portal_group *se_tpg,
1347 char *page)
1348{
1349 struct iscsi_portal_group *tpg = container_of(se_tpg,
1350 struct iscsi_portal_group, tpg_se_tpg);
1351 ssize_t len;
1352
1353 spin_lock(&tpg->tpg_state_lock);
1354 len = sprintf(page, "%d\n",
1355 (tpg->tpg_state == TPG_STATE_ACTIVE) ? 1 : 0);
1356 spin_unlock(&tpg->tpg_state_lock);
1357
1358 return len;
1359}
1360
1361static ssize_t lio_target_tpg_store_enable(
1362 struct se_portal_group *se_tpg,
1363 const char *page,
1364 size_t count)
1365{
1366 struct iscsi_portal_group *tpg = container_of(se_tpg,
1367 struct iscsi_portal_group, tpg_se_tpg);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001368 u32 op;
Jörn Engelad7babd2013-07-03 11:35:11 -04001369 int ret;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001370
Jörn Engelad7babd2013-07-03 11:35:11 -04001371 ret = kstrtou32(page, 0, &op);
1372 if (ret)
1373 return ret;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001374 if ((op != 1) && (op != 0)) {
1375 pr_err("Illegal value for tpg_enable: %u\n", op);
1376 return -EINVAL;
1377 }
1378
1379 ret = iscsit_get_tpg(tpg);
1380 if (ret < 0)
1381 return -EINVAL;
1382
1383 if (op) {
1384 ret = iscsit_tpg_enable_portal_group(tpg);
1385 if (ret < 0)
1386 goto out;
1387 } else {
1388 /*
1389 * iscsit_tpg_disable_portal_group() assumes force=1
1390 */
1391 ret = iscsit_tpg_disable_portal_group(tpg, 1);
1392 if (ret < 0)
1393 goto out;
1394 }
1395
1396 iscsit_put_tpg(tpg);
1397 return count;
1398out:
1399 iscsit_put_tpg(tpg);
1400 return -EINVAL;
1401}
1402
1403TF_TPG_BASE_ATTR(lio_target, enable, S_IRUGO | S_IWUSR);
1404
1405static struct configfs_attribute *lio_target_tpg_attrs[] = {
1406 &lio_target_tpg_enable.attr,
1407 NULL,
1408};
1409
1410/* End items for lio_target_tpg_cit */
1411
1412/* Start items for lio_target_tiqn_cit */
1413
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001414static struct se_portal_group *lio_target_tiqn_addtpg(
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001415 struct se_wwn *wwn,
1416 struct config_group *group,
1417 const char *name)
1418{
1419 struct iscsi_portal_group *tpg;
1420 struct iscsi_tiqn *tiqn;
Jörn Engelad7babd2013-07-03 11:35:11 -04001421 char *tpgt_str;
1422 int ret;
1423 u16 tpgt;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001424
1425 tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
1426 /*
1427 * Only tpgt_# directory groups can be created below
1428 * target/iscsi/iqn.superturodiskarry/
Jörn Engelad7babd2013-07-03 11:35:11 -04001429 */
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001430 tpgt_str = strstr(name, "tpgt_");
1431 if (!tpgt_str) {
1432 pr_err("Unable to locate \"tpgt_#\" directory"
1433 " group\n");
1434 return NULL;
1435 }
1436 tpgt_str += 5; /* Skip ahead of "tpgt_" */
Jörn Engelad7babd2013-07-03 11:35:11 -04001437 ret = kstrtou16(tpgt_str, 0, &tpgt);
1438 if (ret)
1439 return NULL;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001440
1441 tpg = iscsit_alloc_portal_group(tiqn, tpgt);
1442 if (!tpg)
1443 return NULL;
1444
1445 ret = core_tpg_register(
1446 &lio_target_fabric_configfs->tf_ops,
Jörn Engel8359cf42011-11-24 02:05:51 +01001447 wwn, &tpg->tpg_se_tpg, tpg,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001448 TRANSPORT_TPG_TYPE_NORMAL);
1449 if (ret < 0)
1450 return NULL;
1451
1452 ret = iscsit_tpg_add_portal_group(tiqn, tpg);
1453 if (ret != 0)
1454 goto out;
1455
1456 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
1457 pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated TPG: %s\n",
1458 name);
1459 return &tpg->tpg_se_tpg;
1460out:
1461 core_tpg_deregister(&tpg->tpg_se_tpg);
1462 kfree(tpg);
1463 return NULL;
1464}
1465
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001466static void lio_target_tiqn_deltpg(struct se_portal_group *se_tpg)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001467{
1468 struct iscsi_portal_group *tpg;
1469 struct iscsi_tiqn *tiqn;
1470
1471 tpg = container_of(se_tpg, struct iscsi_portal_group, tpg_se_tpg);
1472 tiqn = tpg->tpg_tiqn;
1473 /*
1474 * iscsit_tpg_del_portal_group() assumes force=1
1475 */
1476 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> Releasing TPG\n");
1477 iscsit_tpg_del_portal_group(tiqn, tpg, 1);
1478}
1479
1480/* End items for lio_target_tiqn_cit */
1481
1482/* Start LIO-Target TIQN struct contig_item lio_target_cit */
1483
1484static ssize_t lio_target_wwn_show_attr_lio_version(
1485 struct target_fabric_configfs *tf,
1486 char *page)
1487{
Nicholas Bellinger4c762512013-09-05 15:29:12 -07001488 return sprintf(page, "Datera Inc. iSCSI Target "ISCSIT_VERSION"\n");
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001489}
1490
1491TF_WWN_ATTR_RO(lio_target, lio_version);
1492
1493static struct configfs_attribute *lio_target_wwn_attrs[] = {
1494 &lio_target_wwn_lio_version.attr,
1495 NULL,
1496};
1497
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001498static struct se_wwn *lio_target_call_coreaddtiqn(
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001499 struct target_fabric_configfs *tf,
1500 struct config_group *group,
1501 const char *name)
1502{
1503 struct config_group *stats_cg;
1504 struct iscsi_tiqn *tiqn;
1505
1506 tiqn = iscsit_add_tiqn((unsigned char *)name);
1507 if (IS_ERR(tiqn))
Thomas Meyere1750ba2011-08-01 23:58:18 +02001508 return ERR_CAST(tiqn);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001509 /*
1510 * Setup struct iscsi_wwn_stat_grps for se_wwn->fabric_stat_group.
1511 */
1512 stats_cg = &tiqn->tiqn_wwn.fabric_stat_group;
1513
Sebastian Andrzej Siewior13f6a912012-11-27 18:54:21 +01001514 stats_cg->default_groups = kmalloc(sizeof(struct config_group *) * 6,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001515 GFP_KERNEL);
1516 if (!stats_cg->default_groups) {
1517 pr_err("Unable to allocate memory for"
1518 " stats_cg->default_groups\n");
1519 iscsit_del_tiqn(tiqn);
1520 return ERR_PTR(-ENOMEM);
1521 }
1522
Andy Groverb7eec2c2013-10-09 11:05:57 -07001523 stats_cg->default_groups[0] = &tiqn->tiqn_stat_grps.iscsi_instance_group;
1524 stats_cg->default_groups[1] = &tiqn->tiqn_stat_grps.iscsi_sess_err_group;
1525 stats_cg->default_groups[2] = &tiqn->tiqn_stat_grps.iscsi_tgt_attr_group;
1526 stats_cg->default_groups[3] = &tiqn->tiqn_stat_grps.iscsi_login_stats_group;
1527 stats_cg->default_groups[4] = &tiqn->tiqn_stat_grps.iscsi_logout_stats_group;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001528 stats_cg->default_groups[5] = NULL;
Andy Groverb7eec2c2013-10-09 11:05:57 -07001529 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_instance_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001530 "iscsi_instance", &iscsi_stat_instance_cit);
Andy Groverb7eec2c2013-10-09 11:05:57 -07001531 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_sess_err_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001532 "iscsi_sess_err", &iscsi_stat_sess_err_cit);
Andy Groverb7eec2c2013-10-09 11:05:57 -07001533 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_tgt_attr_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001534 "iscsi_tgt_attr", &iscsi_stat_tgt_attr_cit);
Andy Groverb7eec2c2013-10-09 11:05:57 -07001535 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_login_stats_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001536 "iscsi_login_stats", &iscsi_stat_login_cit);
Andy Groverb7eec2c2013-10-09 11:05:57 -07001537 config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001538 "iscsi_logout_stats", &iscsi_stat_logout_cit);
1539
1540 pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
1541 pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated Node:"
1542 " %s\n", name);
1543 return &tiqn->tiqn_wwn;
1544}
1545
Christoph Hellwigfceb5bc2012-09-26 08:00:36 -04001546static void lio_target_call_coredeltiqn(
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001547 struct se_wwn *wwn)
1548{
1549 struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
1550 struct config_item *df_item;
1551 struct config_group *stats_cg;
1552 int i;
1553
1554 stats_cg = &tiqn->tiqn_wwn.fabric_stat_group;
1555 for (i = 0; stats_cg->default_groups[i]; i++) {
1556 df_item = &stats_cg->default_groups[i]->cg_item;
1557 stats_cg->default_groups[i] = NULL;
1558 config_item_put(df_item);
1559 }
1560 kfree(stats_cg->default_groups);
1561
1562 pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s\n",
1563 tiqn->tiqn);
1564 iscsit_del_tiqn(tiqn);
1565}
1566
1567/* End LIO-Target TIQN struct contig_lio_target_cit */
1568
1569/* Start lio_target_discovery_auth_cit */
1570
1571#define DEF_DISC_AUTH_STR(name, flags) \
1572 __DEF_NACL_AUTH_STR(disc, name, flags) \
1573static ssize_t iscsi_disc_show_##name( \
1574 struct target_fabric_configfs *tf, \
1575 char *page) \
1576{ \
1577 return __iscsi_disc_show_##name(&iscsit_global->discovery_acl, \
1578 page); \
1579} \
1580static ssize_t iscsi_disc_store_##name( \
1581 struct target_fabric_configfs *tf, \
1582 const char *page, \
1583 size_t count) \
1584{ \
1585 return __iscsi_disc_store_##name(&iscsit_global->discovery_acl, \
1586 page, count); \
1587}
1588
1589#define DEF_DISC_AUTH_INT(name) \
1590 __DEF_NACL_AUTH_INT(disc, name) \
1591static ssize_t iscsi_disc_show_##name( \
1592 struct target_fabric_configfs *tf, \
1593 char *page) \
1594{ \
1595 return __iscsi_disc_show_##name(&iscsit_global->discovery_acl, \
1596 page); \
1597}
1598
1599#define DISC_AUTH_ATTR(_name, _mode) TF_DISC_ATTR(iscsi, _name, _mode)
1600#define DISC_AUTH_ATTR_RO(_name) TF_DISC_ATTR_RO(iscsi, _name)
1601
1602/*
1603 * One-way authentication userid
1604 */
1605DEF_DISC_AUTH_STR(userid, NAF_USERID_SET);
1606DISC_AUTH_ATTR(userid, S_IRUGO | S_IWUSR);
1607/*
1608 * One-way authentication password
1609 */
1610DEF_DISC_AUTH_STR(password, NAF_PASSWORD_SET);
1611DISC_AUTH_ATTR(password, S_IRUGO | S_IWUSR);
1612/*
1613 * Enforce mutual authentication
1614 */
1615DEF_DISC_AUTH_INT(authenticate_target);
1616DISC_AUTH_ATTR_RO(authenticate_target);
1617/*
1618 * Mutual authentication userid
1619 */
1620DEF_DISC_AUTH_STR(userid_mutual, NAF_USERID_IN_SET);
1621DISC_AUTH_ATTR(userid_mutual, S_IRUGO | S_IWUSR);
1622/*
1623 * Mutual authentication password
1624 */
1625DEF_DISC_AUTH_STR(password_mutual, NAF_PASSWORD_IN_SET);
1626DISC_AUTH_ATTR(password_mutual, S_IRUGO | S_IWUSR);
1627
1628/*
1629 * enforce_discovery_auth
1630 */
1631static ssize_t iscsi_disc_show_enforce_discovery_auth(
1632 struct target_fabric_configfs *tf,
1633 char *page)
1634{
1635 struct iscsi_node_auth *discovery_auth = &iscsit_global->discovery_acl.node_auth;
1636
1637 return sprintf(page, "%d\n", discovery_auth->enforce_discovery_auth);
1638}
1639
1640static ssize_t iscsi_disc_store_enforce_discovery_auth(
1641 struct target_fabric_configfs *tf,
1642 const char *page,
1643 size_t count)
1644{
1645 struct iscsi_param *param;
1646 struct iscsi_portal_group *discovery_tpg = iscsit_global->discovery_tpg;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001647 u32 op;
Jörn Engelad7babd2013-07-03 11:35:11 -04001648 int err;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001649
Jörn Engelad7babd2013-07-03 11:35:11 -04001650 err = kstrtou32(page, 0, &op);
1651 if (err)
1652 return -EINVAL;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001653 if ((op != 1) && (op != 0)) {
1654 pr_err("Illegal value for enforce_discovery_auth:"
1655 " %u\n", op);
1656 return -EINVAL;
1657 }
1658
1659 if (!discovery_tpg) {
1660 pr_err("iscsit_global->discovery_tpg is NULL\n");
1661 return -EINVAL;
1662 }
1663
1664 param = iscsi_find_param_from_key(AUTHMETHOD,
1665 discovery_tpg->param_list);
1666 if (!param)
1667 return -EINVAL;
1668
1669 if (op) {
1670 /*
1671 * Reset the AuthMethod key to CHAP.
1672 */
1673 if (iscsi_update_param_value(param, CHAP) < 0)
1674 return -EINVAL;
1675
1676 discovery_tpg->tpg_attrib.authentication = 1;
1677 iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 1;
1678 pr_debug("LIO-CORE[0] Successfully enabled"
1679 " authentication enforcement for iSCSI"
1680 " Discovery TPG\n");
1681 } else {
1682 /*
1683 * Reset the AuthMethod key to CHAP,None
1684 */
1685 if (iscsi_update_param_value(param, "CHAP,None") < 0)
1686 return -EINVAL;
1687
1688 discovery_tpg->tpg_attrib.authentication = 0;
1689 iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 0;
1690 pr_debug("LIO-CORE[0] Successfully disabled"
1691 " authentication enforcement for iSCSI"
1692 " Discovery TPG\n");
1693 }
1694
1695 return count;
1696}
1697
1698DISC_AUTH_ATTR(enforce_discovery_auth, S_IRUGO | S_IWUSR);
1699
1700static struct configfs_attribute *lio_target_discovery_auth_attrs[] = {
1701 &iscsi_disc_userid.attr,
1702 &iscsi_disc_password.attr,
1703 &iscsi_disc_authenticate_target.attr,
1704 &iscsi_disc_userid_mutual.attr,
1705 &iscsi_disc_password_mutual.attr,
1706 &iscsi_disc_enforce_discovery_auth.attr,
1707 NULL,
1708};
1709
1710/* End lio_target_discovery_auth_cit */
1711
1712/* Start functions for target_core_fabric_ops */
1713
1714static char *iscsi_get_fabric_name(void)
1715{
1716 return "iSCSI";
1717}
1718
1719static u32 iscsi_get_task_tag(struct se_cmd *se_cmd)
1720{
1721 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1722
Christoph Hellwig66c7db62012-09-26 08:00:39 -04001723 /* only used for printks or comparism with ->ref_task_tag */
1724 return (__force u32)cmd->init_task_tag;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001725}
1726
1727static int iscsi_get_cmd_state(struct se_cmd *se_cmd)
1728{
1729 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1730
1731 return cmd->i_state;
1732}
1733
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001734static u32 lio_sess_get_index(struct se_session *se_sess)
1735{
1736 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1737
1738 return sess->session_index;
1739}
1740
1741static u32 lio_sess_get_initiator_sid(
1742 struct se_session *se_sess,
1743 unsigned char *buf,
1744 u32 size)
1745{
1746 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1747 /*
1748 * iSCSI Initiator Session Identifier from RFC-3720.
1749 */
1750 return snprintf(buf, size, "%02x%02x%02x%02x%02x%02x",
1751 sess->isid[0], sess->isid[1], sess->isid[2],
1752 sess->isid[3], sess->isid[4], sess->isid[5]);
1753}
1754
1755static int lio_queue_data_in(struct se_cmd *se_cmd)
1756{
1757 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1758
1759 cmd->i_state = ISTATE_SEND_DATAIN;
Nicholas Bellinger2ec5a8c2013-03-20 15:29:15 -07001760 cmd->conn->conn_transport->iscsit_queue_data_in(cmd->conn, cmd);
1761
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001762 return 0;
1763}
1764
1765static int lio_write_pending(struct se_cmd *se_cmd)
1766{
1767 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
Nicholas Bellinger3e1c81a2013-03-06 22:18:24 -08001768 struct iscsi_conn *conn = cmd->conn;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001769
1770 if (!cmd->immediate_data && !cmd->unsolicited_data)
Nicholas Bellinger3e1c81a2013-03-06 22:18:24 -08001771 return conn->conn_transport->iscsit_get_dataout(conn, cmd, false);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001772
1773 return 0;
1774}
1775
1776static int lio_write_pending_status(struct se_cmd *se_cmd)
1777{
1778 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1779 int ret;
1780
1781 spin_lock_bh(&cmd->istate_lock);
1782 ret = !(cmd->cmd_flags & ICF_GOT_LAST_DATAOUT);
1783 spin_unlock_bh(&cmd->istate_lock);
1784
1785 return ret;
1786}
1787
1788static int lio_queue_status(struct se_cmd *se_cmd)
1789{
1790 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1791
1792 cmd->i_state = ISTATE_SEND_STATUS;
Nicholas Bellinger2ec5a8c2013-03-20 15:29:15 -07001793 cmd->conn->conn_transport->iscsit_queue_status(cmd->conn, cmd);
1794
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001795 return 0;
1796}
1797
Joern Engelb79fafa2013-07-03 11:22:17 -04001798static void lio_queue_tm_rsp(struct se_cmd *se_cmd)
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001799{
1800 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1801
1802 cmd->i_state = ISTATE_SEND_TASKMGTRSP;
1803 iscsit_add_cmd_to_response_queue(cmd, cmd->conn, cmd->i_state);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001804}
1805
1806static char *lio_tpg_get_endpoint_wwn(struct se_portal_group *se_tpg)
1807{
1808 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1809
1810 return &tpg->tpg_tiqn->tiqn[0];
1811}
1812
1813static u16 lio_tpg_get_tag(struct se_portal_group *se_tpg)
1814{
1815 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1816
1817 return tpg->tpgt;
1818}
1819
1820static u32 lio_tpg_get_default_depth(struct se_portal_group *se_tpg)
1821{
1822 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1823
Andy Groverb7eec2c2013-10-09 11:05:57 -07001824 return tpg->tpg_attrib.default_cmdsn_depth;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001825}
1826
1827static int lio_tpg_check_demo_mode(struct se_portal_group *se_tpg)
1828{
1829 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1830
Andy Groverb7eec2c2013-10-09 11:05:57 -07001831 return tpg->tpg_attrib.generate_node_acls;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001832}
1833
1834static int lio_tpg_check_demo_mode_cache(struct se_portal_group *se_tpg)
1835{
1836 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1837
Andy Groverb7eec2c2013-10-09 11:05:57 -07001838 return tpg->tpg_attrib.cache_dynamic_acls;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001839}
1840
1841static int lio_tpg_check_demo_mode_write_protect(
1842 struct se_portal_group *se_tpg)
1843{
1844 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1845
Andy Groverb7eec2c2013-10-09 11:05:57 -07001846 return tpg->tpg_attrib.demo_mode_write_protect;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001847}
1848
1849static int lio_tpg_check_prod_mode_write_protect(
1850 struct se_portal_group *se_tpg)
1851{
1852 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1853
Andy Groverb7eec2c2013-10-09 11:05:57 -07001854 return tpg->tpg_attrib.prod_mode_write_protect;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001855}
1856
1857static void lio_tpg_release_fabric_acl(
1858 struct se_portal_group *se_tpg,
1859 struct se_node_acl *se_acl)
1860{
1861 struct iscsi_node_acl *acl = container_of(se_acl,
1862 struct iscsi_node_acl, se_node_acl);
1863 kfree(acl);
1864}
1865
1866/*
1867 * Called with spin_lock_bh(struct se_portal_group->session_lock) held..
1868 *
1869 * Also, this function calls iscsit_inc_session_usage_count() on the
1870 * struct iscsi_session in question.
1871 */
1872static int lio_tpg_shutdown_session(struct se_session *se_sess)
1873{
1874 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1875
1876 spin_lock(&sess->conn_lock);
1877 if (atomic_read(&sess->session_fall_back_to_erl0) ||
1878 atomic_read(&sess->session_logout) ||
1879 (sess->time2retain_timer_flags & ISCSI_TF_EXPIRED)) {
1880 spin_unlock(&sess->conn_lock);
1881 return 0;
1882 }
1883 atomic_set(&sess->session_reinstatement, 1);
1884 spin_unlock(&sess->conn_lock);
1885
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001886 iscsit_stop_time2retain_timer(sess);
Nicholas Bellinger99367f02012-02-27 01:43:32 -08001887 iscsit_stop_session(sess, 1, 1);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001888
1889 return 1;
1890}
1891
1892/*
1893 * Calls iscsit_dec_session_usage_count() as inverse of
1894 * lio_tpg_shutdown_session()
1895 */
1896static void lio_tpg_close_session(struct se_session *se_sess)
1897{
1898 struct iscsi_session *sess = se_sess->fabric_sess_ptr;
1899 /*
1900 * If the iSCSI Session for the iSCSI Initiator Node exists,
1901 * forcefully shutdown the iSCSI NEXUS.
1902 */
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001903 iscsit_close_session(sess);
1904}
1905
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001906static u32 lio_tpg_get_inst_index(struct se_portal_group *se_tpg)
1907{
1908 struct iscsi_portal_group *tpg = se_tpg->se_tpg_fabric_ptr;
1909
1910 return tpg->tpg_tiqn->tiqn_index;
1911}
1912
1913static void lio_set_default_node_attributes(struct se_node_acl *se_acl)
1914{
1915 struct iscsi_node_acl *acl = container_of(se_acl, struct iscsi_node_acl,
1916 se_node_acl);
1917
Andy Groverb7eec2c2013-10-09 11:05:57 -07001918 acl->node_attrib.nacl = acl;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001919 iscsit_set_default_node_attribues(acl);
1920}
1921
Nicholas Bellinger3e1c81a2013-03-06 22:18:24 -08001922static int lio_check_stop_free(struct se_cmd *se_cmd)
1923{
1924 return target_put_sess_cmd(se_cmd->se_sess, se_cmd);
1925}
1926
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001927static void lio_release_cmd(struct se_cmd *se_cmd)
1928{
1929 struct iscsi_cmd *cmd = container_of(se_cmd, struct iscsi_cmd, se_cmd);
1930
Nicholas Bellingercdb72662013-03-06 22:09:17 -08001931 pr_debug("Entering lio_release_cmd for se_cmd: %p\n", se_cmd);
Nicholas Bellingerd703ce22013-08-17 14:27:56 -07001932 iscsit_release_cmd(cmd);
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001933}
1934
1935/* End functions for target_core_fabric_ops */
1936
1937int iscsi_target_register_configfs(void)
1938{
1939 struct target_fabric_configfs *fabric;
1940 int ret;
1941
1942 lio_target_fabric_configfs = NULL;
1943 fabric = target_fabric_configfs_init(THIS_MODULE, "iscsi");
1944 if (IS_ERR(fabric)) {
1945 pr_err("target_fabric_configfs_init() for"
1946 " LIO-Target failed!\n");
1947 return PTR_ERR(fabric);
1948 }
1949 /*
1950 * Setup the fabric API of function pointers used by target_core_mod..
1951 */
1952 fabric->tf_ops.get_fabric_name = &iscsi_get_fabric_name;
1953 fabric->tf_ops.get_fabric_proto_ident = &iscsi_get_fabric_proto_ident;
1954 fabric->tf_ops.tpg_get_wwn = &lio_tpg_get_endpoint_wwn;
1955 fabric->tf_ops.tpg_get_tag = &lio_tpg_get_tag;
1956 fabric->tf_ops.tpg_get_default_depth = &lio_tpg_get_default_depth;
1957 fabric->tf_ops.tpg_get_pr_transport_id = &iscsi_get_pr_transport_id;
1958 fabric->tf_ops.tpg_get_pr_transport_id_len =
1959 &iscsi_get_pr_transport_id_len;
1960 fabric->tf_ops.tpg_parse_pr_out_transport_id =
1961 &iscsi_parse_pr_out_transport_id;
1962 fabric->tf_ops.tpg_check_demo_mode = &lio_tpg_check_demo_mode;
1963 fabric->tf_ops.tpg_check_demo_mode_cache =
1964 &lio_tpg_check_demo_mode_cache;
1965 fabric->tf_ops.tpg_check_demo_mode_write_protect =
1966 &lio_tpg_check_demo_mode_write_protect;
1967 fabric->tf_ops.tpg_check_prod_mode_write_protect =
1968 &lio_tpg_check_prod_mode_write_protect;
1969 fabric->tf_ops.tpg_alloc_fabric_acl = &lio_tpg_alloc_fabric_acl;
1970 fabric->tf_ops.tpg_release_fabric_acl = &lio_tpg_release_fabric_acl;
1971 fabric->tf_ops.tpg_get_inst_index = &lio_tpg_get_inst_index;
Nicholas Bellinger3e1c81a2013-03-06 22:18:24 -08001972 fabric->tf_ops.check_stop_free = &lio_check_stop_free,
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001973 fabric->tf_ops.release_cmd = &lio_release_cmd;
1974 fabric->tf_ops.shutdown_session = &lio_tpg_shutdown_session;
1975 fabric->tf_ops.close_session = &lio_tpg_close_session;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001976 fabric->tf_ops.sess_get_index = &lio_sess_get_index;
1977 fabric->tf_ops.sess_get_initiator_sid = &lio_sess_get_initiator_sid;
1978 fabric->tf_ops.write_pending = &lio_write_pending;
1979 fabric->tf_ops.write_pending_status = &lio_write_pending_status;
1980 fabric->tf_ops.set_default_node_attributes =
1981 &lio_set_default_node_attributes;
1982 fabric->tf_ops.get_task_tag = &iscsi_get_task_tag;
1983 fabric->tf_ops.get_cmd_state = &iscsi_get_cmd_state;
1984 fabric->tf_ops.queue_data_in = &lio_queue_data_in;
1985 fabric->tf_ops.queue_status = &lio_queue_status;
1986 fabric->tf_ops.queue_tm_rsp = &lio_queue_tm_rsp;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00001987 /*
1988 * Setup function pointers for generic logic in target_core_fabric_configfs.c
1989 */
1990 fabric->tf_ops.fabric_make_wwn = &lio_target_call_coreaddtiqn;
1991 fabric->tf_ops.fabric_drop_wwn = &lio_target_call_coredeltiqn;
1992 fabric->tf_ops.fabric_make_tpg = &lio_target_tiqn_addtpg;
1993 fabric->tf_ops.fabric_drop_tpg = &lio_target_tiqn_deltpg;
1994 fabric->tf_ops.fabric_post_link = NULL;
1995 fabric->tf_ops.fabric_pre_unlink = NULL;
1996 fabric->tf_ops.fabric_make_np = &lio_target_call_addnptotpg;
1997 fabric->tf_ops.fabric_drop_np = &lio_target_call_delnpfromtpg;
1998 fabric->tf_ops.fabric_make_nodeacl = &lio_target_make_nodeacl;
1999 fabric->tf_ops.fabric_drop_nodeacl = &lio_target_drop_nodeacl;
2000 /*
2001 * Setup default attribute lists for various fabric->tf_cit_tmpl
2002 * sturct config_item_type's
2003 */
Andy Groverd80e224d2013-10-09 11:05:56 -07002004 fabric->tf_cit_tmpl.tfc_discovery_cit.ct_attrs = lio_target_discovery_auth_attrs;
2005 fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = lio_target_wwn_attrs;
2006 fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = lio_target_tpg_attrs;
2007 fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = lio_target_tpg_attrib_attrs;
2008 fabric->tf_cit_tmpl.tfc_tpg_auth_cit.ct_attrs = lio_target_tpg_auth_attrs;
2009 fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = lio_target_tpg_param_attrs;
2010 fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = lio_target_portal_attrs;
2011 fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = lio_target_initiator_attrs;
2012 fabric->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit.ct_attrs = lio_target_nacl_attrib_attrs;
2013 fabric->tf_cit_tmpl.tfc_tpg_nacl_auth_cit.ct_attrs = lio_target_nacl_auth_attrs;
2014 fabric->tf_cit_tmpl.tfc_tpg_nacl_param_cit.ct_attrs = lio_target_nacl_param_attrs;
Nicholas Bellingere48354c2011-07-23 06:43:04 +00002015
2016 ret = target_fabric_configfs_register(fabric);
2017 if (ret < 0) {
2018 pr_err("target_fabric_configfs_register() for"
2019 " LIO-Target failed!\n");
2020 target_fabric_configfs_free(fabric);
2021 return ret;
2022 }
2023
2024 lio_target_fabric_configfs = fabric;
2025 pr_debug("LIO_TARGET[0] - Set fabric ->"
2026 " lio_target_fabric_configfs\n");
2027 return 0;
2028}
2029
2030
2031void iscsi_target_deregister_configfs(void)
2032{
2033 if (!lio_target_fabric_configfs)
2034 return;
2035 /*
2036 * Shutdown discovery sessions and disable discovery TPG
2037 */
2038 if (iscsit_global->discovery_tpg)
2039 iscsit_tpg_disable_portal_group(iscsit_global->discovery_tpg, 1);
2040
2041 target_fabric_configfs_deregister(lio_target_fabric_configfs);
2042 lio_target_fabric_configfs = NULL;
2043 pr_debug("LIO_TARGET[0] - Cleared"
2044 " lio_target_fabric_configfs\n");
2045}