-#warning Fix SYSCTL net_inet_divert
-#if 0
-SYSCTL_DECL(_net_inet_divert);
-SYSCTL_PROC(_net_inet_divert, OID_AUTO, pcblist, CTLFLAG_RD, 0, 0,
- div_pcblist, "S,xinpcb", "List of active divert sockets");
+__private_extern__ int
+div_lock(struct socket *so, int refcount, void *lr)
+{
+ void *lr_saved;
+
+ if (lr == NULL)
+ lr_saved = __builtin_return_address(0);
+ else
+ lr_saved = lr;
+
+#ifdef MORE_DICVLOCK_DEBUG
+ printf("div_lock: so=0x%llx sopcb=0x%llx lock=0x%llx ref=%x "
+ "lr=0x%llx\n", (uint64_t)VM_KERNEL_ADDRPERM(so),
+ (uint64_t)VM_KERNEL_ADDRPERM(so->so_pcb), so->so_pcb ?
+ (uint64_t)VM_KERNEL_ADDRPERM(&(sotoinpcb(so)->inpcb_mtx)) : NULL,
+ so->so_usecount, (uint64_t)VM_KERNEL_ADDRPERM(lr_saved));
+#endif
+ if (so->so_pcb) {
+ lck_mtx_lock(&((struct inpcb *)so->so_pcb)->inpcb_mtx);
+ } else {
+ panic("div_lock: so=%p NO PCB! lr=%p lrh= lrh= %s\n",
+ so, lr_saved, solockhistory_nr(so));
+ /* NOTREACHED */
+ }
+
+ if (so->so_usecount < 0) {
+ panic("div_lock: so=%p so_pcb=%p lr=%p ref=%x lrh= %s\n",
+ so, so->so_pcb, lr_saved, so->so_usecount,
+ solockhistory_nr(so));
+ /* NOTREACHED */
+ }
+
+ if (refcount)
+ so->so_usecount++;
+ so->lock_lr[so->next_lock_lr] = lr_saved;
+ so->next_lock_lr = (so->next_lock_lr+1) % SO_LCKDBG_MAX;
+
+ return (0);
+}
+
+__private_extern__ int
+div_unlock(struct socket *so, int refcount, void *lr)
+{
+ void *lr_saved;
+ lck_mtx_t * mutex_held;
+ struct inpcb *inp = sotoinpcb(so);
+
+ if (lr == NULL)
+ lr_saved = __builtin_return_address(0);
+ else
+ lr_saved = lr;
+
+#ifdef MORE_DICVLOCK_DEBUG
+ printf("div_unlock: so=0x%llx sopcb=0x%llx lock=0x%llx ref=%x "
+ "lr=0x%llx\n", (uint64_t)VM_KERNEL_ADDRPERM(so),
+ (uint64_t)VM_KERNEL_ADDRPERM(so->so_pcb), so->so_pcb ?
+ (uint64_t)VM_KERNEL_ADDRPERM(&(sotoinpcb(so)->inpcb_mtx)) : NULL,
+ so->so_usecount, lr_saved);