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
This commit is contained in:
Alan Somers 2022-10-12 16:44:09 -06:00
parent 787df454c8
commit 15b3e3bb7e

View file

@ -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.
*