Commit baa4d64b authored by Nicholas Bellinger's avatar Nicholas Bellinger

iscsi-target: Initial traditional TCP conversion to iscsit_transport

This patch performs the initial conversion of existing traditional iscsi
to use iscsit_transport API callers.  This includes:

- iscsi-np cleanups for iscsit_transport_type
- Add iscsi-np transport calls w/ ->iscsit_setup_up() and ->iscsit_free_np()
- Convert login thread process context to use ->iscsit_accept_np() for
  connections with pre-allocated struct iscsi_conn
- Convert existing socket accept code to iscsit_accept_np()
- Convert login RX/TX callers to use ->iscsit_get_login_rx() and
  ->iscsit_put_login_tx() to exchange request/response PDUs
- Convert existing socket login RX/TX calls into iscsit_get_login_rx()
  and iscsit_put_login_tx()
- Change iscsit_close_connection() to invoke ->iscsit_free_conn() +
  iscsit_put_transport() calls.
- Add iscsit_register_transport() + iscsit_unregister_transport() calls
  to module init/exit

v4 changes:

- Add missing iscsit_put_transport() call in iscsi_target_setup_login_socket()
  failure case

v2 changes:

- Update module init/exit to use register_transport() + unregister_transport()
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 3f993063
...@@ -49,6 +49,8 @@ ...@@ -49,6 +49,8 @@
#include "iscsi_target_device.h" #include "iscsi_target_device.h"
#include "iscsi_target_stat.h" #include "iscsi_target_stat.h"
#include <target/iscsi/iscsi_transport.h>
static LIST_HEAD(g_tiqn_list); static LIST_HEAD(g_tiqn_list);
static LIST_HEAD(g_np_list); static LIST_HEAD(g_np_list);
static DEFINE_SPINLOCK(tiqn_lock); static DEFINE_SPINLOCK(tiqn_lock);
...@@ -401,8 +403,7 @@ struct iscsi_np *iscsit_add_np( ...@@ -401,8 +403,7 @@ struct iscsi_np *iscsit_add_np(
spin_unlock_bh(&np_lock); spin_unlock_bh(&np_lock);
pr_debug("CORE[0] - Added Network Portal: %s:%hu on %s\n", pr_debug("CORE[0] - Added Network Portal: %s:%hu on %s\n",
np->np_ip, np->np_port, (np->np_network_transport == ISCSI_TCP) ? np->np_ip, np->np_port, np->np_transport->name);
"TCP" : "SCTP");
return np; return np;
} }
...@@ -441,11 +442,10 @@ int iscsit_reset_np_thread( ...@@ -441,11 +442,10 @@ int iscsit_reset_np_thread(
return 0; return 0;
} }
static int iscsit_del_np_comm(struct iscsi_np *np) static void iscsit_free_np(struct iscsi_np *np)
{ {
if (np->np_socket) if (np->np_socket)
sock_release(np->np_socket); sock_release(np->np_socket);
return 0;
} }
int iscsit_del_np(struct iscsi_np *np) int iscsit_del_np(struct iscsi_np *np)
...@@ -467,20 +467,32 @@ int iscsit_del_np(struct iscsi_np *np) ...@@ -467,20 +467,32 @@ int iscsit_del_np(struct iscsi_np *np)
send_sig(SIGINT, np->np_thread, 1); send_sig(SIGINT, np->np_thread, 1);
kthread_stop(np->np_thread); kthread_stop(np->np_thread);
} }
iscsit_del_np_comm(np);
np->np_transport->iscsit_free_np(np);
spin_lock_bh(&np_lock); spin_lock_bh(&np_lock);
list_del(&np->np_list); list_del(&np->np_list);
spin_unlock_bh(&np_lock); spin_unlock_bh(&np_lock);
pr_debug("CORE[0] - Removed Network Portal: %s:%hu on %s\n", pr_debug("CORE[0] - Removed Network Portal: %s:%hu on %s\n",
np->np_ip, np->np_port, (np->np_network_transport == ISCSI_TCP) ? np->np_ip, np->np_port, np->np_transport->name);
"TCP" : "SCTP");
iscsit_put_transport(np->np_transport);
kfree(np); kfree(np);
return 0; return 0;
} }
static struct iscsit_transport iscsi_target_transport = {
.name = "iSCSI/TCP",
.transport_type = ISCSI_TCP,
.owner = NULL,
.iscsit_setup_np = iscsit_setup_np,
.iscsit_accept_np = iscsit_accept_np,
.iscsit_free_np = iscsit_free_np,
.iscsit_get_login_rx = iscsit_get_login_rx,
.iscsit_put_login_tx = iscsit_put_login_tx,
};
static int __init iscsi_target_init_module(void) static int __init iscsi_target_init_module(void)
{ {
int ret = 0; int ret = 0;
...@@ -557,6 +569,8 @@ static int __init iscsi_target_init_module(void) ...@@ -557,6 +569,8 @@ static int __init iscsi_target_init_module(void)
goto ooo_out; goto ooo_out;
} }
iscsit_register_transport(&iscsi_target_transport);
if (iscsit_load_discovery_tpg() < 0) if (iscsit_load_discovery_tpg() < 0)
goto r2t_out; goto r2t_out;
...@@ -587,6 +601,7 @@ static void __exit iscsi_target_cleanup_module(void) ...@@ -587,6 +601,7 @@ static void __exit iscsi_target_cleanup_module(void)
iscsi_deallocate_thread_sets(); iscsi_deallocate_thread_sets();
iscsi_thread_set_free(); iscsi_thread_set_free();
iscsit_release_discovery_tpg(); iscsit_release_discovery_tpg();
iscsit_unregister_transport(&iscsi_target_transport);
kmem_cache_destroy(lio_cmd_cache); kmem_cache_destroy(lio_cmd_cache);
kmem_cache_destroy(lio_qr_cache); kmem_cache_destroy(lio_qr_cache);
kmem_cache_destroy(lio_dr_cache); kmem_cache_destroy(lio_dr_cache);
...@@ -4053,6 +4068,12 @@ int iscsit_close_connection( ...@@ -4053,6 +4068,12 @@ int iscsit_close_connection(
if (conn->sock) if (conn->sock)
sock_release(conn->sock); sock_release(conn->sock);
if (conn->conn_transport->iscsit_free_conn)
conn->conn_transport->iscsit_free_conn(conn);
iscsit_put_transport(conn->conn_transport);
conn->thread_set = NULL; conn->thread_set = NULL;
pr_debug("Moving to TARG_CONN_STATE_FREE.\n"); pr_debug("Moving to TARG_CONN_STATE_FREE.\n");
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
#define ISCSI_IOV_DATA_BUFFER 5 #define ISCSI_IOV_DATA_BUFFER 5
enum tpg_np_network_transport_table { enum iscsit_transport_type {
ISCSI_TCP = 0, ISCSI_TCP = 0,
ISCSI_SCTP_TCP = 1, ISCSI_SCTP_TCP = 1,
ISCSI_SCTP_UDP = 2, ISCSI_SCTP_UDP = 2,
...@@ -503,6 +503,7 @@ struct iscsi_conn { ...@@ -503,6 +503,7 @@ struct iscsi_conn {
u16 login_port; u16 login_port;
u16 local_port; u16 local_port;
int net_size; int net_size;
int login_family;
u32 auth_id; u32 auth_id;
u32 conn_flags; u32 conn_flags;
/* Used for iscsi_tx_login_rsp() */ /* Used for iscsi_tx_login_rsp() */
...@@ -562,9 +563,12 @@ struct iscsi_conn { ...@@ -562,9 +563,12 @@ struct iscsi_conn {
struct list_head immed_queue_list; struct list_head immed_queue_list;
struct list_head response_queue_list; struct list_head response_queue_list;
struct iscsi_conn_ops *conn_ops; struct iscsi_conn_ops *conn_ops;
struct iscsi_login *conn_login;
struct iscsit_transport *conn_transport;
struct iscsi_param_list *param_list; struct iscsi_param_list *param_list;
/* Used for per connection auth state machine */ /* Used for per connection auth state machine */
void *auth_protocol; void *auth_protocol;
void *context;
struct iscsi_login_thread_s *login_thread; struct iscsi_login_thread_s *login_thread;
struct iscsi_portal_group *tpg; struct iscsi_portal_group *tpg;
/* Pointer to parent session */ /* Pointer to parent session */
...@@ -663,6 +667,8 @@ struct iscsi_login { ...@@ -663,6 +667,8 @@ struct iscsi_login {
u8 first_request; u8 first_request;
u8 version_min; u8 version_min;
u8 version_max; u8 version_max;
u8 login_complete;
u8 login_failed;
char isid[6]; char isid[6];
u32 cmd_sn; u32 cmd_sn;
itt_t init_task_tag; itt_t init_task_tag;
...@@ -670,10 +676,11 @@ struct iscsi_login { ...@@ -670,10 +676,11 @@ struct iscsi_login {
u32 rsp_length; u32 rsp_length;
u16 cid; u16 cid;
u16 tsih; u16 tsih;
char *req; char req[ISCSI_HDR_LEN];
char *rsp; char rsp[ISCSI_HDR_LEN];
char *req_buf; char *req_buf;
char *rsp_buf; char *rsp_buf;
struct iscsi_conn *conn;
} ____cacheline_aligned; } ____cacheline_aligned;
struct iscsi_node_attrib { struct iscsi_node_attrib {
...@@ -754,6 +761,8 @@ struct iscsi_np { ...@@ -754,6 +761,8 @@ struct iscsi_np {
struct task_struct *np_thread; struct task_struct *np_thread;
struct timer_list np_login_timer; struct timer_list np_login_timer;
struct iscsi_portal_group *np_login_tpg; struct iscsi_portal_group *np_login_tpg;
void *np_context;
struct iscsit_transport *np_transport;
struct list_head np_list; struct list_head np_list;
} ____cacheline_aligned; } ____cacheline_aligned;
......
This diff is collapsed.
...@@ -4,8 +4,14 @@ ...@@ -4,8 +4,14 @@
extern int iscsi_login_setup_crypto(struct iscsi_conn *); extern int iscsi_login_setup_crypto(struct iscsi_conn *);
extern int iscsi_check_for_session_reinstatement(struct iscsi_conn *); extern int iscsi_check_for_session_reinstatement(struct iscsi_conn *);
extern int iscsi_login_post_auth_non_zero_tsih(struct iscsi_conn *, u16, u32); extern int iscsi_login_post_auth_non_zero_tsih(struct iscsi_conn *, u16, u32);
extern int iscsit_setup_np(struct iscsi_np *,
struct __kernel_sockaddr_storage *);
extern int iscsi_target_setup_login_socket(struct iscsi_np *, extern int iscsi_target_setup_login_socket(struct iscsi_np *,
struct __kernel_sockaddr_storage *); struct __kernel_sockaddr_storage *);
extern int iscsit_accept_np(struct iscsi_np *, struct iscsi_conn *);
extern int iscsit_get_login_rx(struct iscsi_conn *, struct iscsi_login *);
extern int iscsit_put_login_tx(struct iscsi_conn *, struct iscsi_login *, u32);
extern void iscsit_free_conn(struct iscsi_np *, struct iscsi_conn *);
extern int iscsi_target_login_thread(void *); extern int iscsi_target_login_thread(void *);
extern int iscsi_login_disable_FIM_keys(struct iscsi_param_list *, struct iscsi_conn *); extern int iscsi_login_disable_FIM_keys(struct iscsi_param_list *, struct iscsi_conn *);
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <scsi/iscsi_proto.h> #include <scsi/iscsi_proto.h>
#include <target/target_core_base.h> #include <target/target_core_base.h>
#include <target/target_core_fabric.h> #include <target/target_core_fabric.h>
#include <target/iscsi/iscsi_transport.h>
#include "iscsi_target_core.h" #include "iscsi_target_core.h"
#include "iscsi_target_parameters.h" #include "iscsi_target_parameters.h"
...@@ -169,7 +170,7 @@ static void iscsi_remove_failed_auth_entry(struct iscsi_conn *conn) ...@@ -169,7 +170,7 @@ static void iscsi_remove_failed_auth_entry(struct iscsi_conn *conn)
kfree(conn->auth_protocol); kfree(conn->auth_protocol);
} }
static int iscsi_target_check_login_request( int iscsi_target_check_login_request(
struct iscsi_conn *conn, struct iscsi_conn *conn,
struct iscsi_login *login) struct iscsi_login *login)
{ {
...@@ -352,11 +353,8 @@ static int iscsi_target_do_tx_login_io(struct iscsi_conn *conn, struct iscsi_log ...@@ -352,11 +353,8 @@ static int iscsi_target_do_tx_login_io(struct iscsi_conn *conn, struct iscsi_log
padding = ((-login->rsp_length) & 3); padding = ((-login->rsp_length) & 3);
if (iscsi_login_tx_data( if (conn->conn_transport->iscsit_put_login_tx(conn, login,
conn, login->rsp_length + padding) < 0)
login->rsp,
login->rsp_buf,
login->rsp_length + padding) < 0)
return -1; return -1;
login->rsp_length = 0; login->rsp_length = 0;
...@@ -368,72 +366,12 @@ static int iscsi_target_do_tx_login_io(struct iscsi_conn *conn, struct iscsi_log ...@@ -368,72 +366,12 @@ static int iscsi_target_do_tx_login_io(struct iscsi_conn *conn, struct iscsi_log
return 0; return 0;
} }
static int iscsi_target_do_rx_login_io(struct iscsi_conn *conn, struct iscsi_login *login)
{
u32 padding = 0, payload_length;
struct iscsi_login_req *login_req;
if (iscsi_login_rx_data(conn, login->req, ISCSI_HDR_LEN) < 0)
return -1;
login_req = (struct iscsi_login_req *) login->req;
payload_length = ntoh24(login_req->dlength);
pr_debug("Got Login Command, Flags 0x%02x, ITT: 0x%08x,"
" CmdSN: 0x%08x, ExpStatSN: 0x%08x, CID: %hu, Length: %u\n",
login_req->flags, login_req->itt, login_req->cmdsn,
login_req->exp_statsn, login_req->cid, payload_length);
if (iscsi_target_check_login_request(conn, login) < 0)
return -1;
padding = ((-payload_length) & 3);
memset(login->req_buf, 0, MAX_KEY_VALUE_PAIRS);
if (iscsi_login_rx_data(
conn,
login->req_buf,
payload_length + padding) < 0)
return -1;
return 0;
}
static int iscsi_target_do_login_io(struct iscsi_conn *conn, struct iscsi_login *login) static int iscsi_target_do_login_io(struct iscsi_conn *conn, struct iscsi_login *login)
{ {
if (iscsi_target_do_tx_login_io(conn, login) < 0) if (iscsi_target_do_tx_login_io(conn, login) < 0)
return -1; return -1;
if (iscsi_target_do_rx_login_io(conn, login) < 0) if (conn->conn_transport->iscsit_get_login_rx(conn, login) < 0)
return -1;
return 0;
}
static int iscsi_target_get_initial_payload(
struct iscsi_conn *conn,
struct iscsi_login *login)
{
u32 padding = 0, payload_length;
struct iscsi_login_req *login_req;
login_req = (struct iscsi_login_req *) login->req;
payload_length = ntoh24(login_req->dlength);
pr_debug("Got Login Command, Flags 0x%02x, ITT: 0x%08x,"
" CmdSN: 0x%08x, ExpStatSN: 0x%08x, Length: %u\n",
login_req->flags, login_req->itt, login_req->cmdsn,
login_req->exp_statsn, payload_length);
if (iscsi_target_check_login_request(conn, login) < 0)
return -1;
padding = ((-payload_length) & 3);
if (iscsi_login_rx_data(
conn,
login->req_buf,
payload_length + padding) < 0)
return -1; return -1;
return 0; return 0;
...@@ -693,6 +631,7 @@ static int iscsi_target_do_login(struct iscsi_conn *conn, struct iscsi_login *lo ...@@ -693,6 +631,7 @@ static int iscsi_target_do_login(struct iscsi_conn *conn, struct iscsi_login *lo
return -1; return -1;
if (login_rsp->flags & ISCSI_FLAG_LOGIN_TRANSIT) { if (login_rsp->flags & ISCSI_FLAG_LOGIN_TRANSIT) {
login->tsih = conn->sess->tsih; login->tsih = conn->sess->tsih;
login->login_complete = 1;
if (iscsi_target_do_tx_login_io(conn, if (iscsi_target_do_tx_login_io(conn,
login) < 0) login) < 0)
return -1; return -1;
...@@ -736,7 +675,7 @@ static void iscsi_initiatorname_tolower( ...@@ -736,7 +675,7 @@ static void iscsi_initiatorname_tolower(
/* /*
* Processes the first Login Request.. * Processes the first Login Request..
*/ */
static int iscsi_target_locate_portal( int iscsi_target_locate_portal(
struct iscsi_np *np, struct iscsi_np *np,
struct iscsi_conn *conn, struct iscsi_conn *conn,
struct iscsi_login *login) struct iscsi_login *login)
...@@ -798,6 +737,8 @@ static int iscsi_target_locate_portal( ...@@ -798,6 +737,8 @@ static int iscsi_target_locate_portal(
start += strlen(key) + strlen(value) + 2; start += strlen(key) + strlen(value) + 2;
} }
printk("i_buf: %s, s_buf: %s, t_buf: %s\n", i_buf, s_buf, t_buf);
/* /*
* See 5.3. Login Phase. * See 5.3. Login Phase.
*/ */
...@@ -956,100 +897,30 @@ static int iscsi_target_locate_portal( ...@@ -956,100 +897,30 @@ static int iscsi_target_locate_portal(
return ret; return ret;
} }
struct iscsi_login *iscsi_target_init_negotiation(
struct iscsi_np *np,
struct iscsi_conn *conn,
char *login_pdu)
{
struct iscsi_login *login;
login = kzalloc(sizeof(struct iscsi_login), GFP_KERNEL);
if (!login) {
pr_err("Unable to allocate memory for struct iscsi_login.\n");
iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
ISCSI_LOGIN_STATUS_NO_RESOURCES);
return NULL;
}
login->req = kmemdup(login_pdu, ISCSI_HDR_LEN, GFP_KERNEL);
if (!login->req) {
pr_err("Unable to allocate memory for Login Request.\n");
iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
ISCSI_LOGIN_STATUS_NO_RESOURCES);
goto out;
}
login->req_buf = kzalloc(MAX_KEY_VALUE_PAIRS, GFP_KERNEL);
if (!login->req_buf) {
pr_err("Unable to allocate memory for response buffer.\n");
iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
ISCSI_LOGIN_STATUS_NO_RESOURCES);
goto out;
}
/*
* SessionType: Discovery
*
* Locates Default Portal
*
* SessionType: Normal
*
* Locates Target Portal from NP -> Target IQN
*/
if (iscsi_target_locate_portal(np, conn, login) < 0) {
goto out;
}
return login;
out:
kfree(login->req);
kfree(login->req_buf);
kfree(login);
return NULL;
}
int iscsi_target_start_negotiation( int iscsi_target_start_negotiation(
struct iscsi_login *login, struct iscsi_login *login,
struct iscsi_conn *conn) struct iscsi_conn *conn)
{ {
int ret = -1; int ret;
login->rsp = kzalloc(ISCSI_HDR_LEN, GFP_KERNEL);
if (!login->rsp) {
pr_err("Unable to allocate memory for"
" Login Response.\n");
iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
ISCSI_LOGIN_STATUS_NO_RESOURCES);
ret = -1;
goto out;
}
login->rsp_buf = kzalloc(MAX_KEY_VALUE_PAIRS, GFP_KERNEL);
if (!login->rsp_buf) {
pr_err("Unable to allocate memory for"
" request buffer.\n");
iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
ISCSI_LOGIN_STATUS_NO_RESOURCES);
ret = -1;
goto out;
}
ret = iscsi_target_do_login(conn, login); ret = iscsi_target_do_login(conn, login);
out:
if (ret != 0) if (ret != 0)
iscsi_remove_failed_auth_entry(conn); iscsi_remove_failed_auth_entry(conn);
iscsi_target_nego_release(login, conn); iscsi_target_nego_release(conn);
return ret; return ret;
} }
void iscsi_target_nego_release( void iscsi_target_nego_release(struct iscsi_conn *conn)
struct iscsi_login *login,
struct iscsi_conn *conn)
{ {
kfree(login->req); struct iscsi_login *login = conn->conn_login;
kfree(login->rsp);
if (!login)
return;
kfree(login->req_buf); kfree(login->req_buf);
kfree(login->rsp_buf); kfree(login->rsp_buf);
kfree(login); kfree(login);
conn->conn_login = NULL;
} }
...@@ -7,11 +7,14 @@ ...@@ -7,11 +7,14 @@
extern void convert_null_to_semi(char *, int); extern void convert_null_to_semi(char *, int);
extern int extract_param(const char *, const char *, unsigned int, char *, extern int extract_param(const char *, const char *, unsigned int, char *,
unsigned char *); unsigned char *);
extern struct iscsi_login *iscsi_target_init_negotiation( extern int iscsi_target_check_login_request(struct iscsi_conn *,
struct iscsi_np *, struct iscsi_conn *, char *); struct iscsi_login *);
extern int iscsi_target_get_initial_payload(struct iscsi_conn *,
struct iscsi_login *);
extern int iscsi_target_locate_portal(struct iscsi_np *, struct iscsi_conn *,
struct iscsi_login *);
extern int iscsi_target_start_negotiation( extern int iscsi_target_start_negotiation(
struct iscsi_login *, struct iscsi_conn *); struct iscsi_login *, struct iscsi_conn *);
extern void iscsi_target_nego_release( extern void iscsi_target_nego_release(struct iscsi_conn *);
struct iscsi_login *, struct iscsi_conn *);
#endif /* ISCSI_TARGET_NEGO_H */ #endif /* ISCSI_TARGET_NEGO_H */
...@@ -59,7 +59,7 @@ int iscsi_login_tx_data( ...@@ -59,7 +59,7 @@ int iscsi_login_tx_data(
char *text_buf, char *text_buf,
int text_length) int text_length)
{ {
int length, tx_sent; int length, tx_sent, iov_cnt = 1;
struct kvec iov[2]; struct kvec iov[2];
length = (ISCSI_HDR_LEN + text_length); length = (ISCSI_HDR_LEN + text_length);
...@@ -67,8 +67,12 @@ int iscsi_login_tx_data( ...@@ -67,8 +67,12 @@ int iscsi_login_tx_data(
memset(&iov[0], 0, 2 * sizeof(struct kvec)); memset(&iov[0], 0, 2 * sizeof(struct kvec));
iov[0].iov_len = ISCSI_HDR_LEN; iov[0].iov_len = ISCSI_HDR_LEN;
iov[0].iov_base = pdu_buf; iov[0].iov_base = pdu_buf;
iov[1].iov_len = text_length;
iov[1].iov_base = text_buf; if (text_buf && text_length) {
iov[1].iov_len = text_length;
iov[1].iov_base = text_buf;
iov_cnt++;
}
/* /*
* Initial Marker-less Interval. * Initial Marker-less Interval.
...@@ -77,7 +81,7 @@ int iscsi_login_tx_data( ...@@ -77,7 +81,7 @@ int iscsi_login_tx_data(
*/ */
conn->if_marker += length; conn->if_marker += length;
tx_sent = tx_data(conn, &iov[0], 2, length); tx_sent = tx_data(conn, &iov[0], iov_cnt, length);
if (tx_sent != length) { if (tx_sent != length) {
pr_err("tx_data returned %d, expecting %d.\n", pr_err("tx_data returned %d, expecting %d.\n",
tx_sent, length); tx_sent, length);
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#include "iscsi_target.h" #include "iscsi_target.h"
#include "iscsi_target_parameters.h" #include "iscsi_target_parameters.h"
#include <target/iscsi/iscsi_transport.h>
struct iscsi_portal_group *iscsit_alloc_portal_group(struct iscsi_tiqn *tiqn, u16 tpgt) struct iscsi_portal_group *iscsit_alloc_portal_group(struct iscsi_tiqn *tiqn, u16 tpgt)
{ {
struct iscsi_portal_group *tpg; struct iscsi_portal_group *tpg;
...@@ -508,7 +510,7 @@ struct iscsi_tpg_np *iscsit_tpg_add_network_portal( ...@@ -508,7 +510,7 @@ struct iscsi_tpg_np *iscsit_tpg_add_network_portal(
pr_debug("CORE[%s] - Added Network Portal: %s:%hu,%hu on %s\n", pr_debug("CORE[%s] - Added Network Portal: %s:%hu,%hu on %s\n",
tpg->tpg_tiqn->tiqn, np->np_ip, np->np_port, tpg->tpgt, tpg->tpg_tiqn->tiqn, np->np_ip, np->np_port, tpg->tpgt,
(np->np_network_transport == ISCSI_TCP) ? "TCP" : "SCTP"); np->np_transport->name);
return tpg_np; return tpg_np;
} }
...@@ -522,7 +524,7 @@ static int iscsit_tpg_release_np( ...@@ -522,7 +524,7 @@ static int iscsit_tpg_release_np(
pr_debug("CORE[%s] - Removed Network Portal: %s:%hu,%hu on %s\n", pr_debug("CORE[%s] - Removed Network Portal: %s:%hu,%hu on %s\n",
tpg->tpg_tiqn->tiqn, np->np_ip, np->np_port, tpg->tpgt, tpg->tpg_tiqn->tiqn, np->np_ip, np->np_port, tpg->tpgt,
(np->np_network_transport == ISCSI_TCP) ? "TCP" : "SCTP"); np->np_transport->name);
tpg_np->tpg_np = NULL; tpg_np->tpg_np = NULL;
tpg_np->tpg = NULL; tpg_np->tpg = NULL;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <target/target_core_base.h> #include <target/target_core_base.h>
#include <target/target_core_fabric.h> #include <target/target_core_fabric.h>
#include <target/target_core_configfs.h> #include <target/target_core_configfs.h>
#include <target/iscsi/iscsi_transport.h>
#include "iscsi_target_core.h" #include "iscsi_target_core.h"
#include "iscsi_target_parameters.h" #include "iscsi_target_parameters.h"
...@@ -1226,34 +1227,19 @@ int iscsit_fe_sendpage_sg( ...@@ -1226,34 +1227,19 @@ int iscsit_fe_sendpage_sg(
*/ */
int iscsit_tx_login_rsp(struct iscsi_conn *conn, u8 status_class, u8 status_detail) int iscsit_tx_login_rsp(struct iscsi_conn *conn, u8 status_class, u8 status_detail)
{ {
u8 iscsi_hdr[ISCSI_HDR_LEN];
int err;
struct kvec iov;
struct iscsi_login_rsp *hdr; struct iscsi_login_rsp *hdr;
struct iscsi_login *login = conn->conn_login;
login->login_failed = 1;
iscsit_collect_login_stats(conn, status_class, status_detail); iscsit_collect_login_stats(conn, status_class, status_detail);
memset(&iov, 0, sizeof(struct kvec)); hdr = (struct iscsi_login_rsp *)&login->rsp[0];
memset(&iscsi_hdr, 0x0, ISCSI_HDR_LEN);
hdr = (struct iscsi_login_rsp *)&iscsi_hdr;
hdr->opcode = ISCSI_OP_LOGIN_RSP; hdr->opcode = ISCSI_OP_LOGIN_RSP;
hdr->status_class = status_class; hdr->status_class = status_class;
hdr->status_detail = status_detail; hdr->status_detail = status_detail;
hdr->itt = conn->login_itt; hdr->itt = conn->login_itt;
iov.iov_base = &iscsi_hdr; return conn->conn_transport->iscsit_put_login_tx(conn, login, 0);
iov.iov_len = ISCSI_HDR_LEN;
PRINT_BUFF(iscsi_hdr, ISCSI_HDR_LEN);
err = tx_data(conn, &iov, 1, ISCSI_HDR_LEN);
if (err != ISCSI_HDR_LEN) {
pr_err("tx_data returned less than expected\n");
return -1;
}
return 0;
} }
void iscsit_print_session_params(struct iscsi_session *sess) void iscsit_print_session_params(struct iscsi_session *sess)
...@@ -1432,7 +1418,8 @@ void iscsit_collect_login_stats( ...@@ -1432,7 +1418,8 @@ void iscsit_collect_login_stats(
strcpy(ls->last_intr_fail_name, strcpy(ls->last_intr_fail_name,
(intrname ? intrname->value : "Unknown")); (intrname ? intrname->value : "Unknown"));
ls->last_intr_fail_ip_family = conn->sock->sk->sk_family; ls->last_intr_fail_ip_family = conn->login_family;
snprintf(ls->last_intr_fail_ip_addr, IPV6_ADDRESS_SPACE, snprintf(ls->last_intr_fail_ip_addr, IPV6_ADDRESS_SPACE,
"%s", conn->login_ip); "%s", conn->login_ip);
ls->last_fail_time = get_jiffies_64(); ls->last_fail_time = get_jiffies_64();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment