CVSROOT:        /cvs
Module name:    src
Changes by:     [email protected]    2024/02/03 15:50:09

Modified files:
        sys/kern       : uipc_socket.c uipc_socket2.c uipc_syscalls.c 
        sys/miscfs/fifofs: fifo_vnops.c 
        sys/netinet    : ip_divert.c ip_divert.h ip_var.h raw_ip.c 
                         udp_usrreq.c udp_var.h 
        sys/netinet6   : ip6_divert.c ip6_mroute.c ip6_var.h raw_ip6.c 
        sys/sys        : mutex.h protosw.h socketvar.h 

Log message:
Rework socket buffers locking for shared netlock.

Shared netlock is not sufficient to call so{r,w}wakeup(). The following
sowakeup() modifies `sb_flags' and knote(9) stuff. Unfortunately, we
can't call so{r,w}wakeup() with `inp_mtx' mutex(9) because sowakeup()
also calls pgsigio() which grabs kernel lock.

However, `so*_filtops' callbacks only perform read-only access to the
socket stuff, so it is enough to hold shared netlock only, but the klist
stuff needs to be protected.

This diff introduces `sb_mtx' mutex(9) to protect sockbuf. This time
`sb_mtx' used to protect only `sb_flags' and `sb_klist'.

Now we have soassertlocked_readonly() and soassertlocked(). The first
one is happy if only shared netlock is held, meanwhile the second wants
`so_lock' or pru_lock() be held together with shared netlock.

To keep soassertlocked*() assertions soft, we need to know mutex(9)
state, so new mtx_owned() macro was introduces. Also, the new optional
(*pru_locked)() handler brings the state of pru_lock().

Tests and ok from bluhm.

Reply via email to