diff options
author | 2015-12-03 14:05:28 +0000 | |
---|---|---|
committer | 2015-12-03 14:05:28 +0000 | |
commit | 38b876c502fa315fec5f5d459f37a04a4db8522a (patch) | |
tree | 3b3496f0b3b3158f4f5022b38dff3b144c2b19c4 /sys/netinet/tcp_input.c | |
parent | Add sizes to most free calls. OK sashan@ tedu@ (diff) | |
download | wireguard-openbsd-38b876c502fa315fec5f5d459f37a04a4db8522a.tar.xz wireguard-openbsd-38b876c502fa315fec5f5d459f37a04a4db8522a.zip |
To avoid that the stack manipules the pf statekeys directly, introduce
pf_inp_...() lookup, link and unlink functions as an interface.
Locking can be added to them later. Remove the first linking at
the beginning of tcp_input() and udp_input() as it is not necessary.
It will be done later anyway. That code was a relict, from the
time before I had added the second linking.
Input from mikeb@ and sashan@; OK sashan@
Diffstat (limited to 'sys/netinet/tcp_input.c')
-rw-r--r-- | sys/netinet/tcp_input.c | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index af16aae17d1..e82ccaf1bd0 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_input.c,v 1.310 2015/11/29 15:09:32 mpi Exp $ */ +/* $OpenBSD: tcp_input.c,v 1.311 2015/12/03 14:05:28 bluhm Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* @@ -580,11 +580,7 @@ tcp_input(struct mbuf *m, ...) * Locate pcb for segment. */ #if NPF > 0 - if (m->m_pkthdr.pf.statekey) { - inp = m->m_pkthdr.pf.statekey->inp; - if (inp && inp->inp_pf_sk) - KASSERT(m->m_pkthdr.pf.statekey == inp->inp_pf_sk); - } + inp = pf_inp_lookup(m); #endif findpcb: if (inp == NULL) { @@ -602,12 +598,6 @@ findpcb: m->m_pkthdr.ph_rtableid); break; } -#if NPF > 0 - if (m->m_pkthdr.pf.statekey && inp) { - m->m_pkthdr.pf.statekey->inp = inp; - inp->inp_pf_sk = m->m_pkthdr.pf.statekey; - } -#endif } if (inp == NULL) { int inpl_reverse = 0; @@ -880,13 +870,7 @@ findpcb: #endif #if NPF > 0 - if (m->m_pkthdr.pf.statekey && !m->m_pkthdr.pf.statekey->inp && - !inp->inp_pf_sk) { - m->m_pkthdr.pf.statekey->inp = inp; - inp->inp_pf_sk = m->m_pkthdr.pf.statekey; - } - /* The statekey has finished finding the inp, it is no longer needed. */ - m->m_pkthdr.pf.statekey = NULL; + pf_inp_link(m, inp); #endif #ifdef IPSEC @@ -1294,10 +1278,7 @@ trimthenstep6: * has already been linked to the socket. Remove the * link between old socket and new state. */ - if (inp->inp_pf_sk) { - inp->inp_pf_sk->inp = NULL; - inp->inp_pf_sk = NULL; - } + pf_inp_unlink(inp); #endif /* * Advance the iss by at least 32768, but |