iscsi target: make function to get auth from conn
PATCH 1/2 iscsi target: make function to get auth from conn
Move the code to go from iscsi conn to iscsi node auth to a helper function which will also be used in the next patch.
Signed-off-by Mike Christie <[email protected]>
--- drivers/target/iscsi/iscsi_target_nego.c | 35 +++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-)
drivers/target/iscsi/iscsi_target_nego.c +23 -12
@@ -103,13 +103,8 @@ int extract_param(return 0 ; } -static u32 iscsi_handle_authentication ( -struct iscsi_conn *conn, -char *in_buf, -char *out_buf, -int in_length, -int *out_length, -unsigned char *authtype) +static struct iscsi_node_auth *iscsi_target_get_auth_from_conn ( +struct iscsi_conn *conn) {struct iscsi_session *sess = conn->sess;struct iscsi_node_auth *auth;
@@ -125,25 +120,24 @@ static u32 iscsi_handle_authentication(if (!se_nacl) {pr_err ("Unable to locate struct se_node_acl for" " CHAP auth\n" ); -return -1 ; +return NULL ; } iscsi_nacl = container_of(se_nacl, struct iscsi_node_acl, se_node_acl);if (!iscsi_nacl) {pr_err ("Unable to locate struct iscsi_node_acl for" " CHAP auth\n" ); -return -1 ; +return NULL ; }if (se_nacl->dynamic_node_acl) { iscsi_tpg =container_of (se_nacl->se_tpg, - struct iscsi_portal_group, tpg_se_tpg); - + struct iscsi_portal_group, + tpg_se_tpg); auth = &iscsi_tpg->tpg_demo_auth; }else { iscsi_nacl = container_of(se_nacl, struct iscsi_node_acl, se_node_acl); - auth = &iscsi_nacl->node_auth; } }else {
@@ -153,6 +147,23 @@ static u32 iscsi_handle_authentication( auth = &iscsit_global->discovery_acl.node_auth; } +return auth; +} + +static u32 iscsi_handle_authentication ( +struct iscsi_conn *conn, +char *in_buf, +char *out_buf, +int in_length, +int *out_length, +unsigned char *authtype) +{ +struct iscsi_node_auth *auth; + + auth =iscsi_target_get_auth_from_conn (conn); +if (!auth) +return -1 ; +if (strstr ("CHAP" , authtype))strcpy (conn->sess->auth_type,"CHAP" );else
Signature · 1 line
1.8.3.1