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$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CTLD_H
|
|
|
|
#define CTLD_H
|
|
|
|
|
|
|
|
#include <sys/queue.h>
|
2014-04-16 11:00:10 +00:00
|
|
|
#ifdef ICL_KERNEL_PROXY
|
|
|
|
#include <sys/types.h>
|
|
|
|
#endif
|
2014-07-28 12:47:09 +00:00
|
|
|
#include <sys/socket.h>
|
2013-09-14 15:29:06 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <libutil.h>
|
|
|
|
|
|
|
|
#define DEFAULT_CONFIG_PATH "/etc/ctl.conf"
|
|
|
|
#define DEFAULT_PIDFILE "/var/run/ctld.pid"
|
|
|
|
#define DEFAULT_BLOCKSIZE 512
|
2015-10-02 11:16:46 +00:00
|
|
|
#define DEFAULT_CD_BLOCKSIZE 2048
|
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
|
|
|
#define MAX_LUNS 1024
|
2013-09-14 15:29:06 +00:00
|
|
|
#define MAX_NAME_LEN 223
|
|
|
|
#define MAX_DATA_SEGMENT_LENGTH (128 * 1024)
|
2014-11-22 15:09:18 +00:00
|
|
|
#define SOCKBUF_SIZE 1048576
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
|
|
struct auth {
|
|
|
|
TAILQ_ENTRY(auth) a_next;
|
|
|
|
struct auth_group *a_auth_group;
|
|
|
|
char *a_user;
|
|
|
|
char *a_secret;
|
|
|
|
char *a_mutual_user;
|
|
|
|
char *a_mutual_secret;
|
|
|
|
};
|
|
|
|
|
2014-02-11 11:08:04 +00:00
|
|
|
struct auth_name {
|
|
|
|
TAILQ_ENTRY(auth_name) an_next;
|
|
|
|
struct auth_group *an_auth_group;
|
|
|
|
char *an_initator_name;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct auth_portal {
|
|
|
|
TAILQ_ENTRY(auth_portal) ap_next;
|
|
|
|
struct auth_group *ap_auth_group;
|
|
|
|
char *ap_initator_portal;
|
2014-07-28 12:47:09 +00:00
|
|
|
struct sockaddr_storage ap_sa;
|
|
|
|
int ap_mask;
|
2014-02-11 11:08:04 +00:00
|
|
|
};
|
|
|
|
|
2013-09-14 15:29:06 +00:00
|
|
|
#define AG_TYPE_UNKNOWN 0
|
2014-02-11 11:32:36 +00:00
|
|
|
#define AG_TYPE_DENY 1
|
|
|
|
#define AG_TYPE_NO_AUTHENTICATION 2
|
|
|
|
#define AG_TYPE_CHAP 3
|
|
|
|
#define AG_TYPE_CHAP_MUTUAL 4
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
|
|
struct auth_group {
|
|
|
|
TAILQ_ENTRY(auth_group) ag_next;
|
|
|
|
struct conf *ag_conf;
|
|
|
|
char *ag_name;
|
|
|
|
struct target *ag_target;
|
|
|
|
int ag_type;
|
|
|
|
TAILQ_HEAD(, auth) ag_auths;
|
2014-02-11 11:08:04 +00:00
|
|
|
TAILQ_HEAD(, auth_name) ag_names;
|
|
|
|
TAILQ_HEAD(, auth_portal) ag_portals;
|
2013-09-14 15:29:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct portal {
|
|
|
|
TAILQ_ENTRY(portal) p_next;
|
|
|
|
struct portal_group *p_portal_group;
|
|
|
|
bool p_iser;
|
|
|
|
char *p_listen;
|
|
|
|
struct addrinfo *p_ai;
|
2014-04-16 10:29:34 +00:00
|
|
|
#ifdef ICL_KERNEL_PROXY
|
|
|
|
int p_id;
|
|
|
|
#endif
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
|
|
TAILQ_HEAD(, target) p_targets;
|
|
|
|
int p_socket;
|
|
|
|
};
|
|
|
|
|
2015-11-09 18:33:36 +00:00
|
|
|
TAILQ_HEAD(options, option);
|
|
|
|
|
2014-10-29 09:26:55 +00:00
|
|
|
#define PG_FILTER_UNKNOWN 0
|
|
|
|
#define PG_FILTER_NONE 1
|
|
|
|
#define PG_FILTER_PORTAL 2
|
|
|
|
#define PG_FILTER_PORTAL_NAME 3
|
|
|
|
#define PG_FILTER_PORTAL_NAME_AUTH 4
|
|
|
|
|
2013-09-14 15:29:06 +00:00
|
|
|
struct portal_group {
|
|
|
|
TAILQ_ENTRY(portal_group) pg_next;
|
|
|
|
struct conf *pg_conf;
|
2015-11-09 18:33:36 +00:00
|
|
|
struct options pg_options;
|
2013-09-14 15:29:06 +00:00
|
|
|
char *pg_name;
|
|
|
|
struct auth_group *pg_discovery_auth_group;
|
2014-10-29 09:26:55 +00:00
|
|
|
int pg_discovery_filter;
|
2015-09-07 13:43:05 +00:00
|
|
|
int pg_foreign;
|
2013-09-14 15:29:06 +00:00
|
|
|
bool pg_unassigned;
|
|
|
|
TAILQ_HEAD(, portal) pg_portals;
|
2015-02-06 17:43:13 +00:00
|
|
|
TAILQ_HEAD(, port) pg_ports;
|
2015-02-28 12:02:32 +00:00
|
|
|
char *pg_offload;
|
2014-11-09 13:01:09 +00:00
|
|
|
char *pg_redirection;
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
|
|
uint16_t pg_tag;
|
|
|
|
};
|
|
|
|
|
2015-02-07 13:19:04 +00:00
|
|
|
struct pport {
|
|
|
|
TAILQ_ENTRY(pport) pp_next;
|
|
|
|
TAILQ_HEAD(, port) pp_ports;
|
|
|
|
struct conf *pp_conf;
|
|
|
|
char *pp_name;
|
|
|
|
|
|
|
|
uint32_t pp_ctl_port;
|
|
|
|
};
|
|
|
|
|
2015-02-06 17:43:13 +00:00
|
|
|
struct port {
|
|
|
|
TAILQ_ENTRY(port) p_next;
|
|
|
|
TAILQ_ENTRY(port) p_pgs;
|
2015-02-07 13:19:04 +00:00
|
|
|
TAILQ_ENTRY(port) p_pps;
|
2015-02-06 17:43:13 +00:00
|
|
|
TAILQ_ENTRY(port) p_ts;
|
|
|
|
struct conf *p_conf;
|
|
|
|
char *p_name;
|
|
|
|
struct auth_group *p_auth_group;
|
|
|
|
struct portal_group *p_portal_group;
|
2015-02-07 13:19:04 +00:00
|
|
|
struct pport *p_pport;
|
2015-02-06 17:43:13 +00:00
|
|
|
struct target *p_target;
|
2015-09-07 13:43:05 +00:00
|
|
|
int p_foreign;
|
2015-02-06 17:43:13 +00:00
|
|
|
|
|
|
|
uint32_t p_ctl_port;
|
|
|
|
};
|
|
|
|
|
2015-11-09 18:33:36 +00:00
|
|
|
struct option {
|
|
|
|
TAILQ_ENTRY(option) o_next;
|
|
|
|
char *o_name;
|
|
|
|
char *o_value;
|
2013-09-14 15:29:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct lun {
|
|
|
|
TAILQ_ENTRY(lun) l_next;
|
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
|
|
|
struct conf *l_conf;
|
2015-11-09 18:33:36 +00:00
|
|
|
struct options l_options;
|
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 *l_name;
|
2013-09-14 15:29:06 +00:00
|
|
|
char *l_backend;
|
2015-09-27 13:47:28 +00:00
|
|
|
uint8_t l_device_type;
|
2013-09-14 15:29:06 +00:00
|
|
|
int l_blocksize;
|
|
|
|
char *l_device_id;
|
|
|
|
char *l_path;
|
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 *l_scsiname;
|
2013-09-14 15:29:06 +00:00
|
|
|
char *l_serial;
|
|
|
|
int64_t l_size;
|
|
|
|
|
|
|
|
int l_ctl_lun;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct target {
|
|
|
|
TAILQ_ENTRY(target) t_next;
|
|
|
|
struct conf *t_conf;
|
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
|
|
|
struct lun *t_luns[MAX_LUNS];
|
2013-09-14 15:29:06 +00:00
|
|
|
struct auth_group *t_auth_group;
|
2015-02-06 17:43:13 +00:00
|
|
|
TAILQ_HEAD(, port) t_ports;
|
2014-02-11 11:14:50 +00:00
|
|
|
char *t_name;
|
2013-09-14 15:29:06 +00:00
|
|
|
char *t_alias;
|
2014-11-09 13:01:09 +00:00
|
|
|
char *t_redirection;
|
2013-09-14 15:29:06 +00:00
|
|
|
};
|
|
|
|
|
2014-10-25 12:50:26 +00:00
|
|
|
struct isns {
|
|
|
|
TAILQ_ENTRY(isns) i_next;
|
|
|
|
struct conf *i_conf;
|
|
|
|
char *i_addr;
|
|
|
|
struct addrinfo *i_ai;
|
|
|
|
};
|
|
|
|
|
2013-09-14 15:29:06 +00:00
|
|
|
struct conf {
|
|
|
|
char *conf_pidfile_path;
|
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
|
|
|
TAILQ_HEAD(, lun) conf_luns;
|
2013-09-14 15:29:06 +00:00
|
|
|
TAILQ_HEAD(, target) conf_targets;
|
|
|
|
TAILQ_HEAD(, auth_group) conf_auth_groups;
|
2015-02-06 17:43:13 +00:00
|
|
|
TAILQ_HEAD(, port) conf_ports;
|
2013-09-14 15:29:06 +00:00
|
|
|
TAILQ_HEAD(, portal_group) conf_portal_groups;
|
2015-02-07 13:19:04 +00:00
|
|
|
TAILQ_HEAD(, pport) conf_pports;
|
2014-10-25 12:50:26 +00:00
|
|
|
TAILQ_HEAD(, isns) conf_isns;
|
|
|
|
int conf_isns_period;
|
|
|
|
int conf_isns_timeout;
|
2013-09-14 15:29:06 +00:00
|
|
|
int conf_debug;
|
|
|
|
int conf_timeout;
|
|
|
|
int conf_maxproc;
|
|
|
|
|
2014-04-16 10:29:34 +00:00
|
|
|
#ifdef ICL_KERNEL_PROXY
|
|
|
|
int conf_portal_id;
|
|
|
|
#endif
|
2013-09-14 15:29:06 +00:00
|
|
|
struct pidfh *conf_pidfh;
|
2014-02-11 11:27:25 +00:00
|
|
|
|
|
|
|
bool conf_default_pg_defined;
|
|
|
|
bool conf_default_ag_defined;
|
2014-04-16 10:43:12 +00:00
|
|
|
bool conf_kernel_port_on;
|
2013-09-14 15:29:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define CONN_SESSION_TYPE_NONE 0
|
|
|
|
#define CONN_SESSION_TYPE_DISCOVERY 1
|
|
|
|
#define CONN_SESSION_TYPE_NORMAL 2
|
|
|
|
|
|
|
|
#define CONN_DIGEST_NONE 0
|
|
|
|
#define CONN_DIGEST_CRC32C 1
|
|
|
|
|
|
|
|
struct connection {
|
|
|
|
struct portal *conn_portal;
|
2015-02-06 17:43:13 +00:00
|
|
|
struct port *conn_port;
|
2013-09-14 15:29:06 +00:00
|
|
|
struct target *conn_target;
|
|
|
|
int conn_socket;
|
|
|
|
int conn_session_type;
|
|
|
|
char *conn_initiator_name;
|
|
|
|
char *conn_initiator_addr;
|
|
|
|
char *conn_initiator_alias;
|
2014-07-05 21:18:33 +00:00
|
|
|
uint8_t conn_initiator_isid[6];
|
2014-07-28 12:47:09 +00:00
|
|
|
struct sockaddr_storage conn_initiator_sa;
|
2013-09-14 15:29:06 +00:00
|
|
|
uint32_t conn_cmdsn;
|
|
|
|
uint32_t conn_statsn;
|
2017-01-14 18:04:12 +00:00
|
|
|
int conn_max_recv_data_segment_limit;
|
|
|
|
int conn_max_send_data_segment_limit;
|
|
|
|
int conn_max_burst_limit;
|
|
|
|
int conn_first_burst_limit;
|
2016-08-25 05:22:53 +00:00
|
|
|
int conn_max_recv_data_segment_length;
|
|
|
|
int conn_max_send_data_segment_length;
|
|
|
|
int conn_max_burst_length;
|
|
|
|
int conn_first_burst_length;
|
2013-09-14 15:29:06 +00:00
|
|
|
int conn_immediate_data;
|
|
|
|
int conn_header_digest;
|
|
|
|
int conn_data_digest;
|
2014-10-29 09:26:55 +00:00
|
|
|
const char *conn_user;
|
|
|
|
struct chap *conn_chap;
|
2013-09-14 15:29:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct pdu {
|
|
|
|
struct connection *pdu_connection;
|
|
|
|
struct iscsi_bhs *pdu_bhs;
|
|
|
|
char *pdu_data;
|
|
|
|
size_t pdu_data_len;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define KEYS_MAX 1024
|
|
|
|
|
|
|
|
struct keys {
|
|
|
|
char *keys_names[KEYS_MAX];
|
|
|
|
char *keys_values[KEYS_MAX];
|
|
|
|
char *keys_data;
|
|
|
|
size_t keys_data_len;
|
|
|
|
};
|
|
|
|
|
2014-10-22 08:59:23 +00:00
|
|
|
#define CHAP_CHALLENGE_LEN 1024
|
2015-07-03 10:08:10 +00:00
|
|
|
#define CHAP_DIGEST_LEN 16 /* Equal to MD5 digest size. */
|
2014-10-22 08:59:23 +00:00
|
|
|
|
|
|
|
struct chap {
|
|
|
|
unsigned char chap_id;
|
|
|
|
char chap_challenge[CHAP_CHALLENGE_LEN];
|
2015-07-03 10:08:10 +00:00
|
|
|
char chap_response[CHAP_DIGEST_LEN];
|
2014-10-22 08:59:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rchap {
|
|
|
|
char *rchap_secret;
|
|
|
|
unsigned char rchap_id;
|
|
|
|
void *rchap_challenge;
|
|
|
|
size_t rchap_challenge_len;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct chap *chap_new(void);
|
|
|
|
char *chap_get_id(const struct chap *chap);
|
|
|
|
char *chap_get_challenge(const struct chap *chap);
|
|
|
|
int chap_receive(struct chap *chap, const char *response);
|
|
|
|
int chap_authenticate(struct chap *chap,
|
|
|
|
const char *secret);
|
|
|
|
void chap_delete(struct chap *chap);
|
|
|
|
|
|
|
|
struct rchap *rchap_new(const char *secret);
|
|
|
|
int rchap_receive(struct rchap *rchap,
|
|
|
|
const char *id, const char *challenge);
|
|
|
|
char *rchap_get_response(struct rchap *rchap);
|
|
|
|
void rchap_delete(struct rchap *rchap);
|
|
|
|
|
2016-02-03 15:45:13 +00:00
|
|
|
int parse_conf(struct conf *conf, const char *path);
|
|
|
|
int uclparse_conf(struct conf *conf, const char *path);
|
|
|
|
|
2013-09-14 15:29:06 +00:00
|
|
|
struct conf *conf_new(void);
|
|
|
|
struct conf *conf_new_from_kernel(void);
|
|
|
|
void conf_delete(struct conf *conf);
|
|
|
|
int conf_verify(struct conf *conf);
|
|
|
|
|
|
|
|
struct auth_group *auth_group_new(struct conf *conf, const char *name);
|
|
|
|
void auth_group_delete(struct auth_group *ag);
|
2014-04-16 11:01:59 +00:00
|
|
|
struct auth_group *auth_group_find(const struct conf *conf,
|
|
|
|
const char *name);
|
2014-10-29 09:36:02 +00:00
|
|
|
int auth_group_set_type(struct auth_group *ag,
|
2014-02-11 11:26:05 +00:00
|
|
|
const char *type);
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
|
|
const struct auth *auth_new_chap(struct auth_group *ag,
|
|
|
|
const char *user, const char *secret);
|
|
|
|
const struct auth *auth_new_chap_mutual(struct auth_group *ag,
|
|
|
|
const char *user, const char *secret,
|
|
|
|
const char *user2, const char *secret2);
|
2014-04-16 11:01:59 +00:00
|
|
|
const struct auth *auth_find(const struct auth_group *ag,
|
2013-09-14 15:29:06 +00:00
|
|
|
const char *user);
|
|
|
|
|
2014-02-11 11:08:04 +00:00
|
|
|
const struct auth_name *auth_name_new(struct auth_group *ag,
|
|
|
|
const char *initiator_name);
|
|
|
|
bool auth_name_defined(const struct auth_group *ag);
|
|
|
|
const struct auth_name *auth_name_find(const struct auth_group *ag,
|
|
|
|
const char *initiator_name);
|
2014-10-24 11:40:09 +00:00
|
|
|
int auth_name_check(const struct auth_group *ag,
|
|
|
|
const char *initiator_name);
|
2014-02-11 11:08:04 +00:00
|
|
|
|
|
|
|
const struct auth_portal *auth_portal_new(struct auth_group *ag,
|
|
|
|
const char *initiator_portal);
|
|
|
|
bool auth_portal_defined(const struct auth_group *ag);
|
|
|
|
const struct auth_portal *auth_portal_find(const struct auth_group *ag,
|
2014-07-28 12:47:09 +00:00
|
|
|
const struct sockaddr_storage *sa);
|
2014-10-24 11:40:09 +00:00
|
|
|
int auth_portal_check(const struct auth_group *ag,
|
|
|
|
const struct sockaddr_storage *sa);
|
2014-02-11 11:08:04 +00:00
|
|
|
|
2013-09-14 15:29:06 +00:00
|
|
|
struct portal_group *portal_group_new(struct conf *conf, const char *name);
|
|
|
|
void portal_group_delete(struct portal_group *pg);
|
2014-04-16 11:01:59 +00:00
|
|
|
struct portal_group *portal_group_find(const struct conf *conf,
|
|
|
|
const char *name);
|
2013-09-14 15:29:06 +00:00
|
|
|
int portal_group_add_listen(struct portal_group *pg,
|
|
|
|
const char *listen, bool iser);
|
2014-10-29 09:36:02 +00:00
|
|
|
int portal_group_set_filter(struct portal_group *pg,
|
2014-10-29 09:26:55 +00:00
|
|
|
const char *filter);
|
2015-02-28 12:02:32 +00:00
|
|
|
int portal_group_set_offload(struct portal_group *pg,
|
|
|
|
const char *offload);
|
2014-11-09 13:01:09 +00:00
|
|
|
int portal_group_set_redirection(struct portal_group *pg,
|
|
|
|
const char *addr);
|
2013-09-14 15:29:06 +00:00
|
|
|
|
2014-10-25 12:50:26 +00:00
|
|
|
int isns_new(struct conf *conf, const char *addr);
|
|
|
|
void isns_delete(struct isns *is);
|
|
|
|
void isns_register(struct isns *isns, struct isns *oldisns);
|
|
|
|
void isns_check(struct isns *isns);
|
|
|
|
void isns_deregister(struct isns *isns);
|
|
|
|
|
2015-02-07 13:19:04 +00:00
|
|
|
struct pport *pport_new(struct conf *conf, const char *name,
|
|
|
|
uint32_t ctl_port);
|
|
|
|
struct pport *pport_find(const struct conf *conf, const char *name);
|
|
|
|
struct pport *pport_copy(struct pport *pport, struct conf *conf);
|
|
|
|
void pport_delete(struct pport *pport);
|
|
|
|
|
2015-02-06 17:43:13 +00:00
|
|
|
struct port *port_new(struct conf *conf, struct target *target,
|
|
|
|
struct portal_group *pg);
|
2015-02-07 13:19:04 +00:00
|
|
|
struct port *port_new_pp(struct conf *conf, struct target *target,
|
|
|
|
struct pport *pp);
|
2015-02-06 17:43:13 +00:00
|
|
|
struct port *port_find(const struct conf *conf, const char *name);
|
|
|
|
struct port *port_find_in_pg(const struct portal_group *pg,
|
|
|
|
const char *target);
|
|
|
|
void port_delete(struct port *port);
|
|
|
|
|
2014-02-11 11:14:50 +00:00
|
|
|
struct target *target_new(struct conf *conf, const char *name);
|
2013-09-14 15:29:06 +00:00
|
|
|
void target_delete(struct target *target);
|
|
|
|
struct target *target_find(struct conf *conf,
|
2014-02-11 11:14:50 +00:00
|
|
|
const char *name);
|
2014-11-09 13:01:09 +00:00
|
|
|
int target_set_redirection(struct target *target,
|
|
|
|
const char *addr);
|
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
|
|
|
struct lun *lun_new(struct conf *conf, const char *name);
|
2013-09-14 15:29:06 +00:00
|
|
|
void lun_delete(struct lun *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
|
|
|
struct lun *lun_find(const struct conf *conf, const char *name);
|
2013-09-14 15:29:06 +00:00
|
|
|
void lun_set_backend(struct lun *lun, const char *value);
|
2015-09-27 13:47:28 +00:00
|
|
|
void lun_set_device_type(struct lun *lun, uint8_t value);
|
2013-09-14 15:29:06 +00:00
|
|
|
void lun_set_blocksize(struct lun *lun, size_t value);
|
|
|
|
void lun_set_device_id(struct lun *lun, const char *value);
|
|
|
|
void lun_set_path(struct lun *lun, const char *value);
|
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
|
|
|
void lun_set_scsiname(struct lun *lun, const char *value);
|
2013-09-14 15:29:06 +00:00
|
|
|
void lun_set_serial(struct lun *lun, const char *value);
|
|
|
|
void lun_set_size(struct lun *lun, size_t value);
|
|
|
|
void lun_set_ctl_lun(struct lun *lun, uint32_t value);
|
|
|
|
|
2015-11-09 18:33:36 +00:00
|
|
|
struct option *option_new(struct options *os,
|
2013-09-14 15:29:06 +00:00
|
|
|
const char *name, const char *value);
|
2015-11-09 18:33:36 +00:00
|
|
|
void option_delete(struct options *os, struct option *co);
|
|
|
|
struct option *option_find(const struct options *os, const char *name);
|
|
|
|
void option_set(struct option *o, const char *value);
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
|
|
void kernel_init(void);
|
|
|
|
int kernel_lun_add(struct lun *lun);
|
2015-09-06 11:23:01 +00:00
|
|
|
int kernel_lun_modify(struct lun *lun);
|
2013-09-14 15:29:06 +00:00
|
|
|
int kernel_lun_remove(struct lun *lun);
|
|
|
|
void kernel_handoff(struct connection *conn);
|
2015-02-06 21:03:25 +00:00
|
|
|
void kernel_limits(const char *offload,
|
2016-08-25 05:22:53 +00:00
|
|
|
int *max_recv_data_segment_length,
|
|
|
|
int *max_send_data_segment_length,
|
|
|
|
int *max_burst_length,
|
|
|
|
int *first_burst_length);
|
2015-02-06 17:43:13 +00:00
|
|
|
int kernel_port_add(struct port *port);
|
2015-09-13 15:08:06 +00:00
|
|
|
int kernel_port_update(struct port *port, struct port *old);
|
2015-02-06 17:43:13 +00:00
|
|
|
int kernel_port_remove(struct port *port);
|
2013-09-14 15:29:06 +00:00
|
|
|
void kernel_capsicate(void);
|
|
|
|
|
2014-04-16 11:00:10 +00:00
|
|
|
#ifdef ICL_KERNEL_PROXY
|
2014-04-16 10:29:34 +00:00
|
|
|
void kernel_listen(struct addrinfo *ai, bool iser,
|
|
|
|
int portal_id);
|
2014-04-16 11:00:10 +00:00
|
|
|
void kernel_accept(int *connection_id, int *portal_id,
|
|
|
|
struct sockaddr *client_sa,
|
|
|
|
socklen_t *client_salen);
|
2013-09-14 15:29:06 +00:00
|
|
|
void kernel_send(struct pdu *pdu);
|
|
|
|
void kernel_receive(struct pdu *pdu);
|
2014-04-16 11:00:10 +00:00
|
|
|
#endif
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
|
|
struct keys *keys_new(void);
|
|
|
|
void keys_delete(struct keys *keys);
|
|
|
|
void keys_load(struct keys *keys, const struct pdu *pdu);
|
|
|
|
void keys_save(struct keys *keys, struct pdu *pdu);
|
|
|
|
const char *keys_find(struct keys *keys, const char *name);
|
|
|
|
void keys_add(struct keys *keys,
|
|
|
|
const char *name, const char *value);
|
|
|
|
void keys_add_int(struct keys *keys,
|
|
|
|
const char *name, int value);
|
|
|
|
|
|
|
|
struct pdu *pdu_new(struct connection *conn);
|
|
|
|
struct pdu *pdu_new_response(struct pdu *request);
|
|
|
|
void pdu_delete(struct pdu *pdu);
|
|
|
|
void pdu_receive(struct pdu *request);
|
|
|
|
void pdu_send(struct pdu *response);
|
|
|
|
|
|
|
|
void login(struct connection *conn);
|
|
|
|
|
|
|
|
void discovery(struct connection *conn);
|
|
|
|
|
|
|
|
void log_init(int level);
|
|
|
|
void log_set_peer_name(const char *name);
|
|
|
|
void log_set_peer_addr(const char *addr);
|
|
|
|
void log_err(int, const char *, ...)
|
2014-02-11 10:56:43 +00:00
|
|
|
__dead2 __printflike(2, 3);
|
2013-09-14 15:29:06 +00:00
|
|
|
void log_errx(int, const char *, ...)
|
2014-02-11 10:56:43 +00:00
|
|
|
__dead2 __printflike(2, 3);
|
|
|
|
void log_warn(const char *, ...) __printflike(1, 2);
|
2013-09-14 15:29:06 +00:00
|
|
|
void log_warnx(const char *, ...) __printflike(1, 2);
|
2014-02-11 10:56:43 +00:00
|
|
|
void log_debugx(const char *, ...) __printflike(1, 2);
|
2013-09-14 15:29:06 +00:00
|
|
|
|
|
|
|
char *checked_strdup(const char *);
|
|
|
|
bool valid_iscsi_name(const char *name);
|
2014-10-25 12:50:26 +00:00
|
|
|
void set_timeout(int timeout, int fatal);
|
2013-09-14 15:29:06 +00:00
|
|
|
bool timed_out(void);
|
|
|
|
|
|
|
|
#endif /* !CTLD_H */
|