Tidy up the login code; no functional changes.
MFC after: 1 month Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
0e3d9b8126
commit
e2e58f80cc
@ -672,6 +672,7 @@ login(struct connection *conn)
|
|||||||
struct iscsi_bhs_login_response *bhslr2;
|
struct iscsi_bhs_login_response *bhslr2;
|
||||||
struct keys *request_keys, *response_keys;
|
struct keys *request_keys, *response_keys;
|
||||||
struct auth_group *ag;
|
struct auth_group *ag;
|
||||||
|
struct portal_group *pg;
|
||||||
const char *initiator_name, *initiator_alias, *session_type,
|
const char *initiator_name, *initiator_alias, *session_type,
|
||||||
*target_name, *auth_method;
|
*target_name, *auth_method;
|
||||||
|
|
||||||
@ -688,6 +689,8 @@ login(struct connection *conn)
|
|||||||
log_errx(1, "received Login PDU with non-zero TSIH");
|
log_errx(1, "received Login PDU with non-zero TSIH");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pg = conn->conn_portal->p_portal_group;
|
||||||
|
|
||||||
memcpy(conn->conn_initiator_isid, bhslr->bhslr_isid,
|
memcpy(conn->conn_initiator_isid, bhslr->bhslr_isid,
|
||||||
sizeof(conn->conn_initiator_isid));
|
sizeof(conn->conn_initiator_isid));
|
||||||
|
|
||||||
@ -741,9 +744,7 @@ login(struct connection *conn)
|
|||||||
log_errx(1, "received Login PDU without TargetName");
|
log_errx(1, "received Login PDU without TargetName");
|
||||||
}
|
}
|
||||||
|
|
||||||
conn->conn_target =
|
conn->conn_target = target_find(pg->pg_conf, target_name);
|
||||||
target_find(conn->conn_portal->p_portal_group->pg_conf,
|
|
||||||
target_name);
|
|
||||||
if (conn->conn_target == NULL) {
|
if (conn->conn_target == NULL) {
|
||||||
login_send_error(request, 0x02, 0x03);
|
login_send_error(request, 0x02, 0x03);
|
||||||
log_errx(1, "requested target \"%s\" not found",
|
log_errx(1, "requested target \"%s\" not found",
|
||||||
@ -760,14 +761,14 @@ login(struct connection *conn)
|
|||||||
log_debugx("initiator requests to connect "
|
log_debugx("initiator requests to connect "
|
||||||
"to target \"%s\"; auth-group \"%s\"",
|
"to target \"%s\"; auth-group \"%s\"",
|
||||||
conn->conn_target->t_name,
|
conn->conn_target->t_name,
|
||||||
conn->conn_target->t_auth_group->ag_name);
|
ag->ag_name);
|
||||||
} else {
|
} else {
|
||||||
log_debugx("initiator requests to connect "
|
log_debugx("initiator requests to connect "
|
||||||
"to target \"%s\"", conn->conn_target->t_name);
|
"to target \"%s\"", conn->conn_target->t_name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert(conn->conn_session_type == CONN_SESSION_TYPE_DISCOVERY);
|
assert(conn->conn_session_type == CONN_SESSION_TYPE_DISCOVERY);
|
||||||
ag = conn->conn_portal->p_portal_group->pg_discovery_auth_group;
|
ag = pg->pg_discovery_auth_group;
|
||||||
if (ag->ag_name != NULL) {
|
if (ag->ag_name != NULL) {
|
||||||
log_debugx("initiator requests "
|
log_debugx("initiator requests "
|
||||||
"discovery session; auth-group \"%s\"", ag->ag_name);
|
"discovery session; auth-group \"%s\"", ag->ag_name);
|
||||||
@ -837,8 +838,7 @@ login(struct connection *conn)
|
|||||||
response = login_new_response(request);
|
response = login_new_response(request);
|
||||||
bhslr2 = (struct iscsi_bhs_login_response *)response->pdu_bhs;
|
bhslr2 = (struct iscsi_bhs_login_response *)response->pdu_bhs;
|
||||||
bhslr2->bhslr_flags |= BHSLR_FLAGS_TRANSIT;
|
bhslr2->bhslr_flags |= BHSLR_FLAGS_TRANSIT;
|
||||||
login_set_nsg(response,
|
login_set_nsg(response, BHSLR_STAGE_OPERATIONAL_NEGOTIATION);
|
||||||
BHSLR_STAGE_OPERATIONAL_NEGOTIATION);
|
|
||||||
response_keys = keys_new();
|
response_keys = keys_new();
|
||||||
/*
|
/*
|
||||||
* Required by Linux initiator.
|
* Required by Linux initiator.
|
||||||
@ -852,8 +852,8 @@ login(struct connection *conn)
|
|||||||
if (conn->conn_target->t_alias != NULL)
|
if (conn->conn_target->t_alias != NULL)
|
||||||
keys_add(response_keys,
|
keys_add(response_keys,
|
||||||
"TargetAlias", conn->conn_target->t_alias);
|
"TargetAlias", conn->conn_target->t_alias);
|
||||||
keys_add_int(response_keys, "TargetPortalGroupTag",
|
keys_add_int(response_keys,
|
||||||
conn->conn_portal->p_portal_group->pg_tag);
|
"TargetPortalGroupTag", pg->pg_tag);
|
||||||
}
|
}
|
||||||
keys_save(response_keys, response);
|
keys_save(response_keys, response);
|
||||||
pdu_send(response);
|
pdu_send(response);
|
||||||
@ -903,8 +903,8 @@ login(struct connection *conn)
|
|||||||
if (conn->conn_target->t_alias != NULL)
|
if (conn->conn_target->t_alias != NULL)
|
||||||
keys_add(response_keys,
|
keys_add(response_keys,
|
||||||
"TargetAlias", conn->conn_target->t_alias);
|
"TargetAlias", conn->conn_target->t_alias);
|
||||||
keys_add_int(response_keys, "TargetPortalGroupTag",
|
keys_add_int(response_keys,
|
||||||
conn->conn_portal->p_portal_group->pg_tag);
|
"TargetPortalGroupTag", pg->pg_tag);
|
||||||
}
|
}
|
||||||
keys_save(response_keys, response);
|
keys_save(response_keys, response);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user