summaryrefslogtreecommitdiffstats
path: root/sys/netipsec/key_debug.c
diff options
context:
space:
mode:
authorbz <bz@FreeBSD.org>2008-03-02 17:12:28 +0000
committerbz <bz@FreeBSD.org>2008-03-02 17:12:28 +0000
commit767a2621f07a4ba9a59a9d383581ed5558f667db (patch)
tree9e4f7f34605a0e72d8b6dd6e4df767cbae80a7aa /sys/netipsec/key_debug.c
parent3dea77f93cd358a469b5ae398a5e67d559db283a (diff)
downloadFreeBSD-src-767a2621f07a4ba9a59a9d383581ed5558f667db.zip
FreeBSD-src-767a2621f07a4ba9a59a9d383581ed5558f667db.tar.gz
Fix bugs when allocating and passing information of current lifetime and
soft lifetime [1] introduced in rev. 1.21 of key.c. Along with that, fix a related problem in key_debug printing the correct data. While there replace a printf by panic in a sanity check. PR: 120751 Submitted by: Kazuaki ODA (kazuaki aliceblue.jp) [1] MFC after: 5 days
Diffstat (limited to 'sys/netipsec/key_debug.c')
-rw-r--r--sys/netipsec/key_debug.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/sys/netipsec/key_debug.c b/sys/netipsec/key_debug.c
index 7252ea0..7acc266 100644
--- a/sys/netipsec/key_debug.c
+++ b/sys/netipsec/key_debug.c
@@ -52,6 +52,9 @@
#include <netinet/in.h>
#include <netipsec/ipsec.h>
+#ifdef _KERNEL
+#include <netipsec/keydb.h>
+#endif
#ifndef _KERNEL
#include <ctype.h>
@@ -296,7 +299,7 @@ kdebug_sadb_lifetime(ext)
/* sanity check */
if (ext == NULL)
- printf("%s: NULL pointer was passed.\n", __func__);
+ panic("%s: NULL pointer was passed.\n", __func__);
printf("sadb_lifetime{ alloc=%u, bytes=%u\n",
lft->sadb_lifetime_allocations,
@@ -553,6 +556,21 @@ kdebug_secasindex(saidx)
return;
}
+static void
+kdebug_sec_lifetime(struct seclifetime *lft)
+{
+ /* sanity check */
+ if (lft == NULL)
+ panic("%s: NULL pointer was passed.\n", __func__);
+
+ printf("sec_lifetime{ alloc=%u, bytes=%u\n",
+ lft->allocations, (u_int32_t)lft->bytes);
+ printf(" addtime=%u, usetime=%u }\n",
+ (u_int32_t)lft->addtime, (u_int32_t)lft->usetime);
+
+ return;
+}
+
void
kdebug_secasv(sav)
struct secasvar *sav;
@@ -582,11 +600,11 @@ kdebug_secasv(sav)
if (sav->replay != NULL)
kdebug_secreplay(sav->replay);
if (sav->lft_c != NULL)
- kdebug_sadb_lifetime((struct sadb_ext *)sav->lft_c);
+ kdebug_sec_lifetime(sav->lft_c);
if (sav->lft_h != NULL)
- kdebug_sadb_lifetime((struct sadb_ext *)sav->lft_h);
+ kdebug_sec_lifetime(sav->lft_h);
if (sav->lft_s != NULL)
- kdebug_sadb_lifetime((struct sadb_ext *)sav->lft_s);
+ kdebug_sec_lifetime(sav->lft_s);
#ifdef notyet
/* XXX: misc[123] ? */
OpenPOWER on IntegriCloud