Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/iscsid/iscsid.c
Show First 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | log_errx(1, "getaddrinfo for %s failed: %s", | ||||
address, gai_strerror(error)); | address, gai_strerror(error)); | ||||
} | } | ||||
} | } | ||||
static struct connection * | static struct connection * | ||||
connection_new(int iscsi_fd, const struct iscsi_daemon_request *request) | connection_new(int iscsi_fd, const struct iscsi_daemon_request *request) | ||||
{ | { | ||||
struct connection *conn; | struct connection *conn; | ||||
struct iscsi_session_limits *isl; | |||||
struct addrinfo *from_ai, *to_ai; | struct addrinfo *from_ai, *to_ai; | ||||
const char *from_addr, *to_addr; | const char *from_addr, *to_addr; | ||||
#ifdef ICL_KERNEL_PROXY | #ifdef ICL_KERNEL_PROXY | ||||
struct iscsi_daemon_connect idc; | struct iscsi_daemon_connect idc; | ||||
#endif | #endif | ||||
int error, sockbuf; | int error, sockbuf; | ||||
conn = calloc(1, sizeof(*conn)); | conn = calloc(1, sizeof(*conn)); | ||||
if (conn == NULL) | if (conn == NULL) | ||||
log_err(1, "calloc"); | log_err(1, "calloc"); | ||||
/* | /* | ||||
* Default values, from RFC 3720, section 12. | * Default values, from RFC 3720, section 12. | ||||
*/ | */ | ||||
conn->conn_header_digest = CONN_DIGEST_NONE; | conn->conn_header_digest = CONN_DIGEST_NONE; | ||||
conn->conn_data_digest = CONN_DIGEST_NONE; | conn->conn_data_digest = CONN_DIGEST_NONE; | ||||
conn->conn_initial_r2t = true; | conn->conn_initial_r2t = true; | ||||
conn->conn_immediate_data = true; | conn->conn_immediate_data = true; | ||||
conn->conn_max_data_segment_length = 8192; | conn->conn_max_burst_length = MAX_BURST_LENGTH; | ||||
conn->conn_max_burst_length = 262144; | conn->conn_first_burst_length = FIRST_BURST_LENGTH; | ||||
conn->conn_first_burst_length = 65536; | |||||
conn->conn_iscsi_fd = iscsi_fd; | conn->conn_iscsi_fd = iscsi_fd; | ||||
conn->conn_session_id = request->idr_session_id; | conn->conn_session_id = request->idr_session_id; | ||||
memcpy(&conn->conn_conf, &request->idr_conf, sizeof(conn->conn_conf)); | memcpy(&conn->conn_conf, &request->idr_conf, sizeof(conn->conn_conf)); | ||||
memcpy(&conn->conn_isid, &request->idr_isid, sizeof(conn->conn_isid)); | memcpy(&conn->conn_isid, &request->idr_isid, sizeof(conn->conn_isid)); | ||||
conn->conn_tsih = request->idr_tsih; | conn->conn_tsih = request->idr_tsih; | ||||
memcpy(&conn->conn_limits, &request->idr_limits, sizeof(conn->conn_limits)); | |||||
/* | |||||
* Read the driver limits and provide reasonable defaults for the ones | |||||
* the driver doesn't care about. If a max_snd_dsl is not explicitly | |||||
* provided by the driver then we'll make sure both conn->max_snd_dsl | |||||
* and isl->max_snd_dsl are set to the rcv_dsl. This preserves historic | |||||
* behavior. | |||||
*/ | |||||
isl = &conn->conn_limits; | |||||
memcpy(isl, &request->idr_limits, sizeof(*isl)); | |||||
if (isl->isl_max_recv_data_segment_length == 0) { | |||||
conn->conn_max_recv_data_segment_length = 8192; | |||||
conn->conn_max_send_data_segment_length = 8192; | |||||
isl->isl_max_recv_data_segment_length = 8192; | |||||
} else { | |||||
conn->conn_max_recv_data_segment_length = | |||||
isl->isl_max_recv_data_segment_length; | |||||
conn->conn_max_send_data_segment_length = | |||||
isl->isl_max_recv_data_segment_length; | |||||
} | |||||
if (isl->isl_max_send_data_segment_length == 0) { | |||||
isl->isl_max_send_data_segment_length = | |||||
isl->isl_max_recv_data_segment_length; | |||||
} else { | |||||
conn->conn_max_send_data_segment_length = | |||||
isl->isl_max_send_data_segment_length; | |||||
} | |||||
if (isl->isl_max_burst_length == 0) | |||||
isl->isl_max_burst_length = conn->conn_max_burst_length; | |||||
if (isl->isl_first_burst_length == 0) { | |||||
if (isl->isl_max_burst_length < (int)conn->conn_first_burst_length) | |||||
isl->isl_first_burst_length = isl->isl_max_burst_length; | |||||
else | |||||
isl->isl_first_burst_length = conn->conn_first_burst_length; | |||||
} | |||||
from_addr = conn->conn_conf.isc_initiator_addr; | from_addr = conn->conn_conf.isc_initiator_addr; | ||||
to_addr = conn->conn_conf.isc_target_addr; | to_addr = conn->conn_conf.isc_target_addr; | ||||
if (from_addr[0] != '\0') | if (from_addr[0] != '\0') | ||||
resolve_addr(conn, from_addr, &from_ai, true); | resolve_addr(conn, from_addr, &from_ai, true); | ||||
else | else | ||||
from_ai = NULL; | from_ai = NULL; | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | handoff(struct connection *conn) | ||||
strlcpy(idh.idh_target_alias, conn->conn_target_alias, | strlcpy(idh.idh_target_alias, conn->conn_target_alias, | ||||
sizeof(idh.idh_target_alias)); | sizeof(idh.idh_target_alias)); | ||||
idh.idh_tsih = conn->conn_tsih; | idh.idh_tsih = conn->conn_tsih; | ||||
idh.idh_statsn = conn->conn_statsn; | idh.idh_statsn = conn->conn_statsn; | ||||
idh.idh_header_digest = conn->conn_header_digest; | idh.idh_header_digest = conn->conn_header_digest; | ||||
idh.idh_data_digest = conn->conn_data_digest; | idh.idh_data_digest = conn->conn_data_digest; | ||||
idh.idh_initial_r2t = conn->conn_initial_r2t; | idh.idh_initial_r2t = conn->conn_initial_r2t; | ||||
idh.idh_immediate_data = conn->conn_immediate_data; | idh.idh_immediate_data = conn->conn_immediate_data; | ||||
idh.idh_max_data_segment_length = conn->conn_max_data_segment_length; | idh.idh_max_recv_data_segment_length = | ||||
conn->conn_max_recv_data_segment_length; | |||||
idh.idh_max_send_data_segment_length = | |||||
conn->conn_max_send_data_segment_length; | |||||
idh.idh_max_burst_length = conn->conn_max_burst_length; | idh.idh_max_burst_length = conn->conn_max_burst_length; | ||||
idh.idh_first_burst_length = conn->conn_first_burst_length; | idh.idh_first_burst_length = conn->conn_first_burst_length; | ||||
error = ioctl(conn->conn_iscsi_fd, ISCSIDHANDOFF, &idh); | error = ioctl(conn->conn_iscsi_fd, ISCSIDHANDOFF, &idh); | ||||
if (error != 0) | if (error != 0) | ||||
log_err(1, "ISCSIDHANDOFF"); | log_err(1, "ISCSIDHANDOFF"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 318 Lines • Show Last 20 Lines |