From f1a03e38c50a7d5bc9185fe40d17d80197e1b575 Mon Sep 17 00:00:00 2001 From: mav Date: Mon, 5 Oct 2015 08:54:02 +0000 Subject: MFC r287534: Add two new portal group options "tag" and "foreign". They are going to be useful in clustered setups. --- usr.sbin/ctld/ctld.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'usr.sbin/ctld/ctld.c') diff --git a/usr.sbin/ctld/ctld.c b/usr.sbin/ctld/ctld.c index 85f1133..90b74bf 100644 --- a/usr.sbin/ctld/ctld.c +++ b/usr.sbin/ctld/ctld.c @@ -59,7 +59,7 @@ static volatile bool sigterm_received = false; 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 target *target, struct portal_group *pg) 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 conf *newconf) * 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 conf *newconf) * 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 conf *newconf) * 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 conf *newconf) * 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", -- cgit v1.1