Source-Changes-HG archive

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

[src/trunk]: src/sys/net/npf Introduce an npf_conn_destroy_idx() that can han...



details:   https://anonhg.NetBSD.org/src/rev/e21fb76ba575
branches:  trunk
changeset: 964525:e21fb76ba575
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Aug 06 10:25:13 2019 +0000

description:
Introduce an npf_conn_destroy_idx() that can handle partially constructed
conn structures.

diffstat:

 sys/net/npf/npf_conn.c |  15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diffs (61 lines):

diff -r 2bd3deb5eba1 -r e21fb76ba575 sys/net/npf/npf_conn.c
--- a/sys/net/npf/npf_conn.c    Tue Aug 06 08:10:27 2019 +0000
+++ b/sys/net/npf/npf_conn.c    Tue Aug 06 10:25:13 2019 +0000
@@ -107,7 +107,7 @@
 
 #ifdef _KERNEL
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_conn.c,v 1.27 2019/07/23 00:52:01 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_conn.c,v 1.28 2019/08/06 10:25:13 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -143,6 +143,7 @@
 enum { CONN_TRACKING_OFF, CONN_TRACKING_ON };
 
 static nvlist_t *npf_conn_export(npf_t *, npf_conn_t *);
+static void npf_conn_destroy_idx(npf_t *, npf_conn_t *, unsigned);
 
 /*
  * npf_conn_sys{init,fini}: initialise/destroy connection tracking.
@@ -432,7 +433,7 @@
 
        /* Initialize the protocol state. */
        if (!npf_state_init(npc, &con->c_state)) {
-               npf_conn_destroy(npf, con);
+               npf_conn_destroy_idx(npf, con, idx);
                return NULL;
        }
        KASSERT(npf_iscached(npc, NPC_IP46));
@@ -446,7 +447,7 @@
         */
        if (!npf_conn_conkey(npc, fw, true) ||
            !npf_conn_conkey(npc, bk, false)) {
-               npf_conn_destroy(npf, con);
+               npf_conn_destroy_idx(npf, con, idx);
                return NULL;
        }
        con->c_ifid = global ? nbuf->nb_ifid : 0;
@@ -501,8 +502,12 @@
 {
        const npf_connkey_t *key = npf_conn_getforwkey(con);
        const unsigned alen = NPF_CONNKEY_ALEN(key);
-       const unsigned idx __unused = NPF_CONNCACHE(alen);
+       npf_conn_destroy_idx(npf, con, NPF_CONNCACHE(alen));
+}
 
+static void
+npf_conn_destroy_idx(npf_t *npf, npf_conn_t *con, unsigned idx)
+{
        KASSERT(con->c_refcnt == 0);
 
        if (con->c_nat) {
@@ -894,7 +899,7 @@
        npf_conndb_enqueue(cd, con);
        return 0;
 err:
-       npf_conn_destroy(npf, con);
+       npf_conn_destroy_idx(npf, con, idx);
        return EINVAL;
 }
 



Home | Main Index | Thread Index | Old Index