diff options
author | mav <mav@FreeBSD.org> | 2017-04-24 06:33:08 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2017-04-24 06:33:08 +0000 |
commit | 3862a2d7e56c0cb5a757c8a45415fdd9050e76c9 (patch) | |
tree | bd0bba71af68dd3eaae0131831c4c65d8415e498 /usr.sbin | |
parent | 19596a50770647980ebe6a460be3d3abbb49e5d2 (diff) | |
download | FreeBSD-src-3862a2d7e56c0cb5a757c8a45415fdd9050e76c9.zip FreeBSD-src-3862a2d7e56c0cb5a757c8a45415fdd9050e76c9.tar.gz |
MFC r316677: Do not register in CTL portal groups without portals.
From config synthax point of view such portal groups are not incorrect,
but they are useless since can not receive any connection. And since
CTL port resource is very limited, it is good to save it.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ctld/ctld.c | 22 | ||||
-rw-r--r-- | usr.sbin/ctld/ctld.h | 2 |
2 files changed, 18 insertions, 6 deletions
diff --git a/usr.sbin/ctld/ctld.c b/usr.sbin/ctld/ctld.c index 7cac8f6..ebe52d6 100644 --- a/usr.sbin/ctld/ctld.c +++ b/usr.sbin/ctld/ctld.c @@ -1219,7 +1219,6 @@ 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); } @@ -1292,6 +1291,19 @@ port_delete(struct port *port) free(port); } +int +port_is_dummy(struct port *port) +{ + + if (port->p_portal_group) { + if (port->p_portal_group->pg_foreign) + return (1); + if (TAILQ_EMPTY(&port->p_portal_group->pg_portals)) + return (1); + } + return (0); +} + struct target * target_new(struct conf *conf, const char *name) { @@ -1867,10 +1879,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) + if (port_is_dummy(oldport)) continue; newport = port_find(newconf, oldport->p_name); - if (newport != NULL && !newport->p_foreign) + if (newport != NULL && !port_is_dummy(newport)) continue; log_debugx("removing port \"%s\"", oldport->p_name); error = kernel_port_remove(oldport); @@ -1990,11 +2002,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) + if (port_is_dummy(newport)) continue; oldport = port_find(oldconf, newport->p_name); - if (oldport == NULL || oldport->p_foreign) { + if (oldport == NULL || port_is_dummy(oldport)) { log_debugx("adding port \"%s\"", newport->p_name); error = kernel_port_add(newport); } else { diff --git a/usr.sbin/ctld/ctld.h b/usr.sbin/ctld/ctld.h index 7c7c3ba..e2f08a2 100644 --- a/usr.sbin/ctld/ctld.h +++ b/usr.sbin/ctld/ctld.h @@ -149,7 +149,6 @@ struct port { struct portal_group *p_portal_group; struct pport *p_pport; struct target *p_target; - int p_foreign; uint32_t p_ctl_port; }; @@ -363,6 +362,7 @@ 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); +int port_is_dummy(struct port *port); struct target *target_new(struct conf *conf, const char *name); void target_delete(struct target *target); |