summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ctld/ctld.c
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2014-11-09 13:01:09 +0000
committertrasz <trasz@FreeBSD.org>2014-11-09 13:01:09 +0000
commit4eec651ec388a7406d989f93aef0d62f748080fc (patch)
tree7fce56b0e4a689fc51e535b741025162dc8c5f61 /usr.sbin/ctld/ctld.c
parent037bd5af5746c3f20b892933dccfc78a245f81a4 (diff)
downloadFreeBSD-src-4eec651ec388a7406d989f93aef0d62f748080fc.zip
FreeBSD-src-4eec651ec388a7406d989f93aef0d62f748080fc.tar.gz
Add support for sending redirections to iSCSI target.
MFC after: 1 month Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'usr.sbin/ctld/ctld.c')
-rw-r--r--usr.sbin/ctld/ctld.c56
1 files changed, 52 insertions, 4 deletions
diff --git a/usr.sbin/ctld/ctld.c b/usr.sbin/ctld/ctld.c
index a480b2e..bbf8e7d 100644
--- a/usr.sbin/ctld/ctld.c
+++ b/usr.sbin/ctld/ctld.c
@@ -622,6 +622,7 @@ portal_group_delete(struct portal_group *pg)
TAILQ_FOREACH_SAFE(portal, &pg->pg_portals, p_next, tmp)
portal_delete(portal);
free(pg->pg_name);
+ free(pg->pg_redirection);
free(pg);
}
@@ -1000,6 +1001,22 @@ portal_group_set_filter(struct portal_group *pg, const char *str)
return (0);
}
+int
+portal_group_set_redirection(struct portal_group *pg, const char *addr)
+{
+
+ if (pg->pg_redirection != NULL) {
+ log_warnx("cannot set redirection to \"%s\" for "
+ "portal-group \"%s\"; already defined",
+ addr, pg->pg_name);
+ return (1);
+ }
+
+ pg->pg_redirection = checked_strdup(addr);
+
+ return (0);
+}
+
static bool
valid_hex(const char ch)
{
@@ -1144,6 +1161,7 @@ target_delete(struct target *targ)
TAILQ_FOREACH_SAFE(lun, &targ->t_luns, l_next, tmp)
lun_delete(lun);
free(targ->t_name);
+ free(targ->t_redirection);
free(targ);
}
@@ -1160,6 +1178,22 @@ target_find(struct conf *conf, const char *name)
return (NULL);
}
+int
+target_set_redirection(struct target *target, const char *addr)
+{
+
+ if (target->t_redirection != NULL) {
+ log_warnx("cannot set redirection to \"%s\" for "
+ "target \"%s\"; already defined",
+ addr, target->t_name);
+ return (1);
+ }
+
+ target->t_redirection = checked_strdup(addr);
+
+ return (0);
+}
+
struct lun *
lun_new(struct target *targ, int lun_id)
{
@@ -1486,10 +1520,15 @@ conf_verify(struct conf *conf)
return (error);
found = true;
}
- if (!found) {
+ if (!found && targ->t_redirection == NULL) {
log_warnx("no LUNs defined for target \"%s\"",
targ->t_name);
}
+ if (found && targ->t_redirection != NULL) {
+ log_debugx("target \"%s\" contains luns, "
+ " but configured for redirection",
+ targ->t_name);
+ }
}
TAILQ_FOREACH(pg, &conf->conf_portal_groups, pg_next) {
assert(pg->pg_name != NULL);
@@ -1506,13 +1545,22 @@ conf_verify(struct conf *conf)
if (targ->t_portal_group == pg)
break;
}
- if (targ == NULL) {
+ if (pg->pg_redirection != NULL) {
+ if (targ != NULL) {
+ log_debugx("portal-group \"%s\" assigned "
+ "to target \"%s\", but configured "
+ "for redirection",
+ pg->pg_name, targ->t_name);
+ }
+ pg->pg_unassigned = false;
+ } else if (targ != NULL) {
+ pg->pg_unassigned = false;
+ } else {
if (strcmp(pg->pg_name, "default") != 0)
log_warnx("portal-group \"%s\" not assigned "
"to any target", pg->pg_name);
pg->pg_unassigned = true;
- } else
- pg->pg_unassigned = false;
+ }
}
TAILQ_FOREACH(ag, &conf->conf_auth_groups, ag_next) {
if (ag->ag_name == NULL)
OpenPOWER on IntegriCloud