diff options
author | 2011-04-24 19:36:54 +0000 | |
---|---|---|
committer | 2011-04-24 19:36:54 +0000 | |
commit | 806fbec1d553e93c38dd90d3d16e0d84e730756a (patch) | |
tree | 1bfed0d9f934e624cafab1652a1ebe63e84ffa00 /sys/netinet/tcp_input.c | |
parent | Prevent line breaks right before numbers. Groff does the same. (diff) | |
download | wireguard-openbsd-806fbec1d553e93c38dd90d3d16e0d84e730756a.tar.xz wireguard-openbsd-806fbec1d553e93c38dd90d3d16e0d84e730756a.zip |
Double link between pf states and sockets. Henning has already
implemented half of it. The additional part is:
- The pf state lookup for outgoing packets is optimized by using
mbuf->inp->state.
- For incomming tcp, udp, raw, raw6 packets the socket lookup always
is optimized by using mbuf->state->inp.
- All protocols establish the link for incomming packets.
- All protocols set the inp in the mbuf for outgoing packets.
This allows the linkage beginning with the first packet for
outgoing connections.
- In case of divert states, delete the state when the socket closes.
Otherwise new connections could match on old states instead of
being diverted to the listen socket.
ok henning@
Diffstat (limited to 'sys/netinet/tcp_input.c')
-rw-r--r-- | sys/netinet/tcp_input.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 1a724dfa018..b66bfc7754f 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_input.c,v 1.245 2011/04/12 10:47:29 mikeb Exp $ */ +/* $OpenBSD: tcp_input.c,v 1.246 2011/04/24 19:36:54 bluhm Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* @@ -895,7 +895,8 @@ after_listen: #endif #if NPF > 0 - if (m->m_pkthdr.pf.statekey) { + if (m->m_pkthdr.pf.statekey && !inp->inp_pf_sk && + !((struct pf_state_key *)m->m_pkthdr.pf.statekey)->inp) { ((struct pf_state_key *)m->m_pkthdr.pf.statekey)->inp = inp; inp->inp_pf_sk = m->m_pkthdr.pf.statekey; } @@ -1338,6 +1339,19 @@ trimthenstep6: ((opti.ts_present && TSTMP_LT(tp->ts_recent, opti.ts_val)) || SEQ_GT(th->th_seq, tp->rcv_nxt))) { +#if NPF > 0 + /* + * The socket will be recreated but the new state + * has already been linked to the socket. Remove the + * link between old socket and new state. Otherwise + * closing the socket would remove the state. + */ + if (inp->inp_pf_sk) { + ((struct pf_state_key *)inp->inp_pf_sk)->inp = + NULL; + inp->inp_pf_sk = NULL; + } +#endif /* * Advance the iss by at least 32768, but * clear the msb in order to make sure |