Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net/npf - npf_conn_import: add a missing stat counter in...



details:   https://anonhg.NetBSD.org/src/rev/e9cb9f816ecf
branches:  trunk
changeset: 801947:e9cb9f816ecf
user:      rmind <rmind%NetBSD.org@localhost>
date:      Sun Aug 24 20:36:30 2014 +0000

description:
- npf_conn_import: add a missing stat counter increment.
- npf_nat_import: add a missing reference and make a comment.

diffstat:

 sys/net/npf/npf_conn.c |   7 +++++--
 sys/net/npf/npf_ctl.c  |  10 ++++------
 sys/net/npf/npf_nat.c  |  12 +++++++++---
 3 files changed, 18 insertions(+), 11 deletions(-)

diffs (122 lines):

diff -r 2d1cc1b3e2b2 -r e9cb9f816ecf sys/net/npf/npf_conn.c
--- a/sys/net/npf/npf_conn.c    Sun Aug 24 20:30:49 2014 +0000
+++ b/sys/net/npf/npf_conn.c    Sun Aug 24 20:36:30 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npf_conn.c,v 1.11 2014/08/11 23:48:01 rmind Exp $      */
+/*     $NetBSD: npf_conn.c,v 1.12 2014/08/24 20:36:30 rmind Exp $      */
 
 /*-
  * Copyright (c) 2014 Mindaugas Rasiukevicius <rmind at netbsd org>
@@ -99,7 +99,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_conn.c,v 1.11 2014/08/11 23:48:01 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_conn.c,v 1.12 2014/08/24 20:36:30 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -899,6 +899,7 @@
        con = pool_cache_get(conn_cache, PR_WAITOK);
        memset(con, 0, sizeof(npf_conn_t));
        mutex_init(&con->c_lock, MUTEX_DEFAULT, IPL_SOFTNET);
+       npf_stats_inc(NPF_STAT_CONN_CREATE);
 
        prop_dictionary_get_uint32(cdict, "proto", &con->c_proto);
        prop_dictionary_get_uint32(cdict, "flags", &con->c_flags);
@@ -952,6 +953,8 @@
                npf_conndb_remove(cd, fw);
                goto err;
        }
+
+       NPF_PRINTF(("NPF: imported conn %p\n", con));
        npf_conndb_enqueue(cd, con);
        return 0;
 err:
diff -r 2d1cc1b3e2b2 -r e9cb9f816ecf sys/net/npf/npf_ctl.c
--- a/sys/net/npf/npf_ctl.c     Sun Aug 24 20:30:49 2014 +0000
+++ b/sys/net/npf/npf_ctl.c     Sun Aug 24 20:36:30 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npf_ctl.c,v 1.39 2014/08/11 23:48:01 rmind Exp $       */
+/*     $NetBSD: npf_ctl.c,v 1.40 2014/08/24 20:36:30 rmind Exp $       */
 
 /*-
  * Copyright (c) 2009-2014 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_ctl.c,v 1.39 2014/08/11 23:48:01 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_ctl.c,v 1.40 2014/08/24 20:36:30 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -459,7 +459,7 @@
        prop_dictionary_t condict;
        prop_object_iterator_t it;
        npf_conndb_t *cd;
-       int error;
+       int error = 0;
 
        /* Connection list - array */
        if (prop_object_type(conlist) != PROP_TYPE_ARRAY) {
@@ -469,8 +469,6 @@
 
        /* Create a connection database. */
        cd = npf_conndb_create();
-
-       error = 0;
        it = prop_array_iterator(conlist);
        while ((condict = prop_object_iterator_next(it)) != NULL) {
                /* Connection - dictionary. */
@@ -479,7 +477,7 @@
                        error = EINVAL;
                        break;
                }
-               /* Construct and insert real connection structure. */
+               /* Construct and insert the connection. */
                error = npf_conn_import(cd, condict, natlist);
                if (error) {
                        NPF_ERR_DEBUG(errdict);
diff -r 2d1cc1b3e2b2 -r e9cb9f816ecf sys/net/npf/npf_nat.c
--- a/sys/net/npf/npf_nat.c     Sun Aug 24 20:30:49 2014 +0000
+++ b/sys/net/npf/npf_nat.c     Sun Aug 24 20:36:30 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npf_nat.c,v 1.33 2014/08/11 23:48:01 rmind Exp $       */
+/*     $NetBSD: npf_nat.c,v 1.34 2014/08/24 20:36:30 rmind Exp $       */
 
 /*-
  * Copyright (c) 2014 Mindaugas Rasiukevicius <rmind at netbsd org>
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_nat.c,v 1.33 2014/08/11 23:48:01 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_nat.c,v 1.34 2014/08/24 20:36:30 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -812,6 +812,7 @@
 
        mutex_enter(&np->n_lock);
        LIST_REMOVE(nt, nt_entry);
+       KASSERT(np->n_refcnt > 0);
        atomic_dec_uint(&np->n_refcnt);
        mutex_exit(&np->n_lock);
 
@@ -873,9 +874,14 @@
                return NULL;
        }
 
-       LIST_INSERT_HEAD(&np->n_nat_list, nt, nt_entry);
+       /*
+        * Associate, take a reference and insert.  Unlocked since
+        * the policy is not yet visible.
+        */
        nt->nt_natpolicy = np;
        nt->nt_conn = con;
+       np->n_refcnt++;
+       LIST_INSERT_HEAD(&np->n_nat_list, nt, nt_entry);
        return nt;
 }
 



Home | Main Index | Thread Index | Old Index