aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/ctld/parse.y
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2015-02-07 13:19:04 +0000
committerAlexander Motin <mav@FreeBSD.org>2015-02-07 13:19:04 +0000
commit057abcb00413010898f3046f7704444b8f537bab (patch)
treeae85e4ae407409dc63dc9c310d8f357bd42151d2 /usr.sbin/ctld/parse.y
parent6c316535e28ff4150d932e399b3ee3dba3d31339 (diff)
downloadsrc-057abcb00413010898f3046f7704444b8f537bab.tar.gz
src-057abcb00413010898f3046f7704444b8f537bab.zip
Teach ctld(8) to control non-iSCSI CTL ports.
This change introduces new target option "port", that assigns current target to specified CTL port. On config application ctld(8) will apply LUN mapping according to target configuration to specified port and bring the port up. On shutdown cltd(8) will remove the mapping and put the port down. This change allows to configure both iSCSI and FibreChannel targets in the same configuration file in alike way. Kernel side support was added earlier at r278037. MFC after: 2 weeks Relnotes: yes Sponsored by: iXsystems, Inc.
Notes
Notes: svn path=/head/; revision=278354
Diffstat (limited to 'usr.sbin/ctld/parse.y')
-rw-r--r--usr.sbin/ctld/parse.y40
1 files changed, 38 insertions, 2 deletions
diff --git a/usr.sbin/ctld/parse.y b/usr.sbin/ctld/parse.y
index 5eaffe4e324a..a7807eff1434 100644
--- a/usr.sbin/ctld/parse.y
+++ b/usr.sbin/ctld/parse.y
@@ -61,7 +61,7 @@ extern void yyrestart(FILE *);
%token CLOSING_BRACKET DEBUG DEVICE_ID DISCOVERY_AUTH_GROUP DISCOVERY_FILTER
%token INITIATOR_NAME INITIATOR_PORTAL ISNS_SERVER ISNS_PERIOD ISNS_TIMEOUT
%token LISTEN LISTEN_ISER LUN MAXPROC OFFLOAD OPENING_BRACKET OPTION
-%token PATH PIDFILE PORTAL_GROUP REDIRECT SEMICOLON SERIAL SIZE STR
+%token PATH PIDFILE PORT PORTAL_GROUP REDIRECT SEMICOLON SERIAL SIZE STR
%token TARGET TIMEOUT
%union
@@ -467,6 +467,8 @@ target_entry:
|
target_portal_group
|
+ target_port
+ |
target_redirect
|
target_lun
@@ -721,6 +723,36 @@ target_portal_group: PORTAL_GROUP STR STR
}
;
+target_port: PORT STR
+ {
+ struct pport *pp;
+ struct port *tp;
+
+ pp = pport_find(conf, $2);
+ if (pp == NULL) {
+ log_warnx("unknown port \"%s\" for target \"%s\"",
+ $2, target->t_name);
+ free($2);
+ return (1);
+ }
+ if (!TAILQ_EMPTY(&pp->pp_ports)) {
+ log_warnx("can't link port \"%s\" to target \"%s\", "
+ "port already linked to some target",
+ $2, target->t_name);
+ free($2);
+ return (1);
+ }
+ tp = port_new_pp(conf, target, pp);
+ if (tp == NULL) {
+ log_warnx("can't link port \"%s\" to target \"%s\"",
+ $2, target->t_name);
+ free($2);
+ return (1);
+ }
+ free($2);
+ }
+ ;
+
target_redirect: REDIRECT STR
{
int error;
@@ -950,16 +982,20 @@ check_perms(const char *path)
}
struct conf *
-conf_new_from_file(const char *path)
+conf_new_from_file(const char *path, struct conf *oldconf)
{
struct auth_group *ag;
struct portal_group *pg;
+ struct pport *pp;
int error;
log_debugx("obtaining configuration from %s", path);
conf = conf_new();
+ TAILQ_FOREACH(pp, &oldconf->conf_pports, pp_next)
+ pport_copy(pp, conf);
+
ag = auth_group_new(conf, "default");
assert(ag != NULL);