2013-09-14 15:29:06 +00:00
|
|
|
%{
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 2012 The FreeBSD Foundation
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This software was developed by Edward Tomasz Napierala under sponsorship
|
|
|
|
* from the FreeBSD Foundation.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "ctld.h"
|
|
|
|
|
|
|
|
extern FILE *yyin;
|
|
|
|
extern char *yytext;
|
|
|
|
extern int lineno;
|
|
|
|
|
|
|
|
static struct conf *conf = NULL;
|
|
|
|
static struct auth_group *auth_group = NULL;
|
|
|
|
static struct portal_group *portal_group = NULL;
|
|
|
|
static struct target *target = NULL;
|
|
|
|
static struct lun *lun = NULL;
|
|
|
|
|
|
|
|
extern void yyerror(const char *);
|
|
|
|
extern int yylex(void);
|
|
|
|
extern void yyrestart(FILE *);
|
|
|
|
|
|
|
|
%}
|
|
|
|
|
2014-02-11 11:26:05 +00:00
|
|
|
%token ALIAS AUTH_GROUP AUTH_TYPE BACKEND BLOCKSIZE CHAP CHAP_MUTUAL
|
2015-09-27 13:47:28 +00:00
|
|
|
%token CLOSING_BRACKET CTL_LUN DEBUG DEVICE_ID DEVICE_TYPE
|
|
|
|
%token DISCOVERY_AUTH_GROUP DISCOVERY_FILTER FOREIGN
|
2014-10-29 12:12:27 +00:00
|
|
|
%token INITIATOR_NAME INITIATOR_PORTAL ISNS_SERVER ISNS_PERIOD ISNS_TIMEOUT
|
2015-02-06 21:03:25 +00:00
|
|
|
%token LISTEN LISTEN_ISER LUN MAXPROC OFFLOAD OPENING_BRACKET OPTION
|
2015-02-07 13:19:04 +00:00
|
|
|
%token PATH PIDFILE PORT PORTAL_GROUP REDIRECT SEMICOLON SERIAL SIZE STR
|
2015-09-07 13:43:05 +00:00
|
|
|
%token TAG TARGET TIMEOUT
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
|
|
%union
|
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
}
|
|
|
|
|
|
|
|
%token <str> STR
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
statements:
|
|
|
|
|
|
|
|
|
statements statement
|
2014-10-29 12:10:39 +00:00
|
|
|
|
|
|
|
|
statements statement SEMICOLON
|
2013-09-14 15:29:06 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
statement:
|
2014-02-11 11:11:37 +00:00
|
|
|
debug
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
timeout
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
maxproc
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
pidfile
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
2014-10-25 12:50:26 +00:00
|
|
|
isns_server
|
|
|
|
|
|
|
|
|
isns_period
|
|
|
|
|
|
|
|
|
isns_timeout
|
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
auth_group
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
portal_group
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
lun
|
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
target
|
2013-09-14 15:29:06 +00:00
|
|
|
;
|
|
|
|
|
2014-10-28 10:25:59 +00:00
|
|
|
debug: DEBUG STR
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
2014-10-28 10:25:59 +00:00
|
|
|
uint64_t tmp;
|
|
|
|
|
|
|
|
if (expand_number($2, &tmp) != 0) {
|
2014-10-28 10:39:29 +00:00
|
|
|
yyerror("invalid numeric value");
|
2014-10-28 10:25:59 +00:00
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
conf->conf_debug = tmp;
|
2013-09-14 15:29:06 +00:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-10-28 10:25:59 +00:00
|
|
|
timeout: TIMEOUT STR
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
2014-10-28 10:25:59 +00:00
|
|
|
uint64_t tmp;
|
|
|
|
|
|
|
|
if (expand_number($2, &tmp) != 0) {
|
2014-10-28 10:39:29 +00:00
|
|
|
yyerror("invalid numeric value");
|
2014-10-28 10:25:59 +00:00
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
conf->conf_timeout = tmp;
|
2013-09-14 15:29:06 +00:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-10-28 10:25:59 +00:00
|
|
|
maxproc: MAXPROC STR
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
2014-10-28 10:25:59 +00:00
|
|
|
uint64_t tmp;
|
|
|
|
|
|
|
|
if (expand_number($2, &tmp) != 0) {
|
2014-10-28 10:39:29 +00:00
|
|
|
yyerror("invalid numeric value");
|
2014-10-28 10:25:59 +00:00
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
conf->conf_maxproc = tmp;
|
2013-09-14 15:29:06 +00:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
pidfile: PIDFILE STR
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
|
|
|
if (conf->conf_pidfile_path != NULL) {
|
|
|
|
log_warnx("pidfile specified more than once");
|
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
conf->conf_pidfile_path = $2;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-10-25 12:50:26 +00:00
|
|
|
isns_server: ISNS_SERVER STR
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = isns_new(conf, $2);
|
|
|
|
free($2);
|
|
|
|
if (error != 0)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-10-28 10:39:29 +00:00
|
|
|
isns_period: ISNS_PERIOD STR
|
2014-10-25 12:50:26 +00:00
|
|
|
{
|
2014-10-28 10:39:29 +00:00
|
|
|
uint64_t tmp;
|
|
|
|
|
|
|
|
if (expand_number($2, &tmp) != 0) {
|
|
|
|
yyerror("invalid numeric value");
|
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
conf->conf_isns_period = tmp;
|
2014-10-25 12:50:26 +00:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-10-28 10:39:29 +00:00
|
|
|
isns_timeout: ISNS_TIMEOUT STR
|
2014-10-25 12:50:26 +00:00
|
|
|
{
|
2014-10-28 10:39:29 +00:00
|
|
|
uint64_t tmp;
|
|
|
|
|
|
|
|
if (expand_number($2, &tmp) != 0) {
|
|
|
|
yyerror("invalid numeric value");
|
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
conf->conf_isns_timeout = tmp;
|
2014-10-25 12:50:26 +00:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
auth_group: AUTH_GROUP auth_group_name
|
2013-09-14 15:29:06 +00:00
|
|
|
OPENING_BRACKET auth_group_entries CLOSING_BRACKET
|
|
|
|
{
|
|
|
|
auth_group = NULL;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
auth_group_name: STR
|
|
|
|
{
|
2014-02-11 11:29:05 +00:00
|
|
|
/*
|
|
|
|
* Make it possible to redefine default
|
|
|
|
* auth-group. but only once.
|
|
|
|
*/
|
|
|
|
if (strcmp($1, "default") == 0 &&
|
|
|
|
conf->conf_default_ag_defined == false) {
|
|
|
|
auth_group = auth_group_find(conf, $1);
|
|
|
|
conf->conf_default_ag_defined = true;
|
|
|
|
} else {
|
|
|
|
auth_group = auth_group_new(conf, $1);
|
|
|
|
}
|
2013-09-14 15:29:06 +00:00
|
|
|
free($1);
|
|
|
|
if (auth_group == NULL)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
auth_group_entries:
|
|
|
|
|
|
|
|
|
auth_group_entries auth_group_entry
|
2014-10-29 12:10:39 +00:00
|
|
|
|
|
|
|
|
auth_group_entries auth_group_entry SEMICOLON
|
2013-09-14 15:29:06 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
auth_group_entry:
|
2014-02-11 11:26:05 +00:00
|
|
|
auth_group_auth_type
|
|
|
|
|
|
2013-09-14 15:29:06 +00:00
|
|
|
auth_group_chap
|
|
|
|
|
|
|
|
|
auth_group_chap_mutual
|
2014-02-11 11:08:04 +00:00
|
|
|
|
|
|
|
|
auth_group_initiator_name
|
|
|
|
|
|
|
|
|
auth_group_initiator_portal
|
2013-09-14 15:29:06 +00:00
|
|
|
;
|
|
|
|
|
2014-02-11 11:26:05 +00:00
|
|
|
auth_group_auth_type: AUTH_TYPE STR
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
2014-10-29 09:36:02 +00:00
|
|
|
error = auth_group_set_type(auth_group, $2);
|
2014-02-11 11:26:05 +00:00
|
|
|
free($2);
|
|
|
|
if (error != 0)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2013-09-14 15:29:06 +00:00
|
|
|
auth_group_chap: CHAP STR STR
|
|
|
|
{
|
|
|
|
const struct auth *ca;
|
|
|
|
|
|
|
|
ca = auth_new_chap(auth_group, $2, $3);
|
|
|
|
free($2);
|
|
|
|
free($3);
|
|
|
|
if (ca == NULL)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
auth_group_chap_mutual: CHAP_MUTUAL STR STR STR STR
|
|
|
|
{
|
|
|
|
const struct auth *ca;
|
|
|
|
|
|
|
|
ca = auth_new_chap_mutual(auth_group, $2, $3, $4, $5);
|
|
|
|
free($2);
|
|
|
|
free($3);
|
|
|
|
free($4);
|
|
|
|
free($5);
|
|
|
|
if (ca == NULL)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-02-11 11:08:04 +00:00
|
|
|
auth_group_initiator_name: INITIATOR_NAME STR
|
|
|
|
{
|
|
|
|
const struct auth_name *an;
|
|
|
|
|
|
|
|
an = auth_name_new(auth_group, $2);
|
|
|
|
free($2);
|
|
|
|
if (an == NULL)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
auth_group_initiator_portal: INITIATOR_PORTAL STR
|
|
|
|
{
|
|
|
|
const struct auth_portal *ap;
|
|
|
|
|
|
|
|
ap = auth_portal_new(auth_group, $2);
|
|
|
|
free($2);
|
|
|
|
if (ap == NULL)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
portal_group: PORTAL_GROUP portal_group_name
|
2013-09-14 15:29:06 +00:00
|
|
|
OPENING_BRACKET portal_group_entries CLOSING_BRACKET
|
|
|
|
{
|
|
|
|
portal_group = NULL;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
portal_group_name: STR
|
|
|
|
{
|
2014-02-11 11:27:25 +00:00
|
|
|
/*
|
|
|
|
* Make it possible to redefine default
|
|
|
|
* portal-group. but only once.
|
|
|
|
*/
|
|
|
|
if (strcmp($1, "default") == 0 &&
|
|
|
|
conf->conf_default_pg_defined == false) {
|
|
|
|
portal_group = portal_group_find(conf, $1);
|
|
|
|
conf->conf_default_pg_defined = true;
|
|
|
|
} else {
|
|
|
|
portal_group = portal_group_new(conf, $1);
|
|
|
|
}
|
2013-09-14 15:29:06 +00:00
|
|
|
free($1);
|
|
|
|
if (portal_group == NULL)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
portal_group_entries:
|
|
|
|
|
|
|
|
|
portal_group_entries portal_group_entry
|
2014-10-29 12:10:39 +00:00
|
|
|
|
|
|
|
|
portal_group_entries portal_group_entry SEMICOLON
|
2013-09-14 15:29:06 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
portal_group_entry:
|
|
|
|
portal_group_discovery_auth_group
|
|
|
|
|
|
2014-10-29 09:26:55 +00:00
|
|
|
portal_group_discovery_filter
|
|
|
|
|
|
2015-09-07 13:43:05 +00:00
|
|
|
portal_group_foreign
|
|
|
|
|
|
2013-09-14 15:29:06 +00:00
|
|
|
portal_group_listen
|
|
|
|
|
|
|
|
|
portal_group_listen_iser
|
2014-11-09 13:01:09 +00:00
|
|
|
|
|
2015-02-28 12:02:32 +00:00
|
|
|
portal_group_offload
|
|
|
|
|
|
2015-11-09 18:33:36 +00:00
|
|
|
portal_group_option
|
|
|
|
|
|
2014-11-09 13:01:09 +00:00
|
|
|
portal_group_redirect
|
2015-09-07 13:43:05 +00:00
|
|
|
|
|
|
|
|
portal_group_tag
|
2013-09-14 15:29:06 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
portal_group_discovery_auth_group: DISCOVERY_AUTH_GROUP STR
|
|
|
|
{
|
|
|
|
if (portal_group->pg_discovery_auth_group != NULL) {
|
|
|
|
log_warnx("discovery-auth-group for portal-group "
|
|
|
|
"\"%s\" specified more than once",
|
|
|
|
portal_group->pg_name);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
portal_group->pg_discovery_auth_group =
|
|
|
|
auth_group_find(conf, $2);
|
|
|
|
if (portal_group->pg_discovery_auth_group == NULL) {
|
|
|
|
log_warnx("unknown discovery-auth-group \"%s\" "
|
|
|
|
"for portal-group \"%s\"",
|
|
|
|
$2, portal_group->pg_name);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
free($2);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-10-29 09:26:55 +00:00
|
|
|
portal_group_discovery_filter: DISCOVERY_FILTER STR
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
2014-10-29 09:36:02 +00:00
|
|
|
error = portal_group_set_filter(portal_group, $2);
|
2014-10-29 09:26:55 +00:00
|
|
|
free($2);
|
|
|
|
if (error != 0)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2015-09-07 13:43:05 +00:00
|
|
|
portal_group_foreign: FOREIGN
|
|
|
|
{
|
|
|
|
|
|
|
|
portal_group->pg_foreign = 1;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2013-09-14 15:29:06 +00:00
|
|
|
portal_group_listen: LISTEN STR
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = portal_group_add_listen(portal_group, $2, false);
|
|
|
|
free($2);
|
|
|
|
if (error != 0)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
portal_group_listen_iser: LISTEN_ISER STR
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = portal_group_add_listen(portal_group, $2, true);
|
|
|
|
free($2);
|
|
|
|
if (error != 0)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2015-02-28 12:02:32 +00:00
|
|
|
portal_group_offload: OFFLOAD STR
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = portal_group_set_offload(portal_group, $2);
|
|
|
|
free($2);
|
|
|
|
if (error != 0)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2015-11-09 18:33:36 +00:00
|
|
|
portal_group_option: OPTION STR STR
|
|
|
|
{
|
|
|
|
struct option *o;
|
|
|
|
|
|
|
|
o = option_new(&portal_group->pg_options, $2, $3);
|
|
|
|
free($2);
|
|
|
|
free($3);
|
|
|
|
if (o == NULL)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-11-09 13:01:09 +00:00
|
|
|
portal_group_redirect: REDIRECT STR
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = portal_group_set_redirection(portal_group, $2);
|
|
|
|
free($2);
|
|
|
|
if (error != 0)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2015-09-07 13:43:05 +00:00
|
|
|
portal_group_tag: TAG STR
|
|
|
|
{
|
|
|
|
uint64_t tmp;
|
|
|
|
|
|
|
|
if (expand_number($2, &tmp) != 0) {
|
|
|
|
yyerror("invalid numeric value");
|
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
portal_group->pg_tag = tmp;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
lun: LUN lun_name
|
|
|
|
OPENING_BRACKET lun_entries CLOSING_BRACKET
|
|
|
|
{
|
|
|
|
lun = NULL;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
lun_name: STR
|
|
|
|
{
|
|
|
|
lun = lun_new(conf, $1);
|
|
|
|
free($1);
|
|
|
|
if (lun == NULL)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
target: TARGET target_name
|
2013-09-14 15:29:06 +00:00
|
|
|
OPENING_BRACKET target_entries CLOSING_BRACKET
|
|
|
|
{
|
|
|
|
target = NULL;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
target_name: STR
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
|
|
|
target = target_new(conf, $1);
|
|
|
|
free($1);
|
|
|
|
if (target == NULL)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
target_entries:
|
|
|
|
|
|
|
|
|
target_entries target_entry
|
2014-10-29 12:10:39 +00:00
|
|
|
|
|
|
|
|
target_entries target_entry SEMICOLON
|
2013-09-14 15:29:06 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
target_entry:
|
2014-02-11 11:11:37 +00:00
|
|
|
target_alias
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
target_auth_group
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
2014-02-11 11:26:05 +00:00
|
|
|
target_auth_type
|
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
target_chap
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
target_chap_mutual
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
target_initiator_name
|
2014-02-11 11:08:04 +00:00
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
target_initiator_portal
|
2014-02-11 11:08:04 +00:00
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
target_portal_group
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
2015-02-07 13:19:04 +00:00
|
|
|
target_port
|
|
|
|
|
|
2014-11-09 13:01:09 +00:00
|
|
|
target_redirect
|
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
target_lun
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
|
|
|
|
|
target_lun_ref
|
2013-09-14 15:29:06 +00:00
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
target_alias: ALIAS STR
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
|
|
|
if (target->t_alias != NULL) {
|
|
|
|
log_warnx("alias for target \"%s\" "
|
2014-02-11 11:14:50 +00:00
|
|
|
"specified more than once", target->t_name);
|
2013-09-14 15:29:06 +00:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
target->t_alias = $2;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
target_auth_group: AUTH_GROUP STR
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
|
|
|
if (target->t_auth_group != NULL) {
|
|
|
|
if (target->t_auth_group->ag_name != NULL)
|
|
|
|
log_warnx("auth-group for target \"%s\" "
|
2014-02-11 11:14:50 +00:00
|
|
|
"specified more than once", target->t_name);
|
2013-09-14 15:29:06 +00:00
|
|
|
else
|
2014-02-11 11:26:05 +00:00
|
|
|
log_warnx("cannot use both auth-group and explicit "
|
2013-09-14 15:29:06 +00:00
|
|
|
"authorisations for target \"%s\"",
|
2014-02-11 11:14:50 +00:00
|
|
|
target->t_name);
|
2013-09-14 15:29:06 +00:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
target->t_auth_group = auth_group_find(conf, $2);
|
|
|
|
if (target->t_auth_group == NULL) {
|
|
|
|
log_warnx("unknown auth-group \"%s\" for target "
|
2014-02-11 11:14:50 +00:00
|
|
|
"\"%s\"", $2, target->t_name);
|
2013-09-14 15:29:06 +00:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
free($2);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-02-11 11:26:05 +00:00
|
|
|
target_auth_type: AUTH_TYPE STR
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
if (target->t_auth_group != NULL) {
|
|
|
|
if (target->t_auth_group->ag_name != NULL) {
|
|
|
|
log_warnx("cannot use both auth-group and "
|
|
|
|
"auth-type for target \"%s\"",
|
|
|
|
target->t_name);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
target->t_auth_group = auth_group_new(conf, NULL);
|
|
|
|
if (target->t_auth_group == NULL) {
|
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
target->t_auth_group->ag_target = target;
|
|
|
|
}
|
2014-10-29 09:36:02 +00:00
|
|
|
error = auth_group_set_type(target->t_auth_group, $2);
|
2014-02-11 11:26:05 +00:00
|
|
|
free($2);
|
|
|
|
if (error != 0)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
target_chap: CHAP STR STR
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
|
|
|
const struct auth *ca;
|
|
|
|
|
|
|
|
if (target->t_auth_group != NULL) {
|
|
|
|
if (target->t_auth_group->ag_name != NULL) {
|
2014-02-11 11:26:05 +00:00
|
|
|
log_warnx("cannot use both auth-group and "
|
|
|
|
"chap for target \"%s\"",
|
2014-02-11 11:14:50 +00:00
|
|
|
target->t_name);
|
2013-09-14 15:29:06 +00:00
|
|
|
free($2);
|
|
|
|
free($3);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
target->t_auth_group = auth_group_new(conf, NULL);
|
|
|
|
if (target->t_auth_group == NULL) {
|
|
|
|
free($2);
|
|
|
|
free($3);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
target->t_auth_group->ag_target = target;
|
|
|
|
}
|
|
|
|
ca = auth_new_chap(target->t_auth_group, $2, $3);
|
|
|
|
free($2);
|
|
|
|
free($3);
|
|
|
|
if (ca == NULL)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
target_chap_mutual: CHAP_MUTUAL STR STR STR STR
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
|
|
|
const struct auth *ca;
|
|
|
|
|
|
|
|
if (target->t_auth_group != NULL) {
|
|
|
|
if (target->t_auth_group->ag_name != NULL) {
|
2014-02-11 11:26:05 +00:00
|
|
|
log_warnx("cannot use both auth-group and "
|
|
|
|
"chap-mutual for target \"%s\"",
|
2014-02-11 11:14:50 +00:00
|
|
|
target->t_name);
|
2013-09-14 15:29:06 +00:00
|
|
|
free($2);
|
|
|
|
free($3);
|
|
|
|
free($4);
|
|
|
|
free($5);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
target->t_auth_group = auth_group_new(conf, NULL);
|
|
|
|
if (target->t_auth_group == NULL) {
|
|
|
|
free($2);
|
|
|
|
free($3);
|
|
|
|
free($4);
|
|
|
|
free($5);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
target->t_auth_group->ag_target = target;
|
|
|
|
}
|
|
|
|
ca = auth_new_chap_mutual(target->t_auth_group,
|
|
|
|
$2, $3, $4, $5);
|
|
|
|
free($2);
|
|
|
|
free($3);
|
|
|
|
free($4);
|
|
|
|
free($5);
|
|
|
|
if (ca == NULL)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
target_initiator_name: INITIATOR_NAME STR
|
2014-02-11 11:08:04 +00:00
|
|
|
{
|
|
|
|
const struct auth_name *an;
|
|
|
|
|
|
|
|
if (target->t_auth_group != NULL) {
|
|
|
|
if (target->t_auth_group->ag_name != NULL) {
|
2014-02-11 11:26:05 +00:00
|
|
|
log_warnx("cannot use both auth-group and "
|
2014-02-11 11:08:04 +00:00
|
|
|
"initiator-name for target \"%s\"",
|
2014-02-11 11:14:50 +00:00
|
|
|
target->t_name);
|
2014-02-11 11:08:04 +00:00
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
target->t_auth_group = auth_group_new(conf, NULL);
|
|
|
|
if (target->t_auth_group == NULL) {
|
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
target->t_auth_group->ag_target = target;
|
|
|
|
}
|
|
|
|
an = auth_name_new(target->t_auth_group, $2);
|
|
|
|
free($2);
|
|
|
|
if (an == NULL)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
target_initiator_portal: INITIATOR_PORTAL STR
|
2014-02-11 11:08:04 +00:00
|
|
|
{
|
|
|
|
const struct auth_portal *ap;
|
|
|
|
|
|
|
|
if (target->t_auth_group != NULL) {
|
|
|
|
if (target->t_auth_group->ag_name != NULL) {
|
2014-02-11 11:26:05 +00:00
|
|
|
log_warnx("cannot use both auth-group and "
|
2014-02-11 11:08:04 +00:00
|
|
|
"initiator-portal for target \"%s\"",
|
2014-02-11 11:14:50 +00:00
|
|
|
target->t_name);
|
2014-02-11 11:08:04 +00:00
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
target->t_auth_group = auth_group_new(conf, NULL);
|
|
|
|
if (target->t_auth_group == NULL) {
|
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
target->t_auth_group->ag_target = target;
|
|
|
|
}
|
|
|
|
ap = auth_portal_new(target->t_auth_group, $2);
|
|
|
|
free($2);
|
|
|
|
if (ap == NULL)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2015-02-06 17:43:13 +00:00
|
|
|
target_portal_group: PORTAL_GROUP STR STR
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
2015-02-06 17:43:13 +00:00
|
|
|
struct portal_group *tpg;
|
|
|
|
struct auth_group *tag;
|
|
|
|
struct port *tp;
|
|
|
|
|
|
|
|
tpg = portal_group_find(conf, $2);
|
|
|
|
if (tpg == NULL) {
|
|
|
|
log_warnx("unknown portal-group \"%s\" for target "
|
|
|
|
"\"%s\"", $2, target->t_name);
|
2013-09-14 15:29:06 +00:00
|
|
|
free($2);
|
2015-02-06 17:43:13 +00:00
|
|
|
free($3);
|
2013-09-14 15:29:06 +00:00
|
|
|
return (1);
|
|
|
|
}
|
2015-02-06 17:43:13 +00:00
|
|
|
tag = auth_group_find(conf, $3);
|
|
|
|
if (tag == NULL) {
|
|
|
|
log_warnx("unknown auth-group \"%s\" for target "
|
|
|
|
"\"%s\"", $3, target->t_name);
|
|
|
|
free($2);
|
|
|
|
free($3);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
tp = port_new(conf, target, tpg);
|
|
|
|
if (tp == NULL) {
|
|
|
|
log_warnx("can't link portal-group \"%s\" to target "
|
|
|
|
"\"%s\"", $2, target->t_name);
|
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
tp->p_auth_group = tag;
|
|
|
|
free($2);
|
|
|
|
free($3);
|
|
|
|
}
|
|
|
|
| PORTAL_GROUP STR
|
|
|
|
{
|
|
|
|
struct portal_group *tpg;
|
|
|
|
struct port *tp;
|
|
|
|
|
|
|
|
tpg = portal_group_find(conf, $2);
|
|
|
|
if (tpg == NULL) {
|
2013-09-14 15:29:06 +00:00
|
|
|
log_warnx("unknown portal-group \"%s\" for target "
|
2014-02-11 11:14:50 +00:00
|
|
|
"\"%s\"", $2, target->t_name);
|
2015-02-06 17:43:13 +00:00
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
tp = port_new(conf, target, tpg);
|
|
|
|
if (tp == NULL) {
|
|
|
|
log_warnx("can't link portal-group \"%s\" to target "
|
|
|
|
"\"%s\"", $2, target->t_name);
|
2013-09-14 15:29:06 +00:00
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
free($2);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2015-02-07 13:19:04 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-11-09 13:01:09 +00:00
|
|
|
target_redirect: REDIRECT STR
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
|
|
|
error = target_set_redirection(target, $2);
|
|
|
|
free($2);
|
|
|
|
if (error != 0)
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
target_lun: LUN lun_number
|
|
|
|
OPENING_BRACKET lun_entries CLOSING_BRACKET
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
|
|
|
lun = NULL;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-10-28 10:25:59 +00:00
|
|
|
lun_number: STR
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
2014-10-28 10:25:59 +00:00
|
|
|
uint64_t tmp;
|
2015-02-26 09:08:48 +00:00
|
|
|
int ret;
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
char *name;
|
2014-10-28 10:25:59 +00:00
|
|
|
|
|
|
|
if (expand_number($1, &tmp) != 0) {
|
2014-10-28 10:39:29 +00:00
|
|
|
yyerror("invalid numeric value");
|
2014-10-28 10:25:59 +00:00
|
|
|
free($1);
|
|
|
|
return (1);
|
|
|
|
}
|
2016-12-27 17:13:31 +00:00
|
|
|
if (tmp >= MAX_LUNS) {
|
|
|
|
yyerror("LU number is too big");
|
|
|
|
free($1);
|
|
|
|
return (1);
|
|
|
|
}
|
2014-10-28 10:25:59 +00:00
|
|
|
|
2015-02-26 09:08:48 +00:00
|
|
|
ret = asprintf(&name, "%s,lun,%ju", target->t_name, tmp);
|
|
|
|
if (ret <= 0)
|
|
|
|
log_err(1, "asprintf");
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
lun = lun_new(conf, name);
|
2013-09-14 15:29:06 +00:00
|
|
|
if (lun == NULL)
|
|
|
|
return (1);
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
|
|
|
|
lun_set_scsiname(lun, name);
|
|
|
|
target->t_luns[tmp] = lun;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
target_lun_ref: LUN STR STR
|
|
|
|
{
|
|
|
|
uint64_t tmp;
|
|
|
|
|
|
|
|
if (expand_number($2, &tmp) != 0) {
|
|
|
|
yyerror("invalid numeric value");
|
|
|
|
free($2);
|
|
|
|
free($3);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
free($2);
|
2016-12-27 17:13:31 +00:00
|
|
|
if (tmp >= MAX_LUNS) {
|
|
|
|
yyerror("LU number is too big");
|
|
|
|
free($3);
|
|
|
|
return (1);
|
|
|
|
}
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
|
|
|
|
lun = lun_find(conf, $3);
|
|
|
|
free($3);
|
|
|
|
if (lun == NULL)
|
|
|
|
return (1);
|
|
|
|
|
|
|
|
target->t_luns[tmp] = lun;
|
2013-09-14 15:29:06 +00:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
lun_entries:
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
lun_entries lun_entry
|
2014-10-29 12:10:39 +00:00
|
|
|
|
|
|
|
|
lun_entries lun_entry SEMICOLON
|
2013-09-14 15:29:06 +00:00
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
lun_entry:
|
|
|
|
lun_backend
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
lun_blocksize
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
lun_device_id
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
2015-09-27 13:47:28 +00:00
|
|
|
lun_device_type
|
|
|
|
|
|
2015-09-15 13:37:48 +00:00
|
|
|
lun_ctl_lun
|
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
lun_option
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
lun_path
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
lun_serial
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
lun_size
|
2013-09-14 15:29:06 +00:00
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
lun_backend: BACKEND STR
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
|
|
|
if (lun->l_backend != NULL) {
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
log_warnx("backend for lun \"%s\" "
|
2013-09-14 15:29:06 +00:00
|
|
|
"specified more than once",
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
lun->l_name);
|
2013-09-14 15:29:06 +00:00
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
lun_set_backend(lun, $2);
|
|
|
|
free($2);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-10-28 10:25:59 +00:00
|
|
|
lun_blocksize: BLOCKSIZE STR
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
2014-10-28 10:25:59 +00:00
|
|
|
uint64_t tmp;
|
|
|
|
|
|
|
|
if (expand_number($2, &tmp) != 0) {
|
2014-10-28 10:39:29 +00:00
|
|
|
yyerror("invalid numeric value");
|
2014-10-28 10:25:59 +00:00
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
2013-09-14 15:29:06 +00:00
|
|
|
if (lun->l_blocksize != 0) {
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
log_warnx("blocksize for lun \"%s\" "
|
2013-09-14 15:29:06 +00:00
|
|
|
"specified more than once",
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
lun->l_name);
|
2013-09-14 15:29:06 +00:00
|
|
|
return (1);
|
|
|
|
}
|
2014-10-28 10:25:59 +00:00
|
|
|
lun_set_blocksize(lun, tmp);
|
2013-09-14 15:29:06 +00:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
lun_device_id: DEVICE_ID STR
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
|
|
|
if (lun->l_device_id != NULL) {
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
log_warnx("device_id for lun \"%s\" "
|
2013-09-14 15:29:06 +00:00
|
|
|
"specified more than once",
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
lun->l_name);
|
2013-09-14 15:29:06 +00:00
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
lun_set_device_id(lun, $2);
|
|
|
|
free($2);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2015-09-27 13:47:28 +00:00
|
|
|
lun_device_type: DEVICE_TYPE STR
|
|
|
|
{
|
|
|
|
uint64_t tmp;
|
|
|
|
|
|
|
|
if (strcasecmp($2, "disk") == 0 ||
|
|
|
|
strcasecmp($2, "direct") == 0)
|
|
|
|
tmp = 0;
|
|
|
|
else if (strcasecmp($2, "processor") == 0)
|
|
|
|
tmp = 3;
|
|
|
|
else if (strcasecmp($2, "cd") == 0 ||
|
|
|
|
strcasecmp($2, "cdrom") == 0 ||
|
|
|
|
strcasecmp($2, "dvd") == 0 ||
|
|
|
|
strcasecmp($2, "dvdrom") == 0)
|
|
|
|
tmp = 5;
|
|
|
|
else if (expand_number($2, &tmp) != 0 ||
|
|
|
|
tmp > 15) {
|
|
|
|
yyerror("invalid numeric value");
|
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
lun_set_device_type(lun, tmp);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2015-09-15 13:37:48 +00:00
|
|
|
lun_ctl_lun: CTL_LUN STR
|
|
|
|
{
|
|
|
|
uint64_t tmp;
|
|
|
|
|
|
|
|
if (expand_number($2, &tmp) != 0) {
|
|
|
|
yyerror("invalid numeric value");
|
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lun->l_ctl_lun >= 0) {
|
|
|
|
log_warnx("ctl_lun for lun \"%s\" "
|
|
|
|
"specified more than once",
|
|
|
|
lun->l_name);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
lun_set_ctl_lun(lun, tmp);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
lun_option: OPTION STR STR
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
2015-11-09 18:33:36 +00:00
|
|
|
struct option *o;
|
2014-10-22 09:17:17 +00:00
|
|
|
|
2015-11-09 18:33:36 +00:00
|
|
|
o = option_new(&lun->l_options, $2, $3);
|
2013-09-14 15:29:06 +00:00
|
|
|
free($2);
|
|
|
|
free($3);
|
2015-11-09 18:33:36 +00:00
|
|
|
if (o == NULL)
|
2013-09-14 15:29:06 +00:00
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
lun_path: PATH STR
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
|
|
|
if (lun->l_path != NULL) {
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
log_warnx("path for lun \"%s\" "
|
2013-09-14 15:29:06 +00:00
|
|
|
"specified more than once",
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
lun->l_name);
|
2013-09-14 15:29:06 +00:00
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
lun_set_path(lun, $2);
|
|
|
|
free($2);
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2014-02-11 11:11:37 +00:00
|
|
|
lun_serial: SERIAL STR
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
|
|
|
if (lun->l_serial != NULL) {
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
log_warnx("serial for lun \"%s\" "
|
2013-09-14 15:29:06 +00:00
|
|
|
"specified more than once",
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
lun->l_name);
|
2013-09-14 15:29:06 +00:00
|
|
|
free($2);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
lun_set_serial(lun, $2);
|
|
|
|
free($2);
|
2014-10-28 10:25:59 +00:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
lun_size: SIZE STR
|
2014-06-24 19:12:55 +00:00
|
|
|
{
|
2014-10-28 10:25:59 +00:00
|
|
|
uint64_t tmp;
|
2014-06-24 19:12:55 +00:00
|
|
|
|
2014-10-28 10:25:59 +00:00
|
|
|
if (expand_number($2, &tmp) != 0) {
|
2014-10-28 10:39:29 +00:00
|
|
|
yyerror("invalid numeric value");
|
2014-10-28 10:25:59 +00:00
|
|
|
free($2);
|
2014-06-24 19:12:55 +00:00
|
|
|
return (1);
|
|
|
|
}
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
|
|
if (lun->l_size != 0) {
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
log_warnx("size for lun \"%s\" "
|
2013-09-14 15:29:06 +00:00
|
|
|
"specified more than once",
|
CTL LUN mapping rewrite.
Replace iSCSI-specific LUN mapping mechanism with new one, working for any
ports. By default all ports are created without LUN mapping, exposing all
CTL LUNs as before. But, if needed, LUN mapping can be manually set on
per-port basis via ctladm. For its iSCSI ports ctld does it via ioctl(2).
The next step will be to teach ctld to work with FibreChannel ports also.
Respecting additional flexibility of the new mechanism, ctl.conf now allows
alternative syntax for LUN definition. LUNs can now be defined in global
context, and then referenced from targets by unique name, as needed. It
allows same LUN to be exposed several times via multiple targets.
While there, increase limit for LUNs per target in ctld from 256 to 1024.
Some initiators do not support LUNs above 255, but that is not our problem.
Discussed with: trasz
MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.
2015-02-01 21:50:28 +00:00
|
|
|
lun->l_name);
|
2013-09-14 15:29:06 +00:00
|
|
|
return (1);
|
|
|
|
}
|
2014-10-28 10:25:59 +00:00
|
|
|
lun_set_size(lun, tmp);
|
2013-09-14 15:29:06 +00:00
|
|
|
}
|
|
|
|
;
|
|
|
|
%%
|
|
|
|
|
|
|
|
void
|
|
|
|
yyerror(const char *str)
|
|
|
|
{
|
|
|
|
|
|
|
|
log_warnx("error in configuration file at line %d near '%s': %s",
|
|
|
|
lineno, yytext, str);
|
|
|
|
}
|
|
|
|
|
2016-02-03 15:45:13 +00:00
|
|
|
int
|
|
|
|
parse_conf(struct conf *newconf, const char *path)
|
2013-09-14 15:29:06 +00:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
2016-02-03 15:45:13 +00:00
|
|
|
conf = newconf;
|
2013-09-14 15:29:06 +00:00
|
|
|
yyin = fopen(path, "r");
|
|
|
|
if (yyin == NULL) {
|
|
|
|
log_warn("unable to open configuration file %s", path);
|
2016-02-03 15:45:13 +00:00
|
|
|
return (1);
|
2013-09-14 15:29:06 +00:00
|
|
|
}
|
2016-02-03 15:45:13 +00:00
|
|
|
|
2014-02-11 11:37:49 +00:00
|
|
|
lineno = 1;
|
2013-09-14 15:29:06 +00:00
|
|
|
yyrestart(yyin);
|
|
|
|
error = yyparse();
|
|
|
|
auth_group = NULL;
|
|
|
|
portal_group = NULL;
|
|
|
|
target = NULL;
|
|
|
|
lun = NULL;
|
|
|
|
fclose(yyin);
|
|
|
|
|
2016-02-03 15:45:13 +00:00
|
|
|
return (error);
|
2013-09-14 15:29:06 +00:00
|
|
|
}
|