Page MenuHomeFreeBSD

unix: provide an option to return locked from unp_connectat()
ClosedPublic

Authored by glebius on May 23 2022, 9:01 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sep 28 2024, 10:37 AM
Unknown Object (File)
Sep 23 2024, 10:20 PM
Unknown Object (File)
Sep 17 2024, 2:47 PM
Unknown Object (File)
Sep 17 2024, 7:59 AM
Unknown Object (File)
Sep 15 2024, 10:06 PM
Unknown Object (File)
Sep 11 2024, 7:08 AM
Unknown Object (File)
Sep 4 2024, 8:14 PM
Unknown Object (File)
Aug 30 2024, 2:01 AM
Subscribers

Details

Summary

Use this new version in unix/dgram socket when sending to a target
address. This removes extra lock release/acquisition and possible
counter-intuitive ENOTCONN.

Diff Detail

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

Event Timeline

Note: this patch is a step towards D35303.

sys/kern/uipc_usrreq.c
1834

I don't have a concrete suggestion right now, but I don't like these kinds of "naked" boolean flags. IMO it'd be better to have a separate function.

1984–1985
1997

vput() can sleep when releasing the final reference, so we can't hold PCB locks here.

sys/kern/uipc_usrreq.c
1997

Thinking a bit more, unp2 should already hold a use-ref on the vnode, and this ref is protected by the PCB lock. So after the VOP_UNP_CONNECT() call I believe the use count on vp will be >= 2. The problem is that unp2's PCB lock is released after calling sonewconn(), and after that point the use count can drop to 1. But in the !connreq case (i.e., the SOCK_DGRAM case), I think the vput() call is effectively guaranteed not to sleep. Not sure if that's sufficient for you.

glebius added inline comments.
sys/kern/uipc_usrreq.c
1997

Thanks for input! I will put that into a comment.

sys/kern/uipc_usrreq.c
1993

So let's assert !(return_locked && connreq)?

Add assertion befor vput().

sys/kern/uipc_usrreq.c
1220

Instead use unp2 = unp_pcb_lock_peer(unp) and check for NULL. I believe it is possible for the socket to be disconnected again while PCB locks are dropped.

sys/kern/uipc_usrreq.c
1220

I can't understand. The whole idea of this revision is that unp_connectat() doesn't drop the locks and such situation is impossible.

markj added inline comments.
sys/kern/uipc_usrreq.c
1220

Ah, got it.

This revision is now accepted and ready to land.Jun 1 2022, 4:19 PM
This revision was landed with ongoing or failed builds.Jun 24 2022, 4:11 PM
This revision was automatically updated to reflect the committed changes.