Merge tag 'for-3.6-rc6' of git://gitorious.org/linux-pwm/linux-pwm
[deliverable/linux.git] / drivers / target / iscsi / iscsi_target_login.c
1 /*******************************************************************************
2 * This file contains the login functions used by the iSCSI Target driver.
3 *
4 * \u00a9 Copyright 2007-2011 RisingTide Systems LLC.
5 *
6 * Licensed to the Linux Foundation under the General Public License (GPL) version 2.
7 *
8 * Author: Nicholas A. Bellinger <nab@linux-iscsi.org>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 ******************************************************************************/
20
21 #include <linux/string.h>
22 #include <linux/kthread.h>
23 #include <linux/crypto.h>
24 #include <linux/idr.h>
25 #include <scsi/iscsi_proto.h>
26 #include <target/target_core_base.h>
27 #include <target/target_core_fabric.h>
28
29 #include "iscsi_target_core.h"
30 #include "iscsi_target_tq.h"
31 #include "iscsi_target_device.h"
32 #include "iscsi_target_nego.h"
33 #include "iscsi_target_erl0.h"
34 #include "iscsi_target_erl2.h"
35 #include "iscsi_target_login.h"
36 #include "iscsi_target_stat.h"
37 #include "iscsi_target_tpg.h"
38 #include "iscsi_target_util.h"
39 #include "iscsi_target.h"
40 #include "iscsi_target_parameters.h"
41
42 extern struct idr sess_idr;
43 extern struct mutex auth_id_lock;
44 extern spinlock_t sess_idr_lock;
45
46 static int iscsi_login_init_conn(struct iscsi_conn *conn)
47 {
48 INIT_LIST_HEAD(&conn->conn_list);
49 INIT_LIST_HEAD(&conn->conn_cmd_list);
50 INIT_LIST_HEAD(&conn->immed_queue_list);
51 INIT_LIST_HEAD(&conn->response_queue_list);
52 init_completion(&conn->conn_post_wait_comp);
53 init_completion(&conn->conn_wait_comp);
54 init_completion(&conn->conn_wait_rcfr_comp);
55 init_completion(&conn->conn_waiting_on_uc_comp);
56 init_completion(&conn->conn_logout_comp);
57 init_completion(&conn->rx_half_close_comp);
58 init_completion(&conn->tx_half_close_comp);
59 spin_lock_init(&conn->cmd_lock);
60 spin_lock_init(&conn->conn_usage_lock);
61 spin_lock_init(&conn->immed_queue_lock);
62 spin_lock_init(&conn->nopin_timer_lock);
63 spin_lock_init(&conn->response_queue_lock);
64 spin_lock_init(&conn->state_lock);
65
66 if (!zalloc_cpumask_var(&conn->conn_cpumask, GFP_KERNEL)) {
67 pr_err("Unable to allocate conn->conn_cpumask\n");
68 return -ENOMEM;
69 }
70
71 return 0;
72 }
73
74 /*
75 * Used by iscsi_target_nego.c:iscsi_target_locate_portal() to setup
76 * per struct iscsi_conn libcrypto contexts for crc32c and crc32-intel
77 */
78 int iscsi_login_setup_crypto(struct iscsi_conn *conn)
79 {
80 /*
81 * Setup slicing by CRC32C algorithm for RX and TX libcrypto contexts
82 * which will default to crc32c_intel.ko for cpu_has_xmm4_2, or fallback
83 * to software 1x8 byte slicing from crc32c.ko
84 */
85 conn->conn_rx_hash.flags = 0;
86 conn->conn_rx_hash.tfm = crypto_alloc_hash("crc32c", 0,
87 CRYPTO_ALG_ASYNC);
88 if (IS_ERR(conn->conn_rx_hash.tfm)) {
89 pr_err("crypto_alloc_hash() failed for conn_rx_tfm\n");
90 return -ENOMEM;
91 }
92
93 conn->conn_tx_hash.flags = 0;
94 conn->conn_tx_hash.tfm = crypto_alloc_hash("crc32c", 0,
95 CRYPTO_ALG_ASYNC);
96 if (IS_ERR(conn->conn_tx_hash.tfm)) {
97 pr_err("crypto_alloc_hash() failed for conn_tx_tfm\n");
98 crypto_free_hash(conn->conn_rx_hash.tfm);
99 return -ENOMEM;
100 }
101
102 return 0;
103 }
104
105 static int iscsi_login_check_initiator_version(
106 struct iscsi_conn *conn,
107 u8 version_max,
108 u8 version_min)
109 {
110 if ((version_max != 0x00) || (version_min != 0x00)) {
111 pr_err("Unsupported iSCSI IETF Pre-RFC Revision,"
112 " version Min/Max 0x%02x/0x%02x, rejecting login.\n",
113 version_min, version_max);
114 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_INITIATOR_ERR,
115 ISCSI_LOGIN_STATUS_NO_VERSION);
116 return -1;
117 }
118
119 return 0;
120 }
121
122 int iscsi_check_for_session_reinstatement(struct iscsi_conn *conn)
123 {
124 int sessiontype;
125 struct iscsi_param *initiatorname_param = NULL, *sessiontype_param = NULL;
126 struct iscsi_portal_group *tpg = conn->tpg;
127 struct iscsi_session *sess = NULL, *sess_p = NULL;
128 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
129 struct se_session *se_sess, *se_sess_tmp;
130
131 initiatorname_param = iscsi_find_param_from_key(
132 INITIATORNAME, conn->param_list);
133 if (!initiatorname_param)
134 return -1;
135
136 sessiontype_param = iscsi_find_param_from_key(
137 SESSIONTYPE, conn->param_list);
138 if (!sessiontype_param)
139 return -1;
140
141 sessiontype = (strncmp(sessiontype_param->value, NORMAL, 6)) ? 1 : 0;
142
143 spin_lock_bh(&se_tpg->session_lock);
144 list_for_each_entry_safe(se_sess, se_sess_tmp, &se_tpg->tpg_sess_list,
145 sess_list) {
146
147 sess_p = se_sess->fabric_sess_ptr;
148 spin_lock(&sess_p->conn_lock);
149 if (atomic_read(&sess_p->session_fall_back_to_erl0) ||
150 atomic_read(&sess_p->session_logout) ||
151 (sess_p->time2retain_timer_flags & ISCSI_TF_EXPIRED)) {
152 spin_unlock(&sess_p->conn_lock);
153 continue;
154 }
155 if (!memcmp(sess_p->isid, conn->sess->isid, 6) &&
156 (!strcmp(sess_p->sess_ops->InitiatorName,
157 initiatorname_param->value) &&
158 (sess_p->sess_ops->SessionType == sessiontype))) {
159 atomic_set(&sess_p->session_reinstatement, 1);
160 spin_unlock(&sess_p->conn_lock);
161 iscsit_inc_session_usage_count(sess_p);
162 iscsit_stop_time2retain_timer(sess_p);
163 sess = sess_p;
164 break;
165 }
166 spin_unlock(&sess_p->conn_lock);
167 }
168 spin_unlock_bh(&se_tpg->session_lock);
169 /*
170 * If the Time2Retain handler has expired, the session is already gone.
171 */
172 if (!sess)
173 return 0;
174
175 pr_debug("%s iSCSI Session SID %u is still active for %s,"
176 " preforming session reinstatement.\n", (sessiontype) ?
177 "Discovery" : "Normal", sess->sid,
178 sess->sess_ops->InitiatorName);
179
180 spin_lock_bh(&sess->conn_lock);
181 if (sess->session_state == TARG_SESS_STATE_FAILED) {
182 spin_unlock_bh(&sess->conn_lock);
183 iscsit_dec_session_usage_count(sess);
184 target_put_session(sess->se_sess);
185 return 0;
186 }
187 spin_unlock_bh(&sess->conn_lock);
188
189 iscsit_stop_session(sess, 1, 1);
190 iscsit_dec_session_usage_count(sess);
191
192 target_put_session(sess->se_sess);
193 return 0;
194 }
195
196 static void iscsi_login_set_conn_values(
197 struct iscsi_session *sess,
198 struct iscsi_conn *conn,
199 u16 cid)
200 {
201 conn->sess = sess;
202 conn->cid = cid;
203 /*
204 * Generate a random Status sequence number (statsn) for the new
205 * iSCSI connection.
206 */
207 get_random_bytes(&conn->stat_sn, sizeof(u32));
208
209 mutex_lock(&auth_id_lock);
210 conn->auth_id = iscsit_global->auth_id++;
211 mutex_unlock(&auth_id_lock);
212 }
213
214 /*
215 * This is the leading connection of a new session,
216 * or session reinstatement.
217 */
218 static int iscsi_login_zero_tsih_s1(
219 struct iscsi_conn *conn,
220 unsigned char *buf)
221 {
222 struct iscsi_session *sess = NULL;
223 struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf;
224 int ret;
225
226 sess = kzalloc(sizeof(struct iscsi_session), GFP_KERNEL);
227 if (!sess) {
228 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
229 ISCSI_LOGIN_STATUS_NO_RESOURCES);
230 pr_err("Could not allocate memory for session\n");
231 return -ENOMEM;
232 }
233
234 iscsi_login_set_conn_values(sess, conn, pdu->cid);
235 sess->init_task_tag = pdu->itt;
236 memcpy(&sess->isid, pdu->isid, 6);
237 sess->exp_cmd_sn = pdu->cmdsn;
238 INIT_LIST_HEAD(&sess->sess_conn_list);
239 INIT_LIST_HEAD(&sess->sess_ooo_cmdsn_list);
240 INIT_LIST_HEAD(&sess->cr_active_list);
241 INIT_LIST_HEAD(&sess->cr_inactive_list);
242 init_completion(&sess->async_msg_comp);
243 init_completion(&sess->reinstatement_comp);
244 init_completion(&sess->session_wait_comp);
245 init_completion(&sess->session_waiting_on_uc_comp);
246 mutex_init(&sess->cmdsn_mutex);
247 spin_lock_init(&sess->conn_lock);
248 spin_lock_init(&sess->cr_a_lock);
249 spin_lock_init(&sess->cr_i_lock);
250 spin_lock_init(&sess->session_usage_lock);
251 spin_lock_init(&sess->ttt_lock);
252
253 if (!idr_pre_get(&sess_idr, GFP_KERNEL)) {
254 pr_err("idr_pre_get() for sess_idr failed\n");
255 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
256 ISCSI_LOGIN_STATUS_NO_RESOURCES);
257 kfree(sess);
258 return -ENOMEM;
259 }
260 spin_lock(&sess_idr_lock);
261 ret = idr_get_new(&sess_idr, NULL, &sess->session_index);
262 spin_unlock(&sess_idr_lock);
263
264 if (ret < 0) {
265 pr_err("idr_get_new() for sess_idr failed\n");
266 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
267 ISCSI_LOGIN_STATUS_NO_RESOURCES);
268 kfree(sess);
269 return -ENOMEM;
270 }
271
272 sess->creation_time = get_jiffies_64();
273 spin_lock_init(&sess->session_stats_lock);
274 /*
275 * The FFP CmdSN window values will be allocated from the TPG's
276 * Initiator Node's ACL once the login has been successfully completed.
277 */
278 sess->max_cmd_sn = pdu->cmdsn;
279
280 sess->sess_ops = kzalloc(sizeof(struct iscsi_sess_ops), GFP_KERNEL);
281 if (!sess->sess_ops) {
282 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
283 ISCSI_LOGIN_STATUS_NO_RESOURCES);
284 pr_err("Unable to allocate memory for"
285 " struct iscsi_sess_ops.\n");
286 kfree(sess);
287 return -ENOMEM;
288 }
289
290 sess->se_sess = transport_init_session();
291 if (IS_ERR(sess->se_sess)) {
292 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
293 ISCSI_LOGIN_STATUS_NO_RESOURCES);
294 kfree(sess);
295 return -ENOMEM;
296 }
297
298 return 0;
299 }
300
301 static int iscsi_login_zero_tsih_s2(
302 struct iscsi_conn *conn)
303 {
304 struct iscsi_node_attrib *na;
305 struct iscsi_session *sess = conn->sess;
306 unsigned char buf[32];
307
308 sess->tpg = conn->tpg;
309
310 /*
311 * Assign a new TPG Session Handle. Note this is protected with
312 * struct iscsi_portal_group->np_login_sem from iscsit_access_np().
313 */
314 sess->tsih = ++ISCSI_TPG_S(sess)->ntsih;
315 if (!sess->tsih)
316 sess->tsih = ++ISCSI_TPG_S(sess)->ntsih;
317
318 /*
319 * Create the default params from user defined values..
320 */
321 if (iscsi_copy_param_list(&conn->param_list,
322 ISCSI_TPG_C(conn)->param_list, 1) < 0) {
323 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
324 ISCSI_LOGIN_STATUS_NO_RESOURCES);
325 return -1;
326 }
327
328 iscsi_set_keys_to_negotiate(0, conn->param_list);
329
330 if (sess->sess_ops->SessionType)
331 return iscsi_set_keys_irrelevant_for_discovery(
332 conn->param_list);
333
334 na = iscsit_tpg_get_node_attrib(sess);
335
336 /*
337 * Need to send TargetPortalGroupTag back in first login response
338 * on any iSCSI connection where the Initiator provides TargetName.
339 * See 5.3.1. Login Phase Start
340 *
341 * In our case, we have already located the struct iscsi_tiqn at this point.
342 */
343 memset(buf, 0, 32);
344 sprintf(buf, "TargetPortalGroupTag=%hu", ISCSI_TPG_S(sess)->tpgt);
345 if (iscsi_change_param_value(buf, conn->param_list, 0) < 0) {
346 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
347 ISCSI_LOGIN_STATUS_NO_RESOURCES);
348 return -1;
349 }
350
351 /*
352 * Workaround for Initiators that have broken connection recovery logic.
353 *
354 * "We would really like to get rid of this." Linux-iSCSI.org team
355 */
356 memset(buf, 0, 32);
357 sprintf(buf, "ErrorRecoveryLevel=%d", na->default_erl);
358 if (iscsi_change_param_value(buf, conn->param_list, 0) < 0) {
359 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
360 ISCSI_LOGIN_STATUS_NO_RESOURCES);
361 return -1;
362 }
363
364 if (iscsi_login_disable_FIM_keys(conn->param_list, conn) < 0)
365 return -1;
366
367 return 0;
368 }
369
370 /*
371 * Remove PSTATE_NEGOTIATE for the four FIM related keys.
372 * The Initiator node will be able to enable FIM by proposing them itself.
373 */
374 int iscsi_login_disable_FIM_keys(
375 struct iscsi_param_list *param_list,
376 struct iscsi_conn *conn)
377 {
378 struct iscsi_param *param;
379
380 param = iscsi_find_param_from_key("OFMarker", param_list);
381 if (!param) {
382 pr_err("iscsi_find_param_from_key() for"
383 " OFMarker failed\n");
384 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
385 ISCSI_LOGIN_STATUS_NO_RESOURCES);
386 return -1;
387 }
388 param->state &= ~PSTATE_NEGOTIATE;
389
390 param = iscsi_find_param_from_key("OFMarkInt", param_list);
391 if (!param) {
392 pr_err("iscsi_find_param_from_key() for"
393 " IFMarker failed\n");
394 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
395 ISCSI_LOGIN_STATUS_NO_RESOURCES);
396 return -1;
397 }
398 param->state &= ~PSTATE_NEGOTIATE;
399
400 param = iscsi_find_param_from_key("IFMarker", param_list);
401 if (!param) {
402 pr_err("iscsi_find_param_from_key() for"
403 " IFMarker failed\n");
404 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
405 ISCSI_LOGIN_STATUS_NO_RESOURCES);
406 return -1;
407 }
408 param->state &= ~PSTATE_NEGOTIATE;
409
410 param = iscsi_find_param_from_key("IFMarkInt", param_list);
411 if (!param) {
412 pr_err("iscsi_find_param_from_key() for"
413 " IFMarker failed\n");
414 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
415 ISCSI_LOGIN_STATUS_NO_RESOURCES);
416 return -1;
417 }
418 param->state &= ~PSTATE_NEGOTIATE;
419
420 return 0;
421 }
422
423 static int iscsi_login_non_zero_tsih_s1(
424 struct iscsi_conn *conn,
425 unsigned char *buf)
426 {
427 struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf;
428
429 iscsi_login_set_conn_values(NULL, conn, pdu->cid);
430 return 0;
431 }
432
433 /*
434 * Add a new connection to an existing session.
435 */
436 static int iscsi_login_non_zero_tsih_s2(
437 struct iscsi_conn *conn,
438 unsigned char *buf)
439 {
440 struct iscsi_portal_group *tpg = conn->tpg;
441 struct iscsi_session *sess = NULL, *sess_p = NULL;
442 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
443 struct se_session *se_sess, *se_sess_tmp;
444 struct iscsi_login_req *pdu = (struct iscsi_login_req *)buf;
445
446 spin_lock_bh(&se_tpg->session_lock);
447 list_for_each_entry_safe(se_sess, se_sess_tmp, &se_tpg->tpg_sess_list,
448 sess_list) {
449
450 sess_p = (struct iscsi_session *)se_sess->fabric_sess_ptr;
451 if (atomic_read(&sess_p->session_fall_back_to_erl0) ||
452 atomic_read(&sess_p->session_logout) ||
453 (sess_p->time2retain_timer_flags & ISCSI_TF_EXPIRED))
454 continue;
455 if (!memcmp(sess_p->isid, pdu->isid, 6) &&
456 (sess_p->tsih == pdu->tsih)) {
457 iscsit_inc_session_usage_count(sess_p);
458 iscsit_stop_time2retain_timer(sess_p);
459 sess = sess_p;
460 break;
461 }
462 }
463 spin_unlock_bh(&se_tpg->session_lock);
464
465 /*
466 * If the Time2Retain handler has expired, the session is already gone.
467 */
468 if (!sess) {
469 pr_err("Initiator attempting to add a connection to"
470 " a non-existent session, rejecting iSCSI Login.\n");
471 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_INITIATOR_ERR,
472 ISCSI_LOGIN_STATUS_NO_SESSION);
473 return -1;
474 }
475
476 /*
477 * Stop the Time2Retain timer if this is a failed session, we restart
478 * the timer if the login is not successful.
479 */
480 spin_lock_bh(&sess->conn_lock);
481 if (sess->session_state == TARG_SESS_STATE_FAILED)
482 atomic_set(&sess->session_continuation, 1);
483 spin_unlock_bh(&sess->conn_lock);
484
485 iscsi_login_set_conn_values(sess, conn, pdu->cid);
486
487 if (iscsi_copy_param_list(&conn->param_list,
488 ISCSI_TPG_C(conn)->param_list, 0) < 0) {
489 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
490 ISCSI_LOGIN_STATUS_NO_RESOURCES);
491 return -1;
492 }
493
494 iscsi_set_keys_to_negotiate(0, conn->param_list);
495 /*
496 * Need to send TargetPortalGroupTag back in first login response
497 * on any iSCSI connection where the Initiator provides TargetName.
498 * See 5.3.1. Login Phase Start
499 *
500 * In our case, we have already located the struct iscsi_tiqn at this point.
501 */
502 memset(buf, 0, 32);
503 sprintf(buf, "TargetPortalGroupTag=%hu", ISCSI_TPG_S(sess)->tpgt);
504 if (iscsi_change_param_value(buf, conn->param_list, 0) < 0) {
505 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
506 ISCSI_LOGIN_STATUS_NO_RESOURCES);
507 return -1;
508 }
509
510 return iscsi_login_disable_FIM_keys(conn->param_list, conn);
511 }
512
513 int iscsi_login_post_auth_non_zero_tsih(
514 struct iscsi_conn *conn,
515 u16 cid,
516 u32 exp_statsn)
517 {
518 struct iscsi_conn *conn_ptr = NULL;
519 struct iscsi_conn_recovery *cr = NULL;
520 struct iscsi_session *sess = conn->sess;
521
522 /*
523 * By following item 5 in the login table, if we have found
524 * an existing ISID and a valid/existing TSIH and an existing
525 * CID we do connection reinstatement. Currently we dont not
526 * support it so we send back an non-zero status class to the
527 * initiator and release the new connection.
528 */
529 conn_ptr = iscsit_get_conn_from_cid_rcfr(sess, cid);
530 if (conn_ptr) {
531 pr_err("Connection exists with CID %hu for %s,"
532 " performing connection reinstatement.\n",
533 conn_ptr->cid, sess->sess_ops->InitiatorName);
534
535 iscsit_connection_reinstatement_rcfr(conn_ptr);
536 iscsit_dec_conn_usage_count(conn_ptr);
537 }
538
539 /*
540 * Check for any connection recovery entires containing CID.
541 * We use the original ExpStatSN sent in the first login request
542 * to acknowledge commands for the failed connection.
543 *
544 * Also note that an explict logout may have already been sent,
545 * but the response may not be sent due to additional connection
546 * loss.
547 */
548 if (sess->sess_ops->ErrorRecoveryLevel == 2) {
549 cr = iscsit_get_inactive_connection_recovery_entry(
550 sess, cid);
551 if (cr) {
552 pr_debug("Performing implicit logout"
553 " for connection recovery on CID: %hu\n",
554 conn->cid);
555 iscsit_discard_cr_cmds_by_expstatsn(cr, exp_statsn);
556 }
557 }
558
559 /*
560 * Else we follow item 4 from the login table in that we have
561 * found an existing ISID and a valid/existing TSIH and a new
562 * CID we go ahead and continue to add a new connection to the
563 * session.
564 */
565 pr_debug("Adding CID %hu to existing session for %s.\n",
566 cid, sess->sess_ops->InitiatorName);
567
568 if ((atomic_read(&sess->nconn) + 1) > sess->sess_ops->MaxConnections) {
569 pr_err("Adding additional connection to this session"
570 " would exceed MaxConnections %d, login failed.\n",
571 sess->sess_ops->MaxConnections);
572 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_INITIATOR_ERR,
573 ISCSI_LOGIN_STATUS_ISID_ERROR);
574 return -1;
575 }
576
577 return 0;
578 }
579
580 static void iscsi_post_login_start_timers(struct iscsi_conn *conn)
581 {
582 struct iscsi_session *sess = conn->sess;
583
584 if (!sess->sess_ops->SessionType)
585 iscsit_start_nopin_timer(conn);
586 }
587
588 static int iscsi_post_login_handler(
589 struct iscsi_np *np,
590 struct iscsi_conn *conn,
591 u8 zero_tsih)
592 {
593 int stop_timer = 0;
594 struct iscsi_session *sess = conn->sess;
595 struct se_session *se_sess = sess->se_sess;
596 struct iscsi_portal_group *tpg = ISCSI_TPG_S(sess);
597 struct se_portal_group *se_tpg = &tpg->tpg_se_tpg;
598 struct iscsi_thread_set *ts;
599
600 iscsit_inc_conn_usage_count(conn);
601
602 iscsit_collect_login_stats(conn, ISCSI_STATUS_CLS_SUCCESS,
603 ISCSI_LOGIN_STATUS_ACCEPT);
604
605 pr_debug("Moving to TARG_CONN_STATE_LOGGED_IN.\n");
606 conn->conn_state = TARG_CONN_STATE_LOGGED_IN;
607
608 iscsi_set_connection_parameters(conn->conn_ops, conn->param_list);
609 iscsit_set_sync_and_steering_values(conn);
610 /*
611 * SCSI Initiator -> SCSI Target Port Mapping
612 */
613 ts = iscsi_get_thread_set();
614 if (!zero_tsih) {
615 iscsi_set_session_parameters(sess->sess_ops,
616 conn->param_list, 0);
617 iscsi_release_param_list(conn->param_list);
618 conn->param_list = NULL;
619
620 spin_lock_bh(&sess->conn_lock);
621 atomic_set(&sess->session_continuation, 0);
622 if (sess->session_state == TARG_SESS_STATE_FAILED) {
623 pr_debug("Moving to"
624 " TARG_SESS_STATE_LOGGED_IN.\n");
625 sess->session_state = TARG_SESS_STATE_LOGGED_IN;
626 stop_timer = 1;
627 }
628
629 pr_debug("iSCSI Login successful on CID: %hu from %s to"
630 " %s:%hu,%hu\n", conn->cid, conn->login_ip,
631 conn->local_ip, conn->local_port, tpg->tpgt);
632
633 list_add_tail(&conn->conn_list, &sess->sess_conn_list);
634 atomic_inc(&sess->nconn);
635 pr_debug("Incremented iSCSI Connection count to %hu"
636 " from node: %s\n", atomic_read(&sess->nconn),
637 sess->sess_ops->InitiatorName);
638 spin_unlock_bh(&sess->conn_lock);
639
640 iscsi_post_login_start_timers(conn);
641 iscsi_activate_thread_set(conn, ts);
642 /*
643 * Determine CPU mask to ensure connection's RX and TX kthreads
644 * are scheduled on the same CPU.
645 */
646 iscsit_thread_get_cpumask(conn);
647 conn->conn_rx_reset_cpumask = 1;
648 conn->conn_tx_reset_cpumask = 1;
649
650 iscsit_dec_conn_usage_count(conn);
651 if (stop_timer) {
652 spin_lock_bh(&se_tpg->session_lock);
653 iscsit_stop_time2retain_timer(sess);
654 spin_unlock_bh(&se_tpg->session_lock);
655 }
656 iscsit_dec_session_usage_count(sess);
657 return 0;
658 }
659
660 iscsi_set_session_parameters(sess->sess_ops, conn->param_list, 1);
661 iscsi_release_param_list(conn->param_list);
662 conn->param_list = NULL;
663
664 iscsit_determine_maxcmdsn(sess);
665
666 spin_lock_bh(&se_tpg->session_lock);
667 __transport_register_session(&sess->tpg->tpg_se_tpg,
668 se_sess->se_node_acl, se_sess, sess);
669 pr_debug("Moving to TARG_SESS_STATE_LOGGED_IN.\n");
670 sess->session_state = TARG_SESS_STATE_LOGGED_IN;
671
672 pr_debug("iSCSI Login successful on CID: %hu from %s to %s:%hu,%hu\n",
673 conn->cid, conn->login_ip, conn->local_ip, conn->local_port,
674 tpg->tpgt);
675
676 spin_lock_bh(&sess->conn_lock);
677 list_add_tail(&conn->conn_list, &sess->sess_conn_list);
678 atomic_inc(&sess->nconn);
679 pr_debug("Incremented iSCSI Connection count to %hu from node:"
680 " %s\n", atomic_read(&sess->nconn),
681 sess->sess_ops->InitiatorName);
682 spin_unlock_bh(&sess->conn_lock);
683
684 sess->sid = tpg->sid++;
685 if (!sess->sid)
686 sess->sid = tpg->sid++;
687 pr_debug("Established iSCSI session from node: %s\n",
688 sess->sess_ops->InitiatorName);
689
690 tpg->nsessions++;
691 if (tpg->tpg_tiqn)
692 tpg->tpg_tiqn->tiqn_nsessions++;
693
694 pr_debug("Incremented number of active iSCSI sessions to %u on"
695 " iSCSI Target Portal Group: %hu\n", tpg->nsessions, tpg->tpgt);
696 spin_unlock_bh(&se_tpg->session_lock);
697
698 iscsi_post_login_start_timers(conn);
699 iscsi_activate_thread_set(conn, ts);
700 /*
701 * Determine CPU mask to ensure connection's RX and TX kthreads
702 * are scheduled on the same CPU.
703 */
704 iscsit_thread_get_cpumask(conn);
705 conn->conn_rx_reset_cpumask = 1;
706 conn->conn_tx_reset_cpumask = 1;
707
708 iscsit_dec_conn_usage_count(conn);
709
710 return 0;
711 }
712
713 static void iscsi_handle_login_thread_timeout(unsigned long data)
714 {
715 struct iscsi_np *np = (struct iscsi_np *) data;
716
717 spin_lock_bh(&np->np_thread_lock);
718 pr_err("iSCSI Login timeout on Network Portal %s:%hu\n",
719 np->np_ip, np->np_port);
720
721 if (np->np_login_timer_flags & ISCSI_TF_STOP) {
722 spin_unlock_bh(&np->np_thread_lock);
723 return;
724 }
725
726 if (np->np_thread)
727 send_sig(SIGINT, np->np_thread, 1);
728
729 np->np_login_timer_flags &= ~ISCSI_TF_RUNNING;
730 spin_unlock_bh(&np->np_thread_lock);
731 }
732
733 static void iscsi_start_login_thread_timer(struct iscsi_np *np)
734 {
735 /*
736 * This used the TA_LOGIN_TIMEOUT constant because at this
737 * point we do not have access to ISCSI_TPG_ATTRIB(tpg)->login_timeout
738 */
739 spin_lock_bh(&np->np_thread_lock);
740 init_timer(&np->np_login_timer);
741 np->np_login_timer.expires = (get_jiffies_64() + TA_LOGIN_TIMEOUT * HZ);
742 np->np_login_timer.data = (unsigned long)np;
743 np->np_login_timer.function = iscsi_handle_login_thread_timeout;
744 np->np_login_timer_flags &= ~ISCSI_TF_STOP;
745 np->np_login_timer_flags |= ISCSI_TF_RUNNING;
746 add_timer(&np->np_login_timer);
747
748 pr_debug("Added timeout timer to iSCSI login request for"
749 " %u seconds.\n", TA_LOGIN_TIMEOUT);
750 spin_unlock_bh(&np->np_thread_lock);
751 }
752
753 static void iscsi_stop_login_thread_timer(struct iscsi_np *np)
754 {
755 spin_lock_bh(&np->np_thread_lock);
756 if (!(np->np_login_timer_flags & ISCSI_TF_RUNNING)) {
757 spin_unlock_bh(&np->np_thread_lock);
758 return;
759 }
760 np->np_login_timer_flags |= ISCSI_TF_STOP;
761 spin_unlock_bh(&np->np_thread_lock);
762
763 del_timer_sync(&np->np_login_timer);
764
765 spin_lock_bh(&np->np_thread_lock);
766 np->np_login_timer_flags &= ~ISCSI_TF_RUNNING;
767 spin_unlock_bh(&np->np_thread_lock);
768 }
769
770 int iscsi_target_setup_login_socket(
771 struct iscsi_np *np,
772 struct __kernel_sockaddr_storage *sockaddr)
773 {
774 struct socket *sock;
775 int backlog = 5, ret, opt = 0, len;
776
777 switch (np->np_network_transport) {
778 case ISCSI_TCP:
779 np->np_ip_proto = IPPROTO_TCP;
780 np->np_sock_type = SOCK_STREAM;
781 break;
782 case ISCSI_SCTP_TCP:
783 np->np_ip_proto = IPPROTO_SCTP;
784 np->np_sock_type = SOCK_STREAM;
785 break;
786 case ISCSI_SCTP_UDP:
787 np->np_ip_proto = IPPROTO_SCTP;
788 np->np_sock_type = SOCK_SEQPACKET;
789 break;
790 case ISCSI_IWARP_TCP:
791 case ISCSI_IWARP_SCTP:
792 case ISCSI_INFINIBAND:
793 default:
794 pr_err("Unsupported network_transport: %d\n",
795 np->np_network_transport);
796 return -EINVAL;
797 }
798
799 ret = sock_create(sockaddr->ss_family, np->np_sock_type,
800 np->np_ip_proto, &sock);
801 if (ret < 0) {
802 pr_err("sock_create() failed.\n");
803 return ret;
804 }
805 np->np_socket = sock;
806 /*
807 * Setup the np->np_sockaddr from the passed sockaddr setup
808 * in iscsi_target_configfs.c code..
809 */
810 memcpy(&np->np_sockaddr, sockaddr,
811 sizeof(struct __kernel_sockaddr_storage));
812
813 if (sockaddr->ss_family == AF_INET6)
814 len = sizeof(struct sockaddr_in6);
815 else
816 len = sizeof(struct sockaddr_in);
817 /*
818 * Set SO_REUSEADDR, and disable Nagel Algorithm with TCP_NODELAY.
819 */
820 /* FIXME: Someone please explain why this is endian-safe */
821 opt = 1;
822 if (np->np_network_transport == ISCSI_TCP) {
823 ret = kernel_setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
824 (char *)&opt, sizeof(opt));
825 if (ret < 0) {
826 pr_err("kernel_setsockopt() for TCP_NODELAY"
827 " failed: %d\n", ret);
828 goto fail;
829 }
830 }
831
832 /* FIXME: Someone please explain why this is endian-safe */
833 ret = kernel_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
834 (char *)&opt, sizeof(opt));
835 if (ret < 0) {
836 pr_err("kernel_setsockopt() for SO_REUSEADDR"
837 " failed\n");
838 goto fail;
839 }
840
841 ret = kernel_setsockopt(sock, IPPROTO_IP, IP_FREEBIND,
842 (char *)&opt, sizeof(opt));
843 if (ret < 0) {
844 pr_err("kernel_setsockopt() for IP_FREEBIND"
845 " failed\n");
846 goto fail;
847 }
848
849 ret = kernel_bind(sock, (struct sockaddr *)&np->np_sockaddr, len);
850 if (ret < 0) {
851 pr_err("kernel_bind() failed: %d\n", ret);
852 goto fail;
853 }
854
855 ret = kernel_listen(sock, backlog);
856 if (ret != 0) {
857 pr_err("kernel_listen() failed: %d\n", ret);
858 goto fail;
859 }
860
861 return 0;
862
863 fail:
864 np->np_socket = NULL;
865 if (sock)
866 sock_release(sock);
867 return ret;
868 }
869
870 static int __iscsi_target_login_thread(struct iscsi_np *np)
871 {
872 u8 buffer[ISCSI_HDR_LEN], iscsi_opcode, zero_tsih = 0;
873 int err, ret = 0, stop;
874 struct iscsi_conn *conn = NULL;
875 struct iscsi_login *login;
876 struct iscsi_portal_group *tpg = NULL;
877 struct socket *new_sock, *sock;
878 struct kvec iov;
879 struct iscsi_login_req *pdu;
880 struct sockaddr_in sock_in;
881 struct sockaddr_in6 sock_in6;
882
883 flush_signals(current);
884 sock = np->np_socket;
885
886 spin_lock_bh(&np->np_thread_lock);
887 if (np->np_thread_state == ISCSI_NP_THREAD_RESET) {
888 np->np_thread_state = ISCSI_NP_THREAD_ACTIVE;
889 complete(&np->np_restart_comp);
890 } else {
891 np->np_thread_state = ISCSI_NP_THREAD_ACTIVE;
892 }
893 spin_unlock_bh(&np->np_thread_lock);
894
895 if (kernel_accept(sock, &new_sock, 0) < 0) {
896 spin_lock_bh(&np->np_thread_lock);
897 if (np->np_thread_state == ISCSI_NP_THREAD_RESET) {
898 spin_unlock_bh(&np->np_thread_lock);
899 complete(&np->np_restart_comp);
900 /* Get another socket */
901 return 1;
902 }
903 spin_unlock_bh(&np->np_thread_lock);
904 goto out;
905 }
906 iscsi_start_login_thread_timer(np);
907
908 conn = kzalloc(sizeof(struct iscsi_conn), GFP_KERNEL);
909 if (!conn) {
910 pr_err("Could not allocate memory for"
911 " new connection\n");
912 sock_release(new_sock);
913 /* Get another socket */
914 return 1;
915 }
916
917 pr_debug("Moving to TARG_CONN_STATE_FREE.\n");
918 conn->conn_state = TARG_CONN_STATE_FREE;
919 conn->sock = new_sock;
920
921 pr_debug("Moving to TARG_CONN_STATE_XPT_UP.\n");
922 conn->conn_state = TARG_CONN_STATE_XPT_UP;
923
924 /*
925 * Allocate conn->conn_ops early as a failure calling
926 * iscsit_tx_login_rsp() below will call tx_data().
927 */
928 conn->conn_ops = kzalloc(sizeof(struct iscsi_conn_ops), GFP_KERNEL);
929 if (!conn->conn_ops) {
930 pr_err("Unable to allocate memory for"
931 " struct iscsi_conn_ops.\n");
932 goto new_sess_out;
933 }
934 /*
935 * Perform the remaining iSCSI connection initialization items..
936 */
937 if (iscsi_login_init_conn(conn) < 0)
938 goto new_sess_out;
939
940 memset(buffer, 0, ISCSI_HDR_LEN);
941 memset(&iov, 0, sizeof(struct kvec));
942 iov.iov_base = buffer;
943 iov.iov_len = ISCSI_HDR_LEN;
944
945 if (rx_data(conn, &iov, 1, ISCSI_HDR_LEN) <= 0) {
946 pr_err("rx_data() returned an error.\n");
947 goto new_sess_out;
948 }
949
950 iscsi_opcode = (buffer[0] & ISCSI_OPCODE_MASK);
951 if (!(iscsi_opcode & ISCSI_OP_LOGIN)) {
952 pr_err("First opcode is not login request,"
953 " failing login request.\n");
954 goto new_sess_out;
955 }
956
957 pdu = (struct iscsi_login_req *) buffer;
958 pdu->cid = be16_to_cpu(pdu->cid);
959 pdu->tsih = be16_to_cpu(pdu->tsih);
960 pdu->itt = be32_to_cpu(pdu->itt);
961 pdu->cmdsn = be32_to_cpu(pdu->cmdsn);
962 pdu->exp_statsn = be32_to_cpu(pdu->exp_statsn);
963 /*
964 * Used by iscsit_tx_login_rsp() for Login Resonses PDUs
965 * when Status-Class != 0.
966 */
967 conn->login_itt = pdu->itt;
968
969 spin_lock_bh(&np->np_thread_lock);
970 if (np->np_thread_state != ISCSI_NP_THREAD_ACTIVE) {
971 spin_unlock_bh(&np->np_thread_lock);
972 pr_err("iSCSI Network Portal on %s:%hu currently not"
973 " active.\n", np->np_ip, np->np_port);
974 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
975 ISCSI_LOGIN_STATUS_SVC_UNAVAILABLE);
976 goto new_sess_out;
977 }
978 spin_unlock_bh(&np->np_thread_lock);
979
980 if (np->np_sockaddr.ss_family == AF_INET6) {
981 memset(&sock_in6, 0, sizeof(struct sockaddr_in6));
982
983 if (conn->sock->ops->getname(conn->sock,
984 (struct sockaddr *)&sock_in6, &err, 1) < 0) {
985 pr_err("sock_ops->getname() failed.\n");
986 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
987 ISCSI_LOGIN_STATUS_TARGET_ERROR);
988 goto new_sess_out;
989 }
990 snprintf(conn->login_ip, sizeof(conn->login_ip), "%pI6c",
991 &sock_in6.sin6_addr.in6_u);
992 conn->login_port = ntohs(sock_in6.sin6_port);
993
994 if (conn->sock->ops->getname(conn->sock,
995 (struct sockaddr *)&sock_in6, &err, 0) < 0) {
996 pr_err("sock_ops->getname() failed.\n");
997 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
998 ISCSI_LOGIN_STATUS_TARGET_ERROR);
999 goto new_sess_out;
1000 }
1001 snprintf(conn->local_ip, sizeof(conn->local_ip), "%pI6c",
1002 &sock_in6.sin6_addr.in6_u);
1003 conn->local_port = ntohs(sock_in6.sin6_port);
1004
1005 } else {
1006 memset(&sock_in, 0, sizeof(struct sockaddr_in));
1007
1008 if (conn->sock->ops->getname(conn->sock,
1009 (struct sockaddr *)&sock_in, &err, 1) < 0) {
1010 pr_err("sock_ops->getname() failed.\n");
1011 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
1012 ISCSI_LOGIN_STATUS_TARGET_ERROR);
1013 goto new_sess_out;
1014 }
1015 sprintf(conn->login_ip, "%pI4", &sock_in.sin_addr.s_addr);
1016 conn->login_port = ntohs(sock_in.sin_port);
1017
1018 if (conn->sock->ops->getname(conn->sock,
1019 (struct sockaddr *)&sock_in, &err, 0) < 0) {
1020 pr_err("sock_ops->getname() failed.\n");
1021 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
1022 ISCSI_LOGIN_STATUS_TARGET_ERROR);
1023 goto new_sess_out;
1024 }
1025 sprintf(conn->local_ip, "%pI4", &sock_in.sin_addr.s_addr);
1026 conn->local_port = ntohs(sock_in.sin_port);
1027 }
1028
1029 conn->network_transport = np->np_network_transport;
1030
1031 pr_debug("Received iSCSI login request from %s on %s Network"
1032 " Portal %s:%hu\n", conn->login_ip,
1033 (conn->network_transport == ISCSI_TCP) ? "TCP" : "SCTP",
1034 conn->local_ip, conn->local_port);
1035
1036 pr_debug("Moving to TARG_CONN_STATE_IN_LOGIN.\n");
1037 conn->conn_state = TARG_CONN_STATE_IN_LOGIN;
1038
1039 if (iscsi_login_check_initiator_version(conn, pdu->max_version,
1040 pdu->min_version) < 0)
1041 goto new_sess_out;
1042
1043 zero_tsih = (pdu->tsih == 0x0000);
1044 if (zero_tsih) {
1045 /*
1046 * This is the leading connection of a new session.
1047 * We wait until after authentication to check for
1048 * session reinstatement.
1049 */
1050 if (iscsi_login_zero_tsih_s1(conn, buffer) < 0)
1051 goto new_sess_out;
1052 } else {
1053 /*
1054 * Add a new connection to an existing session.
1055 * We check for a non-existant session in
1056 * iscsi_login_non_zero_tsih_s2() below based
1057 * on ISID/TSIH, but wait until after authentication
1058 * to check for connection reinstatement, etc.
1059 */
1060 if (iscsi_login_non_zero_tsih_s1(conn, buffer) < 0)
1061 goto new_sess_out;
1062 }
1063
1064 /*
1065 * This will process the first login request, and call
1066 * iscsi_target_locate_portal(), and return a valid struct iscsi_login.
1067 */
1068 login = iscsi_target_init_negotiation(np, conn, buffer);
1069 if (!login) {
1070 tpg = conn->tpg;
1071 goto new_sess_out;
1072 }
1073
1074 tpg = conn->tpg;
1075 if (!tpg) {
1076 pr_err("Unable to locate struct iscsi_conn->tpg\n");
1077 goto new_sess_out;
1078 }
1079
1080 if (zero_tsih) {
1081 if (iscsi_login_zero_tsih_s2(conn) < 0) {
1082 iscsi_target_nego_release(login, conn);
1083 goto new_sess_out;
1084 }
1085 } else {
1086 if (iscsi_login_non_zero_tsih_s2(conn, buffer) < 0) {
1087 iscsi_target_nego_release(login, conn);
1088 goto old_sess_out;
1089 }
1090 }
1091
1092 if (iscsi_target_start_negotiation(login, conn) < 0)
1093 goto new_sess_out;
1094
1095 if (!conn->sess) {
1096 pr_err("struct iscsi_conn session pointer is NULL!\n");
1097 goto new_sess_out;
1098 }
1099
1100 iscsi_stop_login_thread_timer(np);
1101
1102 if (signal_pending(current))
1103 goto new_sess_out;
1104
1105 ret = iscsi_post_login_handler(np, conn, zero_tsih);
1106
1107 if (ret < 0)
1108 goto new_sess_out;
1109
1110 iscsit_deaccess_np(np, tpg);
1111 tpg = NULL;
1112 /* Get another socket */
1113 return 1;
1114
1115 new_sess_out:
1116 pr_err("iSCSI Login negotiation failed.\n");
1117 iscsit_collect_login_stats(conn, ISCSI_STATUS_CLS_INITIATOR_ERR,
1118 ISCSI_LOGIN_STATUS_INIT_ERR);
1119 if (!zero_tsih || !conn->sess)
1120 goto old_sess_out;
1121 if (conn->sess->se_sess)
1122 transport_free_session(conn->sess->se_sess);
1123 if (conn->sess->session_index != 0) {
1124 spin_lock_bh(&sess_idr_lock);
1125 idr_remove(&sess_idr, conn->sess->session_index);
1126 spin_unlock_bh(&sess_idr_lock);
1127 }
1128 if (conn->sess->sess_ops)
1129 kfree(conn->sess->sess_ops);
1130 if (conn->sess)
1131 kfree(conn->sess);
1132 old_sess_out:
1133 iscsi_stop_login_thread_timer(np);
1134 /*
1135 * If login negotiation fails check if the Time2Retain timer
1136 * needs to be restarted.
1137 */
1138 if (!zero_tsih && conn->sess) {
1139 spin_lock_bh(&conn->sess->conn_lock);
1140 if (conn->sess->session_state == TARG_SESS_STATE_FAILED) {
1141 struct se_portal_group *se_tpg =
1142 &ISCSI_TPG_C(conn)->tpg_se_tpg;
1143
1144 atomic_set(&conn->sess->session_continuation, 0);
1145 spin_unlock_bh(&conn->sess->conn_lock);
1146 spin_lock_bh(&se_tpg->session_lock);
1147 iscsit_start_time2retain_handler(conn->sess);
1148 spin_unlock_bh(&se_tpg->session_lock);
1149 } else
1150 spin_unlock_bh(&conn->sess->conn_lock);
1151 iscsit_dec_session_usage_count(conn->sess);
1152 }
1153
1154 if (!IS_ERR(conn->conn_rx_hash.tfm))
1155 crypto_free_hash(conn->conn_rx_hash.tfm);
1156 if (!IS_ERR(conn->conn_tx_hash.tfm))
1157 crypto_free_hash(conn->conn_tx_hash.tfm);
1158
1159 if (conn->conn_cpumask)
1160 free_cpumask_var(conn->conn_cpumask);
1161
1162 kfree(conn->conn_ops);
1163
1164 if (conn->param_list) {
1165 iscsi_release_param_list(conn->param_list);
1166 conn->param_list = NULL;
1167 }
1168 if (conn->sock)
1169 sock_release(conn->sock);
1170 kfree(conn);
1171
1172 if (tpg) {
1173 iscsit_deaccess_np(np, tpg);
1174 tpg = NULL;
1175 }
1176
1177 out:
1178 stop = kthread_should_stop();
1179 if (!stop && signal_pending(current)) {
1180 spin_lock_bh(&np->np_thread_lock);
1181 stop = (np->np_thread_state == ISCSI_NP_THREAD_SHUTDOWN);
1182 spin_unlock_bh(&np->np_thread_lock);
1183 }
1184 /* Wait for another socket.. */
1185 if (!stop)
1186 return 1;
1187
1188 iscsi_stop_login_thread_timer(np);
1189 spin_lock_bh(&np->np_thread_lock);
1190 np->np_thread_state = ISCSI_NP_THREAD_EXIT;
1191 spin_unlock_bh(&np->np_thread_lock);
1192 return 0;
1193 }
1194
1195 int iscsi_target_login_thread(void *arg)
1196 {
1197 struct iscsi_np *np = arg;
1198 int ret;
1199
1200 allow_signal(SIGINT);
1201
1202 while (!kthread_should_stop()) {
1203 ret = __iscsi_target_login_thread(np);
1204 /*
1205 * We break and exit here unless another sock_accept() call
1206 * is expected.
1207 */
1208 if (ret != 1)
1209 break;
1210 }
1211
1212 return 0;
1213 }
This page took 0.057087 seconds and 6 git commands to generate.