Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netipsec Provide and apply key_sp_refcnt (NFC)
details: https://anonhg.NetBSD.org/src/rev/5b4960bacb5d
branches: trunk
changeset: 355333:5b4960bacb5d
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Wed Jul 26 03:59:59 2017 +0000
description:
Provide and apply key_sp_refcnt (NFC)
It simplifies further changes.
diffstat:
sys/netipsec/ipsec.c | 12 ++++++------
sys/netipsec/key.c | 22 ++++++++++++++++------
sys/netipsec/key.h | 3 ++-
sys/netipsec/key_debug.c | 7 ++++---
4 files changed, 28 insertions(+), 16 deletions(-)
diffs (177 lines):
diff -r f7ecef81117f -r 5b4960bacb5d sys/netipsec/ipsec.c
--- a/sys/netipsec/ipsec.c Wed Jul 26 03:46:54 2017 +0000
+++ b/sys/netipsec/ipsec.c Wed Jul 26 03:59:59 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ipsec.c,v 1.110 2017/07/21 04:50:11 ozaki-r Exp $ */
+/* $NetBSD: ipsec.c,v 1.111 2017/07/26 03:59:59 ozaki-r Exp $ */
/* $FreeBSD: /usr/local/www/cvsroot/FreeBSD/src/sys/netipsec/ipsec.c,v 1.2.2.2 2003/07/01 01:38:13 sam Exp $ */
/* $KAME: ipsec.c,v 1.103 2001/05/24 07:14:18 sakane Exp $ */
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.110 2017/07/21 04:50:11 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ipsec.c,v 1.111 2017/07/26 03:59:59 ozaki-r Exp $");
/*
* IPsec controller part.
@@ -256,7 +256,7 @@
KEY_SP_REF(pcbsp->sp_cache[dir].cachesp);
KEYDEBUG_PRINTF(KEYDEBUG_IPSEC_STAMP,
"DP cause refcnt++:%d SP:%p\n",
- pcbsp->sp_cache[dir].cachesp->refcnt,
+ key_sp_refcnt(pcbsp->sp_cache[dir].cachesp),
pcbsp->sp_cache[dir].cachesp);
return pcbsp->sp_cache[dir].cachesp;
}
@@ -282,7 +282,7 @@
KEY_SP_REF(pcbsp->sp_cache[dir].cachesp);
KEYDEBUG_PRINTF(KEYDEBUG_IPSEC_STAMP,
"DP cause refcnt++:%d SP:%p\n",
- pcbsp->sp_cache[dir].cachesp->refcnt,
+ key_sp_refcnt(pcbsp->sp_cache[dir].cachesp),
pcbsp->sp_cache[dir].cachesp);
/*
@@ -392,7 +392,7 @@
KEY_SP_REF(sp);
KEYDEBUG_PRINTF(KEYDEBUG_IPSEC_STAMP, "DP returns SP:%p (%u)\n",
- sp, sp->refcnt);
+ sp, key_sp_refcnt(sp));
return sp;
}
#define KEY_GET_DEFAULT_SP(af) \
@@ -531,7 +531,7 @@
currsp->policy);
KEYDEBUG_PRINTF(KEYDEBUG_IPSEC_STAMP,
"DP (priv %u policy %u) allocates SP:%p (refcnt %u)\n",
- pcbsp->priv, currsp->policy, sp, sp->refcnt);
+ pcbsp->priv, currsp->policy, sp, key_sp_refcnt(sp));
ipsec_fillpcbcache(pcbsp, m, sp, dir);
return sp;
}
diff -r f7ecef81117f -r 5b4960bacb5d sys/netipsec/key.c
--- a/sys/netipsec/key.c Wed Jul 26 03:46:54 2017 +0000
+++ b/sys/netipsec/key.c Wed Jul 26 03:59:59 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: key.c,v 1.192 2017/07/26 01:33:35 ozaki-r Exp $ */
+/* $NetBSD: key.c,v 1.193 2017/07/26 03:59:59 ozaki-r Exp $ */
/* $FreeBSD: src/sys/netipsec/key.c,v 1.3.2.3 2004/02/14 22:23:23 bms Exp $ */
/* $KAME: key.c,v 1.191 2001/06/27 10:46:49 sakane Exp $ */
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.192 2017/07/26 01:33:35 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key.c,v 1.193 2017/07/26 03:59:59 ozaki-r Exp $");
/*
* This code is referd to RFC 2367
@@ -602,6 +602,15 @@
REFLOG("SP_DELREF", (p), (where), (tag)); \
} while (0)
+u_int
+key_sp_refcnt(const struct secpolicy *sp)
+{
+
+ if (sp == NULL)
+ return 0;
+
+ return sp->refcnt;
+}
static inline void
key_sp_dead(struct secpolicy *sp)
@@ -686,7 +695,7 @@
KEYDEBUG_PRINTF(KEYDEBUG_IPSEC_STAMP,
"DP return SP:%p (ID=%u) refcnt %u\n",
- sp, sp ? sp->id : 0, sp ? sp->refcnt : 0);
+ sp, sp ? sp->id : 0, key_sp_refcnt(sp));
return sp;
}
@@ -762,7 +771,7 @@
done:
KEYDEBUG_PRINTF(KEYDEBUG_IPSEC_STAMP,
"DP return SP:%p (ID=%u) refcnt %u\n",
- sp, sp ? sp->id : 0, sp ? sp->refcnt : 0);
+ sp, sp ? sp->id : 0, key_sp_refcnt(sp));
return sp;
}
@@ -1112,7 +1121,7 @@
KEYDEBUG_PRINTF(KEYDEBUG_IPSEC_STAMP,
"DP SP:%p (ID=%u) from %s:%u; refcnt now %u\n",
- sp, sp->id, where, tag, sp->refcnt);
+ sp, sp->id, where, tag, key_sp_refcnt(sp));
}
void
@@ -2492,7 +2501,8 @@
{
struct mbuf *result = NULL, *m;
- m = key_setsadbmsg(type, 0, SADB_SATYPE_UNSPEC, seq, pid, sp->refcnt);
+ m = key_setsadbmsg(type, 0, SADB_SATYPE_UNSPEC, seq, pid,
+ key_sp_refcnt(sp));
if (!m)
goto fail;
result = m;
diff -r f7ecef81117f -r 5b4960bacb5d sys/netipsec/key.h
--- a/sys/netipsec/key.h Wed Jul 26 03:46:54 2017 +0000
+++ b/sys/netipsec/key.h Wed Jul 26 03:59:59 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: key.h,v 1.24 2017/07/21 04:39:08 ozaki-r Exp $ */
+/* $NetBSD: key.h,v 1.25 2017/07/26 03:59:59 ozaki-r Exp $ */
/* $FreeBSD: src/sys/netipsec/key.h,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $ */
/* $KAME: key.h,v 1.21 2001/07/27 03:51:30 itojun Exp $ */
@@ -56,6 +56,7 @@
const struct sockaddr *, const char*, int);
/* NB: prepend with _ for KAME IPv6 compatbility */
void _key_freesp(struct secpolicy **, const char*, int);
+u_int key_sp_refcnt(const struct secpolicy *);
void key_sp_ref(struct secpolicy *, const char*, int);
void key_sa_ref(struct secasvar *, const char*, int);
diff -r f7ecef81117f -r 5b4960bacb5d sys/netipsec/key_debug.c
--- a/sys/netipsec/key_debug.c Wed Jul 26 03:46:54 2017 +0000
+++ b/sys/netipsec/key_debug.c Wed Jul 26 03:59:59 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: key_debug.c,v 1.18 2017/07/21 04:50:11 ozaki-r Exp $ */
+/* $NetBSD: key_debug.c,v 1.19 2017/07/26 03:59:59 ozaki-r Exp $ */
/* $FreeBSD: src/sys/netipsec/key_debug.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $ */
/* $KAME: key_debug.c,v 1.26 2001/06/27 10:46:50 sakane Exp $ */
@@ -33,7 +33,7 @@
#ifdef _KERNEL
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: key_debug.c,v 1.18 2017/07/21 04:50:11 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: key_debug.c,v 1.19 2017/07/26 03:59:59 ozaki-r Exp $");
#endif
#if defined(_KERNEL_OPT)
@@ -51,6 +51,7 @@
#include <net/route.h>
+#include <netipsec/key.h>
#include <netipsec/key_var.h>
#include <netipsec/key_debug.h>
@@ -461,7 +462,7 @@
panic("kdebug_secpolicy: NULL pointer was passed");
printf("secpolicy{ refcnt=%u state=%u policy=%u\n",
- sp->refcnt, sp->state, sp->policy);
+ key_sp_refcnt(sp), sp->state, sp->policy);
kdebug_secpolicyindex(&sp->spidx);
Home |
Main Index |
Thread Index |
Old Index