-/* $OpenBSD: kern_sysctl.c,v 1.422 2024/01/15 15:47:37 mvs Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.423 2024/01/18 08:48:32 mvs Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
if (so == NULL) {
so = (struct socket *)fp->f_data;
/* if so is passed as parameter it is already locked */
- switch (so->so_proto->pr_domain->dom_family) {
- case AF_INET:
- case AF_INET6:
- NET_LOCK();
- locked = 1;
- break;
- }
+ solock(so);
+ locked = 1;
}
kf->so_type = so->so_type;
kf->so_splicelen = -1;
if (so->so_pcb == NULL) {
if (locked)
- NET_UNLOCK();
+ sounlock(so);
break;
}
switch (kf->so_family) {
case AF_INET: {
struct inpcb *inpcb = so->so_pcb;
- NET_ASSERT_LOCKED();
+ soassertlocked(so);
if (show_pointers)
kf->inp_ppcb = PTRTOINT64(inpcb->inp_ppcb);
kf->inp_lport = inpcb->inp_lport;
case AF_INET6: {
struct inpcb *inpcb = so->so_pcb;
- NET_ASSERT_LOCKED();
+ soassertlocked(so);
if (show_pointers)
kf->inp_ppcb = PTRTOINT64(inpcb->inp_ppcb);
kf->inp_lport = inpcb->inp_lport;
}
}
if (locked)
- NET_UNLOCK();
+ sounlock(so);
break;
}