Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/ctld/kernel.c
Show First 20 Lines • Show All 916 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
if (req.status != CTL_ISCSI_OK) { | if (req.status != CTL_ISCSI_OK) { | ||||
log_errx(1, "error returned from CTL iSCSI handoff request: " | log_errx(1, "error returned from CTL iSCSI handoff request: " | ||||
"%s; dropping connection", req.error_str); | "%s; dropping connection", req.error_str); | ||||
} | } | ||||
} | } | ||||
int | |||||
kernel_maxconn(struct connection *conn) | |||||
{ | |||||
struct ctl_iscsi req; | |||||
bzero(&req, sizeof(req)); | |||||
req.type = CTL_ISCSI_MAXCONN; | |||||
strlcpy(req.data.maxconn.target_name, | |||||
conn->conn_target->t_name, sizeof(req.data.maxconn.target_name)); | |||||
req.data.maxconn.portal_group_tag = | |||||
conn->conn_portal->p_portal_group->pg_tag; | |||||
if (ioctl(ctl_fd, CTL_ISCSI, &req) == -1) { | |||||
log_err(1, "error issuing CTL_ISCSI ioctl; " | |||||
"dropping connection"); | |||||
return (1); | |||||
} | |||||
if (req.status != CTL_ISCSI_OK) { | |||||
log_errx(1, "error returned from CTL iSCSI maxconn request: " | |||||
"%s; dropping connection", req.error_str); | |||||
return (1); | |||||
} | |||||
return !(req.data.maxconn.nb_conn < req.data.maxconn.max_conn); | |||||
} | |||||
void | void | ||||
kernel_limits(const char *offload, size_t *max_data_segment_length) | kernel_limits(const char *offload, size_t *max_data_segment_length) | ||||
{ | { | ||||
struct ctl_iscsi req; | struct ctl_iscsi req; | ||||
bzero(&req, sizeof(req)); | bzero(&req, sizeof(req)); | ||||
req.type = CTL_ISCSI_LIMITS; | req.type = CTL_ISCSI_LIMITS; | ||||
Show All 34 Lines | kernel_port_add(struct port *port) | ||||
char tagstr[16]; | char tagstr[16]; | ||||
int error, i, n; | int error, i, n; | ||||
/* Create iSCSI port. */ | /* Create iSCSI port. */ | ||||
if (port->p_portal_group) { | if (port->p_portal_group) { | ||||
bzero(&req, sizeof(req)); | bzero(&req, sizeof(req)); | ||||
strlcpy(req.driver, "iscsi", sizeof(req.driver)); | strlcpy(req.driver, "iscsi", sizeof(req.driver)); | ||||
req.reqtype = CTL_REQ_CREATE; | req.reqtype = CTL_REQ_CREATE; | ||||
req.num_args = 5; | req.num_args = 6; | ||||
TAILQ_FOREACH(o, &pg->pg_options, o_next) | TAILQ_FOREACH(o, &pg->pg_options, o_next) | ||||
req.num_args++; | req.num_args++; | ||||
req.args = malloc(req.num_args * sizeof(*req.args)); | req.args = malloc(req.num_args * sizeof(*req.args)); | ||||
if (req.args == NULL) | if (req.args == NULL) | ||||
log_err(1, "malloc"); | log_err(1, "malloc"); | ||||
n = 0; | n = 0; | ||||
req.args[n].namelen = sizeof("port_id"); | req.args[n].namelen = sizeof("port_id"); | ||||
req.args[n].name = __DECONST(char *, "port_id"); | req.args[n].name = __DECONST(char *, "port_id"); | ||||
req.args[n].vallen = sizeof(port->p_ctl_port); | req.args[n].vallen = sizeof(port->p_ctl_port); | ||||
req.args[n].value = &port->p_ctl_port; | req.args[n].value = &port->p_ctl_port; | ||||
req.args[n++].flags = CTL_BEARG_WR; | req.args[n++].flags = CTL_BEARG_WR; | ||||
str_arg(&req.args[n++], "cfiscsi_target", targ->t_name); | str_arg(&req.args[n++], "cfiscsi_target", targ->t_name); | ||||
snprintf(tagstr, sizeof(tagstr), "%d", pg->pg_tag); | snprintf(tagstr, sizeof(tagstr), "%d", pg->pg_tag); | ||||
str_arg(&req.args[n++], "cfiscsi_portal_group_tag", tagstr); | str_arg(&req.args[n++], "cfiscsi_portal_group_tag", tagstr); | ||||
if (targ->t_alias) | if (targ->t_alias) | ||||
str_arg(&req.args[n++], "cfiscsi_target_alias", targ->t_alias); | str_arg(&req.args[n++], "cfiscsi_target_alias", targ->t_alias); | ||||
if (targ->t_max_conn) | |||||
str_arg(&req.args[n++], "cfiscsi_max_conn", targ->t_max_conn); | |||||
str_arg(&req.args[n++], "ctld_portal_group_name", pg->pg_name); | str_arg(&req.args[n++], "ctld_portal_group_name", pg->pg_name); | ||||
TAILQ_FOREACH(o, &pg->pg_options, o_next) | TAILQ_FOREACH(o, &pg->pg_options, o_next) | ||||
str_arg(&req.args[n++], o->o_name, o->o_value); | str_arg(&req.args[n++], o->o_name, o->o_value); | ||||
req.num_args = n; | req.num_args = n; | ||||
error = ioctl(ctl_fd, CTL_PORT_REQ, &req); | error = ioctl(ctl_fd, CTL_PORT_REQ, &req); | ||||
free(req.args); | free(req.args); | ||||
if (error != 0) { | if (error != 0) { | ||||
log_warn("error issuing CTL_PORT_REQ ioctl"); | log_warn("error issuing CTL_PORT_REQ ioctl"); | ||||
▲ Show 20 Lines • Show All 286 Lines • Show Last 20 Lines |