drivers/target/iscsi/iscsi_target_nego.c
Source file repositories/reference/linux-study-clean/drivers/target/iscsi/iscsi_target_nego.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/target/iscsi/iscsi_target_nego.c- Extension
.c- Size
- 37460 bytes
- Lines
- 1397
- Domain
- Driver Families
- Bucket
- drivers/target
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/ctype.hlinux/kthread.hlinux/slab.hlinux/sched/signal.hnet/sock.htrace/events/sock.hscsi/iscsi_proto.htarget/target_core_base.htarget/target_core_fabric.htarget/iscsi/iscsi_transport.htarget/iscsi/iscsi_target_core.hiscsi_target_parameters.hiscsi_target_login.hiscsi_target_nego.hiscsi_target_tpg.hiscsi_target_util.hiscsi_target.hiscsi_target_auth.h
Detected Declarations
function convert_null_to_semifunction strlen_semifunction extract_paramfunction iscsi_handle_authenticationfunction iscsi_remove_failed_auth_entryfunction iscsi_target_check_login_requestfunction iscsi_target_check_first_requestfunction list_for_each_entryfunction iscsi_target_do_tx_login_iofunction iscsi_target_sk_data_readyfunction iscsi_target_set_sock_callbacksfunction iscsi_target_restore_sock_callbacksfunction __iscsi_target_sk_check_closefunction iscsi_target_sk_check_closefunction iscsi_target_sk_check_flagfunction iscsi_target_sk_check_and_clearfunction iscsi_target_login_dropfunction iscsi_target_do_login_rxfunction iscsi_target_do_login_rxfunction ongoingfunction iscsi_target_sk_state_changefunction iscsi_target_do_login_rxfunction iscsi_target_check_for_existing_instancesfunction iscsi_target_do_authenticationfunction iscsi_conn_auth_requiredfunction iscsi_target_handle_csg_zerofunction iscsi_conn_authenticatedfunction iscsi_target_handle_csg_onefunction iscsi_target_do_loginfunction iscsi_initiatorname_tolowerfunction iscsi_target_locate_portalfunction iscsi_login_non_zero_tsih_s2function iscsi_target_start_negotiationfunction iscsi_target_nego_releaseexport iscsi_target_check_login_request
Annotated Snippet
if (!strncmp(param->name, SESSIONTYPE, 11)) {
if (!IS_PSTATE_ACCEPTOR(param)) {
pr_err("SessionType key not received"
" in first login request.\n");
iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_INITIATOR_ERR,
ISCSI_LOGIN_STATUS_MISSING_FIELDS);
return -1;
}
if (!strncmp(param->value, DISCOVERY, 9))
return 0;
}
if (!strncmp(param->name, INITIATORNAME, 13)) {
if (!IS_PSTATE_ACCEPTOR(param)) {
if (!login->leading_connection)
continue;
pr_err("InitiatorName key not received"
" in first login request.\n");
iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_INITIATOR_ERR,
ISCSI_LOGIN_STATUS_MISSING_FIELDS);
return -1;
}
/*
* For non-leading connections, double check that the
* received InitiatorName matches the existing session's
* struct iscsi_node_acl.
*/
if (!login->leading_connection) {
se_nacl = conn->sess->se_sess->se_node_acl;
if (!se_nacl) {
pr_err("Unable to locate"
" struct se_node_acl\n");
iscsit_tx_login_rsp(conn,
ISCSI_STATUS_CLS_INITIATOR_ERR,
ISCSI_LOGIN_STATUS_TGT_NOT_FOUND);
return -1;
}
if (strcmp(param->value,
se_nacl->initiatorname)) {
pr_err("Incorrect"
" InitiatorName: %s for this"
" iSCSI Initiator Node.\n",
param->value);
iscsit_tx_login_rsp(conn,
ISCSI_STATUS_CLS_INITIATOR_ERR,
ISCSI_LOGIN_STATUS_TGT_NOT_FOUND);
return -1;
}
}
}
}
return 0;
}
static int iscsi_target_do_tx_login_io(struct iscsit_conn *conn, struct iscsi_login *login)
{
u32 padding = 0;
struct iscsi_login_rsp *login_rsp;
login_rsp = (struct iscsi_login_rsp *) login->rsp;
login_rsp->opcode = ISCSI_OP_LOGIN_RSP;
hton24(login_rsp->dlength, login->rsp_length);
memcpy(login_rsp->isid, login->isid, 6);
login_rsp->tsih = cpu_to_be16(login->tsih);
login_rsp->itt = login->init_task_tag;
login_rsp->statsn = cpu_to_be32(conn->stat_sn++);
login_rsp->exp_cmdsn = cpu_to_be32(conn->sess->exp_cmd_sn);
login_rsp->max_cmdsn = cpu_to_be32((u32) atomic_read(&conn->sess->max_cmd_sn));
pr_debug("Sending Login Response, Flags: 0x%02x, ITT: 0x%08x,"
" ExpCmdSN; 0x%08x, MaxCmdSN: 0x%08x, StatSN: 0x%08x, Length:"
" %u\n", login_rsp->flags, (__force u32)login_rsp->itt,
ntohl(login_rsp->exp_cmdsn), ntohl(login_rsp->max_cmdsn),
ntohl(login_rsp->statsn), login->rsp_length);
padding = ((-login->rsp_length) & 3);
/*
* Before sending the last login response containing the transition
* bit for full-feature-phase, go ahead and start up TX/RX threads
* now to avoid potential resource allocation failures after the
* final login response has been sent.
*/
if (login->login_complete) {
int rc = iscsit_start_kthreads(conn);
if (rc) {
Annotation
- Immediate include surface: `linux/ctype.h`, `linux/kthread.h`, `linux/slab.h`, `linux/sched/signal.h`, `net/sock.h`, `trace/events/sock.h`, `scsi/iscsi_proto.h`, `target/target_core_base.h`.
- Detected declarations: `function convert_null_to_semi`, `function strlen_semi`, `function extract_param`, `function iscsi_handle_authentication`, `function iscsi_remove_failed_auth_entry`, `function iscsi_target_check_login_request`, `function iscsi_target_check_first_request`, `function list_for_each_entry`, `function iscsi_target_do_tx_login_io`, `function iscsi_target_sk_data_ready`.
- Atlas domain: Driver Families / drivers/target.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.