diff --git a/usr.sbin/ctld/ctld.c b/usr.sbin/ctld/ctld.c --- a/usr.sbin/ctld/ctld.c +++ b/usr.sbin/ctld/ctld.c @@ -2113,7 +2113,7 @@ /* * 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 @@ 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. *