Page MenuHomeFreeBSD

unix: split `unp_connectat()` in two
ClosedPublic

Authored by inquire_JohnEricson.me on Jul 22 2026, 9:36 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Aug 29, 10:03 PM
Unknown Object (File)
Sat, Aug 29, 3:05 AM
Unknown Object (File)
Thu, Aug 27, 1:03 PM
Unknown Object (File)
Thu, Aug 27, 6:44 AM
Unknown Object (File)
Mon, Aug 24, 6:11 PM
Unknown Object (File)
Mon, Aug 24, 6:07 PM
Unknown Object (File)
Fri, Aug 21, 9:46 PM
Unknown Object (File)
Fri, Aug 21, 11:39 AM
Subscribers

Details

Summary

Factor the second half — connecting to an already-resolved peer PCB —
out into a new unp_connect_peer(), leaving unp_connectat() with the
connection state machine and pathname resolution. No functional change.

The helper's contract: the caller guarantees stability of the peer PCB
(vnode lock plus unp_vp_mtxpool lock for peers found via
VOP_UNP_CONNECT()), has set UNP_CONNECTING on the connecting socket,
and clears it again on error; the helper clears it on success.

This prepares for connecting to a peer named by something other than a
pathname.

Signed-off-by: John Ericson <John.Ericson@Obsidian.Systems>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Looks good to me overall.

sys/kern/uipc_usrreq.c
3003

If you write this fragment like this:

if (unp2 == NULL)
    error = ECONNREFUSED;
else
    error = unp_connect_peer(so, unp2, &sa, td, return_locked);
mtx_unlock(vplock);

then you don't need the bad2 label.

Rework error handling to avoid "bad2" as requested

This revision is now accepted and ready to land.Jul 24 2026, 1:45 PM

OK thanks for approving! To be clear, I don't think I have permissions to land it (not really sure how arcanist intended contributors to do this part). Will one of you land it either now, or once we've approved the whole stack?

OK thanks for approving! To be clear, I don't think I have permissions to land it (not really sure how arcanist intended contributors to do this part). Will one of you land it either now, or once we've approved the whole stack?

Yeah, at this point it's up to someone with commit access to actually land the patch and push to git.

I think it's ok to land this as a standalone cleanup, but it'd be nice to conclude the discussion on D58405 first. (If you want to have a broader discussion of the proposal, starting a thread on the freebsd-hackers@ or freebsd-arch@ mailing lists would be the way to go.)

Sure, that sounds good to me. I just wanted to double-check the process. I am happy to continue discussing on D58405, and don't see a need to create a broader mailing list thread if we end up just on Phabricator with you two happy to approve it.

(BTW concurrently to this patch series, I am also working on what I proposed long ago in https://lists.freebsd.org/archives/freebsd-arch/2022-January/000140.html. That is far more involved, and so I think it *does* merit mailing list discussion, but I'll refrain from sending another email until I have a complete draft.)

This revision was automatically updated to reflect the committed changes.