-#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, int lr)
+ {
+ int lr_saved;
+ if (lr == 0)
+ lr_saved = (unsigned int) __builtin_return_address(0);
+ else lr_saved = lr;
+
+#ifdef MORE_DICVLOCK_DEBUG
+ printf("div_lock: so=%x sopcb=%x lock=%x ref=%x lr=%x\n",
+ so,
+ so->so_pcb,
+ so->so_pcb ? ((struct inpcb *)so->so_pcb)->inpcb_mtx : 0,
+ so->so_usecount,
+ lr_saved);
+#endif
+ if (so->so_pcb) {
+ lck_mtx_lock(((struct inpcb *)so->so_pcb)->inpcb_mtx);
+ } else {
+ panic("div_lock: so=%x NO PCB! lr=%x\n", so, lr_saved);
+ lck_mtx_lock(so->so_proto->pr_domain->dom_mtx);
+ }
+
+ if (so->so_usecount < 0)
+ panic("div_lock: so=%x so_pcb=%x lr=%x ref=%x\n",
+ so, so->so_pcb, lr_saved, so->so_usecount);
+
+ if (refcount)
+ so->so_usecount++;
+ so->lock_lr[so->next_lock_lr] = (u_int32_t *)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, int lr)
+{
+ int lr_saved;
+ lck_mtx_t * mutex_held;
+ struct inpcb *inp = sotoinpcb(so);
+
+ if (lr == 0)
+ lr_saved = (unsigned int) __builtin_return_address(0);
+ else lr_saved = lr;
+
+
+#ifdef MORE_DICVLOCK_DEBUG
+ printf("div_unlock: so=%x sopcb=%x lock=%x ref=%x lr=%x\n",
+ so,
+ so->so_pcb,
+ so->so_pcb ? ((struct inpcb *)so->so_pcb)->inpcb_mtx : 0,
+ so->so_usecount,
+ lr_saved);