aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2022-10-12 22:44:09 +0000
committerAlan Somers <asomers@FreeBSD.org>2022-10-22 00:28:45 +0000
commit15b3e3bb7efcbf7c29ab76e9ea7990c17df790e6 (patch)
tree221a5e3c349f561ddd05d3e8937eee7ce8c22db5
parent787df454c8175e58131f582c05c169070fb6ca7c (diff)
downloadsrc-15b3e3bb7efcbf7c29ab76e9ea7990c17df790e6.tar.gz
src-15b3e3bb7efcbf7c29ab76e9ea7990c17df790e6.zip
ctld: if adding a target fails, retry it on the next reload
If the admin creates more CTL ports than kern.cam.ctl.max_ports, then adding some will fail. If he then removes some ports and does "service ctld reload", he would expect that the new ports would get added in the newly-freed port space. But they don't, because ctld assigned them port numbers during their first creation attempts. Fix this bug by removing newly created ports from ctld's internal list if the kernel rejects them for any reason. That way, a subsequent config reload will attempt to add them again, possibly with new port numbers. MFC after: 2 weeks Sponsored by: Axcient Reviewed by: jhb, mav Differential Revision: https://reviews.freebsd.org/D36974
-rw-r--r--usr.sbin/ctld/ctld.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.sbin/ctld/ctld.c b/usr.sbin/ctld/ctld.c
index 3f4bca632512..7ee381de08a7 100644
--- a/usr.sbin/ctld/ctld.c
+++ b/usr.sbin/ctld/ctld.c
@@ -2113,7 +2113,7 @@ conf_apply(struct conf *oldconf, struct conf *newconf)
/*
* Now add new ports or modify existing ones.
*/
- TAILQ_FOREACH(newport, &newconf->conf_ports, p_next) {
+ TAILQ_FOREACH_SAFE(newport, &newconf->conf_ports, p_next, tmpport) {
if (port_is_dummy(newport))
continue;
oldport = port_find(oldconf, newport->p_name);
@@ -2130,6 +2130,8 @@ conf_apply(struct conf *oldconf, struct conf *newconf)
log_warnx("failed to %s port %s",
(oldport == NULL) ? "add" : "update",
newport->p_name);
+ if (oldport == NULL || port_is_dummy(oldport))
+ port_delete(newport);
/*
* XXX: Uncomment after fixing the root cause.
*