[Bug 287741] ctld deletes ports if they already exist

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 23 Jun 2025 18:07:25 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=287741

--- Comment #6 from Dag-Erling Smørgrav <des@FreeBSD.org> ---
I don't know how much more explicit I can get.  I had four numbered items
(although I suppose one might argue that the first and fourth are just one):

> (1) If kernel_port_add() fails because the port being added already exists, it returns non-zero, with no way for the caller to determine that the error can safely be ignored.
> (2) kernel_port_update() always returns zero, regardless of outcome.
> (3) The log_warnx() call in the error case should print "add" when port_is_dummy(newport) is true, not only when oldport is NULL.  In fact, this log_warnx() call is only reached in the add case since kernel_port_update() never returns non-zero.
> (4) If kernel_port_add() failed because the port already existed, we now react by deleting it.

I later added a fifth:

> I'm still investigating but it's starting to look like their management system actually creates both the ports and the ctld configuration concurrently at boot time, so contrary to what I initially believed, ctld always starts with all the ports already configured.

You addressed (3) in passing, and answered a question I didn't ask (and never
would, because it makes no sense) about removing the kernel_port_add() call. 
The rest is little more than a summary of the code, with which I'm already
familiar, and your musings about a race strongly suggest that you did not read
my fifth point at all.

I'll point out in passing that while (2) isn't really our main concern at this
juncture, it does seem like a pretty serious bug.

I'm not asking for a handout here.  We have significant resources which we can
devote to fixing the problem, but we need to understand it properly first, and
for that to happen, I need you to address the points I make, not the ones I
don't.

-- 
You are receiving this mail because:
You are the assignee for the bug.