aboutsummaryrefslogtreecommitdiff
path: root/sys/netipsec
diff options
context:
space:
mode:
authorMarcin Wojtas <mw@FreeBSD.org>2020-10-16 11:27:01 +0000
committerMarcin Wojtas <mw@FreeBSD.org>2020-10-16 11:27:01 +0000
commitac152c14e01dff90318c32a7e6919396d8465e84 (patch)
treea77e60d8c894765475d54658c77209b5ffddb6f9 /sys/netipsec
parent4d36d1fd5972d46b8f356a751538f2fff118cd28 (diff)
downloadsrc-ac152c14e01dff90318c32a7e6919396d8465e84.tar.gz
src-ac152c14e01dff90318c32a7e6919396d8465e84.zip
Trigger soft lifetime expiration on sequence number
This patch adds 80% of UINT32_MAX limit on sequence number. When sequence number reaches limit kernel sends SADB_EXPIRE message to IKE daemon which is responsible to perform rekeying. Submitted by: Patryk Duda <pdk@semihalf.com> Reviewed by: ae Differential revision: https://reviews.freebsd.org/D22370 Obtained from: Semihalf Sponsored by: Stormshield
Notes
Notes: svn path=/head/; revision=366759
Diffstat (limited to 'sys/netipsec')
-rw-r--r--sys/netipsec/key.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c
index cd99f3d251d8..86dc9ea41024 100644
--- a/sys/netipsec/key.c
+++ b/sys/netipsec/key.c
@@ -101,6 +101,7 @@
#define FULLMASK 0xff
#define _BITS(bytes) ((bytes) << 3)
+#define UINT32_80PCT 0xcccccccc
/*
* Note on SA reference counting:
* - SAs that are not in DEAD state will have (total external reference + 1)
@@ -4536,7 +4537,11 @@ key_flush_sad(time_t now)
(sav->lft_s->usetime != 0 && sav->firstused &&
now - sav->firstused > sav->lft_s->usetime) ||
(sav->lft_s->bytes != 0 && counter_u64_fetch(
- sav->lft_c_bytes) > sav->lft_s->bytes))) {
+ sav->lft_c_bytes) > sav->lft_s->bytes) ||
+ (!(sav->flags & SADB_X_SAFLAGS_ESN) &&
+ (sav->replay != NULL) && (
+ (sav->replay->count > UINT32_80PCT) ||
+ (sav->replay->last > UINT32_80PCT))))) {
SECASVAR_UNLOCK(sav);
SAV_ADDREF(sav);
LIST_INSERT_HEAD(&sexpireq, sav, drainq);