summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ctld
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2014-05-07 07:35:21 +0000
committertrasz <trasz@FreeBSD.org>2014-05-07 07:35:21 +0000
commit04b1f4adf57fd2b112a952d43ae4f981d90d30f3 (patch)
treef899464591824ad3bc8b0223f2826f66ac9a83fd /usr.sbin/ctld
parent1abd1411d77ee0527d37dab1e14b506831a9b9dc (diff)
downloadFreeBSD-src-04b1f4adf57fd2b112a952d43ae4f981d90d30f3.zip
FreeBSD-src-04b1f4adf57fd2b112a952d43ae4f981d90d30f3.tar.gz
MFC r264528:
Rework the way we enable CTL iSCSI port. Previously conf_apply() needed it to be already enabled, because listening in proxy mode requires it; however, it's conf_apply() that opens pidfiles, so it resulted in port being enabled before pidfile was opened. This was not so bad, but it was also disabled when pidfile couldn't be opened due to ctld already running; this means that starting second ctld instance screwed up the first. Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'usr.sbin/ctld')
-rw-r--r--usr.sbin/ctld/ctld.c21
-rw-r--r--usr.sbin/ctld/ctld.h1
-rw-r--r--usr.sbin/ctld/parse.y2
3 files changed, 16 insertions, 8 deletions
diff --git a/usr.sbin/ctld/ctld.c b/usr.sbin/ctld/ctld.c
index a884cf8..a8b1f6b 100644
--- a/usr.sbin/ctld/ctld.c
+++ b/usr.sbin/ctld/ctld.c
@@ -1209,6 +1209,19 @@ conf_apply(struct conf *oldconf, struct conf *newconf)
}
}
+ if (oldconf->conf_kernel_port_on != newconf->conf_kernel_port_on) {
+ if (newconf->conf_kernel_port_on == true) {
+ log_debugx("enabling CTL iSCSI port");
+ error = kernel_port_on();
+ if (error != 0)
+ log_errx(1, "failed to enable CTL iSCSI port, exiting");
+ } else {
+ error = kernel_port_off();
+ if (error != 0)
+ log_warnx("failed to disable CTL iSCSI port");
+ }
+ }
+
TAILQ_FOREACH_SAFE(oldtarg, &oldconf->conf_targets, t_next, tmptarg) {
/*
* First, remove any targets present in the old configuration
@@ -1837,11 +1850,6 @@ main(int argc, char **argv)
newconf->conf_debug = debug;
}
- log_debugx("enabling CTL iSCSI port");
- error = kernel_port_on();
- if (error != 0)
- log_errx(1, "failed to enable CTL iSCSI port, exiting");
-
error = conf_apply(oldconf, newconf);
if (error != 0)
log_errx(1, "failed to apply configuration, exiting");
@@ -1886,9 +1894,6 @@ main(int argc, char **argv)
log_debugx("disabling CTL iSCSI port "
"and terminating all connections");
- error = kernel_port_off();
- if (error != 0)
- log_warnx("failed to disable CTL iSCSI port");
oldconf = newconf;
newconf = conf_new();
diff --git a/usr.sbin/ctld/ctld.h b/usr.sbin/ctld/ctld.h
index be7be13..fe5abfe 100644
--- a/usr.sbin/ctld/ctld.h
+++ b/usr.sbin/ctld/ctld.h
@@ -156,6 +156,7 @@ struct conf {
bool conf_default_pg_defined;
bool conf_default_ag_defined;
+ bool conf_kernel_port_on;
};
#define CONN_SESSION_TYPE_NONE 0
diff --git a/usr.sbin/ctld/parse.y b/usr.sbin/ctld/parse.y
index 6299b58..e4b160e 100644
--- a/usr.sbin/ctld/parse.y
+++ b/usr.sbin/ctld/parse.y
@@ -773,6 +773,8 @@ conf_new_from_file(const char *path)
portal_group_add_listen(pg, "[::]:3260", false);
}
+ conf->conf_kernel_port_on = true;
+
error = conf_verify(conf);
if (error != 0) {
conf_delete(conf);
OpenPOWER on IntegriCloud