On Mon, Mar 06, 2017 at 12:13:48PM +0100, Martin Pieuchot wrote:
> In sysctl_file() splnet() is no longer what we want. Arguably the
> KERNEL_LOCK() should be enough, but since pf(4) is messing with these
> tables, and nobody turned this part of pf(4) MP, let's require the
> NET_LOCK().
>
> ok?
OK bluhm@
I think we should do the same for the other loops and insertions
of this queue.
ok?
bluhm
Index: netinet/in_pcb.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/in_pcb.c,v
retrieving revision 1.218
diff -u -p -r1.218 in_pcb.c
--- netinet/in_pcb.c 6 Mar 2017 08:59:07 -0000 1.218
+++ netinet/in_pcb.c 6 Mar 2017 19:07:17 -0000
@@ -249,10 +249,9 @@ int
in_pcballoc(struct socket *so, struct inpcbtable *table)
{
struct inpcb *inp;
- int s;
struct inpcbhead *head;
- splsoftassert(IPL_SOFTNET);
+ NET_ASSERT_LOCKED();
if (inpcb_pool_initialized == 0) {
pool_init(&inpcb_pool, sizeof(struct inpcb), 0,
@@ -269,7 +268,6 @@ in_pcballoc(struct socket *so, struct in
inp->inp_seclevel[SL_ESP_NETWORK] = IPSEC_ESP_NETWORK_LEVEL_DEFAULT;
inp->inp_seclevel[SL_IPCOMP] = IPSEC_IPCOMP_LEVEL_DEFAULT;
inp->inp_rtableid = curproc->p_p->ps_rtableid;
- s = splnet();
if (table->inpt_hash != 0 &&
table->inpt_count++ > INPCBHASH_LOADFACTOR(table->inpt_hash))
(void)in_pcbresize(table, (table->inpt_hash + 1) * 2);
@@ -279,7 +277,6 @@ in_pcballoc(struct socket *so, struct in
head = INPCBHASH(table, &inp->inp_faddr, inp->inp_fport,
&inp->inp_laddr, inp->inp_lport, rtable_l2(inp->inp_rtableid));
LIST_INSERT_HEAD(head, inp, inp_hash);
- splx(s);
so->so_pcb = inp;
inp->inp_hops = -1;
@@ -577,9 +574,8 @@ void
in_pcbdetach(struct inpcb *inp)
{
struct socket *so = inp->inp_socket;
- int s;
- splsoftassert(IPL_SOFTNET);
+ NET_ASSERT_LOCKED();
so->so_pcb = 0;
sofree(so);
@@ -602,12 +598,10 @@ in_pcbdetach(struct inpcb *inp)
pf_inp_unlink(inp);
}
#endif
- s = splnet();
LIST_REMOVE(inp, inp_lhash);
LIST_REMOVE(inp, inp_hash);
TAILQ_REMOVE(&inp->inp_table->inpt_queue, inp, inp_queue);
inp->inp_table->inpt_count--;
- splx(s);
pool_put(&inpcb_pool, inp);
}
@@ -661,7 +655,7 @@ in_pcbnotifyall(struct inpcbtable *table
struct inpcb *inp, *ninp;
struct in_addr faddr;
- splsoftassert(IPL_SOFTNET);
+ NET_ASSERT_LOCKED();
#ifdef INET6
/*
@@ -956,10 +950,10 @@ void
in_pcbrehash(struct inpcb *inp)
{
struct inpcbtable *table = inp->inp_table;
- int s;
struct inpcbhead *head;
- s = splnet();
+ NET_ASSERT_LOCKED();
+
LIST_REMOVE(inp, inp_lhash);
head = INPCBLHASH(table, inp->inp_lport, inp->inp_rtableid);
LIST_INSERT_HEAD(head, inp, inp_lhash);
@@ -975,7 +969,6 @@ in_pcbrehash(struct inpcb *inp)
&inp->inp_laddr, inp->inp_lport,
rtable_l2(inp->inp_rtableid));
LIST_INSERT_HEAD(head, inp, inp_hash);
- splx(s);
}
int
Index: netinet6/in6_pcb.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/in6_pcb.c,v
retrieving revision 1.96
diff -u -p -r1.96 in6_pcb.c
--- netinet6/in6_pcb.c 4 Aug 2016 20:46:24 -0000 1.96
+++ netinet6/in6_pcb.c 6 Mar 2017 19:07:51 -0000
@@ -334,6 +334,8 @@ in6_pcbnotify(struct inpcbtable *head, s
int errno, nmatch = 0;
u_int32_t flowinfo;
+ NET_ASSERT_LOCKED();
+
if ((unsigned)cmd >= PRC_NCMDS)
return (0);