git: 15b3e3bb7efc - main - ctld: if adding a target fails, retry it on the next reload
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 22 Oct 2022 00:30:20 UTC
The branch main has been updated by asomers:
URL: https://cgit.FreeBSD.org/src/commit/?id=15b3e3bb7efcbf7c29ab76e9ea7990c17df790e6
commit 15b3e3bb7efcbf7c29ab76e9ea7990c17df790e6
Author: Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2022-10-12 22:44:09 +0000
Commit: Alan Somers <asomers@FreeBSD.org>
CommitDate: 2022-10-22 00:28:45 +0000
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
---
usr.sbin/ctld/ctld.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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.
*