| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: npf_state.c,v 1.3 2011/01/18 20:33:46 rmind Exp $ */ | | 1 | /* $NetBSD: npf_state.c,v 1.4 2011/04/25 22:16:21 yamt Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2010 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This material is based upon work partially supported by The | | 7 | * This material is based upon work partially supported by The |
8 | * NetBSD Foundation under a contract with Mindaugas Rasiukevicius. | | 8 | * NetBSD Foundation under a contract with Mindaugas Rasiukevicius. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -24,27 +24,27 @@ | | | @@ -24,27 +24,27 @@ |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * NPF state engine to track connections. | | 33 | * NPF state engine to track connections. |
34 | */ | | 34 | */ |
35 | | | 35 | |
36 | #include <sys/cdefs.h> | | 36 | #include <sys/cdefs.h> |
37 | __KERNEL_RCSID(0, "$NetBSD: npf_state.c,v 1.3 2011/01/18 20:33:46 rmind Exp $"); | | 37 | __KERNEL_RCSID(0, "$NetBSD: npf_state.c,v 1.4 2011/04/25 22:16:21 yamt Exp $"); |
38 | | | 38 | |
39 | #include <sys/param.h> | | 39 | #include <sys/param.h> |
40 | #include <sys/systm.h> | | 40 | #include <sys/systm.h> |
41 | | | 41 | |
42 | #include <sys/mutex.h> | | 42 | #include <sys/mutex.h> |
43 | #include <netinet/in.h> | | 43 | #include <netinet/in.h> |
44 | #include <netinet/tcp.h> | | 44 | #include <netinet/tcp.h> |
45 | #include <netinet/tcp_seq.h> | | 45 | #include <netinet/tcp_seq.h> |
46 | #include <netinet/tcp_fsm.h> | | 46 | #include <netinet/tcp_fsm.h> |
47 | | | 47 | |
48 | #include "npf_impl.h" | | 48 | #include "npf_impl.h" |
49 | | | 49 | |
50 | /* TCP session expiration table. */ | | 50 | /* TCP session expiration table. */ |
| @@ -394,30 +394,28 @@ npf_state_inspect(const npf_cache_t *npc | | | @@ -394,30 +394,28 @@ npf_state_inspect(const npf_cache_t *npc |
394 | * npf_state_etime: return session expiration time according to the state. | | 394 | * npf_state_etime: return session expiration time according to the state. |
395 | */ | | 395 | */ |
396 | int | | 396 | int |
397 | npf_state_etime(const npf_state_t *nst, const int proto) | | 397 | npf_state_etime(const npf_state_t *nst, const int proto) |
398 | { | | 398 | { |
399 | const int state = nst->nst_state; | | 399 | const int state = nst->nst_state; |
400 | | | 400 | |
401 | if (__predict_true(proto == IPPROTO_TCP)) { | | 401 | if (__predict_true(proto == IPPROTO_TCP)) { |
402 | return tcp_expire_table[state]; | | 402 | return tcp_expire_table[state]; |
403 | } | | 403 | } |
404 | return expire_table[proto]; | | 404 | return expire_table[proto]; |
405 | } | | 405 | } |
406 | | | 406 | |
407 | #if defined(DDB) || defined(_NPF_TESTING) | | | |
408 | | | | |
409 | void | | 407 | void |
410 | npf_state_dump(npf_state_t *nst) | | 408 | npf_state_dump(npf_state_t *nst) |
411 | { | | 409 | { |
| | | 410 | #if defined(DDB) || defined(_NPF_TESTING) |
412 | npf_tcpstate_t *fst = &nst->nst_tcpst[0], *tst = &nst->nst_tcpst[1]; | | 411 | npf_tcpstate_t *fst = &nst->nst_tcpst[0], *tst = &nst->nst_tcpst[1]; |
413 | | | 412 | |
414 | printf("\tstate (%p) %d:\n\t\t" | | 413 | printf("\tstate (%p) %d:\n\t\t" |
415 | "F { seqend %u ackend %u mwin %u wscale %u }\n\t\t" | | 414 | "F { seqend %u ackend %u mwin %u wscale %u }\n\t\t" |
416 | "T { seqend %u ackend %u mwin %u wscale %u }\n", | | 415 | "T { seqend %u ackend %u mwin %u wscale %u }\n", |
417 | nst, nst->nst_state, | | 416 | nst, nst->nst_state, |
418 | fst->nst_seqend, fst->nst_ackend, fst->nst_maxwin, fst->nst_wscale, | | 417 | fst->nst_seqend, fst->nst_ackend, fst->nst_maxwin, fst->nst_wscale, |
419 | tst->nst_seqend, tst->nst_ackend, tst->nst_maxwin, tst->nst_wscale | | 418 | tst->nst_seqend, tst->nst_ackend, tst->nst_maxwin, tst->nst_wscale |
420 | ); | | 419 | ); |
421 | } | | | |
422 | | | | |
423 | #endif | | 420 | #endif |
| | | 421 | } |