Our plan is to work on the socket layer protocol per protocol. claudio@
already sent some diffs to make the iteration on the PF_ROUTE socket
list MP-safe. However that isn't enough for the inner par of the loop.
Since socket flag access and socket buffer modifications need to be
atomic until somebody proves the contrary. I'd like to assert that
the KERNEL_LOCK() is held for pfkey/routing and local sockets.
The diff below only makes sense if socket buffer functions assert for
the related "socket lock".
ok?
Index: kern/uipc_socket2.c
===================================================================
RCS file: /cvs/src/sys/kern/uipc_socket2.c,v
retrieving revision 1.77
diff -u -p -r1.77 uipc_socket2.c
--- kern/uipc_socket2.c 27 May 2017 18:50:53 -0000 1.77
+++ kern/uipc_socket2.c 6 Jun 2017 15:29:05 -0000
@@ -292,10 +292,18 @@ sounlock(int s)
void
soassertlocked(struct socket *so)
{
- if ((so->so_proto->pr_domain->dom_family != PF_LOCAL) &&
- (so->so_proto->pr_domain->dom_family != PF_ROUTE) &&
- (so->so_proto->pr_domain->dom_family != PF_KEY))
+ switch (so->so_proto->pr_domain->dom_family) {
+ case PF_INET:
+ case PF_INET6:
NET_ASSERT_LOCKED();
+ break;
+ case PF_LOCAL:
+ case PF_ROUTE:
+ case PF_KEY:
+ default:
+ KERNEL_ASSERT_LOCKED();
+ break;
+ }
}
int