in_pcb: add in_pcbrele_rlock()

The helper that derefs and rlocks the provided inp.  Returns false if inp
is still usable.

Reviewed by:	glebius, markj
Sponsored by:	Nvidia networking
Differential revision:	https://reviews.freebsd.org/D51143
This commit is contained in:
Konstantin Belousov
2025-07-03 13:36:58 +03:00
parent 63389aea24
commit 1b7d0c2ee9
2 changed files with 18 additions and 0 deletions
+17
View File
@@ -1744,6 +1744,23 @@ in_pcbrele(struct inpcb *inp, const inp_lookup_t lock)
in_pcbrele_rlocked(inp) : in_pcbrele_wlocked(inp)); in_pcbrele_rlocked(inp) : in_pcbrele_wlocked(inp));
} }
/*
* Dereference and rlock inp, for which the caller must own the
* reference. Returns true if inp no longer usable, false otherwise.
*/
bool
in_pcbrele_rlock(struct inpcb *inp)
{
INP_RLOCK(inp);
if (in_pcbrele_rlocked(inp))
return (true);
if ((inp->inp_flags & INP_FREED) != 0) {
INP_RUNLOCK(inp);
return (true);
}
return (false);
}
/* /*
* Unconditionally schedule an inpcb to be freed by decrementing its * Unconditionally schedule an inpcb to be freed by decrementing its
* reference count, which should occur only after the inpcb has been detached * reference count, which should occur only after the inpcb has been detached
+1
View File
@@ -681,6 +681,7 @@ void in_pcbref(struct inpcb *);
bool in_pcbrele(struct inpcb *, inp_lookup_t); bool in_pcbrele(struct inpcb *, inp_lookup_t);
bool in_pcbrele_rlocked(struct inpcb *); bool in_pcbrele_rlocked(struct inpcb *);
bool in_pcbrele_wlocked(struct inpcb *); bool in_pcbrele_wlocked(struct inpcb *);
bool in_pcbrele_rlock(struct inpcb *inp);
typedef bool inp_match_t(const struct inpcb *, void *); typedef bool inp_match_t(const struct inpcb *, void *);
struct inpcb_iterator { struct inpcb_iterator {