svn commit: r288729 - stable/10/usr.sbin/ctld
Alexander Motin
mav at FreeBSD.org
Mon Oct 5 08:54:04 UTC 2015
Author: mav
Date: Mon Oct 5 08:54:02 2015
New Revision: 288729
URL: https://svnweb.freebsd.org/changeset/base/288729
Log:
MFC r287534: Add two new portal group options "tag" and "foreign".
They are going to be useful in clustered setups.
Modified:
stable/10/usr.sbin/ctld/ctl.conf.5
stable/10/usr.sbin/ctld/ctld.c
stable/10/usr.sbin/ctld/ctld.h
stable/10/usr.sbin/ctld/parse.y
stable/10/usr.sbin/ctld/token.l
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/usr.sbin/ctld/ctl.conf.5
==============================================================================
--- stable/10/usr.sbin/ctld/ctl.conf.5 Mon Oct 5 08:52:37 2015 (r288728)
+++ stable/10/usr.sbin/ctld/ctl.conf.5 Mon Oct 5 08:54:02 2015 (r288729)
@@ -1,4 +1,5 @@
.\" Copyright (c) 2012 The FreeBSD Foundation
+.\" Copyright (c) 2015 Alexander Motin <mav at FreeBSD.org>
.\" All rights reserved.
.\"
.\" This software was developed by Edward Tomasz Napierala under sponsorship
@@ -27,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 24, 2015
+.Dd September 7, 2015
.Dt CTL.CONF 5
.Os
.Sh NAME
@@ -239,6 +240,15 @@ Redirection happens before authenticatio
or
.Sy initiator-portal
checks are skipped.
+.It Ic tag Ar value
+Unique 16-bit tag value of this
+.Sy portal-group .
+If not specified, the value is generated automatically.
+.It Ic foreign
+Specifies that this
+.Sy portal-group
+is listened by some other host.
+This host will announce it on discovery stage, but won't listen.
.El
.Ss target Context
.Bl -tag -width indent
Modified: stable/10/usr.sbin/ctld/ctld.c
==============================================================================
--- stable/10/usr.sbin/ctld/ctld.c Mon Oct 5 08:52:37 2015 (r288728)
+++ stable/10/usr.sbin/ctld/ctld.c Mon Oct 5 08:54:02 2015 (r288729)
@@ -59,7 +59,7 @@ static volatile bool sigterm_received =
static volatile bool sigalrm_received = false;
static int nchildren = 0;
-static uint16_t last_portal_group_tag = 0;
+static uint16_t last_portal_group_tag = 0xff;
static void
usage(void)
@@ -1212,6 +1212,7 @@ port_new(struct conf *conf, struct targe
port->p_target = target;
TAILQ_INSERT_TAIL(&pg->pg_ports, port, p_pgs);
port->p_portal_group = pg;
+ port->p_foreign = pg->pg_foreign;
return (port);
}
@@ -1717,14 +1718,16 @@ conf_verify(struct conf *conf)
if (pg->pg_discovery_filter == PG_FILTER_UNKNOWN)
pg->pg_discovery_filter = PG_FILTER_NONE;
- if (!TAILQ_EMPTY(&pg->pg_ports)) {
- if (pg->pg_redirection != NULL) {
+ if (pg->pg_redirection != NULL) {
+ if (!TAILQ_EMPTY(&pg->pg_ports)) {
log_debugx("portal-group \"%s\" assigned "
"to target, but configured "
"for redirection",
pg->pg_name);
}
pg->pg_unassigned = false;
+ } else if (!TAILQ_EMPTY(&pg->pg_ports)) {
+ pg->pg_unassigned = false;
} else {
if (strcmp(pg->pg_name, "default") != 0)
log_warnx("portal-group \"%s\" not assigned "
@@ -1818,6 +1821,8 @@ conf_apply(struct conf *oldconf, struct
* Go through the new portal groups, assigning tags or preserving old.
*/
TAILQ_FOREACH(newpg, &newconf->conf_portal_groups, pg_next) {
+ if (newpg->pg_tag != 0)
+ continue;
oldpg = portal_group_find(oldconf, newpg->pg_name);
if (oldpg != NULL)
newpg->pg_tag = oldpg->pg_tag;
@@ -1847,8 +1852,10 @@ conf_apply(struct conf *oldconf, struct
* and missing in the new one.
*/
TAILQ_FOREACH_SAFE(oldport, &oldconf->conf_ports, p_next, tmpport) {
+ if (oldport->p_foreign)
+ continue;
newport = port_find(newconf, oldport->p_name);
- if (newport != NULL)
+ if (newport != NULL && !newport->p_foreign)
continue;
log_debugx("removing port \"%s\"", oldport->p_name);
error = kernel_port_remove(oldport);
@@ -1968,9 +1975,11 @@ conf_apply(struct conf *oldconf, struct
* Now add new ports or modify existing ones.
*/
TAILQ_FOREACH(newport, &newconf->conf_ports, p_next) {
+ if (newport->p_foreign)
+ continue;
oldport = port_find(oldconf, newport->p_name);
- if (oldport == NULL) {
+ if (oldport == NULL || oldport->p_foreign) {
log_debugx("adding port \"%s\"", newport->p_name);
error = kernel_port_add(newport);
} else {
@@ -1994,6 +2003,8 @@ conf_apply(struct conf *oldconf, struct
* Go through the new portals, opening the sockets as neccessary.
*/
TAILQ_FOREACH(newpg, &newconf->conf_portal_groups, pg_next) {
+ if (newpg->pg_foreign)
+ continue;
if (newpg->pg_unassigned) {
log_debugx("not listening on portal-group \"%s\", "
"not assigned to any target",
Modified: stable/10/usr.sbin/ctld/ctld.h
==============================================================================
--- stable/10/usr.sbin/ctld/ctld.h Mon Oct 5 08:52:37 2015 (r288728)
+++ stable/10/usr.sbin/ctld/ctld.h Mon Oct 5 08:54:02 2015 (r288729)
@@ -116,6 +116,7 @@ struct portal_group {
char *pg_name;
struct auth_group *pg_discovery_auth_group;
int pg_discovery_filter;
+ int pg_foreign;
bool pg_unassigned;
TAILQ_HEAD(, portal) pg_portals;
TAILQ_HEAD(, port) pg_ports;
@@ -144,6 +145,7 @@ struct port {
struct portal_group *p_portal_group;
struct pport *p_pport;
struct target *p_target;
+ int p_foreign;
uint32_t p_ctl_port;
};
Modified: stable/10/usr.sbin/ctld/parse.y
==============================================================================
--- stable/10/usr.sbin/ctld/parse.y Mon Oct 5 08:52:37 2015 (r288728)
+++ stable/10/usr.sbin/ctld/parse.y Mon Oct 5 08:54:02 2015 (r288729)
@@ -58,10 +58,11 @@ extern void yyrestart(FILE *);
%token ALIAS AUTH_GROUP AUTH_TYPE BACKEND BLOCKSIZE CHAP CHAP_MUTUAL
%token CLOSING_BRACKET DEBUG DEVICE_ID DISCOVERY_AUTH_GROUP DISCOVERY_FILTER
+%token FOREIGN
%token INITIATOR_NAME INITIATOR_PORTAL ISNS_SERVER ISNS_PERIOD ISNS_TIMEOUT
%token LISTEN LISTEN_ISER LUN MAXPROC OPENING_BRACKET OPTION
%token PATH PIDFILE PORT PORTAL_GROUP REDIRECT SEMICOLON SERIAL SIZE STR
-%token TARGET TIMEOUT
+%token TAG TARGET TIMEOUT
%union
{
@@ -337,11 +338,15 @@ portal_group_entry:
|
portal_group_discovery_filter
|
+ portal_group_foreign
+ |
portal_group_listen
|
portal_group_listen_iser
|
portal_group_redirect
+ |
+ portal_group_tag
;
portal_group_discovery_auth_group: DISCOVERY_AUTH_GROUP STR
@@ -375,6 +380,13 @@ portal_group_discovery_filter: DISCOVERY
}
;
+portal_group_foreign: FOREIGN
+ {
+
+ portal_group->pg_foreign = 1;
+ }
+ ;
+
portal_group_listen: LISTEN STR
{
int error;
@@ -408,6 +420,20 @@ portal_group_redirect: REDIRECT STR
}
;
+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;
+ }
+ ;
+
lun: LUN lun_name
OPENING_BRACKET lun_entries CLOSING_BRACKET
{
Modified: stable/10/usr.sbin/ctld/token.l
==============================================================================
--- stable/10/usr.sbin/ctld/token.l Mon Oct 5 08:52:37 2015 (r288728)
+++ stable/10/usr.sbin/ctld/token.l Mon Oct 5 08:54:02 2015 (r288729)
@@ -58,6 +58,7 @@ debug { return DEBUG; }
device-id { return DEVICE_ID; }
discovery-auth-group { return DISCOVERY_AUTH_GROUP; }
discovery-filter { return DISCOVERY_FILTER; }
+foreign { return FOREIGN; }
initiator-name { return INITIATOR_NAME; }
initiator-portal { return INITIATOR_PORTAL; }
listen { return LISTEN; }
@@ -75,6 +76,7 @@ portal-group { return PORTAL_GROUP; }
redirect { return REDIRECT; }
serial { return SERIAL; }
size { return SIZE; }
+tag { return TAG; }
target { return TARGET; }
timeout { return TIMEOUT; }
\"[^"]+\" { yylval.str = strndup(yytext + 1,
More information about the svn-src-stable-10
mailing list