Mon Apr 25 22:16:21 2011 UTC ()
fix module build


(yamt)
diff -r1.4 -r1.5 src/sys/net/npf/npf.c
diff -r1.3 -r1.4 src/sys/net/npf/npf_state.c

cvs diff -r1.4 -r1.5 src/sys/net/npf/npf.c (expand / switch to unified diff)

--- src/sys/net/npf/npf.c 2011/02/02 02:20:25 1.4
+++ src/sys/net/npf/npf.c 2011/04/25 22:16:21 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: npf.c,v 1.4 2011/02/02 02:20:25 rmind Exp $ */ 1/* $NetBSD: npf.c,v 1.5 2011/04/25 22:16:21 yamt Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2009-2010 The NetBSD Foundation, Inc. 4 * Copyright (c) 2009-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,51 +24,52 @@ @@ -24,51 +24,52 @@
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 main: dynamic load/initialisation and unload routines. 33 * NPF main: dynamic load/initialisation and unload routines.
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37__KERNEL_RCSID(0, "$NetBSD: npf.c,v 1.4 2011/02/02 02:20:25 rmind Exp $"); 37__KERNEL_RCSID(0, "$NetBSD: npf.c,v 1.5 2011/04/25 22:16:21 yamt Exp $");
38 38
39#include <sys/param.h> 39#include <sys/param.h>
40#include <sys/types.h> 40#include <sys/types.h>
41 41
42#include <sys/atomic.h> 42#include <sys/atomic.h>
43#include <sys/conf.h> 43#include <sys/conf.h>
44#include <sys/kauth.h> 44#include <sys/kauth.h>
45#include <sys/kmem.h> 45#include <sys/kmem.h>
46#include <sys/lwp.h> 46#include <sys/lwp.h>
47#include <sys/module.h> 47#include <sys/module.h>
48#include <sys/percpu.h> 48#include <sys/percpu.h>
49#include <sys/rwlock.h> 49#include <sys/rwlock.h>
50#include <sys/socketvar.h> 50#include <sys/socketvar.h>
51#include <sys/uio.h> 51#include <sys/uio.h>
52 52
53#include "npf_impl.h" 53#include "npf_impl.h"
54 54
55/* 55/*
56 * Module and device structures. 56 * Module and device structures.
57 */ 57 */
58MODULE(MODULE_CLASS_MISC, npf, NULL); 58MODULE(MODULE_CLASS_MISC, npf, NULL);
59 59
60void npfattach(int); 60void npfattach(int);
61 61
 62static int npf_fini(void);
62static int npf_dev_open(dev_t, int, int, lwp_t *); 63static int npf_dev_open(dev_t, int, int, lwp_t *);
63static int npf_dev_close(dev_t, int, int, lwp_t *); 64static int npf_dev_close(dev_t, int, int, lwp_t *);
64static int npf_dev_ioctl(dev_t, u_long, void *, int, lwp_t *); 65static int npf_dev_ioctl(dev_t, u_long, void *, int, lwp_t *);
65static int npf_dev_poll(dev_t, int, lwp_t *); 66static int npf_dev_poll(dev_t, int, lwp_t *);
66static int npf_dev_read(dev_t, struct uio *, int); 67static int npf_dev_read(dev_t, struct uio *, int);
67 68
68typedef struct { 69typedef struct {
69 npf_ruleset_t * n_rules; 70 npf_ruleset_t * n_rules;
70 npf_tableset_t * n_tables; 71 npf_tableset_t * n_tables;
71 npf_ruleset_t * n_nat_rules; 72 npf_ruleset_t * n_nat_rules;
72} npf_core_t; 73} npf_core_t;
73 74
74static void npf_core_destroy(npf_core_t *); 75static void npf_core_destroy(npf_core_t *);

cvs diff -r1.3 -r1.4 src/sys/net/npf/npf_state.c (expand / switch to unified diff)

--- src/sys/net/npf/npf_state.c 2011/01/18 20:33:46 1.3
+++ src/sys/net/npf/npf_state.c 2011/04/25 22:16:21 1.4
@@ -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 */
396int 396int
397npf_state_etime(const npf_state_t *nst, const int proto) 397npf_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 
409void 407void
410npf_state_dump(npf_state_t *nst) 408npf_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}