Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/ctld/ctld.c
Show First 20 Lines • Show All 1,228 Lines • ▼ Show 20 Lines | if (port_find(conf, name) != NULL) { | ||||
free(name); | free(name); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
port = calloc(1, sizeof(*port)); | port = calloc(1, sizeof(*port)); | ||||
if (port == NULL) | if (port == NULL) | ||||
log_err(1, "calloc"); | log_err(1, "calloc"); | ||||
port->p_conf = conf; | port->p_conf = conf; | ||||
port->p_name = name; | port->p_name = name; | ||||
port->p_ioctl_port = 0; | |||||
TAILQ_INSERT_TAIL(&conf->conf_ports, port, p_next); | TAILQ_INSERT_TAIL(&conf->conf_ports, port, p_next); | ||||
TAILQ_INSERT_TAIL(&target->t_ports, port, p_ts); | TAILQ_INSERT_TAIL(&target->t_ports, port, p_ts); | ||||
port->p_target = target; | port->p_target = target; | ||||
TAILQ_INSERT_TAIL(&pg->pg_ports, port, p_pgs); | TAILQ_INSERT_TAIL(&pg->pg_ports, port, p_pgs); | ||||
port->p_portal_group = pg; | port->p_portal_group = pg; | ||||
return (port); | return (port); | ||||
} | } | ||||
struct port * | struct port * | ||||
port_new_ioctl(struct conf *conf, struct target *target, int pp, int vp) | |||||
{ | |||||
struct pport *pport; | |||||
struct port *port; | |||||
char *pname; | |||||
char *name; | |||||
int ret; | |||||
ret = asprintf(&pname, "ioctl/%d/%d", pp, vp); | |||||
if (ret <= 0) { | |||||
log_err(1, "asprintf"); | |||||
return (NULL); | |||||
} | |||||
pport = pport_find(conf, pname); | |||||
if (pport != NULL) { | |||||
free(pname); | |||||
return (port_new_pp(conf, target, pport)); | |||||
} | |||||
ret = asprintf(&name, "%s-%s", pname, target->t_name); | |||||
free(pname); | |||||
if (ret <= 0) | |||||
log_err(1, "asprintf"); | |||||
if (port_find(conf, name) != NULL) { | |||||
log_warnx("duplicate port \"%s\"", name); | |||||
free(name); | |||||
return (NULL); | |||||
} | |||||
port = calloc(1, sizeof(*port)); | |||||
if (port == NULL) | |||||
log_err(1, "calloc"); | |||||
port->p_conf = conf; | |||||
port->p_name = name; | |||||
port->p_ioctl_port = 1; | |||||
port->p_ioctl_pp = pp; | |||||
port->p_ioctl_vp = vp; | |||||
TAILQ_INSERT_TAIL(&conf->conf_ports, port, p_next); | |||||
TAILQ_INSERT_TAIL(&target->t_ports, port, p_ts); | |||||
port->p_target = target; | |||||
return (port); | |||||
} | |||||
struct port * | |||||
port_new_pp(struct conf *conf, struct target *target, struct pport *pp) | port_new_pp(struct conf *conf, struct target *target, struct pport *pp) | ||||
{ | { | ||||
struct port *port; | struct port *port; | ||||
char *name; | char *name; | ||||
int ret; | int ret; | ||||
ret = asprintf(&name, "%s-%s", pp->pp_name, target->t_name); | ret = asprintf(&name, "%s-%s", pp->pp_name, target->t_name); | ||||
if (ret <= 0) | if (ret <= 0) | ||||
▲ Show 20 Lines • Show All 368 Lines • ▼ Show 20 Lines | TAILQ_FOREACH(ag, &conf->conf_auth_groups, ag_next) { | ||||
fprintf(stderr, "auth-group %s {\n", ag->ag_name); | fprintf(stderr, "auth-group %s {\n", ag->ag_name); | ||||
TAILQ_FOREACH(auth, &ag->ag_auths, a_next) | TAILQ_FOREACH(auth, &ag->ag_auths, a_next) | ||||
fprintf(stderr, "\t chap-mutual %s %s %s %s\n", | fprintf(stderr, "\t chap-mutual %s %s %s %s\n", | ||||
auth->a_user, auth->a_secret, | auth->a_user, auth->a_secret, | ||||
auth->a_mutual_user, auth->a_mutual_secret); | auth->a_mutual_user, auth->a_mutual_secret); | ||||
TAILQ_FOREACH(auth_name, &ag->ag_names, an_next) | TAILQ_FOREACH(auth_name, &ag->ag_names, an_next) | ||||
fprintf(stderr, "\t initiator-name %s\n", | fprintf(stderr, "\t initiator-name %s\n", | ||||
auth_name->an_initator_name); | auth_name->an_initator_name); | ||||
TAILQ_FOREACH(auth_portal, &ag->ag_portals, an_next) | TAILQ_FOREACH(auth_portal, &ag->ag_portals, ap_next) | ||||
fprintf(stderr, "\t initiator-portal %s\n", | fprintf(stderr, "\t initiator-portal %s\n", | ||||
auth_portal->an_initator_portal); | auth_portal->ap_initator_portal); | ||||
fprintf(stderr, "}\n"); | fprintf(stderr, "}\n"); | ||||
} | } | ||||
TAILQ_FOREACH(pg, &conf->conf_portal_groups, pg_next) { | TAILQ_FOREACH(pg, &conf->conf_portal_groups, pg_next) { | ||||
fprintf(stderr, "portal-group %s {\n", pg->pg_name); | fprintf(stderr, "portal-group %s {\n", pg->pg_name); | ||||
TAILQ_FOREACH(portal, &pg->pg_portals, p_next) | TAILQ_FOREACH(portal, &pg->pg_portals, p_next) | ||||
fprintf(stderr, "\t listen %s\n", portal->p_listen); | fprintf(stderr, "\t listen %s\n", portal->p_listen); | ||||
fprintf(stderr, "}\n"); | fprintf(stderr, "}\n"); | ||||
} | } | ||||
TAILQ_FOREACH(lun, &conf->conf_luns, l_next) { | TAILQ_FOREACH(lun, &conf->conf_luns, l_next) { | ||||
fprintf(stderr, "\tlun %s {\n", lun->l_name); | fprintf(stderr, "\tlun %s {\n", lun->l_name); | ||||
fprintf(stderr, "\t\tpath %s\n", lun->l_path); | fprintf(stderr, "\t\tpath %s\n", lun->l_path); | ||||
TAILQ_FOREACH(o, &lun->l_options, o_next) | TAILQ_FOREACH(o, &lun->l_options, o_next) | ||||
fprintf(stderr, "\t\toption %s %s\n", | fprintf(stderr, "\t\toption %s %s\n", | ||||
lo->o_name, lo->o_value); | o->o_name, o->o_value); | ||||
fprintf(stderr, "\t}\n"); | fprintf(stderr, "\t}\n"); | ||||
} | } | ||||
TAILQ_FOREACH(targ, &conf->conf_targets, t_next) { | TAILQ_FOREACH(targ, &conf->conf_targets, t_next) { | ||||
fprintf(stderr, "target %s {\n", targ->t_name); | fprintf(stderr, "target %s {\n", targ->t_name); | ||||
if (targ->t_alias != NULL) | if (targ->t_alias != NULL) | ||||
fprintf(stderr, "\t alias %s\n", targ->t_alias); | fprintf(stderr, "\t alias %s\n", targ->t_alias); | ||||
fprintf(stderr, "}\n"); | fprintf(stderr, "}\n"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,090 Lines • Show Last 20 Lines |