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
This commit is contained in:
parent
3dea77f93c
commit
767a2621f0
@ -3137,7 +3137,7 @@ key_setsaval(sav, m, mhp)
|
||||
sav->created = time_second;
|
||||
|
||||
/* make lifetime for CURRENT */
|
||||
sav->lft_c = malloc(sizeof(struct sadb_lifetime), M_IPSEC_MISC, M_NOWAIT);
|
||||
sav->lft_c = malloc(sizeof(struct seclifetime), M_IPSEC_MISC, M_NOWAIT);
|
||||
if (sav->lft_c == NULL) {
|
||||
ipseclog((LOG_DEBUG, "%s: No more memory.\n", __func__));
|
||||
error = ENOBUFS;
|
||||
@ -6323,7 +6323,12 @@ key_expire(struct secasvar *sav)
|
||||
lt->sadb_lifetime_addtime = sav->lft_c->addtime;
|
||||
lt->sadb_lifetime_usetime = sav->lft_c->usetime;
|
||||
lt = (struct sadb_lifetime *)(mtod(m, caddr_t) + len / 2);
|
||||
bcopy(sav->lft_s, lt, sizeof(*lt));
|
||||
lt->sadb_lifetime_len = PFKEY_UNIT64(sizeof(struct sadb_lifetime));
|
||||
lt->sadb_lifetime_exttype = SADB_EXT_LIFETIME_SOFT;
|
||||
lt->sadb_lifetime_allocations = sav->lft_s->allocations;
|
||||
lt->sadb_lifetime_bytes = sav->lft_s->bytes;
|
||||
lt->sadb_lifetime_addtime = sav->lft_s->addtime;
|
||||
lt->sadb_lifetime_usetime = sav->lft_s->usetime;
|
||||
m_cat(result, m);
|
||||
|
||||
/* set sadb_address for source */
|
||||
|
@ -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] ? */
|
||||
|
Loading…
Reference in New Issue
Block a user